summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/ffmpeg/libavcodec
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-08 14:30:41 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-12 13:49:54 +0200
commitab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch)
tree498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/ffmpeg/libavcodec
parent4ce69f7403811819800e7c5ae1318b2647e778d1 (diff)
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/ffmpeg/libavcodec')
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/4xm.c136
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/8bps.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/Makefile117
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/a64multienc.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aac_adtstoasc_bsf.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aacadtsdec.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aacdec.c78
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aacps.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aactab.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aactab.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/Makefile28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/asm-offsets.h30
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/cabac.h104
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/fft_init_aarch64.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/fft_neon.S442
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264chroma_init_aarch64.c59
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264cmc_neon.S402
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_init_aarch64.c101
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_neon.S498
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264idct_neon.S408
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_init_aarch64.c172
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_neon.S934
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_init_aarch64.c123
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_neon.S397
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/mdct_neon.S323
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_init.c39
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S226
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/neon.S149
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/neontest.c79
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_init.c45
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_neon.S647
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/rv40dsp_init_aarch64.c48
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/vc1dsp_init_aarch64.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp.S (renamed from chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.h)18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp_init.c (renamed from chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.h)18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_init.c34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_neon.S82
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3.h84
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3_parser.c27
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3_parser.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dec.c311
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dec.h42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dec_fixed.c176
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dec_float.c89
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dsp.c28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3dsp.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3enc.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3enc.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3enc_fixed.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3enc_float.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3enc_template.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3tab.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ac3tab.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/adpcm.c17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/adpcm_data.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/adpcm_data.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/adx.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/adxdec.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aic.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/alac.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aliaspixdec.c128
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/aliaspixenc.c134
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/allcodecs.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/alsdec.c26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ansi.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/apedec.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/Makefile56
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/asm-offsets.h19
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/cabac.h108
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dca.h23
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_init_arm.c26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_neon.S48
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_vfp.S39
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.S7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.h16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_arm.c38
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv5te.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv6.c40
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_neon.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_init_arm.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_neon.S2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/flacdsp_init_arm.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/fmtconvert_neon.S2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/h264cmc_neon.S13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_init_arm.c46
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/h264idct_neon.S16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/h264pred_init_arm.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.S26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_armv6.S14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_init_arm.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/int_neon.S18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mdct_neon.S2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv5te.S655
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv6.S533
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_init_arm.c146
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_neon.S2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/neontest.c79
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/simple_idct_arm.S1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/startcode_armv6.S (renamed from chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_armv6.S)6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp.h (renamed from chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.h)11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_arm.c36
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_neon.c119
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_neon.S1170
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/videodsp_armv5te.S4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_init_arm.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_neon.S2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_armv6.S24
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_armv6.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_neon.c45
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_neon.S117
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac1data.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac3plus.c1818
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac3plus.h240
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac3plus_data.h1914
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac3plusdec.c396
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/atrac3plusdsp.c638
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/avcodec.h295
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/avfft.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/avpacket.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/Makefile20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/config_bfin.h65
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/dsputil.S (renamed from chromium/third_party/ffmpeg/libavcodec/bfin/pixels_bfin.S)3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.c173
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.h95
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_init.c195
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/fdct_bfin.S17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_no_rnd.S81
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.c123
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.h50
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_init.c146
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/idct_bfin.S13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/mpegvideo_bfin.c152
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/pixels.S (renamed from chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_bfin.S)176
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/pixels.h42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp.S (renamed from chromium/third_party/ffmpeg/libavcodec/bfin/vp3_idct_bfin.S)13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp_init.c (renamed from chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.c)11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bink.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/binkaudio.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/binkdsp.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bit_depth_template.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bitstream.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bmp.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bmp_parser.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/brender_pix.c216
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/brenderpix.c292
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/bytestream.h26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cabac.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cabac.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cabac_functions.h7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cavs.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cavsdec.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cavsdsp.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cinepakenc.c1335
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cllc.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cngdec.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cngenc.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/codec_desc.c661
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cook.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/copy_block.h47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cos_tablegen.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/cpia.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dca.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dcadata.h387
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dcadec.c118
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dcadsp.c54
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dcadsp.h11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dcaenc.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dct-test.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dct.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dfa.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dirac_arith.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dirac_dwt.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dirac_dwt.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/diracdec.c157
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhd_parser.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhddata.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhddata.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhddec.c169
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhdenc.c494
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dnxhdenc.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dpx.c11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.c (renamed from chromium/third_party/ffmpeg/libavcodec/x86/rnd_mmx.c)29
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.h95
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsddec.c167
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsputil.c3471
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsputil.h255
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsputil_template.c408
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dsputilenc_template.c51
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dv.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvbsub.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvbsubdec.c29
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvdata.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvdata.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvdsubdec.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvdsubenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dvenc.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxa.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxtory.c575
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2.c66
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2_h264.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2_internal.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2_mpeg2.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/dxva2_vc1.c50
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/eac3dec.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/eacmv.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/eamad.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/eatgv.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/elbg.c34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/error_resilience.c282
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/error_resilience.h22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/evrcdata.h8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/evrcdec.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/exif.c17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/exif.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/exr.c888
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/faxcompr.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft-fixed-test.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft-fixed32-test.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft-internal.h10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft-test.c28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft.h19
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft_fixed.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft_fixed_32.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft_float.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft_table.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fft_template.c23
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ffv1.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ffv1.h8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ffv1dec.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ffv1enc.c65
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ffwavesynth.c11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fic.c459
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flac_parser.c17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flacdec.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flacdsp.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flacdsp.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flacdsp_lpc_template.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flacenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flashsv.c11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flashsv2enc.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/flvdec.c44
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/frame_thread_encoder.c27
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/fraps.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/g2meet.c174
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/g723_1.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/g729postfilter.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/get_bits.h24
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/gifdec.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/golomb.h12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h261data.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h261dec.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h261enc.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h263.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h263dec.c40
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264.c3749
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264.h143
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_cabac.c9
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_cavlc.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_direct.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_loopfilter.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_mb.c820
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_mb_template.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_mc_template.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_mvpred.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_parser.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_picture.c211
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_ps.c60
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_refs.c212
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_sei.c60
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264_slice.c2565
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264chroma.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264chroma.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264chroma_template.c43
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264data.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264dsp.c44
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264dsp.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264idct_template.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264pred.c42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264pred.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264pred_template.c75
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264qpel.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264qpel.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/h264qpel_template.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc.c877
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc.h118
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_cabac.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_filter.c368
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_mvs.c117
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_ps.c104
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_refs.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevc_sei.c16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevcdsp.c131
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevcdsp.h122
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevcdsp_template.c1117
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hevcpred_template.c391
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hnm4video.c11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hpel_template.c148
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hpeldsp.c307
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hpeldsp.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/hpeldsp_template.c254
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffman.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffman.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffyuv.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffyuv.h27
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffyuvdec.c447
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/huffyuvenc.c437
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/iff.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/imgconvert.c193
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/imgconvert.h18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/indeo3.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/indeo4data.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/indeo5.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/intelh263dec.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/internal.h39
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/interplayvideo.c25
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/intrax8.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ituh263dec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ituh263enc.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ivi_common.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/j2kenc.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/jpeg2000dec.c29
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/jpeg2000dwt.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/jpegls.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/jpeglsdec.c60
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/jvdec.c44
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/kbdwin.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/kbdwin.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/kgv1dec.c45
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/lagarith.c38
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libfdk-aacdec.c32
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libfdk-aacenc.c50
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libopencore-amr.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libopenjpegdec.c181
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libopenjpegenc.c52
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libopusdec.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libspeexdec.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libstagefright.cpp2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libtwolame.c167
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libutvideodec.cpp4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libutvideoenc.cpp10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libvorbisenc.c42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libvpx.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libvpx.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libvpxdec.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libvpxenc.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libwebpenc.c285
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libx264.c106
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libx265.c313
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libxavs.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libxvid.c31
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/libzvbi-teletextdec.c158
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ljpegenc.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.c128
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.h40
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/lzw.c29
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/lzwenc.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mace.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mathops.h13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mathtables.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mdct_fixed.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mdct_fixed_32.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mdct_float.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mdct_template.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mdec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/metasound.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpeg.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpegbdec.c19
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpegdec.c325
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpegdec.h11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpegenc.c79
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mjpegenc.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlp.h10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlp_parser.c23
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlp_parser.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlpdec.c152
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlpdsp.c73
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mlpdsp.h46
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/motion_est.c35
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/motion_est_template.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/motionpixels.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpc8.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg12.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg12dec.c1020
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg12enc.c56
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg4video.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg4video_parser.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg4videodec.c32
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpeg4videoenc.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudio_parser.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudiodec_template.c24
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegaudioenc_template.c16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegutils.c80
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegutils.h127
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegvideo.c1031
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegvideo.h156
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegvideo_enc.c382
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegvideo_motion.c93
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mpegvideo_xvmc.c66
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/msmpeg4.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/msmpeg4dec.c28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/msrle.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss1.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss12.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss12.h14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss2.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss3.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mss4.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/msvideo1.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/msvideo1enc.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mvcdec.c140
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/mxpegdec.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/nellymoserenc.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/nuv.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/on2avc.c1015
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/on2avcdata.c9383
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/on2avcdata.h82
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/options.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/options_table.h15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus.c428
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus.h411
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus_celt.c2221
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus_imdct.c272
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus_imdct.h57
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus_parser.c75
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opus_silk.c1597
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/opusdec.c673
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/paf.c251
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/parser.c205
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pcm-dvd.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pgssubdec.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pixels.h37
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/png.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/png_parser.c49
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pngdec.c189
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pngdsp.c9
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pngenc.c167
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/Makefile12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.c1166
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.h11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_ppc.c165
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/fdct_altivec.c396
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/fft_altivec.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/gmc_altivec.c138
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/h264chroma_init.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/h264dsp.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/h264qpel.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.h34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/idct_altivec.c313
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/int_altivec.c113
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/mpegaudiodsp_altivec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/vp3dsp_altivec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/proresdsp.c34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/proresdsp.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/proresenc_kostya.c50
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/psymodel.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/pthread_frame.c30
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/put_bits.h7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/qcelpdata.h28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/qcelpdec.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/qtrleenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ra144.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ra144.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ra144dec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ra144enc.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ratecontrol.c34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ratecontrol.h8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/raw.c43
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/raw.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rawdec.c129
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rawenc.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rnd_avg.h10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/roqvideo.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/roqvideodec.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/roqvideoenc.c53
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rpza.c76
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rtjpeg.c29
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rtjpeg.h9
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv10.c143
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv30.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv30data.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv30dsp.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv34.c23
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv34.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv34dsp.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv40.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/rv40dsp.c99
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/s302menc.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sanm.c506
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sanm_data.h248
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sbrdsp.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sgi.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sgidec.c78
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sgienc.c36
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sgirledec.c65
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sh4/Makefile2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sh4/README6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.c107
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sh4/idct_sh4.c210
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sh4/sh4.h44
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/shorten.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/simple_idct.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/simple_idct_template.c26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/smacker.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/smvjpegdec.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snow.c16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snow.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snow_dwt.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snow_dwt.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snowdec.c33
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/snowenc.c43
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sonic.c167
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sp5xdec.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sparc/Makefile4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sparc/README6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sparc/hpeldsp_vis.c3524
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sparc/simple_idct_vis.c531
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sparc/vis.h264
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/startcode.c57
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/startcode.h35
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/svq1enc.c38
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/svq3.c107
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/svq3.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/synth_filter.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/synth_filter.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/takdec.c10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tiff.c285
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tiff.h20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tiff_common.c32
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tiff_common.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tiffenc.c25
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tpel_template.c80
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tpeldsp.c333
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tpeldsp.h59
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/truemotion1.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/truemotion2.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tscc2.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/tta.c42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ttadsp.c57
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ttadsp.h34
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/ttaenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/utils.c422
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/utvideodec.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/utvideoenc.c54
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_h264.c21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_internal.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg2.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg4.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vaapi_vc1.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vble.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1.c94
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1.h17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1_parser.c284
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1dec.c297
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1dsp.c831
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vc1dsp.h15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vda.c72
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vda.h75
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vda_h264.c308
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vda_h264_dec.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vda_internal.h33
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau.c59
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau_h264.c44
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau_internal.h13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg12.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg4.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vdpau_vc1.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/version.h28
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/videodsp.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/videodsp.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/videodsp_template.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vima.c123
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vmdav.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vmnc.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vorbis.c13
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vorbisdec.c56
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vorbisdsp.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vorbisdsp.h1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vorbisenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp3.c1538
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp3_parser.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp3data.h5846
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp3dsp.c142
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp5.c26
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp56.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp56.h3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp6.c30
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8.c1916
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8.h53
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8_parser.c15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8data.h339
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8dsp.c809
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp8dsp.h17
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp9.c627
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp9_parser.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp9dsp.c70
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vp9dsp.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/vqavideo.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wavpack.c15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/webp.c48
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wma.c14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wmadec.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wmalosslessdec.c38
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wmaprodec.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wmv2.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wmv2dec.c6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/wnv1.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/Makefile46
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp.asm133
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp_init.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/cabac.h14
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/cavsdsp.c66
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/constants.h2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dca.h60
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dcadsp.asm431
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dcadsp_init.c113
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/deinterlace.asm2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.asm49
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.c67
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc_init.c (renamed from chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.c)33
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputil.asm174
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputil_init.c185
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputil_mmx.c124
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputil_qns_template.c8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputil_x86.h152
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc.asm16
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc_mmx.c1525
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/fdct.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/flacdsp.asm74
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/flacdsp_init.c45
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/fmtconvert.asm11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/fpel.asm11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/fpel.h43
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/fpel_mmx.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h263_loopfilter.asm4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc.asm5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock.asm42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm21
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_i386.h6
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_idct.asm85
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_idct_10bit.asm24
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred.asm96
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm90
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_init.c31
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel.c9
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm32
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_weight.asm10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264_weight_10bit.asm9
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264chroma_init.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/h264dsp_init.c15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hevc_mc.asm1256
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp.h123
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp_init.c377
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.asm24
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.h38
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_init.c47
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_mmx.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_rnd_template.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/idct_sse2_xvid.c20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/imdct36.asm23
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/inline_asm.h100
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp.asm292
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp_init.c62
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/lpc.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mathops.h5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mlpdsp.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/motion_est.c318
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mpeg4qpel.asm4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mpegaudiodsp.c22
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mpegvideo.c115
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc.c133
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc_template.c12
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/proresdsp.asm4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/proresdsp_init.c5
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/qpel.asm11
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/rnd_template.c4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/rv34dsp_init.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp.asm8
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp_init.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp.asm30
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp_init.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/simple_idct.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/snowdsp.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/ttadsp.asm119
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/ttadsp_init.c42
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_init.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_mmx.c124
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/videodsp_init.c3
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vorbisdsp_init.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp3dsp_init.c7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp56_arith.h15
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp6dsp_init.c1
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp.asm20
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_init.c82
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_loopfilter.asm10
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp9dsp_init.c232
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp9intrapred.asm1405
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp9itxfm.asm1388
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp9lpf.asm817
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/x86/vp9mc.asm140
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/xbmdec.c87
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/xsubenc.c2
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/xvmc.h4
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/xvmc_internal.h7
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/xwddec.c18
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/zmbv.c6
727 files changed, 73511 insertions, 29302 deletions
diff --git a/chromium/third_party/ffmpeg/libavcodec/4xm.c b/chromium/third_party/ffmpeg/libavcodec/4xm.c
index eb07cc370df..23ba1ecee7a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/4xm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/4xm.c
@@ -24,8 +24,11 @@
* 4XM codec.
*/
+#include <inttypes.h>
+
#include "libavutil/avassert.h"
#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -131,7 +134,8 @@ typedef struct CFrameBuffer {
typedef struct FourXContext {
AVCodecContext *avctx;
DSPContext dsp;
- AVFrame *current_picture, *last_picture;
+ uint16_t *frame_buffer;
+ uint16_t *last_frame_buffer;
GetBitContext pre_gb; ///< ac/dc prefix
GetBitContext gb;
GetByteContext g;
@@ -341,7 +345,7 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
int code = get_vlc2(&f->gb,
block_type_vlc[1 - (f->version > 1)][index].table,
BLOCK_TYPE_VLC_BITS, 1);
- uint16_t *start = (uint16_t *)f->last_picture->data[0];
+ uint16_t *start = f->last_frame_buffer;
uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w);
int ret;
int scale = 1;
@@ -414,29 +418,18 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
return 0;
}
-static int decode_p_frame(FourXContext *f, AVFrame *frame,
- const uint8_t *buf, int length)
+static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
{
int x, y;
const int width = f->avctx->width;
const int height = f->avctx->height;
- uint16_t *dst = (uint16_t *)frame->data[0];
- const int stride = frame->linesize[0] >> 1;
+ uint16_t *dst = f->frame_buffer;
uint16_t *src;
unsigned int bitstream_size, bytestream_size, wordstream_size, extra,
bytestream_offset, wordstream_offset;
int ret;
- if (!f->last_picture->data[0]) {
- if ((ret = ff_get_buffer(f->avctx, f->last_picture,
- AV_GET_BUFFER_FLAG_REF)) < 0) {
- return ret;
- }
- for (y=0; y<f->avctx->height; y++)
- memset(f->last_picture->data[0] + y*f->last_picture->linesize[0], 0, 2*f->avctx->width);
- }
-
- src = (uint16_t *)f->last_picture->data[0];
+ src = f->last_frame_buffer;
if (f->version > 1) {
extra = 20;
@@ -476,14 +469,14 @@ static int decode_p_frame(FourXContext *f, AVFrame *frame,
bytestream2_init(&f->g, buf + bytestream_offset,
length - bytestream_offset);
- init_mv(f, frame->linesize[0]);
+ init_mv(f, width * 2);
for (y = 0; y < height; y += 8) {
for (x = 0; x < width; x += 8)
- if ((ret = decode_p_block(f, dst + x, src + x, 3, 3, stride)) < 0)
+ if ((ret = decode_p_block(f, dst + x, src + x, 3, 3, width)) < 0)
return ret;
- src += 8 * stride;
- dst += 8 * stride;
+ src += 8 * width;
+ dst += 8 * width;
}
return 0;
@@ -548,12 +541,12 @@ static int decode_i_block(FourXContext *f, int16_t *block)
return 0;
}
-static inline void idct_put(FourXContext *f, AVFrame *frame, int x, int y)
+static inline void idct_put(FourXContext *f, int x, int y)
{
int16_t (*block)[64] = f->block;
- int stride = frame->linesize[0] >> 1;
+ int stride = f->avctx->width;
int i;
- uint16_t *dst = ((uint16_t*)frame->data[0]) + y * stride + x;
+ uint16_t *dst = f->frame_buffer + y * stride + x;
for (i = 0; i < 4; i++) {
block[i][0] += 0x80 * 8 * 8;
@@ -713,14 +706,13 @@ static int mix(int c0, int c1)
return red / 3 * 1024 + green / 3 * 32 + blue / 3;
}
-static int decode_i2_frame(FourXContext *f, AVFrame *frame, const uint8_t *buf, int length)
+static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
{
int x, y, x2, y2;
const int width = f->avctx->width;
const int height = f->avctx->height;
const int mbs = (FFALIGN(width, 16) >> 4) * (FFALIGN(height, 16) >> 4);
- uint16_t *dst = (uint16_t*)frame->data[0];
- const int stride = frame->linesize[0]>>1;
+ uint16_t *dst = f->frame_buffer;
const uint8_t *buf_end = buf + length;
GetByteContext g3;
@@ -751,18 +743,18 @@ static int decode_i2_frame(FourXContext *f, AVFrame *frame, const uint8_t *buf,
for (y2 = 0; y2 < 16; y2++) {
for (x2 = 0; x2 < 16; x2++) {
int index = 2 * (x2 >> 2) + 8 * (y2 >> 2);
- dst[y2 * stride + x2] = color[(bits >> index) & 3];
+ dst[y2 * width + x2] = color[(bits >> index) & 3];
}
}
dst += 16;
}
- dst += 16 * stride - x;
+ dst += 16 * width - x;
}
return 0;
}
-static int decode_i_frame(FourXContext *f, AVFrame *frame, const uint8_t *buf, int length)
+static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
{
int x, y, ret;
const int width = f->avctx->width;
@@ -816,7 +808,7 @@ static int decode_i_frame(FourXContext *f, AVFrame *frame, const uint8_t *buf, i
if ((ret = decode_i_mb(f)) < 0)
return ret;
- idct_put(f, frame, x, y);
+ idct_put(f, x, y);
}
}
@@ -841,7 +833,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
av_assert0(avctx->width % 16 == 0 && avctx->height % 16 == 0);
if (buf_size < AV_RL32(buf + 4) + 8) {
- av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n",
+ av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %"PRIu32"\n",
buf_size, AV_RL32(buf + 4));
return AVERROR_INVALIDDATA;
}
@@ -919,29 +911,24 @@ static int decode_frame(AVCodecContext *avctx, void *data,
frame_size = buf_size - 12;
}
- FFSWAP(AVFrame*, f->current_picture, f->last_picture);
-
- // alternatively we would have to use our own buffer management
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
-
- if ((ret = ff_reget_buffer(avctx, f->current_picture)) < 0)
+ if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
return ret;
if (frame_4cc == AV_RL32("ifr2")) {
- f->current_picture->pict_type = AV_PICTURE_TYPE_I;
- if ((ret = decode_i2_frame(f, f->current_picture, buf - 4, frame_size + 4)) < 0) {
+ picture->pict_type = AV_PICTURE_TYPE_I;
+ if ((ret = decode_i2_frame(f, buf - 4, frame_size + 4)) < 0) {
av_log(f->avctx, AV_LOG_ERROR, "decode i2 frame failed\n");
return ret;
}
} else if (frame_4cc == AV_RL32("ifrm")) {
- f->current_picture->pict_type = AV_PICTURE_TYPE_I;
- if ((ret = decode_i_frame(f, f->current_picture, buf, frame_size)) < 0) {
+ picture->pict_type = AV_PICTURE_TYPE_I;
+ if ((ret = decode_i_frame(f, buf, frame_size)) < 0) {
av_log(f->avctx, AV_LOG_ERROR, "decode i frame failed\n");
return ret;
}
} else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
- f->current_picture->pict_type = AV_PICTURE_TYPE_P;
- if ((ret = decode_p_frame(f, f->current_picture, buf, frame_size)) < 0) {
+ picture->pict_type = AV_PICTURE_TYPE_P;
+ if ((ret = decode_p_frame(f, buf, frame_size)) < 0) {
av_log(f->avctx, AV_LOG_ERROR, "decode p frame failed\n");
return ret;
}
@@ -953,10 +940,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
buf_size);
}
- f->current_picture->key_frame = f->current_picture->pict_type == AV_PICTURE_TYPE_I;
+ picture->key_frame = picture->pict_type == AV_PICTURE_TYPE_I;
+
+ av_image_copy_plane(picture->data[0], picture->linesize[0],
+ (const uint8_t*)f->frame_buffer, avctx->width * 2,
+ avctx->width * 2, avctx->height);
+ FFSWAP(uint16_t *, f->frame_buffer, f->last_frame_buffer);
- if ((ret = av_frame_ref(picture, f->current_picture)) < 0)
- return ret;
*got_frame = 1;
emms_c();
@@ -964,9 +954,28 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return buf_size;
}
+static av_cold int decode_end(AVCodecContext *avctx)
+{
+ FourXContext * const f = avctx->priv_data;
+ int i;
+
+ av_freep(&f->frame_buffer);
+ av_freep(&f->last_frame_buffer);
+ av_freep(&f->bitstream_buffer);
+ f->bitstream_buffer_size = 0;
+ for (i = 0; i < CFRAME_BUFFER_COUNT; i++) {
+ av_freep(&f->cfrm[i].data);
+ f->cfrm[i].allocated_size = 0;
+ }
+ ff_free_vlc(&f->pre_vlc);
+
+ return 0;
+}
+
static av_cold int decode_init(AVCodecContext *avctx)
{
FourXContext * const f = avctx->priv_data;
+ int ret;
if (avctx->extradata_size != 4 || !avctx->extradata) {
av_log(avctx, AV_LOG_ERROR, "extradata wrong or missing\n");
@@ -977,6 +986,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
+ ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
+ if (ret < 0)
+ return ret;
+
+ f->frame_buffer = av_mallocz(avctx->width * avctx->height * 2);
+ f->last_frame_buffer = av_mallocz(avctx->width * avctx->height * 2);
+ if (!f->frame_buffer || !f->last_frame_buffer) {
+ decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
+
f->version = AV_RL32(avctx->extradata) >> 16;
ff_dsputil_init(&f->dsp, avctx);
f->avctx = avctx;
@@ -987,30 +1007,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
else
avctx->pix_fmt = AV_PIX_FMT_BGR555;
- f->current_picture = av_frame_alloc();
- f->last_picture = av_frame_alloc();
- if (!f->current_picture || !f->last_picture)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
-
-static av_cold int decode_end(AVCodecContext *avctx)
-{
- FourXContext * const f = avctx->priv_data;
- int i;
-
- av_freep(&f->bitstream_buffer);
- f->bitstream_buffer_size = 0;
- for (i = 0; i < CFRAME_BUFFER_COUNT; i++) {
- av_freep(&f->cfrm[i].data);
- f->cfrm[i].allocated_size = 0;
- }
- ff_free_vlc(&f->pre_vlc);
- av_frame_free(&f->current_picture);
- av_frame_free(&f->last_picture);
-
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/8bps.c b/chromium/third_party/ffmpeg/libavcodec/8bps.c
index d01ef924c79..e00bdfc8086 100644
--- a/chromium/third_party/ffmpeg/libavcodec/8bps.c
+++ b/chromium/third_party/ffmpeg/libavcodec/8bps.c
@@ -150,7 +150,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
c->planemap[0] = 0; // 1st plane is palette indexes
break;
case 24:
- avctx->pix_fmt = avctx->get_format(avctx, pixfmt_rgb24);
+ avctx->pix_fmt = ff_get_format(avctx, pixfmt_rgb24);
c->planes = 3;
c->planemap[0] = 2; // 1st plane is red
c->planemap[1] = 1; // 2nd plane is green
diff --git a/chromium/third_party/ffmpeg/libavcodec/Makefile b/chromium/third_party/ffmpeg/libavcodec/Makefile
index 0f6f881cf80..f1690a82ed9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/Makefile
+++ b/chromium/third_party/ffmpeg/libavcodec/Makefile
@@ -1,7 +1,6 @@
include $(SUBDIR)../config.mak
NAME = avcodec
-FFLIBS = avutil
HEADERS = avcodec.h \
avfft.h \
@@ -26,7 +25,6 @@ OBJS = allcodecs.o \
options.o \
parser.o \
raw.o \
- rawdec.o \
resample.o \
resample2.o \
utils.o \
@@ -35,6 +33,7 @@ OBJS = allcodecs.o \
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o
OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o
+OBJS-$(CONFIG_CABAC) += cabac.o
OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o
OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
OBJS-$(CONFIG_DXVA2) += dxva2.o
@@ -50,12 +49,14 @@ OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \
OBJS-$(CONFIG_GOLOMB) += golomb.o
OBJS-$(CONFIG_H263DSP) += h263dsp.o
OBJS-$(CONFIG_H264CHROMA) += h264chroma.o
-OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
+OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o startcode.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
+OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o
OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
+OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
OBJS-$(CONFIG_LPC) += lpc.o
OBJS-$(CONFIG_LSP) += lsp.o
OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o mdct_fixed_32.o
@@ -65,7 +66,8 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_data.o \
mpegaudiodsp_fixed.o \
mpegaudiodsp_float.o
-OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideo_motion.o
+OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideo_motion.o \
+ mpegutils.o
OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \
motion_est.o ratecontrol.o
OBJS-$(CONFIG_RANGECODER) += rangecoder.o
@@ -73,7 +75,9 @@ RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o
OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
OBJS-$(CONFIG_SHARED) += log2_tab.o
OBJS-$(CONFIG_SINEWIN) += sinewin.o
+OBJS-$(CONFIG_TPELDSP) += tpeldsp.o
OBJS-$(CONFIG_VAAPI) += vaapi.o
+OBJS-$(CONFIG_VDA) += vda.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
@@ -90,13 +94,16 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
psymodel.o iirfilter.o \
mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
-OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o kbdwin.o
+OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o
+OBJS-$(CONFIG_AC3_FIXED_DECODER) += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3enc.o ac3tab.o \
ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o
OBJS-$(CONFIG_AIC_DECODER) += aic.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o alac_data.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER) += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER) += aliaspixenc.o
OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
OBJS-$(CONFIG_AMRNB_DECODER) += amrnbdec.o celp_filters.o \
celp_math.o acelp_filters.o \
@@ -106,7 +113,6 @@ OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o celp_filters.o \
celp_math.o acelp_filters.o \
acelp_vectors.o \
acelp_pitch_delay.o
-OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpeg.o \
mpegvideo_enc.o motion_est.o \
ratecontrol.o mpeg12data.o \
@@ -124,6 +130,8 @@ OBJS-$(CONFIG_ASV2_DECODER) += asvdec.o asv.o mpeg12data.o
OBJS-$(CONFIG_ASV2_ENCODER) += asvenc.o asv.o mpeg12data.o
OBJS-$(CONFIG_ATRAC1_DECODER) += atrac1.o atrac.o
OBJS-$(CONFIG_ATRAC3_DECODER) += atrac3.o atrac.o
+OBJS-$(CONFIG_ATRAC3P_DECODER) += atrac3plusdec.o atrac3plus.o \
+ atrac3plusdsp.o atrac.o
OBJS-$(CONFIG_AURA_DECODER) += cyuv.o
OBJS-$(CONFIG_AURA2_DECODER) += aura.o
OBJS-$(CONFIG_AVRN_DECODER) += avrndec.o mjpegdec.o mjpeg.o
@@ -144,13 +152,14 @@ OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmv.o
OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmv.o
-OBJS-$(CONFIG_BRENDER_PIX_DECODER) += brender_pix.o
+OBJS-$(CONFIG_BRENDER_PIX_DECODER) += brenderpix.o
OBJS-$(CONFIG_C93_DECODER) += c93.o
OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \
cavsdata.o mpeg12data.o
OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o
OBJS-$(CONFIG_CDXL_DECODER) += cdxl.o
OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
+OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
OBJS-$(CONFIG_CLJR_DECODER) += cljr.o
OBJS-$(CONFIG_CLJR_ENCODER) += cljr.o
OBJS-$(CONFIG_CLLC_DECODER) += cllc.o
@@ -170,6 +179,10 @@ OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
OBJS-$(CONFIG_DPX_DECODER) += dpx.o
OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
+OBJS-$(CONFIG_DSD_LSBF_DECODER) += dsddec.o
+OBJS-$(CONFIG_DSD_MSBF_DECODER) += dsddec.o
+OBJS-$(CONFIG_DSD_LSBF_PLANAR_DECODER) += dsddec.o
+OBJS-$(CONFIG_DSD_MSBF_PLANAR_DECODER) += dsddec.o
OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinav.o
OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o
OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o
@@ -198,9 +211,8 @@ OBJS-$(CONFIG_EVRC_DECODER) += evrcdec.o acelp_vectors.o lsp.o
OBJS-$(CONFIG_EXR_DECODER) += exr.o
OBJS-$(CONFIG_FFV1_DECODER) += ffv1dec.o ffv1.o
OBJS-$(CONFIG_FFV1_ENCODER) += ffv1enc.o ffv1.o
-OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o huffyuvdec.o
-OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o huffyuvenc.o
OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
+OBJS-$(CONFIG_FIC_DECODER) += fic.o
OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o flacdsp.o
OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o flacdsp.o vorbis_data.o
OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
@@ -227,18 +239,17 @@ OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
intelh263dec.o
OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
h263.o ituh263enc.o flvenc.o
-OBJS-$(CONFIG_H264_DECODER) += h264.o \
- h264_loopfilter.o h264_direct.o \
- cabac.o h264_sei.o h264_ps.o \
- h264_refs.o h264_cavlc.o h264_cabac.o
+OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
+ h264_direct.o h264_loopfilter.o \
+ h264_mb.o h264_picture.o h264_ps.o \
+ h264_refs.o h264_sei.o h264_slice.o
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \
hevc_cabac.o hevc_refs.o hevcpred.o \
- hevcdsp.o hevc_filter.o cabac.o
+ hevcdsp.o hevc_filter.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o
-OBJS-$(CONFIG_IAC_DECODER) += imc.o
OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o
OBJS-$(CONFIG_IDF_DECODER) += bintext.o cga_data.o
OBJS-$(CONFIG_IFF_BYTERUN1_DECODER) += iff.o
@@ -255,8 +266,7 @@ OBJS-$(CONFIG_JPEG2000_ENCODER) += j2kenc.o mqcenc.o mqc.o jpeg2000.o \
jpeg2000dwt.o
OBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dec.o jpeg2000.o \
jpeg2000dwt.o mqcdec.o mqc.o
-OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o \
- mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o
OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o
OBJS-$(CONFIG_JV_DECODER) += jvdec.o
OBJS-$(CONFIG_KGV1_DECODER) += kgv1dec.o
@@ -273,7 +283,7 @@ OBJS-$(CONFIG_MICRODVD_DECODER) += microdvddec.o ass.o
OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o
OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o mjpeg.o
OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpeg.o
-OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o
OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o
OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o
@@ -297,23 +307,16 @@ OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o
OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12.o mpeg12data.o \
mpegvideo.o error_resilience.o
-OBJS-$(CONFIG_MPEG_XVMC_DECODER) += mpegvideo_xvmc.o
OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o
OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
-OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o \
- h263dec.o h263.o ituh263dec.o \
- mpeg4videodec.o
-OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
- h263.o
-OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o \
- h263dec.o h263.o ituh263dec.o \
- mpeg4videodec.o
-OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
- h263.o
+OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
OBJS-$(CONFIG_MSA1_DECODER) += mss3.o mss34dsp.o
OBJS-$(CONFIG_MSS1_DECODER) += mss1.o mss12.o
@@ -324,10 +327,14 @@ OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
OBJS-$(CONFIG_MTS2_DECODER) += mss4.o mss34dsp.o
OBJS-$(CONFIG_MVC1_DECODER) += mvcdec.o
OBJS-$(CONFIG_MVC2_DECODER) += mvcdec.o
-OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
+OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
+OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o \
+ opus_imdct.o opus_silk.o \
+ vorbis_data.o
OBJS-$(CONFIG_PAF_VIDEO_DECODER) += paf.o
OBJS-$(CONFIG_PAF_AUDIO_DECODER) += paf.o
OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
@@ -351,7 +358,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o
OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o
-OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o proresdsp.o
+OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
OBJS-$(CONFIG_PTX_DECODER) += ptx.o
OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \
celp_filters.o acelp_vectors.o \
@@ -407,7 +414,7 @@ OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_SONIC_DECODER) += sonic.o
OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
-OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o
OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o
OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o
OBJS-$(CONFIG_SUBRIP_DECODER) += srtdec.o ass.o
@@ -419,17 +426,13 @@ OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o \
h263.o ituh263enc.o
-OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o h263.o h264.o \
- h264_loopfilter.o h264_direct.o \
- h264_sei.o h264_ps.o h264_refs.o \
- h264_cavlc.o h264_cabac.o cabac.o
+OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o
OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o
OBJS-$(CONFIG_TARGA_DECODER) += targa.o
OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o rle.o
OBJS-$(CONFIG_TARGA_Y216_DECODER) += targa_y216dec.o
OBJS-$(CONFIG_THEORA_DECODER) += xiph.o
-OBJS-$(CONFIG_THP_DECODER) += mjpegdec.o mjpeg.o
OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o faxcompr.o tiff_data.o tiff_common.o
OBJS-$(CONFIG_TIFF_ENCODER) += tiffenc.o rle.o lzwenc.o tiff_data.o
@@ -440,7 +443,7 @@ OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o
OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o
OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o
OBJS-$(CONFIG_TSCC2_DECODER) += tscc2.o
-OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o
+OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o ttadsp.o
OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttadata.o
OBJS-$(CONFIG_TWINVQ_DECODER) += twinvqdec.o twinvq.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o
@@ -460,7 +463,7 @@ OBJS-$(CONFIG_VB_DECODER) += vb.o
OBJS-$(CONFIG_VBLE_DECODER) += vble.o
OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o \
msmpeg4dec.o msmpeg4.o msmpeg4data.o \
- intrax8.o intrax8dsp.o wmv2dsp.o
+ wmv2dsp.o startcode.o
OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o
@@ -474,6 +477,7 @@ OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \
vp56rac.o
OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \
vp6dsp.o vp56rac.o
+OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp8dsp.o vp56rac.o
OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o
OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9dsp.o vp56rac.o
OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
@@ -481,7 +485,7 @@ OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
OBJS-$(CONFIG_WAVPACK_ENCODER) += wavpackenc.o
OBJS-$(CONFIG_WEBP_DECODER) += vp8.o vp8dsp.o vp56rac.o
-OBJS-$(CONFIG_WEBP_DECODER) += webp.o
+OBJS-$(CONFIG_WEBP_DECODER) += webp.o exif.o tiff_common.o
OBJS-$(CONFIG_WEBVTT_DECODER) += webvttdec.o
OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma_common.o
OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o wma_common.o
@@ -494,8 +498,7 @@ OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
acelp_vectors.o acelp_filters.o
OBJS-$(CONFIG_WMV1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o wmv2dsp.o \
- msmpeg4dec.o msmpeg4.o msmpeg4data.o \
- intrax8.o intrax8dsp.o
+ msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o wmv2dsp.o \
msmpeg4.o msmpeg4enc.o msmpeg4data.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
@@ -622,6 +625,7 @@ OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcmenc.o adpcm_data.o
@@ -635,9 +639,11 @@ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o
OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o
+OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o
OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o vaapi_mpeg.o
OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o
+OBJS-$(CONFIG_MPEG2_XVMC_HWACCEL) += mpegvideo_xvmc.o
OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o vaapi_mpeg.o
OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL) += vdpau_mpeg4.o
OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
@@ -672,6 +678,7 @@ OBJS-$(CONFIG_MPEGTS_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
+OBJS-$(CONFIG_OGA_MUXER) += xiph.o flac.o flacdata.o
OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o flac.o flacdata.o \
mpeg12data.o vorbis_parser.o \
dirac.o vorbis_data.o
@@ -734,7 +741,9 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o
+OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
+OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o
@@ -761,11 +770,7 @@ OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \
OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
-OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \
- cabac.o \
- h264_refs.o h264_sei.o h264_direct.o \
- h264_loopfilter.o h264_cabac.o \
- h264_cavlc.o h264_ps.o
+OBJS-$(CONFIG_H264_PARSER) += h264_parser.o
OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o
@@ -777,13 +782,15 @@ OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o \
mpegaudiodecheader.o mpegaudiodata.o
OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o \
mpeg12.o mpeg12data.o
+OBJS-$(CONFIG_OPUS_PARSER) += opus_parser.o opus.o vorbis_data.o
+OBJS-$(CONFIG_PNG_PARSER) += png_parser.o
OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o
OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o
-OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
+OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o vc1dsp.o \
msmpeg4.o msmpeg4data.o mpeg4video.o \
- h263.o
+ h263.o startcode.o
OBJS-$(CONFIG_VORBIS_PARSER) += vorbis_parser.o xiph.o
OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o
OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o
@@ -807,9 +814,7 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o
# thread libraries
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
-OBJS-$(HAVE_PTHREADS) += pthread.o pthread_slice.o pthread_frame.o
-OBJS-$(HAVE_W32THREADS) += pthread.o pthread_slice.o pthread_frame.o
-OBJS-$(HAVE_OS2THREADS) += pthread.o pthread_slice.o pthread_frame.o
+OBJS-$(HAVE_THREADS) += pthread.o pthread_slice.o pthread_frame.o
OBJS-$(CONFIG_FRAME_THREAD_ENCODER) += frame_thread_encoder.o
@@ -827,9 +832,9 @@ SKIPHEADERS += %_tablegen.h \
SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h
-SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h
+SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
-SKIPHEADERS-$(CONFIG_VDA) += vda.h
+SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
TESTPROGS = cabac \
@@ -852,6 +857,7 @@ HOSTPROGS = aac_tablegen \
aacps_tablegen \
cbrt_tablegen \
cos_tablegen \
+ dsd_tablegen \
dv_tablegen \
motionpixels_tablegen \
mpegaudio_tablegen \
@@ -876,7 +882,7 @@ else
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
endif
-GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dv_tables.h \
+GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dsd_tables.h dv_tables.h \
sinewin_tables.h mpegaudio_tables.h motionpixels_tables.h \
pcm_tables.h qdm2_tables.h
GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS))
@@ -888,6 +894,7 @@ ifdef CONFIG_HARDCODED_TABLES
$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h
$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h
+$(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h
$(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
$(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
$(SUBDIR)mpegaudiodec_fixed.o: $(SUBDIR)mpegaudio_tables.h
diff --git a/chromium/third_party/ffmpeg/libavcodec/a64multienc.c b/chromium/third_party/ffmpeg/libavcodec/a64multienc.c
index 6dd5c2c2ad5..306777418d9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/a64multienc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/a64multienc.c
@@ -195,7 +195,7 @@ static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
return 0;
}
-static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
+static av_cold int a64multi_encode_init(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
int a;
@@ -220,9 +220,9 @@ static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
a64_palette[mc_colors[a]][2] * 0.11;
}
- if (!(c->mc_meta_charset = av_malloc(32000 * c->mc_lifetime * sizeof(int))) ||
+ if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
- !(c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int))) ||
+ !(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
!(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
@@ -402,7 +402,7 @@ AVCodec ff_a64multi_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_A64_MULTI,
.priv_data_size = sizeof(A64Context),
- .init = a64multi_init_encoder,
+ .init = a64multi_encode_init,
.encode2 = a64multi_encode_frame,
.close = a64multi_close_encoder,
.pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE},
@@ -416,7 +416,7 @@ AVCodec ff_a64multi5_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_A64_MULTI5,
.priv_data_size = sizeof(A64Context),
- .init = a64multi_init_encoder,
+ .init = a64multi_encode_init,
.encode2 = a64multi_encode_frame,
.close = a64multi_close_encoder,
.pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE},
diff --git a/chromium/third_party/ffmpeg/libavcodec/aac_adtstoasc_bsf.c b/chromium/third_party/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
index c8f9e0ae690..37ba5c17d2c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
@@ -87,6 +87,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
buf_size -= get_bits_count(&gb)/8;
buf += get_bits_count(&gb)/8;
}
+ av_free(avctx->extradata);
avctx->extradata_size = 2 + pce_size;
avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
diff --git a/chromium/third_party/ffmpeg/libavcodec/aacadtsdec.c b/chromium/third_party/ffmpeg/libavcodec/aacadtsdec.c
index c9718c45998..d0814ac27e1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aacadtsdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aacadtsdec.c
@@ -31,7 +31,7 @@ int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
int size, rdb, ch, sr;
int aot, crc_abs;
- if(get_bits(gbc, 12) != 0xfff)
+ if (get_bits(gbc, 12) != 0xfff)
return AAC_AC3_PARSE_ERROR_SYNC;
skip_bits1(gbc); /* id */
@@ -39,10 +39,10 @@ int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
crc_abs = get_bits1(gbc); /* protection_absent */
aot = get_bits(gbc, 2); /* profile_objecttype */
sr = get_bits(gbc, 4); /* sample_frequency_index */
- if(!avpriv_mpeg4audio_sample_rates[sr])
+ if (!avpriv_mpeg4audio_sample_rates[sr])
return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
skip_bits1(gbc); /* private_bit */
- ch = get_bits(gbc, 3); /* channel_configuration */
+ ch = get_bits(gbc, 3); /* channel_configuration */
skip_bits1(gbc); /* original/copy */
skip_bits1(gbc); /* home */
@@ -50,8 +50,8 @@ int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
/* adts_variable_header */
skip_bits1(gbc); /* copyright_identification_bit */
skip_bits1(gbc); /* copyright_identification_start */
- size = get_bits(gbc, 13); /* aac_frame_length */
- if(size < AAC_ADTS_HEADER_SIZE)
+ size = get_bits(gbc, 13); /* aac_frame_length */
+ if (size < AAC_ADTS_HEADER_SIZE)
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
skip_bits(gbc, 11); /* adts_buffer_fullness */
diff --git a/chromium/third_party/ffmpeg/libavcodec/aacdec.c b/chromium/third_party/ffmpeg/libavcodec/aacdec.c
index 1fb91853d01..a8f76e73e11 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aacdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aacdec.c
@@ -196,6 +196,9 @@ static int frame_configure_elements(AVCodecContext *avctx)
/* get output buffer */
av_frame_unref(ac->frame);
+ if (!avctx->channels)
+ return 1;
+
ac->frame->nb_samples = 2048;
if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0)
return ret;
@@ -534,6 +537,25 @@ static int set_default_channel_config(AVCodecContext *avctx,
*tags = tags_per_config[channel_config];
memcpy(layout_map, aac_channel_layout_map[channel_config - 1],
*tags * sizeof(*layout_map));
+
+ /*
+ * AAC specification has 7.1(wide) as a default layout for 8-channel streams.
+ * However, at least Nero AAC encoder encodes 7.1 streams using the default
+ * channel config 7, mapping the side channels of the original audio stream
+ * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD
+ * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding
+ * the incorrect streams as if they were correct (and as the encoder intended).
+ *
+ * As actual intended 7.1(wide) streams are very rare, default to assuming a
+ * 7.1 layout was intended.
+ */
+ if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
+ av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
+ " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
+ " according to the specification instead.\n", FF_COMPLIANCE_STRICT);
+ layout_map[2][2] = AAC_CHANNEL_SIDE;
+ }
+
return 0;
}
@@ -1114,7 +1136,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0 * 32768.0);
// window initialization
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
- ff_kbd_window_init(ff_aac_kbd_long_512, 4.0, 512);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_init_ff_sine_windows(10);
ff_init_ff_sine_windows( 9);
@@ -1227,13 +1248,14 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
ics->swb_offset = ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
ics->num_swb = ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
+ ics->tns_max_bands = ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index];
if (!ics->num_swb || !ics->swb_offset)
return AVERROR_BUG;
} else {
ics->swb_offset = ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
ics->num_swb = ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+ ics->tns_max_bands = ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
}
- ics->tns_max_bands = ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
if (aot != AOT_ER_AAC_ELD) {
ics->predictor_present = get_bits1(gb);
ics->predictor_reset_group = 0;
@@ -1404,12 +1426,12 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb,
return -1;
pulse->pos[0] = swb_offset[pulse_swb];
pulse->pos[0] += get_bits(gb, 5);
- if (pulse->pos[0] > 1023)
+ if (pulse->pos[0] >= swb_offset[num_swb])
return -1;
pulse->amp[0] = get_bits(gb, 4);
for (i = 1; i < pulse->num_pulse; i++) {
pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
- if (pulse->pos[i] > 1023)
+ if (pulse->pos[i] >= swb_offset[num_swb])
return -1;
pulse->amp[i] = get_bits(gb, 4);
}
@@ -2509,14 +2531,20 @@ static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce)
float *in = sce->coeffs;
float *out = sce->ret;
float *saved = sce->saved;
- const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_512 : ff_sine_512;
float *buf = ac->buf_mdct;
// imdct
ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
// window overlapping
- ac->fdsp.vector_fmul_window(out, saved, buf, lwindow_prev, 256);
+ if (ics->use_kb_window[1]) {
+ // AAC LD uses a low overlap sine window instead of a KBD window
+ memcpy(out, saved, 192 * sizeof(float));
+ ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64);
+ memcpy( out + 320, buf + 64, 192 * sizeof(float));
+ } else {
+ ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256);
+ }
// buffer update
memcpy(saved, buf + 256, 256 * sizeof(float));
@@ -2603,7 +2631,7 @@ static void apply_dependent_coupling(AACContext *ac,
const float gain = cce->coup.gain[index][idx];
for (group = 0; group < ics->group_len[g]; group++) {
for (k = offsets[i]; k < offsets[i + 1]; k++) {
- // XXX dsputil-ize
+ // FIXME: SIMDify
dest[group * 128 + k] += gain * src[group * 128 + k];
}
}
@@ -2844,6 +2872,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, void *data,
spectral_to_sample(ac);
ac->frame->nb_samples = samples;
+ ac->frame->sample_rate = avctx->sample_rate;
*got_frame_ptr = 1;
skip_bits_long(gb, get_bits_left(gb));
@@ -2978,22 +3007,6 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0;
samples <<= multiplier;
- /* for dual-mono audio (SCE + SCE) */
- is_dmono = ac->dmono_mode && sce_count == 2 &&
- ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
-
- if (samples)
- ac->frame->nb_samples = samples;
- else
- av_frame_unref(ac->frame);
- *got_frame_ptr = !!samples;
-
- if (is_dmono) {
- if (ac->dmono_mode == 1)
- ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0];
- else if (ac->dmono_mode == 2)
- ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1];
- }
if (ac->oc[1].status && audio_found) {
avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier;
@@ -3007,6 +3020,25 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
if (side && side_size>=4)
AV_WL32(side, 2*AV_RL32(side));
}
+
+ *got_frame_ptr = !!samples;
+ if (samples) {
+ ac->frame->nb_samples = samples;
+ ac->frame->sample_rate = avctx->sample_rate;
+ } else
+ av_frame_unref(ac->frame);
+ *got_frame_ptr = !!samples;
+
+ /* for dual-mono audio (SCE + SCE) */
+ is_dmono = ac->dmono_mode && sce_count == 2 &&
+ ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
+ if (is_dmono) {
+ if (ac->dmono_mode == 1)
+ ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0];
+ else if (ac->dmono_mode == 2)
+ ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1];
+ }
+
return 0;
fail:
pop_output_configuration(ac);
diff --git a/chromium/third_party/ffmpeg/libavcodec/aacps.c b/chromium/third_party/ffmpeg/libavcodec/aacps.c
index 9b7bdae584b..20012f9b31d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aacps.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aacps.c
@@ -432,6 +432,7 @@ static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64],
#define DECAY_SLOPE 0.05f
/// Number of frequency bands that can be addressed by the parameter index, b(k)
static const int NR_PAR_BANDS[] = { 20, 34 };
+static const int NR_IPDOPD_BANDS[] = { 11, 17 };
/// Number of frequency bands that can be addressed by the sub subband index, k
static const int NR_BANDS[] = { 71, 91 };
/// Start frequency band for the all-pass filter decay slope
@@ -828,7 +829,7 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2
h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
- if (!PS_BASELINE && ps->enable_ipdopd && 2*b <= NR_PAR_BANDS[is34]) {
+ if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) {
//The spec say says to only run this smoother when enable_ipdopd
//is set but the reference decoder appears to run it constantly
float h11i, h12i, h21i, h22i;
diff --git a/chromium/third_party/ffmpeg/libavcodec/aactab.c b/chromium/third_party/ffmpeg/libavcodec/aactab.c
index 7ec83745359..eb882e89769 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aactab.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aactab.c
@@ -34,7 +34,6 @@
#include <stdint.h>
DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, float, ff_aac_kbd_long_512 )[512];
DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128];
const uint8_t ff_aac_num_swb_1024[] = {
@@ -1237,6 +1236,10 @@ const uint8_t ff_tns_max_bands_1024[] = {
31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, 39
};
+const uint8_t ff_tns_max_bands_512[] = {
+ 0, 0, 0, 31, 32, 37, 31, 31, 0, 0, 0, 0, 0
+};
+
const uint8_t ff_tns_max_bands_128[] = {
9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/aactab.h b/chromium/third_party/ffmpeg/libavcodec/aactab.h
index 699d99d696c..5ed850888f5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aactab.h
+++ b/chromium/third_party/ffmpeg/libavcodec/aactab.h
@@ -45,7 +45,6 @@
* @{
*/
DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_512 )[512];
DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128];
const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window)[1920];
// @}
@@ -76,6 +75,7 @@ extern const uint16_t * const ff_swb_offset_512 [13];
extern const uint16_t * const ff_swb_offset_128 [13];
extern const uint8_t ff_tns_max_bands_1024[13];
+extern const uint8_t ff_tns_max_bands_512 [13];
extern const uint8_t ff_tns_max_bands_128 [13];
#endif /* AVCODEC_AACTAB_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/Makefile b/chromium/third_party/ffmpeg/libavcodec/aarch64/Makefile
new file mode 100644
index 00000000000..964428e35de
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/Makefile
@@ -0,0 +1,28 @@
+OBJS-$(CONFIG_FFT) += aarch64/fft_init_aarch64.o
+OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o
+OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
+OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
+OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o
+OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
+OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
+OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
+
+OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opus_imdct_init.o
+OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
+OBJS-$(CONFIG_VC1_DECODER) += aarch64/vc1dsp_init_aarch64.o
+OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.o
+
+ARMV8-OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp.o
+
+NEON-OBJS-$(CONFIG_FFT) += aarch64/fft_neon.o
+NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o
+NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \
+ aarch64/h264idct_neon.o
+NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
+ aarch64/hpeldsp_neon.o
+NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
+NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
+NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o
+
+NEON-OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opus_imdct_neon.o
+NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/asm-offsets.h b/chromium/third_party/ffmpeg/libavcodec/aarch64/asm-offsets.h
new file mode 100644
index 00000000000..8defd7c9eca
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/asm-offsets.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AARCH64_ASM_OFFSETS_H
+#define AVCODEC_AARCH64_ASM_OFFSETS_H
+
+/* CeltIMDCTContext */
+#define CELT_EXPTAB 0x20
+#define CELT_FFT_N 0x00
+#define CELT_LEN2 0x04
+#define CELT_LEN4 (CELT_LEN2 + 0x4) // loaded as pair
+#define CELT_TMP 0x10
+#define CELT_TWIDDLE (CELT_TMP + 0x8) // loaded as pair
+
+#endif /* AVCODEC_AARCH64_ASM_OFFSETS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/cabac.h b/chromium/third_party/ffmpeg/libavcodec/aarch64/cabac.h
new file mode 100644
index 00000000000..6b9b77eb30b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/cabac.h
@@ -0,0 +1,104 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AARCH64_CABAC_H
+#define AVCODEC_AARCH64_CABAC_H
+
+#include "config.h"
+#if HAVE_INLINE_ASM
+
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "libavcodec/cabac.h"
+
+#define get_cabac_inline get_cabac_inline_aarch64
+static av_always_inline int get_cabac_inline_aarch64(CABACContext *c,
+ uint8_t *const state)
+{
+ int bit;
+ void *reg_a, *reg_b, *reg_c, *tmp;
+
+ __asm__ volatile(
+ "ldrb %w[bit] , [%[state]] \n\t"
+ "add %[r_b] , %[tables] , %[lps_off] \n\t"
+ "mov %w[tmp] , %w[range] \n\t"
+ "and %w[range] , %w[range] , #0xC0 \n\t"
+ "lsl %w[r_c] , %w[range] , #1 \n\t"
+ "add %[r_b] , %[r_b] , %w[bit], UXTW \n\t"
+ "ldrb %w[range] , [%[r_b], %w[r_c], SXTW] \n\t"
+ "sub %w[r_c] , %w[tmp] , %w[range] \n\t"
+ "lsl %w[tmp] , %w[r_c] , #17 \n\t"
+ "cmp %w[tmp] , %w[low] \n\t"
+ "csel %w[tmp] , %w[tmp] , wzr , cc \n\t"
+ "csel %w[range] , %w[r_c] , %w[range], gt \n\t"
+ "cinv %w[bit] , %w[bit] , cc \n\t"
+ "sub %w[low] , %w[low] , %w[tmp] \n\t"
+ "add %[r_b] , %[tables] , %[norm_off] \n\t"
+ "add %[r_a] , %[tables] , %[mlps_off] \n\t"
+ "ldrb %w[tmp] , [%[r_b], %w[range], SXTW] \n\t"
+ "ldrb %w[r_a] , [%[r_a], %w[bit], SXTW] \n\t"
+ "lsl %w[low] , %w[low] , %w[tmp] \n\t"
+ "lsl %w[range] , %w[range] , %w[tmp] \n\t"
+ "uxth %w[r_c] , %w[low] \n\t"
+ "strb %w[r_a] , [%[state]] \n\t"
+ "cbnz %w[r_c] , 2f \n\t"
+ "ldr %[r_c] , [%[c], %[byte]] \n\t"
+ "ldr %[r_a] , [%[c], %[end]] \n\t"
+ "ldrh %w[tmp] , [%[r_c]] \n\t"
+ "cmp %[r_c] , %[r_a] \n\t"
+ "b.ge 1f \n\t"
+ "add %[r_a] , %[r_c] , #2 \n\t"
+ "str %[r_a] , [%[c], %[byte]] \n\t"
+ "1: \n\t"
+ "sub %w[r_c] , %w[low] , #1 \n\t"
+ "eor %w[r_c] , %w[r_c] , %w[low] \n\t"
+ "rev %w[tmp] , %w[tmp] \n\t"
+ "lsr %w[r_c] , %w[r_c] , #15 \n\t"
+ "lsr %w[tmp] , %w[tmp] , #15 \n\t"
+ "ldrb %w[r_c] , [%[r_b], %w[r_c], SXTW] \n\t"
+ "mov %w[r_b] , #0xFFFF \n\t"
+ "mov %w[r_a] , #7 \n\t"
+ "sub %w[tmp] , %w[tmp] , %w[r_b] \n\t"
+ "sub %w[r_c] , %w[r_a] , %w[r_c] \n\t"
+ "lsl %w[tmp] , %w[tmp] , %w[r_c] \n\t"
+ "add %w[low] , %w[low] , %w[tmp] \n\t"
+ "2: \n\t"
+ : [bit]"=&r"(bit),
+ [low]"+&r"(c->low),
+ [range]"+&r"(c->range),
+ [r_a]"=&r"(reg_a),
+ [r_b]"=&r"(reg_b),
+ [r_c]"=&r"(reg_c),
+ [tmp]"=&r"(tmp)
+ : [c]"r"(c),
+ [state]"r"(state),
+ [tables]"r"(ff_h264_cabac_tables),
+ [byte]"i"(offsetof(CABACContext, bytestream)),
+ [end]"i"(offsetof(CABACContext, bytestream_end)),
+ [norm_off]"I"(H264_NORM_SHIFT_OFFSET),
+ [lps_off]"I"(H264_LPS_RANGE_OFFSET),
+ [mlps_off]"I"(H264_MLPS_STATE_OFFSET + 128)
+ : "memory", "cc"
+ );
+
+ return bit & 1;
+}
+
+#endif /* HAVE_INLINE_ASM */
+
+#endif /* AVCODEC_AARCH64_CABAC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_init_aarch64.c
new file mode 100644
index 00000000000..8514d3b07b4
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_init_aarch64.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/fft.h"
+
+void ff_fft_permute_neon(FFTContext *s, FFTComplex *z);
+void ff_fft_calc_neon(FFTContext *s, FFTComplex *z);
+
+void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
+void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
+void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
+
+av_cold void ff_fft_init_aarch64(FFTContext *s)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ s->fft_permute = ff_fft_permute_neon;
+ s->fft_calc = ff_fft_calc_neon;
+#if CONFIG_MDCT
+ s->imdct_calc = ff_imdct_calc_neon;
+ s->imdct_half = ff_imdct_half_neon;
+ s->mdct_calc = ff_mdct_calc_neon;
+ s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
+#endif
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_neon.S
new file mode 100644
index 00000000000..70365d4f646
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/fft_neon.S
@@ -0,0 +1,442 @@
+/*
+ * ARM NEON optimised FFT
+ *
+ * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2009 Naotoshi Nojiri
+ * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This algorithm (though not any of the implementation details) is
+ * based on libdjbfft by D. J. Bernstein.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+#define M_SQRT1_2 0.70710678118654752440
+
+.macro transpose d0, d1, s0, s1
+ trn1 \d0, \s0, \s1
+ trn2 \d1, \s0, \s1
+.endm
+
+
+function fft4_neon
+ ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
+
+ fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1
+ fsub v6.2s, v0.2s, v1.2s // r0-r1,i0-i1
+
+ ext v16.8b, v2.8b, v3.8b, #4
+ ext v17.8b, v3.8b, v2.8b, #4
+
+ fadd v5.2s, v2.2s, v3.2s // i2+i3,r2+r3
+ fsub v7.2s, v16.2s, v17.2s // r3-r2,i2-i3
+
+ fadd v0.2s, v4.2s, v5.2s
+ fsub v2.2s, v4.2s, v5.2s
+ fadd v1.2s, v6.2s, v7.2s
+ fsub v3.2s, v6.2s, v7.2s
+
+ st1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0]
+
+ ret
+endfunc
+
+function fft8_neon
+ mov x1, x0
+ ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
+ ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
+ ext v22.8b, v2.8b, v3.8b, #4
+ ext v23.8b, v3.8b, v2.8b, #4
+ fadd v4.2s, v16.2s, v17.2s // r4+r5,i4+i5
+ fadd v5.2s, v18.2s, v19.2s // r6+r7,i6+i7
+ fsub v17.2s, v16.2s, v17.2s // r4-r5,i4-i5
+ fsub v19.2s, v18.2s, v19.2s // r6-r7,i6-i7
+ rev64 v27.2s, v28.2s // ???
+ fadd v20.2s, v0.2s, v1.2s // r0+r1,i0+i1
+ fadd v21.2s, v2.2s, v3.2s // r2+r3,i2+i3
+ fmul v26.2s, v17.2s, v28.2s // -a2r*w,a2i*w
+ ext v6.8b, v4.8b, v5.8b, #4
+ ext v7.8b, v5.8b, v4.8b, #4
+ fmul v27.2s, v19.2s, v27.2s // a3r*w,-a3i*w
+ fsub v23.2s, v22.2s, v23.2s // i2-i3,r3-r2
+ fsub v22.2s, v0.2s, v1.2s // r0-r1,i0-i1
+ fmul v24.2s, v17.2s, v28.s[1] // a2r*w,a2i*w
+ fmul v25.2s, v19.2s, v28.s[1] // a3r*w,a3i*w
+ fadd v0.2s, v20.2s, v21.2s
+ fsub v2.2s, v20.2s, v21.2s
+ fadd v1.2s, v22.2s, v23.2s
+ rev64 v26.2s, v26.2s
+ rev64 v27.2s, v27.2s
+ fsub v3.2s, v22.2s, v23.2s
+ fsub v6.2s, v6.2s, v7.2s
+ fadd v24.2s, v24.2s, v26.2s // a2r+a2i,a2i-a2r t1,t2
+ fadd v25.2s, v25.2s, v27.2s // a3r-a3i,a3i+a3r t5,t6
+ fadd v7.2s, v4.2s, v5.2s
+ fsub v18.2s, v2.2s, v6.2s
+ ext v26.8b, v24.8b, v25.8b, #4
+ ext v27.8b, v25.8b, v24.8b, #4
+ fadd v2.2s, v2.2s, v6.2s
+ fsub v16.2s, v0.2s, v7.2s
+ fadd v5.2s, v25.2s, v24.2s
+ fsub v4.2s, v26.2s, v27.2s
+ fadd v0.2s, v0.2s, v7.2s
+ fsub v17.2s, v1.2s, v5.2s
+ fsub v19.2s, v3.2s, v4.2s
+ fadd v3.2s, v3.2s, v4.2s
+ fadd v1.2s, v1.2s, v5.2s
+
+ st1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0]
+ st1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x1]
+
+ ret
+endfunc
+
+function fft16_neon
+ mov x1, x0
+ ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32
+ ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32
+ ext v22.8b, v2.8b, v3.8b, #4
+ ext v23.8b, v3.8b, v2.8b, #4
+ fadd v4.2s, v16.2s, v17.2s // r4+r5,i4+i5
+ fadd v5.2s, v18.2s, v19.2s // r6+r7,i6+i7
+ fsub v17.2s, v16.2s, v17.2s // r4-r5,i4-i5
+ fsub v19.2s, v18.2s, v19.2s // r6-r7,i6-i7
+ rev64 v27.2s, v28.2s // ???
+ fadd v20.2s, v0.2s, v1.2s // r0+r1,i0+i1
+ fadd v21.2s, v2.2s, v3.2s // r2+r3,i2+i3
+ fmul v26.2s, v17.2s, v28.2s // -a2r*w,a2i*w
+ ext v6.8b, v4.8b, v5.8b, #4
+ ext v7.8b, v5.8b, v4.8b, #4
+ fmul v27.2s, v19.2s, v27.2s // a3r*w,-a3i*w
+ fsub v23.2s, v22.2s, v23.2s // i2-i3,r3-r2
+ fsub v22.2s, v0.2s, v1.2s // r0-r1,i0-i1
+ fmul v24.2s, v17.2s, v28.s[1] // a2r*w,a2i*w
+ fmul v25.2s, v19.2s, v28.s[1] // a3r*w,a3i*w
+ fadd v0.2s, v20.2s, v21.2s
+ fsub v2.2s, v20.2s, v21.2s
+ fadd v1.2s, v22.2s, v23.2s
+ rev64 v26.2s, v26.2s
+ rev64 v27.2s, v27.2s
+ fsub v3.2s, v22.2s, v23.2s
+ fsub v6.2s, v6.2s, v7.2s
+ fadd v24.2s, v24.2s, v26.2s // a2r+a2i,a2i-a2r t1,t2
+ fadd v25.2s, v25.2s, v27.2s // a3r-a3i,a3i+a3r t5,t6
+ fadd v7.2s, v4.2s, v5.2s
+ fsub v18.2s, v2.2s, v6.2s
+ ld1 {v20.4s,v21.4s}, [x0], #32
+ ld1 {v22.4s,v23.4s}, [x0], #32
+ ext v26.8b, v24.8b, v25.8b, #4
+ ext v27.8b, v25.8b, v24.8b, #4
+ fadd v2.2s, v2.2s, v6.2s
+ fsub v16.2s, v0.2s, v7.2s
+ fadd v5.2s, v25.2s, v24.2s
+ fsub v4.2s, v26.2s, v27.2s
+ transpose v24.2d, v25.2d, v20.2d, v22.2d
+ transpose v26.2d, v27.2d, v21.2d, v23.2d
+ fadd v0.2s, v0.2s, v7.2s
+ fsub v17.2s, v1.2s, v5.2s
+ fsub v19.2s, v3.2s, v4.2s
+ fadd v3.2s, v3.2s, v4.2s
+ fadd v1.2s, v1.2s, v5.2s
+ ext v20.16b, v21.16b, v21.16b, #4
+ ext v21.16b, v23.16b, v23.16b, #4
+
+ zip1 v0.2d, v0.2d, v1.2d // {z[0], z[1]}
+ zip1 v1.2d, v2.2d, v3.2d // {z[2], z[3]}
+ zip1 v2.2d, v16.2d, v17.2d // {z[o1], z[o1+1]}
+ zip1 v3.2d, v18.2d, v19.2d // {z[o1+2],z[o1+3]}
+
+ // 2 x fft4
+ transpose v22.2d, v23.2d, v20.2d, v21.2d
+
+ fadd v4.4s, v24.4s, v25.4s
+ fadd v5.4s, v26.4s, v27.4s
+ fsub v6.4s, v24.4s, v25.4s
+ fsub v7.4s, v22.4s, v23.4s
+
+ ld1 {v23.4s}, [x14]
+
+ fadd v24.4s, v4.4s, v5.4s // {z[o2+0],z[o2+1]}
+ fsub v26.4s, v4.4s, v5.4s // {z[o2+2],z[o2+3]}
+ fadd v25.4s, v6.4s, v7.4s // {z[o3+0],z[o3+1]}
+ fsub v27.4s, v6.4s, v7.4s // {z[o3+2],z[o3+3]}
+
+ //fft_pass_neon_16
+ rev64 v7.4s, v25.4s
+ fmul v25.4s, v25.4s, v23.s[1]
+ fmul v7.4s, v7.4s, v29.4s
+ fmla v25.4s, v7.4s, v23.s[3] // {t1a,t2a,t5a,t6a}
+
+ zip1 v20.4s, v24.4s, v25.4s
+ zip2 v21.4s, v24.4s, v25.4s
+ fneg v22.4s, v20.4s
+ fadd v4.4s, v21.4s, v20.4s
+ fsub v6.4s, v20.4s, v21.4s // just the second half
+ fadd v5.4s, v21.4s, v22.4s // just the first half
+
+ tbl v4.16b, {v4.16b}, v30.16b // trans4_float
+ tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
+
+ fsub v20.4s, v0.4s, v4.4s // {z[o2],z[o2+1]}
+ fadd v16.4s, v0.4s, v4.4s // {z[0], z[1]}
+ fsub v22.4s, v2.4s, v5.4s // {z[o3],z[o3+1]}
+ fadd v18.4s, v2.4s, v5.4s // {z[o1],z[o1+1]}
+
+//second half
+ rev64 v6.4s, v26.4s
+ fmul v26.4s, v26.4s, v23.s[2]
+ rev64 v7.4s, v27.4s
+ fmul v27.4s, v27.4s, v23.s[3]
+ fmul v6.4s, v6.4s, v29.4s
+ fmul v7.4s, v7.4s, v29.4s
+ fmla v26.4s, v6.4s, v23.s[2] // {t1,t2,t5,t6}
+ fmla v27.4s, v7.4s, v23.s[1] // {t1a,t2a,t5a,t6a}
+
+ zip1 v24.4s, v26.4s, v27.4s
+ zip2 v25.4s, v26.4s, v27.4s
+ fneg v26.4s, v24.4s
+ fadd v4.4s, v25.4s, v24.4s
+ fsub v6.4s, v24.4s, v25.4s // just the second half
+ fadd v5.4s, v25.4s, v26.4s // just the first half
+
+ tbl v4.16b, {v4.16b}, v30.16b // trans4_float
+ tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
+
+ fadd v17.4s, v1.4s, v4.4s // {z[2], z[3]}
+ fsub v21.4s, v1.4s, v4.4s // {z[o2+2],z[o2+3]}
+ fadd v19.4s, v3.4s, v5.4s // {z[o1+2],z[o1+3]}
+ fsub v23.4s, v3.4s, v5.4s // {z[o3+2],z[o3+3]}
+
+ st1 {v16.4s,v17.4s}, [x1], #32
+ st1 {v18.4s,v19.4s}, [x1], #32
+ st1 {v20.4s,v21.4s}, [x1], #32
+ st1 {v22.4s,v23.4s}, [x1], #32
+
+ ret
+endfunc
+
+
+const trans4_float, align=4
+ .byte 0, 1, 2, 3
+ .byte 8, 9, 10, 11
+ .byte 4, 5, 6, 7
+ .byte 12, 13, 14, 15
+endconst
+
+const trans8_float, align=4
+ .byte 24, 25, 26, 27
+ .byte 0, 1, 2, 3
+ .byte 28, 29, 30, 31
+ .byte 4, 5, 6, 7
+endconst
+
+function fft_pass_neon
+ sub x6, x2, #1 // n - 1, loop counter
+ lsl x5, x2, #3 // 2 * n * sizeof FFTSample
+ lsl x1, x2, #4 // 2 * n * sizeof FFTComplex
+ add x5, x4, x5 // wim
+ add x3, x1, x2, lsl #5 // 4 * n * sizeof FFTComplex
+ add x2, x0, x2, lsl #5 // &z[o2]
+ add x3, x0, x3 // &z[o3]
+ add x1, x0, x1 // &z[o1]
+ ld1 {v20.4s},[x2] // {z[o2],z[o2+1]}
+ ld1 {v22.4s},[x3] // {z[o3],z[o3+1]}
+ ld1 {v4.2s}, [x4], #8 // {wre[0],wre[1]}
+ trn2 v25.2d, v20.2d, v22.2d
+ sub x5, x5, #4 // wim--
+ trn1 v24.2d, v20.2d, v22.2d
+ ld1 {v5.s}[0], [x5], x7 // d5[0] = wim[-1]
+ rev64 v7.4s, v25.4s
+ fmul v25.4s, v25.4s, v4.s[1]
+ ld1 {v16.4s}, [x0] // {z[0],z[1]}
+ fmul v7.4s, v7.4s, v29.4s
+ ld1 {v17.4s}, [x1] // {z[o1],z[o1+1]}
+ prfm pldl1keep, [x2, #16]
+ prfm pldl1keep, [x3, #16]
+ fmla v25.4s, v7.4s, v5.s[0] // {t1a,t2a,t5a,t6a}
+ prfm pldl1keep, [x0, #16]
+ prfm pldl1keep, [x1, #16]
+
+ zip1 v20.4s, v24.4s, v25.4s
+ zip2 v21.4s, v24.4s, v25.4s
+ fneg v22.4s, v20.4s
+ fadd v4.4s, v21.4s, v20.4s
+ fsub v6.4s, v20.4s, v21.4s // just the second half
+ fadd v5.4s, v21.4s, v22.4s // just the first half
+
+ tbl v4.16b, {v4.16b}, v30.16b // trans4_float
+ tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
+
+ fadd v20.4s, v16.4s, v4.4s
+ fsub v22.4s, v16.4s, v4.4s
+ fadd v21.4s, v17.4s, v5.4s
+ st1 {v20.4s}, [x0], #16 // {z[0], z[1]}
+ fsub v23.4s, v17.4s, v5.4s
+
+ st1 {v21.4s}, [x1], #16 // {z[o1],z[o1+1]}
+ st1 {v22.4s}, [x2], #16 // {z[o2],z[o2+1]}
+ st1 {v23.4s}, [x3], #16 // {z[o3],z[o3+1]}
+1:
+ ld1 {v20.4s},[x2] // {z[o2],z[o2+1]}
+ ld1 {v22.4s},[x3] // {z[o3],z[o3+1]}
+ ld1 {v4.2s}, [x4], #8 // {wre[0],wre[1]}
+ transpose v26.2d, v27.2d, v20.2d, v22.2d
+ ld1 {v5.2s}, [x5], x7 // {wim[-1],wim[0]}
+ rev64 v6.4s, v26.4s
+ fmul v26.4s, v26.4s, v4.s[0]
+ rev64 v7.4s, v27.4s
+ fmul v27.4s, v27.4s, v4.s[1]
+ fmul v6.4s, v6.4s, v29.4s
+ fmul v7.4s, v7.4s, v29.4s
+ ld1 {v16.4s},[x0] // {z[0],z[1]}
+ fmla v26.4s, v6.4s, v5.s[1] // {t1,t2,t5,t6}
+ fmla v27.4s, v7.4s, v5.s[0] // {t1a,t2a,t5a,t6a}
+ ld1 {v17.4s},[x1] // {z[o1],z[o1+1]}
+
+ subs x6, x6, #1 // n--
+
+ zip1 v20.4s, v26.4s, v27.4s
+ zip2 v21.4s, v26.4s, v27.4s
+ fneg v22.4s, v20.4s
+ fadd v4.4s, v21.4s, v20.4s
+ fsub v6.4s, v20.4s, v21.4s // just the second half
+ fadd v5.4s, v21.4s, v22.4s // just the first half
+
+ tbl v4.16b, {v4.16b}, v30.16b // trans4_float
+ tbl v5.16b, {v5.16b,v6.16b}, v31.16b // trans8_float
+
+ fadd v20.4s, v16.4s, v4.4s
+ fsub v22.4s, v16.4s, v4.4s
+ fadd v21.4s, v17.4s, v5.4s
+ st1 {v20.4s}, [x0], #16 // {z[0], z[1]}
+ fsub v23.4s, v17.4s, v5.4s
+
+ st1 {v21.4s}, [x1], #16 // {z[o1],z[o1+1]}
+ st1 {v22.4s}, [x2], #16 // {z[o2],z[o2+1]}
+ st1 {v23.4s}, [x3], #16 // {z[o3],z[o3+1]}
+ b.ne 1b
+
+ ret
+endfunc
+
+.macro def_fft n, n2, n4
+function fft\n\()_neon align=6
+ sub sp, sp, #16
+ stp x28, x30, [sp]
+ add x28, x0, #\n4*2*8
+ bl fft\n2\()_neon
+ mov x0, x28
+ bl fft\n4\()_neon
+ add x0, x28, #\n4*1*8
+ bl fft\n4\()_neon
+ sub x0, x28, #\n4*2*8
+ ldp x28, x30, [sp], #16
+ movrel x4, X(ff_cos_\n)
+ mov x2, #\n4>>1
+ b fft_pass_neon
+endfunc
+.endm
+
+ def_fft 32, 16, 8
+ def_fft 64, 32, 16
+ def_fft 128, 64, 32
+ def_fft 256, 128, 64
+ def_fft 512, 256, 128
+ def_fft 1024, 512, 256
+ def_fft 2048, 1024, 512
+ def_fft 4096, 2048, 1024
+ def_fft 8192, 4096, 2048
+ def_fft 16384, 8192, 4096
+ def_fft 32768, 16384, 8192
+ def_fft 65536, 32768, 16384
+
+function ff_fft_calc_neon, export=1
+ prfm pldl1keep, [x1]
+ movrel x10, trans4_float
+ ldr w2, [x0]
+ movrel x11, trans8_float
+ sub w2, w2, #2
+ movrel x3, fft_tab_neon
+ ld1 {v30.16b}, [x10]
+ mov x7, #-8
+ movrel x12, pmmp
+ ldr x3, [x3, x2, lsl #3]
+ movrel x13, mppm
+ movrel x14, X(ff_cos_16)
+ ld1 {v31.16b}, [x11]
+ mov x0, x1
+ ld1 {v29.4s}, [x12] // pmmp
+ ld1 {v28.4s}, [x13]
+ br x3
+endfunc
+
+function ff_fft_permute_neon, export=1
+ mov x6, #1
+ ldr w2, [x0] // nbits
+ ldr x3, [x0, #16] // tmp_buf
+ ldr x0, [x0, #8] // revtab
+ lsl x6, x6, x2
+ mov x2, x6
+1:
+ ld1 {v0.2s,v1.2s}, [x1], #16
+ ldr w4, [x0], #4
+ uxth w5, w4
+ lsr w4, w4, #16
+ add x5, x3, x5, lsl #3
+ add x4, x3, x4, lsl #3
+ st1 {v0.2s}, [x5]
+ st1 {v1.2s}, [x4]
+ subs x6, x6, #2
+ b.gt 1b
+
+ sub x1, x1, x2, lsl #3
+1:
+ ld1 {v0.4s,v1.4s}, [x3], #32
+ st1 {v0.4s,v1.4s}, [x1], #32
+ subs x2, x2, #4
+ b.gt 1b
+
+ ret
+endfunc
+
+const fft_tab_neon
+ .quad fft4_neon
+ .quad fft8_neon
+ .quad fft16_neon
+ .quad fft32_neon
+ .quad fft64_neon
+ .quad fft128_neon
+ .quad fft256_neon
+ .quad fft512_neon
+ .quad fft1024_neon
+ .quad fft2048_neon
+ .quad fft4096_neon
+ .quad fft8192_neon
+ .quad fft16384_neon
+ .quad fft32768_neon
+ .quad fft65536_neon
+endconst
+
+const pmmp, align=4
+ .float +1.0, -1.0, -1.0, +1.0
+endconst
+
+const mppm, align=4
+ .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
+endconst
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264chroma_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264chroma_init_aarch64.c
new file mode 100644
index 00000000000..2af62becf7c
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264chroma_init_aarch64.c
@@ -0,0 +1,59 @@
+/*
+ * ARM NEON optimised H.264 chroma functions
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/h264chroma.h"
+
+#include "config.h"
+
+void ff_put_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+void ff_put_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+void ff_put_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+
+void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, int stride,
+ int h, int x, int y);
+
+av_cold void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth)
+{
+ const int high_bit_depth = bit_depth > 8;
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags) && !high_bit_depth) {
+ c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;
+ c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;
+ c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_neon;
+
+ c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_neon;
+ c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_neon;
+ c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264cmc_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264cmc_neon.S
new file mode 100644
index 00000000000..a6ed877f2d6
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264cmc_neon.S
@@ -0,0 +1,402 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+/* chroma_mc8(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
+.macro h264_chroma_mc8 type, codec=h264
+function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
+ sxtw x2, w2
+ .ifc \type,avg
+ mov x8, x0
+ .endif
+ prfm pldl1strm, [x1]
+ prfm pldl1strm, [x1, x2]
+ .ifc \codec,rv40
+ movrel x6, rv40bias
+ lsr w9, w5, #1
+ lsr w10, w4, #1
+ lsl w9, w9, #3
+ lsl w10, w10, #1
+ add w9, w9, w10
+ add x6, x6, w9, UXTW
+ ld1r {v22.8H}, [x6]
+ .endif
+ .ifc \codec,vc1
+ movi v22.8H, #28
+ .endif
+ mul w7, w4, w5
+ lsl w14, w5, #3
+ lsl w13, w4, #3
+ cmp w7, #0
+ sub w6, w14, w7
+ sub w12, w13, w7
+ sub w4, w7, w13
+ sub w4, w4, w14
+ add w4, w4, #64
+ b.eq 2f
+
+ dup v0.8B, w4
+ dup v1.8B, w12
+ ld1 {v4.8B, v5.8B}, [x1], x2
+ dup v2.8B, w6
+ dup v3.8B, w7
+ ext v5.8B, v4.8B, v5.8B, #1
+1: ld1 {v6.8B, v7.8B}, [x1], x2
+ umull v16.8H, v4.8B, v0.8B
+ umlal v16.8H, v5.8B, v1.8B
+ ext v7.8B, v6.8B, v7.8B, #1
+ ld1 {v4.8B, v5.8B}, [x1], x2
+ umlal v16.8H, v6.8B, v2.8B
+ prfm pldl1strm, [x1]
+ ext v5.8B, v4.8B, v5.8B, #1
+ umlal v16.8H, v7.8B, v3.8B
+ umull v17.8H, v6.8B, v0.8B
+ subs w3, w3, #2
+ umlal v17.8H, v7.8B, v1.8B
+ umlal v17.8H, v4.8B, v2.8B
+ umlal v17.8H, v5.8B, v3.8B
+ prfm pldl1strm, [x1, x2]
+ .ifc \codec,h264
+ rshrn v16.8B, v16.8H, #6
+ rshrn v17.8B, v17.8H, #6
+ .else
+ add v16.8H, v16.8H, v22.8H
+ add v17.8H, v17.8H, v22.8H
+ shrn v16.8B, v16.8H, #6
+ shrn v17.8B, v17.8H, #6
+ .endif
+ .ifc \type,avg
+ ld1 {v20.8B}, [x8], x2
+ ld1 {v21.8B}, [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ urhadd v17.8B, v17.8B, v21.8B
+ .endif
+ st1 {v16.8B}, [x0], x2
+ st1 {v17.8B}, [x0], x2
+ b.gt 1b
+ ret
+
+2: tst w6, w6
+ add w12, w12, w6
+ dup v0.8B, w4
+ dup v1.8B, w12
+ b.eq 4f
+
+ ld1 {v4.8B}, [x1], x2
+3: ld1 {v6.8B}, [x1], x2
+ umull v16.8H, v4.8B, v0.8B
+ umlal v16.8H, v6.8B, v1.8B
+ ld1 {v4.8B}, [x1], x2
+ umull v17.8H, v6.8B, v0.8B
+ umlal v17.8H, v4.8B, v1.8B
+ prfm pldl1strm, [x1]
+ .ifc \codec,h264
+ rshrn v16.8B, v16.8H, #6
+ rshrn v17.8B, v17.8H, #6
+ .else
+ add v16.8H, v16.8H, v22.8H
+ add v17.8H, v17.8H, v22.8H
+ shrn v16.8B, v16.8H, #6
+ shrn v17.8B, v17.8H, #6
+ .endif
+ prfm pldl1strm, [x1, x2]
+ .ifc \type,avg
+ ld1 {v20.8B}, [x8], x2
+ ld1 {v21.8B}, [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ urhadd v17.8B, v17.8B, v21.8B
+ .endif
+ subs w3, w3, #2
+ st1 {v16.8B}, [x0], x2
+ st1 {v17.8B}, [x0], x2
+ b.gt 3b
+ ret
+
+4: ld1 {v4.8B, v5.8B}, [x1], x2
+ ld1 {v6.8B, v7.8B}, [x1], x2
+ ext v5.8B, v4.8B, v5.8B, #1
+ ext v7.8B, v6.8B, v7.8B, #1
+ prfm pldl1strm, [x1]
+ subs w3, w3, #2
+ umull v16.8H, v4.8B, v0.8B
+ umlal v16.8H, v5.8B, v1.8B
+ umull v17.8H, v6.8B, v0.8B
+ umlal v17.8H, v7.8B, v1.8B
+ prfm pldl1strm, [x1, x2]
+ .ifc \codec,h264
+ rshrn v16.8B, v16.8H, #6
+ rshrn v17.8B, v17.8H, #6
+ .else
+ add v16.8H, v16.8H, v22.8H
+ add v17.8H, v17.8H, v22.8H
+ shrn v16.8B, v16.8H, #6
+ shrn v17.8B, v17.8H, #6
+ .endif
+ .ifc \type,avg
+ ld1 {v20.8B}, [x8], x2
+ ld1 {v21.8B}, [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ urhadd v17.8B, v17.8B, v21.8B
+ .endif
+ st1 {v16.8B}, [x0], x2
+ st1 {v17.8B}, [x0], x2
+ b.gt 4b
+ ret
+endfunc
+.endm
+
+/* chroma_mc4(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y) */
+.macro h264_chroma_mc4 type, codec=h264
+function ff_\type\()_\codec\()_chroma_mc4_neon, export=1
+ sxtw x2, w2
+ .ifc \type,avg
+ mov x8, x0
+ .endif
+ prfm pldl1strm, [x1]
+ prfm pldl1strm, [x1, x2]
+ .ifc \codec,rv40
+ movrel x6, rv40bias
+ lsr w9, w5, #1
+ lsr w10, w4, #1
+ lsl w9, w9, #3
+ lsl w10, w10, #1
+ add w9, w9, w10
+ add x6, x6, w9, UXTW
+ ld1r {v22.8H}, [x6]
+ .endif
+ .ifc \codec,vc1
+ movi v22.8H, #28
+ .endif
+ mul w7, w4, w5
+ lsl w14, w5, #3
+ lsl w13, w4, #3
+ cmp w7, #0
+ sub w6, w14, w7
+ sub w12, w13, w7
+ sub w4, w7, w13
+ sub w4, w4, w14
+ add w4, w4, #64
+ b.eq 2f
+
+ dup v24.8B, w4
+ dup v25.8B, w12
+ ld1 {v4.8B}, [x1], x2
+ dup v26.8B, w6
+ dup v27.8B, w7
+ ext v5.8B, v4.8B, v5.8B, #1
+ trn1 v0.2S, v24.2S, v25.2S
+ trn1 v2.2S, v26.2S, v27.2S
+ trn1 v4.2S, v4.2S, v5.2S
+1: ld1 {v6.8B}, [x1], x2
+ ext v7.8B, v6.8B, v7.8B, #1
+ trn1 v6.2S, v6.2S, v7.2S
+ umull v18.8H, v4.8B, v0.8B
+ umlal v18.8H, v6.8B, v2.8B
+ ld1 {v4.8B}, [x1], x2
+ ext v5.8B, v4.8B, v5.8B, #1
+ trn1 v4.2S, v4.2S, v5.2S
+ prfm pldl1strm, [x1]
+ umull v19.8H, v6.8B, v0.8B
+ umlal v19.8H, v4.8B, v2.8B
+ trn1 v30.2D, v18.2D, v19.2D
+ trn2 v31.2D, v18.2D, v19.2D
+ add v18.8H, v30.8H, v31.8H
+ .ifc \codec,h264
+ rshrn v16.8B, v18.8H, #6
+ .else
+ add v18.8H, v18.8H, v22.8H
+ shrn v16.8B, v18.8H, #6
+ .endif
+ subs w3, w3, #2
+ prfm pldl1strm, [x1, x2]
+ .ifc \type,avg
+ ld1 {v20.S}[0], [x8], x2
+ ld1 {v20.S}[1], [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ .endif
+ st1 {v16.S}[0], [x0], x2
+ st1 {v16.S}[1], [x0], x2
+ b.gt 1b
+ ret
+
+2: tst w6, w6
+ add w12, w12, w6
+ dup v30.8B, w4
+ dup v31.8B, w12
+ trn1 v0.2S, v30.2S, v31.2S
+ trn2 v1.2S, v30.2S, v31.2S
+ b.eq 4f
+
+ ext v1.8B, v0.8B, v1.8B, #4
+ ld1 {v4.S}[0], [x1], x2
+3: ld1 {v4.S}[1], [x1], x2
+ umull v18.8H, v4.8B, v0.8B
+ ld1 {v4.S}[0], [x1], x2
+ umull v19.8H, v4.8B, v1.8B
+ trn1 v30.2D, v18.2D, v19.2D
+ trn2 v31.2D, v18.2D, v19.2D
+ add v18.8H, v30.8H, v31.8H
+ prfm pldl1strm, [x1]
+ .ifc \codec,h264
+ rshrn v16.8B, v18.8H, #6
+ .else
+ add v18.8H, v18.8H, v22.8H
+ shrn v16.8B, v18.8H, #6
+ .endif
+ .ifc \type,avg
+ ld1 {v20.S}[0], [x8], x2
+ ld1 {v20.S}[1], [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ .endif
+ subs w3, w3, #2
+ prfm pldl1strm, [x1, x2]
+ st1 {v16.S}[0], [x0], x2
+ st1 {v16.S}[1], [x0], x2
+ b.gt 3b
+ ret
+
+4: ld1 {v4.8B}, [x1], x2
+ ld1 {v6.8B}, [x1], x2
+ ext v5.8B, v4.8B, v5.8B, #1
+ ext v7.8B, v6.8B, v7.8B, #1
+ trn1 v4.2S, v4.2S, v5.2S
+ trn1 v6.2S, v6.2S, v7.2S
+ umull v18.8H, v4.8B, v0.8B
+ umull v19.8H, v6.8B, v0.8B
+ subs w3, w3, #2
+ trn1 v30.2D, v18.2D, v19.2D
+ trn2 v31.2D, v18.2D, v19.2D
+ add v18.8H, v30.8H, v31.8H
+ prfm pldl1strm, [x1]
+ .ifc \codec,h264
+ rshrn v16.8B, v18.8H, #6
+ .else
+ add v18.8H, v18.8H, v22.8H
+ shrn v16.8B, v18.8H, #6
+ .endif
+ .ifc \type,avg
+ ld1 {v20.S}[0], [x8], x2
+ ld1 {v20.S}[1], [x8], x2
+ urhadd v16.8B, v16.8B, v20.8B
+ .endif
+ prfm pldl1strm, [x1]
+ st1 {v16.S}[0], [x0], x2
+ st1 {v16.S}[1], [x0], x2
+ b.gt 4b
+ ret
+endfunc
+.endm
+
+.macro h264_chroma_mc2 type
+function ff_\type\()_h264_chroma_mc2_neon, export=1
+ sxtw x2, w2
+ prfm pldl1strm, [x1]
+ prfm pldl1strm, [x1, x2]
+ orr w7, w4, w5
+ cbz w7, 2f
+
+ mul w7, w4, w5
+ lsl w14, w5, #3
+ lsl w13, w4, #3
+ sub w6, w14, w7
+ sub w12, w13, w7
+ sub w4, w7, w13
+ sub w4, w4, w14
+ add w4, w4, #64
+ dup v0.8B, w4
+ dup v2.8B, w12
+ dup v1.8B, w6
+ dup v3.8B, w7
+ trn1 v0.4H, v0.4H, v2.4H
+ trn1 v1.4H, v1.4H, v3.4H
+1:
+ ld1 {v4.S}[0], [x1], x2
+ ld1 {v4.S}[1], [x1], x2
+ rev64 v5.2S, v4.2S
+ ld1 {v5.S}[1], [x1]
+ ext v6.8B, v4.8B, v5.8B, #1
+ ext v7.8B, v5.8B, v4.8B, #1
+ trn1 v4.4H, v4.4H, v6.4H
+ trn1 v5.4H, v5.4H, v7.4H
+ umull v16.8H, v4.8B, v0.8B
+ umlal v16.8H, v5.8B, v1.8B
+ .ifc \type,avg
+ ld1 {v18.H}[0], [x0], x2
+ ld1 {v18.H}[2], [x0]
+ sub x0, x0, x2
+ .endif
+ rev64 v17.4S, v16.4S
+ add v16.8H, v16.8H, v17.8H
+ rshrn v16.8B, v16.8H, #6
+ .ifc \type,avg
+ urhadd v16.8B, v16.8B, v18.8B
+ .endif
+ st1 {v16.H}[0], [x0], x2
+ st1 {v16.H}[2], [x0], x2
+ subs w3, w3, #2
+ b.gt 1b
+ ret
+
+2:
+ ld1 {v16.H}[0], [x1], x2
+ ld1 {v16.H}[1], [x1], x2
+ .ifc \type,avg
+ ld1 {v18.H}[0], [x0], x2
+ ld1 {v18.H}[1], [x0]
+ sub x0, x0, x2
+ urhadd v16.8B, v16.8B, v18.8B
+ .endif
+ st1 {v16.H}[0], [x0], x2
+ st1 {v16.H}[1], [x0], x2
+ subs w3, w3, #2
+ b.gt 2b
+ ret
+endfunc
+.endm
+
+ h264_chroma_mc8 put
+ h264_chroma_mc8 avg
+ h264_chroma_mc4 put
+ h264_chroma_mc4 avg
+ h264_chroma_mc2 put
+ h264_chroma_mc2 avg
+
+#if CONFIG_RV40_DECODER
+const rv40bias
+ .short 0, 16, 32, 16
+ .short 32, 28, 32, 28
+ .short 0, 32, 16, 32
+ .short 32, 28, 32, 28
+endconst
+
+ h264_chroma_mc8 put, rv40
+ h264_chroma_mc8 avg, rv40
+ h264_chroma_mc4 put, rv40
+ h264_chroma_mc4 avg, rv40
+#endif
+
+#if CONFIG_VC1_DECODER
+ h264_chroma_mc8 put, vc1
+ h264_chroma_mc8 avg, vc1
+ h264_chroma_mc4 put, vc1
+ h264_chroma_mc4 avg, vc1
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_init_aarch64.c
new file mode 100644
index 00000000000..ed5e4bdd9b5
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_init_aarch64.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/h264dsp.h"
+
+void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
+ int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
+ int beta, int8_t *tc0);
+void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
+ int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
+ int beta, int8_t *tc0);
+
+void ff_weight_h264_pixels_16_neon(uint8_t *dst, int stride, int height,
+ int log2_den, int weight, int offset);
+void ff_weight_h264_pixels_8_neon(uint8_t *dst, int stride, int height,
+ int log2_den, int weight, int offset);
+void ff_weight_h264_pixels_4_neon(uint8_t *dst, int stride, int height,
+ int log2_den, int weight, int offset);
+
+void ff_biweight_h264_pixels_16_neon(uint8_t *dst, uint8_t *src, int stride,
+ int height, int log2_den, int weightd,
+ int weights, int offset);
+void ff_biweight_h264_pixels_8_neon(uint8_t *dst, uint8_t *src, int stride,
+ int height, int log2_den, int weightd,
+ int weights, int offset);
+void ff_biweight_h264_pixels_4_neon(uint8_t *dst, uint8_t *src, int stride,
+ int height, int log2_den, int weightd,
+ int weights, int offset);
+
+void ff_h264_idct_add_neon(uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct_dc_add_neon(uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset,
+ int16_t *block, int stride,
+ const uint8_t nnzc[6*8]);
+void ff_h264_idct_add16intra_neon(uint8_t *dst, const int *block_offset,
+ int16_t *block, int stride,
+ const uint8_t nnzc[6*8]);
+void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset,
+ int16_t *block, int stride,
+ const uint8_t nnzc[6*8]);
+
+void ff_h264_idct8_add_neon(uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct8_dc_add_neon(uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset,
+ int16_t *block, int stride,
+ const uint8_t nnzc[6*8]);
+
+av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
+ const int chroma_format_idc)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags) && bit_depth == 8) {
+ c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
+ c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;
+ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
+ c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
+
+ c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon;
+ c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon;
+ c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon;
+
+ c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon;
+ c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon;
+ c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon;
+
+ c->h264_idct_add = ff_h264_idct_add_neon;
+ c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
+ c->h264_idct_add16 = ff_h264_idct_add16_neon;
+ c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
+ if (chroma_format_idc <= 1)
+ c->h264_idct_add8 = ff_h264_idct_add8_neon;
+ c->h264_idct8_add = ff_h264_idct8_add_neon;
+ c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
+ c->h264_idct8_add4 = ff_h264_idct8_add4_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_neon.S
new file mode 100644
index 00000000000..4ec35f29050
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264dsp_neon.S
@@ -0,0 +1,498 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+#include "neon.S"
+
+.macro h264_loop_filter_start
+ cmp w2, #0
+ ldr w6, [x4]
+ ccmp w3, #0, #0, ne
+ mov v24.S[0], w6
+ and w6, w6, w6, lsl #16
+ b.eq 1f
+ ands w6, w6, w6, lsl #8
+ b.ge 2f
+1:
+ ret
+2:
+.endm
+
+.macro h264_loop_filter_luma
+ dup v22.16B, w2 // alpha
+ uxtl v24.8H, v24.8B
+ uabd v21.16B, v16.16B, v0.16B // abs(p0 - q0)
+ uxtl v24.4S, v24.4H
+ uabd v28.16B, v18.16B, v16.16B // abs(p1 - p0)
+ sli v24.8H, v24.8H, #8
+ uabd v30.16B, v2.16B, v0.16B // abs(q1 - q0)
+ sli v24.4S, v24.4S, #16
+ cmhi v21.16B, v22.16B, v21.16B // < alpha
+ dup v22.16B, w3 // beta
+ cmlt v23.16B, v24.16B, #0
+ cmhi v28.16B, v22.16B, v28.16B // < beta
+ cmhi v30.16B, v22.16B, v30.16B // < beta
+ bic v21.16B, v21.16B, v23.16B
+ uabd v17.16B, v20.16B, v16.16B // abs(p2 - p0)
+ and v21.16B, v21.16B, v28.16B
+ uabd v19.16B, v4.16B, v0.16B // abs(q2 - q0)
+ cmhi v17.16B, v22.16B, v17.16B // < beta
+ and v21.16B, v21.16B, v30.16B
+ cmhi v19.16B, v22.16B, v19.16B // < beta
+ and v17.16B, v17.16B, v21.16B
+ and v19.16B, v19.16B, v21.16B
+ and v24.16B, v24.16B, v21.16B
+ urhadd v28.16B, v16.16B, v0.16B
+ sub v21.16B, v24.16B, v17.16B
+ uqadd v23.16B, v18.16B, v24.16B
+ uhadd v20.16B, v20.16B, v28.16B
+ sub v21.16B, v21.16B, v19.16B
+ uhadd v28.16B, v4.16B, v28.16B
+ umin v23.16B, v23.16B, v20.16B
+ uqsub v22.16B, v18.16B, v24.16B
+ uqadd v4.16B, v2.16B, v24.16B
+ umax v23.16B, v23.16B, v22.16B
+ uqsub v22.16B, v2.16B, v24.16B
+ umin v28.16B, v4.16B, v28.16B
+ uxtl v4.8H, v0.8B
+ umax v28.16B, v28.16B, v22.16B
+ uxtl2 v20.8H, v0.16B
+ usubw v4.8H, v4.8H, v16.8B
+ usubw2 v20.8H, v20.8H, v16.16B
+ shl v4.8H, v4.8H, #2
+ shl v20.8H, v20.8H, #2
+ uaddw v4.8H, v4.8H, v18.8B
+ uaddw2 v20.8H, v20.8H, v18.16B
+ usubw v4.8H, v4.8H, v2.8B
+ usubw2 v20.8H, v20.8H, v2.16B
+ rshrn v4.8B, v4.8H, #3
+ rshrn2 v4.16B, v20.8H, #3
+ bsl v17.16B, v23.16B, v18.16B
+ bsl v19.16B, v28.16B, v2.16B
+ neg v23.16B, v21.16B
+ uxtl v28.8H, v16.8B
+ smin v4.16B, v4.16B, v21.16B
+ uxtl2 v21.8H, v16.16B
+ smax v4.16B, v4.16B, v23.16B
+ uxtl v22.8H, v0.8B
+ uxtl2 v24.8H, v0.16B
+ saddw v28.8H, v28.8H, v4.8B
+ saddw2 v21.8H, v21.8H, v4.16B
+ ssubw v22.8H, v22.8H, v4.8B
+ ssubw2 v24.8H, v24.8H, v4.16B
+ sqxtun v16.8B, v28.8H
+ sqxtun2 v16.16B, v21.8H
+ sqxtun v0.8B, v22.8H
+ sqxtun2 v0.16B, v24.8H
+.endm
+
+function ff_h264_v_loop_filter_luma_neon, export=1
+ h264_loop_filter_start
+ sxtw x1, w1
+
+ ld1 {v0.16B}, [x0], x1
+ ld1 {v2.16B}, [x0], x1
+ ld1 {v4.16B}, [x0], x1
+ sub x0, x0, x1, lsl #2
+ sub x0, x0, x1, lsl #1
+ ld1 {v20.16B}, [x0], x1
+ ld1 {v18.16B}, [x0], x1
+ ld1 {v16.16B}, [x0], x1
+
+ h264_loop_filter_luma
+
+ sub x0, x0, x1, lsl #1
+ st1 {v17.16B}, [x0], x1
+ st1 {v16.16B}, [x0], x1
+ st1 {v0.16B}, [x0], x1
+ st1 {v19.16B}, [x0]
+
+ ret
+endfunc
+
+function ff_h264_h_loop_filter_luma_neon, export=1
+ h264_loop_filter_start
+
+ sub x0, x0, #4
+ ld1 {v6.8B}, [x0], x1
+ ld1 {v20.8B}, [x0], x1
+ ld1 {v18.8B}, [x0], x1
+ ld1 {v16.8B}, [x0], x1
+ ld1 {v0.8B}, [x0], x1
+ ld1 {v2.8B}, [x0], x1
+ ld1 {v4.8B}, [x0], x1
+ ld1 {v26.8B}, [x0], x1
+ ld1 {v6.D}[1], [x0], x1
+ ld1 {v20.D}[1], [x0], x1
+ ld1 {v18.D}[1], [x0], x1
+ ld1 {v16.D}[1], [x0], x1
+ ld1 {v0.D}[1], [x0], x1
+ ld1 {v2.D}[1], [x0], x1
+ ld1 {v4.D}[1], [x0], x1
+ ld1 {v26.D}[1], [x0], x1
+
+ transpose_8x16B v6, v20, v18, v16, v0, v2, v4, v26, v21, v23
+
+ h264_loop_filter_luma
+
+ transpose_4x16B v17, v16, v0, v19, v21, v23, v25, v27
+
+ sub x0, x0, x1, lsl #4
+ add x0, x0, #2
+ st1 {v17.S}[0], [x0], x1
+ st1 {v16.S}[0], [x0], x1
+ st1 {v0.S}[0], [x0], x1
+ st1 {v19.S}[0], [x0], x1
+ st1 {v17.S}[1], [x0], x1
+ st1 {v16.S}[1], [x0], x1
+ st1 {v0.S}[1], [x0], x1
+ st1 {v19.S}[1], [x0], x1
+ st1 {v17.S}[2], [x0], x1
+ st1 {v16.S}[2], [x0], x1
+ st1 {v0.S}[2], [x0], x1
+ st1 {v19.S}[2], [x0], x1
+ st1 {v17.S}[3], [x0], x1
+ st1 {v16.S}[3], [x0], x1
+ st1 {v0.S}[3], [x0], x1
+ st1 {v19.S}[3], [x0], x1
+
+ ret
+endfunc
+
+.macro h264_loop_filter_chroma
+ dup v22.8B, w2 // alpha
+ uxtl v24.8H, v24.8B
+ uabd v26.8B, v16.8B, v0.8B // abs(p0 - q0)
+ uxtl v4.8H, v0.8B
+ uabd v28.8B, v18.8B, v16.8B // abs(p1 - p0)
+ usubw v4.8H, v4.8H, v16.8B
+ sli v24.8H, v24.8H, #8
+ shl v4.8H, v4.8H, #2
+ uabd v30.8B, v2.8B, v0.8B // abs(q1 - q0)
+ uaddw v4.8H, v4.8H, v18.8B
+ cmhi v26.8B, v22.8B, v26.8B // < alpha
+ usubw v4.8H, v4.8H, v2.8B
+ dup v22.8B, w3 // beta
+ rshrn v4.8B, v4.8H, #3
+ cmhi v28.8B, v22.8B, v28.8B // < beta
+ cmhi v30.8B, v22.8B, v30.8B // < beta
+ smin v4.8B, v4.8B, v24.8B
+ neg v25.8B, v24.8B
+ and v26.8B, v26.8B, v28.8B
+ smax v4.8B, v4.8B, v25.8B
+ and v26.8B, v26.8B, v30.8B
+ uxtl v22.8H, v0.8B
+ and v4.8B, v4.8B, v26.8B
+ uxtl v28.8H, v16.8B
+ saddw v28.8H, v28.8H, v4.8B
+ ssubw v22.8H, v22.8H, v4.8B
+ sqxtun v16.8B, v28.8H
+ sqxtun v0.8B, v22.8H
+.endm
+
+function ff_h264_v_loop_filter_chroma_neon, export=1
+ h264_loop_filter_start
+
+ sub x0, x0, x1, lsl #1
+ ld1 {v18.8B}, [x0], x1
+ ld1 {v16.8B}, [x0], x1
+ ld1 {v0.8B}, [x0], x1
+ ld1 {v2.8B}, [x0]
+
+ h264_loop_filter_chroma
+
+ sub x0, x0, x1, lsl #1
+ st1 {v16.8B}, [x0], x1
+ st1 {v0.8B}, [x0], x1
+
+ ret
+endfunc
+
+function ff_h264_h_loop_filter_chroma_neon, export=1
+ h264_loop_filter_start
+
+ sub x0, x0, #2
+ ld1 {v18.S}[0], [x0], x1
+ ld1 {v16.S}[0], [x0], x1
+ ld1 {v0.S}[0], [x0], x1
+ ld1 {v2.S}[0], [x0], x1
+ ld1 {v18.S}[1], [x0], x1
+ ld1 {v16.S}[1], [x0], x1
+ ld1 {v0.S}[1], [x0], x1
+ ld1 {v2.S}[1], [x0], x1
+
+ transpose_4x8B v18, v16, v0, v2, v28, v29, v30, v31
+
+ h264_loop_filter_chroma
+
+ transpose_4x8B v18, v16, v0, v2, v28, v29, v30, v31
+
+ sub x0, x0, x1, lsl #3
+ st1 {v18.S}[0], [x0], x1
+ st1 {v16.S}[0], [x0], x1
+ st1 {v0.S}[0], [x0], x1
+ st1 {v2.S}[0], [x0], x1
+ st1 {v18.S}[1], [x0], x1
+ st1 {v16.S}[1], [x0], x1
+ st1 {v0.S}[1], [x0], x1
+ st1 {v2.S}[1], [x0], x1
+
+ ret
+endfunc
+
+.macro biweight_16 macs, macd
+ dup v0.16B, w5
+ dup v1.16B, w6
+ mov v4.16B, v16.16B
+ mov v6.16B, v16.16B
+1: subs w3, w3, #2
+ ld1 {v20.16B}, [x0], x2
+ \macd v4.8H, v0.8B, v20.8B
+ \macd\()2 v6.8H, v0.16B, v20.16B
+ ld1 {v22.16B}, [x1], x2
+ \macs v4.8H, v1.8B, v22.8B
+ \macs\()2 v6.8H, v1.16B, v22.16B
+ mov v24.16B, v16.16B
+ ld1 {v28.16B}, [x0], x2
+ mov v26.16B, v16.16B
+ \macd v24.8H, v0.8B, v28.8B
+ \macd\()2 v26.8H, v0.16B, v28.16B
+ ld1 {v30.16B}, [x1], x2
+ \macs v24.8H, v1.8B, v30.8B
+ \macs\()2 v26.8H, v1.16B, v30.16B
+ sshl v4.8H, v4.8H, v18.8H
+ sshl v6.8H, v6.8H, v18.8H
+ sqxtun v4.8B, v4.8H
+ sqxtun2 v4.16B, v6.8H
+ sshl v24.8H, v24.8H, v18.8H
+ sshl v26.8H, v26.8H, v18.8H
+ sqxtun v24.8B, v24.8H
+ sqxtun2 v24.16B, v26.8H
+ mov v6.16B, v16.16B
+ st1 {v4.16B}, [x7], x2
+ mov v4.16B, v16.16B
+ st1 {v24.16B}, [x7], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro biweight_8 macs, macd
+ dup v0.8B, w5
+ dup v1.8B, w6
+ mov v2.16B, v16.16B
+ mov v20.16B, v16.16B
+1: subs w3, w3, #2
+ ld1 {v4.8B}, [x0], x2
+ \macd v2.8H, v0.8B, v4.8B
+ ld1 {v5.8B}, [x1], x2
+ \macs v2.8H, v1.8B, v5.8B
+ ld1 {v6.8B}, [x0], x2
+ \macd v20.8H, v0.8B, v6.8B
+ ld1 {v7.8B}, [x1], x2
+ \macs v20.8H, v1.8B, v7.8B
+ sshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ sshl v20.8H, v20.8H, v18.8H
+ sqxtun v4.8B, v20.8H
+ mov v20.16B, v16.16B
+ st1 {v2.8B}, [x7], x2
+ mov v2.16B, v16.16B
+ st1 {v4.8B}, [x7], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro biweight_4 macs, macd
+ dup v0.8B, w5
+ dup v1.8B, w6
+ mov v2.16B, v16.16B
+ mov v20.16B,v16.16B
+1: subs w3, w3, #4
+ ld1 {v4.S}[0], [x0], x2
+ ld1 {v4.S}[1], [x0], x2
+ \macd v2.8H, v0.8B, v4.8B
+ ld1 {v5.S}[0], [x1], x2
+ ld1 {v5.S}[1], [x1], x2
+ \macs v2.8H, v1.8B, v5.8B
+ b.lt 2f
+ ld1 {v6.S}[0], [x0], x2
+ ld1 {v6.S}[1], [x0], x2
+ \macd v20.8H, v0.8B, v6.8B
+ ld1 {v7.S}[0], [x1], x2
+ ld1 {v7.S}[1], [x1], x2
+ \macs v20.8H, v1.8B, v7.8B
+ sshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ sshl v20.8H, v20.8H, v18.8H
+ sqxtun v4.8B, v20.8H
+ mov v20.16B, v16.16B
+ st1 {v2.S}[0], [x7], x2
+ st1 {v2.S}[1], [x7], x2
+ mov v2.16B, v16.16B
+ st1 {v4.S}[0], [x7], x2
+ st1 {v4.S}[1], [x7], x2
+ b.ne 1b
+ ret
+2: sshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ st1 {v2.S}[0], [x7], x2
+ st1 {v2.S}[1], [x7], x2
+ ret
+.endm
+
+.macro biweight_func w
+function ff_biweight_h264_pixels_\w\()_neon, export=1
+ sxtw x2, w2
+ lsr w8, w5, #31
+ add w7, w7, #1
+ eor w8, w8, w6, lsr #30
+ orr w7, w7, #1
+ dup v18.8H, w4
+ lsl w7, w7, w4
+ not v18.16B, v18.16B
+ dup v16.8H, w7
+ mov x7, x0
+ cbz w8, 10f
+ subs w8, w8, #1
+ b.eq 20f
+ subs w8, w8, #1
+ b.eq 30f
+ b 40f
+10: biweight_\w umlal, umlal
+20: neg w5, w5
+ biweight_\w umlal, umlsl
+30: neg w5, w5
+ neg w6, w6
+ biweight_\w umlsl, umlsl
+40: neg w6, w6
+ biweight_\w umlsl, umlal
+endfunc
+.endm
+
+ biweight_func 16
+ biweight_func 8
+ biweight_func 4
+
+.macro weight_16 add
+ dup v0.16B, w4
+1: subs w2, w2, #2
+ ld1 {v20.16B}, [x0], x1
+ umull v4.8H, v0.8B, v20.8B
+ umull2 v6.8H, v0.16B, v20.16B
+ ld1 {v28.16B}, [x0], x1
+ umull v24.8H, v0.8B, v28.8B
+ umull2 v26.8H, v0.16B, v28.16B
+ \add v4.8H, v16.8H, v4.8H
+ srshl v4.8H, v4.8H, v18.8H
+ \add v6.8H, v16.8H, v6.8H
+ srshl v6.8H, v6.8H, v18.8H
+ sqxtun v4.8B, v4.8H
+ sqxtun2 v4.16B, v6.8H
+ \add v24.8H, v16.8H, v24.8H
+ srshl v24.8H, v24.8H, v18.8H
+ \add v26.8H, v16.8H, v26.8H
+ srshl v26.8H, v26.8H, v18.8H
+ sqxtun v24.8B, v24.8H
+ sqxtun2 v24.16B, v26.8H
+ st1 {v4.16B}, [x5], x1
+ st1 {v24.16B}, [x5], x1
+ b.ne 1b
+ ret
+.endm
+
+.macro weight_8 add
+ dup v0.8B, w4
+1: subs w2, w2, #2
+ ld1 {v4.8B}, [x0], x1
+ umull v2.8H, v0.8B, v4.8B
+ ld1 {v6.8B}, [x0], x1
+ umull v20.8H, v0.8B, v6.8B
+ \add v2.8H, v16.8H, v2.8H
+ srshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ \add v20.8H, v16.8H, v20.8H
+ srshl v20.8H, v20.8H, v18.8H
+ sqxtun v4.8B, v20.8H
+ st1 {v2.8B}, [x5], x1
+ st1 {v4.8B}, [x5], x1
+ b.ne 1b
+ ret
+.endm
+
+.macro weight_4 add
+ dup v0.8B, w4
+1: subs w2, w2, #4
+ ld1 {v4.S}[0], [x0], x1
+ ld1 {v4.S}[1], [x0], x1
+ umull v2.8H, v0.8B, v4.8B
+ b.lt 2f
+ ld1 {v6.S}[0], [x0], x1
+ ld1 {v6.S}[1], [x0], x1
+ umull v20.8H, v0.8B, v6.8B
+ \add v2.8H, v16.8H, v2.8H
+ srshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ \add v20.8H, v16.8H, v20.8H
+ srshl v20.8H, v20.8h, v18.8H
+ sqxtun v4.8B, v20.8H
+ st1 {v2.S}[0], [x5], x1
+ st1 {v2.S}[1], [x5], x1
+ st1 {v4.S}[0], [x5], x1
+ st1 {v4.S}[1], [x5], x1
+ b.ne 1b
+ ret
+2: \add v2.8H, v16.8H, v2.8H
+ srshl v2.8H, v2.8H, v18.8H
+ sqxtun v2.8B, v2.8H
+ st1 {v2.S}[0], [x5], x1
+ st1 {v2.S}[1], [x5], x1
+ ret
+.endm
+
+.macro weight_func w
+function ff_weight_h264_pixels_\w\()_neon, export=1
+ sxtw x1, w1
+ cmp w3, #1
+ mov w6, #1
+ lsl w5, w5, w3
+ dup v16.8H, w5
+ mov x5, x0
+ b.le 20f
+ sub w6, w6, w3
+ dup v18.8H, w6
+ cmp w4, #0
+ b.lt 10f
+ weight_\w shadd
+10: neg w4, w4
+ weight_\w shsub
+20: neg w6, w3
+ dup v18.8H, w6
+ cmp w4, #0
+ b.lt 10f
+ weight_\w add
+10: neg w4, w4
+ weight_\w sub
+endfunc
+.endm
+
+ weight_func 16
+ weight_func 8
+ weight_func 4
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264idct_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264idct_neon.S
new file mode 100644
index 00000000000..04b5a47f043
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264idct_neon.S
@@ -0,0 +1,408 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+#include "neon.S"
+
+function ff_h264_idct_add_neon, export=1
+ ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1]
+ sxtw x2, w2
+ movi v30.8H, #0
+
+ add v4.4H, v0.4H, v2.4H
+ sshr v16.4H, v1.4H, #1
+ st1 {v30.8H}, [x1], #16
+ sshr v17.4H, v3.4H, #1
+ st1 {v30.8H}, [x1], #16
+ sub v5.4H, v0.4H, v2.4H
+ add v6.4H, v1.4H, v17.4H
+ sub v7.4H, v16.4H, v3.4H
+ add v0.4H, v4.4H, v6.4H
+ add v1.4H, v5.4H, v7.4H
+ sub v2.4H, v4.4H, v6.4H
+ sub v3.4H, v5.4H, v7.4H
+
+ transpose_4x4H v0, v1, v2, v3, v4, v5, v6, v7
+
+ add v4.4H, v0.4H, v3.4H
+ ld1 {v18.S}[0], [x0], x2
+ sshr v16.4H, v2.4H, #1
+ sshr v17.4H, v1.4H, #1
+ ld1 {v19.S}[1], [x0], x2
+ sub v5.4H, v0.4H, v3.4H
+ ld1 {v18.S}[1], [x0], x2
+ add v6.4H, v16.4H, v1.4H
+ ins v4.D[1], v5.D[0]
+ sub v7.4H, v2.4H, v17.4H
+ ld1 {v19.S}[0], [x0], x2
+ ins v6.D[1], v7.D[0]
+ sub x0, x0, x2, lsl #2
+ add v0.8H, v4.8H, v6.8H
+ sub v1.8H, v4.8H, v6.8H
+
+ srshr v0.8H, v0.8H, #6
+ srshr v1.8H, v1.8H, #6
+
+ uaddw v0.8H, v0.8H, v18.8B
+ uaddw v1.8H, v1.8H, v19.8B
+
+ sqxtun v0.8B, v0.8H
+ sqxtun v1.8B, v1.8H
+
+ st1 {v0.S}[0], [x0], x2
+ st1 {v1.S}[1], [x0], x2
+ st1 {v0.S}[1], [x0], x2
+ st1 {v1.S}[0], [x0], x2
+
+ sub x1, x1, #32
+ ret
+endfunc
+
+function ff_h264_idct_dc_add_neon, export=1
+ sxtw x2, w2
+ mov w3, #0
+ ld1r {v2.8H}, [x1]
+ strh w3, [x1]
+ srshr v2.8H, v2.8H, #6
+ ld1 {v0.S}[0], [x0], x2
+ ld1 {v0.S}[1], [x0], x2
+ uaddw v3.8H, v2.8H, v0.8B
+ ld1 {v1.S}[0], [x0], x2
+ ld1 {v1.S}[1], [x0], x2
+ uaddw v4.8H, v2.8H, v1.8B
+ sqxtun v0.8B, v3.8H
+ sqxtun v1.8B, v4.8H
+ sub x0, x0, x2, lsl #2
+ st1 {v0.S}[0], [x0], x2
+ st1 {v0.S}[1], [x0], x2
+ st1 {v1.S}[0], [x0], x2
+ st1 {v1.S}[1], [x0], x2
+ ret
+endfunc
+
+function ff_h264_idct_add16_neon, export=1
+ mov x12, x30
+ mov x6, x0 // dest
+ mov x5, x1 // block_offset
+ mov x1, x2 // block
+ mov w9, w3 // stride
+ movrel x7, scan8
+ mov x10, #16
+ movrel x13, X(ff_h264_idct_dc_add_neon)
+ movrel x14, X(ff_h264_idct_add_neon)
+1: mov w2, w9
+ ldrb w3, [x7], #1
+ ldrsw x0, [x5], #4
+ ldrb w3, [x4, w3, uxtw]
+ subs w3, w3, #1
+ b.lt 2f
+ ldrsh w3, [x1]
+ add x0, x0, x6
+ ccmp w3, #0, #4, eq
+ csel x15, x13, x14, ne
+ blr x15
+2: subs x10, x10, #1
+ add x1, x1, #32
+ b.ne 1b
+ ret x12
+endfunc
+
+function ff_h264_idct_add16intra_neon, export=1
+ mov x12, x30
+ mov x6, x0 // dest
+ mov x5, x1 // block_offset
+ mov x1, x2 // block
+ mov w9, w3 // stride
+ movrel x7, scan8
+ mov x10, #16
+ movrel x13, X(ff_h264_idct_dc_add_neon)
+ movrel x14, X(ff_h264_idct_add_neon)
+1: mov w2, w9
+ ldrb w3, [x7], #1
+ ldrsw x0, [x5], #4
+ ldrb w3, [x4, w3, uxtw]
+ add x0, x0, x6
+ cmp w3, #0
+ ldrsh w3, [x1]
+ csel x15, x13, x14, eq
+ ccmp w3, #0, #0, eq
+ b.eq 2f
+ blr x15
+2: subs x10, x10, #1
+ add x1, x1, #32
+ b.ne 1b
+ ret x12
+endfunc
+
+function ff_h264_idct_add8_neon, export=1
+ sub sp, sp, #0x40
+ stp x19, x20, [sp]
+ mov x12, x30
+ ldp x6, x15, [x0] // dest[0], dest[1]
+ add x5, x1, #16*4 // block_offset
+ add x9, x2, #16*32 // block
+ mov w19, w3 // stride
+ movrel x13, X(ff_h264_idct_dc_add_neon)
+ movrel x14, X(ff_h264_idct_add_neon)
+ movrel x7, scan8+16
+ mov x10, #0
+ mov x11, #16
+1: mov w2, w19
+ ldrb w3, [x7, x10] // scan8[i]
+ ldrsw x0, [x5, x10, lsl #2] // block_offset[i]
+ ldrb w3, [x4, w3, uxtw] // nnzc[ scan8[i] ]
+ add x0, x0, x6 // block_offset[i] + dst[j-1]
+ add x1, x9, x10, lsl #5 // block + i * 16
+ cmp w3, #0
+ ldrsh w3, [x1] // block[i*16]
+ csel x20, x13, x14, eq
+ ccmp w3, #0, #0, eq
+ b.eq 2f
+ blr x20
+2: add x10, x10, #1
+ cmp x10, #4
+ csel x10, x11, x10, eq // mov x10, #16
+ csel x6, x15, x6, eq
+ cmp x10, #20
+ b.lt 1b
+ ldp x19, x20, [sp]
+ add sp, sp, #0x40
+ ret x12
+endfunc
+
+.macro idct8x8_cols pass
+ .if \pass == 0
+ va .req v18
+ vb .req v30
+ sshr v18.8H, v26.8H, #1
+ add v16.8H, v24.8H, v28.8H
+ ld1 {v30.8H, v31.8H}, [x1]
+ st1 {v19.8H}, [x1], #16
+ st1 {v19.8H}, [x1], #16
+ sub v17.8H, v24.8H, v28.8H
+ sshr v19.8H, v30.8H, #1
+ sub v18.8H, v18.8H, v30.8H
+ add v19.8H, v19.8H, v26.8H
+ .else
+ va .req v30
+ vb .req v18
+ sshr v30.8H, v26.8H, #1
+ sshr v19.8H, v18.8H, #1
+ add v16.8H, v24.8H, v28.8H
+ sub v17.8H, v24.8H, v28.8H
+ sub v30.8H, v30.8H, v18.8H
+ add v19.8H, v19.8H, v26.8H
+ .endif
+ add v26.8H, v17.8H, va.8H
+ sub v28.8H, v17.8H, va.8H
+ add v24.8H, v16.8H, v19.8H
+ sub vb.8H, v16.8H, v19.8H
+ sub v16.8H, v29.8H, v27.8H
+ add v17.8H, v31.8H, v25.8H
+ sub va.8H, v31.8H, v25.8H
+ add v19.8H, v29.8H, v27.8H
+ sub v16.8H, v16.8H, v31.8H
+ sub v17.8H, v17.8H, v27.8H
+ add va.8H, va.8H, v29.8H
+ add v19.8H, v19.8H, v25.8H
+ sshr v25.8H, v25.8H, #1
+ sshr v27.8H, v27.8H, #1
+ sshr v29.8H, v29.8H, #1
+ sshr v31.8H, v31.8H, #1
+ sub v16.8H, v16.8H, v31.8H
+ sub v17.8H, v17.8H, v27.8H
+ add va.8H, va.8H, v29.8H
+ add v19.8H, v19.8H, v25.8H
+ sshr v25.8H, v16.8H, #2
+ sshr v27.8H, v17.8H, #2
+ sshr v29.8H, va.8H, #2
+ sshr v31.8H, v19.8H, #2
+ sub v19.8H, v19.8H, v25.8H
+ sub va.8H, v27.8H, va.8H
+ add v17.8H, v17.8H, v29.8H
+ add v16.8H, v16.8H, v31.8H
+ .if \pass == 0
+ sub v31.8H, v24.8H, v19.8H
+ add v24.8H, v24.8H, v19.8H
+ add v25.8H, v26.8H, v18.8H
+ sub v18.8H, v26.8H, v18.8H
+ add v26.8H, v28.8H, v17.8H
+ add v27.8H, v30.8H, v16.8H
+ sub v29.8H, v28.8H, v17.8H
+ sub v28.8H, v30.8H, v16.8H
+ .else
+ sub v31.8H, v24.8H, v19.8H
+ add v24.8H, v24.8H, v19.8H
+ add v25.8H, v26.8H, v30.8H
+ sub v30.8H, v26.8H, v30.8H
+ add v26.8H, v28.8H, v17.8H
+ sub v29.8H, v28.8H, v17.8H
+ add v27.8H, v18.8H, v16.8H
+ sub v28.8H, v18.8H, v16.8H
+ .endif
+ .unreq va
+ .unreq vb
+.endm
+
+function ff_h264_idct8_add_neon, export=1
+ movi v19.8H, #0
+ ld1 {v24.8H, v25.8H}, [x1]
+ st1 {v19.8H}, [x1], #16
+ st1 {v19.8H}, [x1], #16
+ ld1 {v26.8H, v27.8H}, [x1]
+ st1 {v19.8H}, [x1], #16
+ st1 {v19.8H}, [x1], #16
+ ld1 {v28.8H, v29.8H}, [x1]
+ st1 {v19.8H}, [x1], #16
+ st1 {v19.8H}, [x1], #16
+
+ idct8x8_cols 0
+ transpose_8x8H v24, v25, v26, v27, v28, v29, v18, v31, v6, v7
+ idct8x8_cols 1
+
+ mov x3, x0
+ srshr v24.8H, v24.8H, #6
+ ld1 {v0.8B}, [x0], x2
+ srshr v25.8H, v25.8H, #6
+ ld1 {v1.8B}, [x0], x2
+ srshr v26.8H, v26.8H, #6
+ ld1 {v2.8B}, [x0], x2
+ srshr v27.8H, v27.8H, #6
+ ld1 {v3.8B}, [x0], x2
+ srshr v28.8H, v28.8H, #6
+ ld1 {v4.8B}, [x0], x2
+ srshr v29.8H, v29.8H, #6
+ ld1 {v5.8B}, [x0], x2
+ srshr v30.8H, v30.8H, #6
+ ld1 {v6.8B}, [x0], x2
+ srshr v31.8H, v31.8H, #6
+ ld1 {v7.8B}, [x0], x2
+ uaddw v24.8H, v24.8H, v0.8B
+ uaddw v25.8H, v25.8H, v1.8B
+ uaddw v26.8H, v26.8H, v2.8B
+ sqxtun v0.8B, v24.8H
+ uaddw v27.8H, v27.8H, v3.8B
+ sqxtun v1.8B, v25.8H
+ uaddw v28.8H, v28.8H, v4.8B
+ sqxtun v2.8B, v26.8H
+ st1 {v0.8B}, [x3], x2
+ uaddw v29.8H, v29.8H, v5.8B
+ sqxtun v3.8B, v27.8H
+ st1 {v1.8B}, [x3], x2
+ uaddw v30.8H, v30.8H, v6.8B
+ sqxtun v4.8B, v28.8H
+ st1 {v2.8B}, [x3], x2
+ uaddw v31.8H, v31.8H, v7.8B
+ sqxtun v5.8B, v29.8H
+ st1 {v3.8B}, [x3], x2
+ sqxtun v6.8B, v30.8H
+ sqxtun v7.8B, v31.8H
+ st1 {v4.8B}, [x3], x2
+ st1 {v5.8B}, [x3], x2
+ st1 {v6.8B}, [x3], x2
+ st1 {v7.8B}, [x3], x2
+
+ sub x1, x1, #128
+ ret
+endfunc
+
+function ff_h264_idct8_dc_add_neon, export=1
+ mov w3, #0
+ sxtw x2, w2
+ ld1r {v31.8H}, [x1]
+ strh w3, [x1]
+ ld1 {v0.8B}, [x0], x2
+ srshr v31.8H, v31.8H, #6
+ ld1 {v1.8B}, [x0], x2
+ ld1 {v2.8B}, [x0], x2
+ uaddw v24.8H, v31.8H, v0.8B
+ ld1 {v3.8B}, [x0], x2
+ uaddw v25.8H, v31.8H, v1.8B
+ ld1 {v4.8B}, [x0], x2
+ uaddw v26.8H, v31.8H, v2.8B
+ ld1 {v5.8B}, [x0], x2
+ uaddw v27.8H, v31.8H, v3.8B
+ ld1 {v6.8B}, [x0], x2
+ uaddw v28.8H, v31.8H, v4.8B
+ ld1 {v7.8B}, [x0], x2
+ uaddw v29.8H, v31.8H, v5.8B
+ uaddw v30.8H, v31.8H, v6.8B
+ uaddw v31.8H, v31.8H, v7.8B
+ sqxtun v0.8B, v24.8H
+ sqxtun v1.8B, v25.8H
+ sqxtun v2.8B, v26.8H
+ sqxtun v3.8B, v27.8H
+ sub x0, x0, x2, lsl #3
+ st1 {v0.8B}, [x0], x2
+ sqxtun v4.8B, v28.8H
+ st1 {v1.8B}, [x0], x2
+ sqxtun v5.8B, v29.8H
+ st1 {v2.8B}, [x0], x2
+ sqxtun v6.8B, v30.8H
+ st1 {v3.8B}, [x0], x2
+ sqxtun v7.8B, v31.8H
+ st1 {v4.8B}, [x0], x2
+ st1 {v5.8B}, [x0], x2
+ st1 {v6.8B}, [x0], x2
+ st1 {v7.8B}, [x0], x2
+ ret
+endfunc
+
+function ff_h264_idct8_add4_neon, export=1
+ mov x12, x30
+ mov x6, x0
+ mov x5, x1
+ mov x1, x2
+ mov w2, w3
+ movrel x7, scan8
+ mov w10, #16
+ movrel x13, X(ff_h264_idct8_dc_add_neon)
+ movrel x14, X(ff_h264_idct8_add_neon)
+1: ldrb w9, [x7], #4
+ ldrsw x0, [x5], #16
+ ldrb w9, [x4, w9, UXTW]
+ subs w9, w9, #1
+ b.lt 2f
+ ldrsh w11, [x1]
+ add x0, x6, x0
+ ccmp w11, #0, #4, eq
+ csel x15, x13, x14, ne
+ blr x15
+2: subs w10, w10, #4
+ add x1, x1, #128
+ b.ne 1b
+ ret x12
+endfunc
+
+const scan8
+ .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
+ .byte 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8
+ .byte 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8
+ .byte 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8
+ .byte 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8
+ .byte 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8
+ .byte 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8
+ .byte 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8
+ .byte 4+11*8, 5+11*8, 4+12*8, 5+12*8
+ .byte 6+11*8, 7+11*8, 6+12*8, 7+12*8
+ .byte 4+13*8, 5+13*8, 4+14*8, 5+14*8
+ .byte 6+13*8, 7+13*8, 6+14*8, 7+14*8
+endconst
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_init_aarch64.c
new file mode 100644
index 00000000000..0578c01704c
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_init_aarch64.c
@@ -0,0 +1,172 @@
+/*
+ * ARM NEON optimised DSP functions
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/h264qpel.h"
+
+void ff_put_h264_qpel16_mc00_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc10_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc20_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc30_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc01_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc11_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc21_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc31_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc02_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc12_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc22_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc32_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc03_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc13_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc23_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel16_mc33_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+
+void ff_put_h264_qpel8_mc00_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc10_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc20_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc30_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc01_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc11_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc21_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc31_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc02_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc12_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc22_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc32_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc03_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc13_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc23_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_h264_qpel8_mc33_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+
+void ff_avg_h264_qpel16_mc00_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc10_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc20_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc30_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc01_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc11_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc21_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc31_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc02_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc12_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc22_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc32_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc03_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc13_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc23_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel16_mc33_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+
+void ff_avg_h264_qpel8_mc00_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc10_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc20_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc30_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc01_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc11_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc21_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc31_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc02_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc12_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc22_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc32_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc03_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc13_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc23_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_avg_h264_qpel8_mc33_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+
+av_cold void ff_h264qpel_init_aarch64(H264QpelContext *c, int bit_depth)
+{
+ const int high_bit_depth = bit_depth > 8;
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags) && !high_bit_depth) {
+ c->put_h264_qpel_pixels_tab[0][ 0] = ff_put_h264_qpel16_mc00_neon;
+ c->put_h264_qpel_pixels_tab[0][ 1] = ff_put_h264_qpel16_mc10_neon;
+ c->put_h264_qpel_pixels_tab[0][ 2] = ff_put_h264_qpel16_mc20_neon;
+ c->put_h264_qpel_pixels_tab[0][ 3] = ff_put_h264_qpel16_mc30_neon;
+ c->put_h264_qpel_pixels_tab[0][ 4] = ff_put_h264_qpel16_mc01_neon;
+ c->put_h264_qpel_pixels_tab[0][ 5] = ff_put_h264_qpel16_mc11_neon;
+ c->put_h264_qpel_pixels_tab[0][ 6] = ff_put_h264_qpel16_mc21_neon;
+ c->put_h264_qpel_pixels_tab[0][ 7] = ff_put_h264_qpel16_mc31_neon;
+ c->put_h264_qpel_pixels_tab[0][ 8] = ff_put_h264_qpel16_mc02_neon;
+ c->put_h264_qpel_pixels_tab[0][ 9] = ff_put_h264_qpel16_mc12_neon;
+ c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_neon;
+ c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_neon;
+ c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_neon;
+ c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_neon;
+ c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_neon;
+ c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_neon;
+
+ c->put_h264_qpel_pixels_tab[1][ 0] = ff_put_h264_qpel8_mc00_neon;
+ c->put_h264_qpel_pixels_tab[1][ 1] = ff_put_h264_qpel8_mc10_neon;
+ c->put_h264_qpel_pixels_tab[1][ 2] = ff_put_h264_qpel8_mc20_neon;
+ c->put_h264_qpel_pixels_tab[1][ 3] = ff_put_h264_qpel8_mc30_neon;
+ c->put_h264_qpel_pixels_tab[1][ 4] = ff_put_h264_qpel8_mc01_neon;
+ c->put_h264_qpel_pixels_tab[1][ 5] = ff_put_h264_qpel8_mc11_neon;
+ c->put_h264_qpel_pixels_tab[1][ 6] = ff_put_h264_qpel8_mc21_neon;
+ c->put_h264_qpel_pixels_tab[1][ 7] = ff_put_h264_qpel8_mc31_neon;
+ c->put_h264_qpel_pixels_tab[1][ 8] = ff_put_h264_qpel8_mc02_neon;
+ c->put_h264_qpel_pixels_tab[1][ 9] = ff_put_h264_qpel8_mc12_neon;
+ c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_neon;
+ c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_neon;
+ c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_neon;
+ c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_neon;
+ c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_neon;
+ c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_neon;
+
+ c->avg_h264_qpel_pixels_tab[0][ 0] = ff_avg_h264_qpel16_mc00_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 1] = ff_avg_h264_qpel16_mc10_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 2] = ff_avg_h264_qpel16_mc20_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 3] = ff_avg_h264_qpel16_mc30_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 4] = ff_avg_h264_qpel16_mc01_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 5] = ff_avg_h264_qpel16_mc11_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 6] = ff_avg_h264_qpel16_mc21_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 7] = ff_avg_h264_qpel16_mc31_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 8] = ff_avg_h264_qpel16_mc02_neon;
+ c->avg_h264_qpel_pixels_tab[0][ 9] = ff_avg_h264_qpel16_mc12_neon;
+ c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_neon;
+ c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_neon;
+ c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_neon;
+ c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_neon;
+ c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_neon;
+ c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_neon;
+
+ c->avg_h264_qpel_pixels_tab[1][ 0] = ff_avg_h264_qpel8_mc00_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 1] = ff_avg_h264_qpel8_mc10_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 2] = ff_avg_h264_qpel8_mc20_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 3] = ff_avg_h264_qpel8_mc30_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 4] = ff_avg_h264_qpel8_mc01_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 5] = ff_avg_h264_qpel8_mc11_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 6] = ff_avg_h264_qpel8_mc21_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 7] = ff_avg_h264_qpel8_mc31_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 8] = ff_avg_h264_qpel8_mc02_neon;
+ c->avg_h264_qpel_pixels_tab[1][ 9] = ff_avg_h264_qpel8_mc12_neon;
+ c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_neon;
+ c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_neon;
+ c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_neon;
+ c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_neon;
+ c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_neon;
+ c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_neon.S
new file mode 100644
index 00000000000..d27cfac4941
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/h264qpel_neon.S
@@ -0,0 +1,934 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+#include "neon.S"
+
+ /* H.264 qpel MC */
+
+.macro lowpass_const r
+ movz \r, #20, lsl #16
+ movk \r, #5
+ mov v6.S[0], \r
+.endm
+
+//trashes v0-v5
+.macro lowpass_8 r0, r1, r2, r3, d0, d1, narrow=1
+ ext v2.8B, \r0\().8B, \r1\().8B, #2
+ ext v3.8B, \r0\().8B, \r1\().8B, #3
+ uaddl v2.8H, v2.8B, v3.8B
+ ext v4.8B, \r0\().8B, \r1\().8B, #1
+ ext v5.8B, \r0\().8B, \r1\().8B, #4
+ uaddl v4.8H, v4.8B, v5.8B
+ ext v1.8B, \r0\().8B, \r1\().8B, #5
+ uaddl \d0\().8H, \r0\().8B, v1.8B
+ ext v0.8B, \r2\().8B, \r3\().8B, #2
+ mla \d0\().8H, v2.8H, v6.H[1]
+ ext v1.8B, \r2\().8B, \r3\().8B, #3
+ uaddl v0.8H, v0.8B, v1.8B
+ ext v1.8B, \r2\().8B, \r3\().8B, #1
+ mls \d0\().8H, v4.8H, v6.H[0]
+ ext v3.8B, \r2\().8B, \r3\().8B, #4
+ uaddl v1.8H, v1.8B, v3.8B
+ ext v2.8B, \r2\().8B, \r3\().8B, #5
+ uaddl \d1\().8H, \r2\().8B, v2.8B
+ mla \d1\().8H, v0.8H, v6.H[1]
+ mls \d1\().8H, v1.8H, v6.H[0]
+ .if \narrow
+ sqrshrun \d0\().8B, \d0\().8H, #5
+ sqrshrun \d1\().8B, \d1\().8H, #5
+ .endif
+.endm
+
+//trashes v0-v5, v7, v30-v31
+.macro lowpass_8H r0, r1
+ ext v0.16B, \r0\().16B, \r0\().16B, #2
+ ext v1.16B, \r0\().16B, \r0\().16B, #3
+ uaddl v0.8H, v0.8B, v1.8B
+ ext v2.16B, \r0\().16B, \r0\().16B, #1
+ ext v3.16B, \r0\().16B, \r0\().16B, #4
+ uaddl v2.8H, v2.8B, v3.8B
+ ext v30.16B, \r0\().16B, \r0\().16B, #5
+ uaddl \r0\().8H, \r0\().8B, v30.8B
+ ext v4.16B, \r1\().16B, \r1\().16B, #2
+ mla \r0\().8H, v0.8H, v6.H[1]
+ ext v5.16B, \r1\().16B, \r1\().16B, #3
+ uaddl v4.8H, v4.8B, v5.8B
+ ext v7.16B, \r1\().16B, \r1\().16B, #1
+ mls \r0\().8H, v2.8H, v6.H[0]
+ ext v0.16B, \r1\().16B, \r1\().16B, #4
+ uaddl v7.8H, v7.8B, v0.8B
+ ext v31.16B, \r1\().16B, \r1\().16B, #5
+ uaddl \r1\().8H, \r1\().8B, v31.8B
+ mla \r1\().8H, v4.8H, v6.H[1]
+ mls \r1\().8H, v7.8H, v6.H[0]
+.endm
+
+// trashes v2-v5, v30
+.macro lowpass_8_1 r0, r1, d0, narrow=1
+ ext v2.8B, \r0\().8B, \r1\().8B, #2
+ ext v3.8B, \r0\().8B, \r1\().8B, #3
+ uaddl v2.8H, v2.8B, v3.8B
+ ext v4.8B, \r0\().8B, \r1\().8B, #1
+ ext v5.8B, \r0\().8B, \r1\().8B, #4
+ uaddl v4.8H, v4.8B, v5.8B
+ ext v30.8B, \r0\().8B, \r1\().8B, #5
+ uaddl \d0\().8H, \r0\().8B, v30.8B
+ mla \d0\().8H, v2.8H, v6.H[1]
+ mls \d0\().8H, v4.8H, v6.H[0]
+ .if \narrow
+ sqrshrun \d0\().8B, \d0\().8H, #5
+ .endif
+.endm
+
+// trashed v0-v7
+.macro lowpass_8.16 r0, r1, r2
+ ext v1.16B, \r0\().16B, \r1\().16B, #4
+ ext v0.16B, \r0\().16B, \r1\().16B, #6
+ saddl v5.4S, v1.4H, v0.4H
+ ext v2.16B, \r0\().16B, \r1\().16B, #2
+ saddl2 v1.4S, v1.8H, v0.8H
+ ext v3.16B, \r0\().16B, \r1\().16B, #8
+ saddl v6.4S, v2.4H, v3.4H
+ ext \r1\().16B, \r0\().16B, \r1\().16B, #10
+ saddl2 v2.4S, v2.8H, v3.8H
+ saddl v0.4S, \r0\().4H, \r1\().4H
+ saddl2 v4.4S, \r0\().8H, \r1\().8H
+
+ shl v3.4S, v5.4S, #4
+ shl v5.4S, v5.4S, #2
+ shl v7.4S, v6.4S, #2
+ add v5.4S, v5.4S, v3.4S
+ add v6.4S, v6.4S, v7.4S
+
+ shl v3.4S, v1.4S, #4
+ shl v1.4S, v1.4S, #2
+ shl v7.4S, v2.4S, #2
+ add v1.4S, v1.4S, v3.4S
+ add v2.4S, v2.4S, v7.4S
+
+ add v5.4S, v5.4S, v0.4S
+ sub v5.4S, v5.4S, v6.4S
+
+ add v1.4S, v1.4S, v4.4S
+ sub v1.4S, v1.4S, v2.4S
+
+ rshrn v5.4H, v5.4S, #10
+ rshrn2 v5.8H, v1.4S, #10
+
+ sqxtun \r2\().8B, v5.8H
+.endm
+
+function put_h264_qpel16_h_lowpass_neon_packed
+ mov x4, x30
+ mov x12, #16
+ mov x3, #8
+ bl put_h264_qpel8_h_lowpass_neon
+ sub x1, x1, x2, lsl #4
+ add x1, x1, #8
+ mov x12, #16
+ mov x30, x4
+ b put_h264_qpel8_h_lowpass_neon
+endfunc
+
+.macro h264_qpel_h_lowpass type
+function \type\()_h264_qpel16_h_lowpass_neon
+ mov x13, x30
+ mov x12, #16
+ bl \type\()_h264_qpel8_h_lowpass_neon
+ sub x0, x0, x3, lsl #4
+ sub x1, x1, x2, lsl #4
+ add x0, x0, #8
+ add x1, x1, #8
+ mov x12, #16
+ mov x30, x13
+endfunc
+
+function \type\()_h264_qpel8_h_lowpass_neon
+1: ld1 {v28.8B, v29.8B}, [x1], x2
+ ld1 {v16.8B, v17.8B}, [x1], x2
+ subs x12, x12, #2
+ lowpass_8 v28, v29, v16, v17, v28, v16
+ .ifc \type,avg
+ ld1 {v2.8B}, [x0], x3
+ urhadd v28.8B, v28.8B, v2.8B
+ ld1 {v3.8B}, [x0]
+ urhadd v16.8B, v16.8B, v3.8B
+ sub x0, x0, x3
+ .endif
+ st1 {v28.8B}, [x0], x3
+ st1 {v16.8B}, [x0], x3
+ b.ne 1b
+ ret
+endfunc
+.endm
+
+ h264_qpel_h_lowpass put
+ h264_qpel_h_lowpass avg
+
+.macro h264_qpel_h_lowpass_l2 type
+function \type\()_h264_qpel16_h_lowpass_l2_neon
+ mov x13, x30
+ mov x12, #16
+ bl \type\()_h264_qpel8_h_lowpass_l2_neon
+ sub x0, x0, x2, lsl #4
+ sub x1, x1, x2, lsl #4
+ sub x3, x3, x2, lsl #4
+ add x0, x0, #8
+ add x1, x1, #8
+ add x3, x3, #8
+ mov x12, #16
+ mov x30, x13
+endfunc
+
+function \type\()_h264_qpel8_h_lowpass_l2_neon
+1: ld1 {v26.8B, v27.8B}, [x1], x2
+ ld1 {v16.8B, v17.8B}, [x1], x2
+ ld1 {v28.8B}, [x3], x2
+ ld1 {v29.8B}, [x3], x2
+ subs x12, x12, #2
+ lowpass_8 v26, v27, v16, v17, v26, v27
+ urhadd v26.8B, v26.8B, v28.8B
+ urhadd v27.8B, v27.8B, v29.8B
+ .ifc \type,avg
+ ld1 {v2.8B}, [x0], x2
+ urhadd v26.8B, v26.8B, v2.8B
+ ld1 {v3.8B}, [x0]
+ urhadd v27.8B, v27.8B, v3.8B
+ sub x0, x0, x2
+ .endif
+ st1 {v26.8B}, [x0], x2
+ st1 {v27.8B}, [x0], x2
+ b.ne 1b
+ ret
+endfunc
+.endm
+
+ h264_qpel_h_lowpass_l2 put
+ h264_qpel_h_lowpass_l2 avg
+
+function put_h264_qpel16_v_lowpass_neon_packed
+ mov x4, x30
+ mov x2, #8
+ bl put_h264_qpel8_v_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ bl put_h264_qpel8_v_lowpass_neon
+ sub x1, x1, x3, lsl #4
+ sub x1, x1, x3, lsl #2
+ add x1, x1, #8
+ bl put_h264_qpel8_v_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ mov x30, x4
+ b put_h264_qpel8_v_lowpass_neon
+endfunc
+
+.macro h264_qpel_v_lowpass type
+function \type\()_h264_qpel16_v_lowpass_neon
+ mov x4, x30
+ bl \type\()_h264_qpel8_v_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ bl \type\()_h264_qpel8_v_lowpass_neon
+ sub x0, x0, x2, lsl #4
+ add x0, x0, #8
+ sub x1, x1, x3, lsl #4
+ sub x1, x1, x3, lsl #2
+ add x1, x1, #8
+ bl \type\()_h264_qpel8_v_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ mov x30, x4
+endfunc
+
+function \type\()_h264_qpel8_v_lowpass_neon
+ ld1 {v16.8B}, [x1], x3
+ ld1 {v18.8B}, [x1], x3
+ ld1 {v20.8B}, [x1], x3
+ ld1 {v22.8B}, [x1], x3
+ ld1 {v24.8B}, [x1], x3
+ ld1 {v26.8B}, [x1], x3
+ ld1 {v28.8B}, [x1], x3
+ ld1 {v30.8B}, [x1], x3
+ ld1 {v17.8B}, [x1], x3
+ ld1 {v19.8B}, [x1], x3
+ ld1 {v21.8B}, [x1], x3
+ ld1 {v23.8B}, [x1], x3
+ ld1 {v25.8B}, [x1]
+
+ transpose_8x8B v16, v18, v20, v22, v24, v26, v28, v30, v0, v1
+ transpose_8x8B v17, v19, v21, v23, v25, v27, v29, v31, v0, v1
+ lowpass_8 v16, v17, v18, v19, v16, v17
+ lowpass_8 v20, v21, v22, v23, v18, v19
+ lowpass_8 v24, v25, v26, v27, v20, v21
+ lowpass_8 v28, v29, v30, v31, v22, v23
+ transpose_8x8B v16, v17, v18, v19, v20, v21, v22, v23, v0, v1
+
+ .ifc \type,avg
+ ld1 {v24.8B}, [x0], x2
+ urhadd v16.8B, v16.8B, v24.8B
+ ld1 {v25.8B}, [x0], x2
+ urhadd v17.8B, v17.8B, v25.8B
+ ld1 {v26.8B}, [x0], x2
+ urhadd v18.8B, v18.8B, v26.8B
+ ld1 {v27.8B}, [x0], x2
+ urhadd v19.8B, v19.8B, v27.8B
+ ld1 {v28.8B}, [x0], x2
+ urhadd v20.8B, v20.8B, v28.8B
+ ld1 {v29.8B}, [x0], x2
+ urhadd v21.8B, v21.8B, v29.8B
+ ld1 {v30.8B}, [x0], x2
+ urhadd v22.8B, v22.8B, v30.8B
+ ld1 {v31.8B}, [x0], x2
+ urhadd v23.8B, v23.8B, v31.8B
+ sub x0, x0, x2, lsl #3
+ .endif
+
+ st1 {v16.8B}, [x0], x2
+ st1 {v17.8B}, [x0], x2
+ st1 {v18.8B}, [x0], x2
+ st1 {v19.8B}, [x0], x2
+ st1 {v20.8B}, [x0], x2
+ st1 {v21.8B}, [x0], x2
+ st1 {v22.8B}, [x0], x2
+ st1 {v23.8B}, [x0], x2
+
+ ret
+endfunc
+.endm
+
+ h264_qpel_v_lowpass put
+ h264_qpel_v_lowpass avg
+
+.macro h264_qpel_v_lowpass_l2 type
+function \type\()_h264_qpel16_v_lowpass_l2_neon
+ mov x4, x30
+ bl \type\()_h264_qpel8_v_lowpass_l2_neon
+ sub x1, x1, x3, lsl #2
+ bl \type\()_h264_qpel8_v_lowpass_l2_neon
+ sub x0, x0, x3, lsl #4
+ sub x12, x12, x2, lsl #4
+ add x0, x0, #8
+ add x12, x12, #8
+ sub x1, x1, x3, lsl #4
+ sub x1, x1, x3, lsl #2
+ add x1, x1, #8
+ bl \type\()_h264_qpel8_v_lowpass_l2_neon
+ sub x1, x1, x3, lsl #2
+ mov x30, x4
+endfunc
+
+function \type\()_h264_qpel8_v_lowpass_l2_neon
+ ld1 {v16.8B}, [x1], x3
+ ld1 {v18.8B}, [x1], x3
+ ld1 {v20.8B}, [x1], x3
+ ld1 {v22.8B}, [x1], x3
+ ld1 {v24.8B}, [x1], x3
+ ld1 {v26.8B}, [x1], x3
+ ld1 {v28.8B}, [x1], x3
+ ld1 {v30.8B}, [x1], x3
+ ld1 {v17.8B}, [x1], x3
+ ld1 {v19.8B}, [x1], x3
+ ld1 {v21.8B}, [x1], x3
+ ld1 {v23.8B}, [x1], x3
+ ld1 {v25.8B}, [x1]
+
+ transpose_8x8B v16, v18, v20, v22, v24, v26, v28, v30, v0, v1
+ transpose_8x8B v17, v19, v21, v23, v25, v27, v29, v31, v0, v1
+ lowpass_8 v16, v17, v18, v19, v16, v17
+ lowpass_8 v20, v21, v22, v23, v18, v19
+ lowpass_8 v24, v25, v26, v27, v20, v21
+ lowpass_8 v28, v29, v30, v31, v22, v23
+ transpose_8x8B v16, v17, v18, v19, v20, v21, v22, v23, v0, v1
+
+ ld1 {v24.8B}, [x12], x2
+ ld1 {v25.8B}, [x12], x2
+ ld1 {v26.8B}, [x12], x2
+ ld1 {v27.8B}, [x12], x2
+ ld1 {v28.8B}, [x12], x2
+ urhadd v16.8B, v24.8B, v16.8B
+ urhadd v17.8B, v25.8B, v17.8B
+ ld1 {v29.8B}, [x12], x2
+ urhadd v18.8B, v26.8B, v18.8B
+ urhadd v19.8B, v27.8B, v19.8B
+ ld1 {v30.8B}, [x12], x2
+ urhadd v20.8B, v28.8B, v20.8B
+ urhadd v21.8B, v29.8B, v21.8B
+ ld1 {v31.8B}, [x12], x2
+ urhadd v22.8B, v30.8B, v22.8B
+ urhadd v23.8B, v31.8B, v23.8B
+
+ .ifc \type,avg
+ ld1 {v24.8B}, [x0], x3
+ urhadd v16.8B, v16.8B, v24.8B
+ ld1 {v25.8B}, [x0], x3
+ urhadd v17.8B, v17.8B, v25.8B
+ ld1 {v26.8B}, [x0], x3
+ urhadd v18.8B, v18.8B, v26.8B
+ ld1 {v27.8B}, [x0], x3
+ urhadd v19.8B, v19.8B, v27.8B
+ ld1 {v28.8B}, [x0], x3
+ urhadd v20.8B, v20.8B, v28.8B
+ ld1 {v29.8B}, [x0], x3
+ urhadd v21.8B, v21.8B, v29.8B
+ ld1 {v30.8B}, [x0], x3
+ urhadd v22.8B, v22.8B, v30.8B
+ ld1 {v31.8B}, [x0], x3
+ urhadd v23.8B, v23.8B, v31.8B
+ sub x0, x0, x3, lsl #3
+ .endif
+
+ st1 {v16.8B}, [x0], x3
+ st1 {v17.8B}, [x0], x3
+ st1 {v18.8B}, [x0], x3
+ st1 {v19.8B}, [x0], x3
+ st1 {v20.8B}, [x0], x3
+ st1 {v21.8B}, [x0], x3
+ st1 {v22.8B}, [x0], x3
+ st1 {v23.8B}, [x0], x3
+
+ ret
+endfunc
+.endm
+
+ h264_qpel_v_lowpass_l2 put
+ h264_qpel_v_lowpass_l2 avg
+
+function put_h264_qpel8_hv_lowpass_neon_top
+ lowpass_const w12
+ ld1 {v16.8H}, [x1], x3
+ ld1 {v17.8H}, [x1], x3
+ ld1 {v18.8H}, [x1], x3
+ ld1 {v19.8H}, [x1], x3
+ ld1 {v20.8H}, [x1], x3
+ ld1 {v21.8H}, [x1], x3
+ ld1 {v22.8H}, [x1], x3
+ ld1 {v23.8H}, [x1], x3
+ ld1 {v24.8H}, [x1], x3
+ ld1 {v25.8H}, [x1], x3
+ ld1 {v26.8H}, [x1], x3
+ ld1 {v27.8H}, [x1], x3
+ ld1 {v28.8H}, [x1]
+ lowpass_8H v16, v17
+ lowpass_8H v18, v19
+ lowpass_8H v20, v21
+ lowpass_8H v22, v23
+ lowpass_8H v24, v25
+ lowpass_8H v26, v27
+ lowpass_8H v28, v29
+
+ transpose_8x8H v16, v17, v18, v19, v20, v21, v22, v23, v0, v1
+ transpose_8x8H v24, v25, v26, v27, v28, v29, v30, v31, v0, v1
+
+ lowpass_8.16 v16, v24, v16
+ lowpass_8.16 v17, v25, v17
+
+ lowpass_8.16 v18, v26, v18
+ lowpass_8.16 v19, v27, v19
+
+ lowpass_8.16 v20, v28, v20
+ lowpass_8.16 v21, v29, v21
+
+ lowpass_8.16 v22, v30, v22
+ lowpass_8.16 v23, v31, v23
+
+ transpose_8x8B v16, v17, v18, v19, v20, v21, v22, v23, v0, v1
+
+ ret
+endfunc
+
+.macro h264_qpel8_hv_lowpass type
+function \type\()_h264_qpel8_hv_lowpass_neon
+ mov x10, x30
+ bl put_h264_qpel8_hv_lowpass_neon_top
+ .ifc \type,avg
+ ld1 {v0.8B}, [x0], x2
+ urhadd v16.8B, v16.8B, v0.8B
+ ld1 {v1.8B}, [x0], x2
+ urhadd v17.8B, v17.8B, v1.8B
+ ld1 {v2.8B}, [x0], x2
+ urhadd v18.8B, v18.8B, v2.8B
+ ld1 {v3.8B}, [x0], x2
+ urhadd v19.8B, v19.8B, v3.8B
+ ld1 {v4.8B}, [x0], x2
+ urhadd v20.8B, v20.8B, v4.8B
+ ld1 {v5.8B}, [x0], x2
+ urhadd v21.8B, v21.8B, v5.8B
+ ld1 {v6.8B}, [x0], x2
+ urhadd v22.8B, v22.8B, v6.8B
+ ld1 {v7.8B}, [x0], x2
+ urhadd v23.8B, v23.8B, v7.8B
+ sub x0, x0, x2, lsl #3
+ .endif
+
+ st1 {v16.8B}, [x0], x2
+ st1 {v17.8B}, [x0], x2
+ st1 {v18.8B}, [x0], x2
+ st1 {v19.8B}, [x0], x2
+ st1 {v20.8B}, [x0], x2
+ st1 {v21.8B}, [x0], x2
+ st1 {v22.8B}, [x0], x2
+ st1 {v23.8B}, [x0], x2
+
+ ret x10
+endfunc
+.endm
+
+ h264_qpel8_hv_lowpass put
+ h264_qpel8_hv_lowpass avg
+
+.macro h264_qpel8_hv_lowpass_l2 type
+function \type\()_h264_qpel8_hv_lowpass_l2_neon
+ mov x10, x30
+ bl put_h264_qpel8_hv_lowpass_neon_top
+
+ ld1 {v0.8B, v1.8B}, [x2], #16
+ ld1 {v2.8B, v3.8B}, [x2], #16
+ urhadd v0.8B, v0.8B, v16.8B
+ urhadd v1.8B, v1.8B, v17.8B
+ ld1 {v4.8B, v5.8B}, [x2], #16
+ urhadd v2.8B, v2.8B, v18.8B
+ urhadd v3.8B, v3.8B, v19.8B
+ ld1 {v6.8B, v7.8B}, [x2], #16
+ urhadd v4.8B, v4.8B, v20.8B
+ urhadd v5.8B, v5.8B, v21.8B
+ urhadd v6.8B, v6.8B, v22.8B
+ urhadd v7.8B, v7.8B, v23.8B
+ .ifc \type,avg
+ ld1 {v16.8B}, [x0], x3
+ urhadd v0.8B, v0.8B, v16.8B
+ ld1 {v17.8B}, [x0], x3
+ urhadd v1.8B, v1.8B, v17.8B
+ ld1 {v18.8B}, [x0], x3
+ urhadd v2.8B, v2.8B, v18.8B
+ ld1 {v19.8B}, [x0], x3
+ urhadd v3.8B, v3.8B, v19.8B
+ ld1 {v20.8B}, [x0], x3
+ urhadd v4.8B, v4.8B, v20.8B
+ ld1 {v21.8B}, [x0], x3
+ urhadd v5.8B, v5.8B, v21.8B
+ ld1 {v22.8B}, [x0], x3
+ urhadd v6.8B, v6.8B, v22.8B
+ ld1 {v23.8B}, [x0], x3
+ urhadd v7.8B, v7.8B, v23.8B
+ sub x0, x0, x3, lsl #3
+ .endif
+ st1 {v0.8B}, [x0], x3
+ st1 {v1.8B}, [x0], x3
+ st1 {v2.8B}, [x0], x3
+ st1 {v3.8B}, [x0], x3
+ st1 {v4.8B}, [x0], x3
+ st1 {v5.8B}, [x0], x3
+ st1 {v6.8B}, [x0], x3
+ st1 {v7.8B}, [x0], x3
+
+ ret x10
+endfunc
+.endm
+
+ h264_qpel8_hv_lowpass_l2 put
+ h264_qpel8_hv_lowpass_l2 avg
+
+.macro h264_qpel16_hv type
+function \type\()_h264_qpel16_hv_lowpass_neon
+ mov x13, x30
+ bl \type\()_h264_qpel8_hv_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ bl \type\()_h264_qpel8_hv_lowpass_neon
+ sub x1, x1, x3, lsl #4
+ sub x1, x1, x3, lsl #2
+ add x1, x1, #8
+ sub x0, x0, x2, lsl #4
+ add x0, x0, #8
+ bl \type\()_h264_qpel8_hv_lowpass_neon
+ sub x1, x1, x3, lsl #2
+ mov x30, x13
+ b \type\()_h264_qpel8_hv_lowpass_neon
+endfunc
+
+function \type\()_h264_qpel16_hv_lowpass_l2_neon
+ mov x13, x30
+ sub x2, x4, #256
+ bl \type\()_h264_qpel8_hv_lowpass_l2_neon
+ sub x1, x1, x3, lsl #2
+ bl \type\()_h264_qpel8_hv_lowpass_l2_neon
+ sub x1, x1, x3, lsl #4
+ sub x1, x1, x3, lsl #2
+ add x1, x1, #8
+ sub x0, x0, x3, lsl #4
+ add x0, x0, #8
+ bl \type\()_h264_qpel8_hv_lowpass_l2_neon
+ sub x1, x1, x3, lsl #2
+ mov x30, x13
+ b \type\()_h264_qpel8_hv_lowpass_l2_neon
+endfunc
+.endm
+
+ h264_qpel16_hv put
+ h264_qpel16_hv avg
+
+.macro h264_qpel8 type
+function ff_\type\()_h264_qpel8_mc10_neon, export=1
+ lowpass_const w3
+ mov x3, x1
+ sub x1, x1, #2
+ mov x12, #8
+ b \type\()_h264_qpel8_h_lowpass_l2_neon
+endfunc
+
+function ff_\type\()_h264_qpel8_mc20_neon, export=1
+ lowpass_const w3
+ sub x1, x1, #2
+ mov x3, x2
+ mov x12, #8
+ b \type\()_h264_qpel8_h_lowpass_neon
+endfunc
+
+function ff_\type\()_h264_qpel8_mc30_neon, export=1
+ lowpass_const w3
+ add x3, x1, #1
+ sub x1, x1, #2
+ mov x12, #8
+ b \type\()_h264_qpel8_h_lowpass_l2_neon
+endfunc
+
+function ff_\type\()_h264_qpel8_mc01_neon, export=1
+ mov x14, x30
+ mov x12, x1
+\type\()_h264_qpel8_mc01:
+ lowpass_const w3
+ mov x3, x2
+ sub x1, x1, x2, lsl #1
+ bl \type\()_h264_qpel8_v_lowpass_l2_neon
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc11_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel8_mc11:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #64
+ mov x0, sp
+ sub x1, x1, #2
+ mov x3, #8
+ mov x12, #8
+ bl put_h264_qpel8_h_lowpass_neon
+ mov x0, x8
+ mov x3, x2
+ mov x12, sp
+ sub x1, x9, x2, lsl #1
+ mov x2, #8
+ bl \type\()_h264_qpel8_v_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc21_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel8_mc21:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #(8*8+16*12)
+ sub x1, x1, #2
+ mov x3, #8
+ mov x0, sp
+ mov x12, #8
+ bl put_h264_qpel8_h_lowpass_neon
+ mov x4, x0
+ mov x0, x8
+ sub x1, x9, x2, lsl #1
+ sub x1, x1, #2
+ mov x3, x2
+ sub x2, x4, #64
+ bl \type\()_h264_qpel8_hv_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc31_neon, export=1
+ add x1, x1, #1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ sub x1, x1, #1
+ b \type\()_h264_qpel8_mc11
+endfunc
+
+function ff_\type\()_h264_qpel8_mc02_neon, export=1
+ mov x14, x30
+ lowpass_const w3
+ sub x1, x1, x2, lsl #1
+ mov x3, x2
+ bl \type\()_h264_qpel8_v_lowpass_neon
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc12_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel8_mc12:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #(8*8+16*12)
+ sub x1, x1, x2, lsl #1
+ mov x3, x2
+ mov x2, #8
+ mov x0, sp
+ bl put_h264_qpel8_v_lowpass_neon
+ mov x4, x0
+ mov x0, x8
+ sub x1, x9, x3, lsl #1
+ sub x1, x1, #2
+ sub x2, x4, #64
+ bl \type\()_h264_qpel8_hv_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc22_neon, export=1
+ mov x14, x30
+ mov x11, sp
+ sub x1, x1, x2, lsl #1
+ sub x1, x1, #2
+ mov x3, x2
+ bl \type\()_h264_qpel8_hv_lowpass_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel8_mc32_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, #1
+ b \type\()_h264_qpel8_mc12
+endfunc
+
+function ff_\type\()_h264_qpel8_mc03_neon, export=1
+ mov x14, x30
+ add x12, x1, x2
+ b \type\()_h264_qpel8_mc01
+endfunc
+
+function ff_\type\()_h264_qpel8_mc13_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ b \type\()_h264_qpel8_mc11
+endfunc
+
+function ff_\type\()_h264_qpel8_mc23_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ b \type\()_h264_qpel8_mc21
+endfunc
+
+function ff_\type\()_h264_qpel8_mc33_neon, export=1
+ add x1, x1, #1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ sub x1, x1, #1
+ b \type\()_h264_qpel8_mc11
+endfunc
+.endm
+
+ h264_qpel8 put
+ h264_qpel8 avg
+
+.macro h264_qpel16 type
+function ff_\type\()_h264_qpel16_mc10_neon, export=1
+ lowpass_const w3
+ mov x3, x1
+ sub x1, x1, #2
+ b \type\()_h264_qpel16_h_lowpass_l2_neon
+endfunc
+
+function ff_\type\()_h264_qpel16_mc20_neon, export=1
+ lowpass_const w3
+ sub x1, x1, #2
+ mov x3, x2
+ b \type\()_h264_qpel16_h_lowpass_neon
+endfunc
+
+function ff_\type\()_h264_qpel16_mc30_neon, export=1
+ lowpass_const w3
+ add x3, x1, #1
+ sub x1, x1, #2
+ b \type\()_h264_qpel16_h_lowpass_l2_neon
+endfunc
+
+function ff_\type\()_h264_qpel16_mc01_neon, export=1
+ mov x14, x30
+ mov x12, x1
+\type\()_h264_qpel16_mc01:
+ lowpass_const w3
+ mov x3, x2
+ sub x1, x1, x2, lsl #1
+ bl \type\()_h264_qpel16_v_lowpass_l2_neon
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc11_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel16_mc11:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #256
+ mov x0, sp
+ sub x1, x1, #2
+ mov x3, #16
+ bl put_h264_qpel16_h_lowpass_neon
+ mov x0, x8
+ mov x3, x2
+ mov x12, sp
+ sub x1, x9, x2, lsl #1
+ mov x2, #16
+ bl \type\()_h264_qpel16_v_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc21_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel16_mc21:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #(16*16+16*12)
+ sub x1, x1, #2
+ mov x0, sp
+ bl put_h264_qpel16_h_lowpass_neon_packed
+ mov x4, x0
+ mov x0, x8
+ sub x1, x9, x2, lsl #1
+ sub x1, x1, #2
+ mov x3, x2
+ bl \type\()_h264_qpel16_hv_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc31_neon, export=1
+ add x1, x1, #1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ sub x1, x1, #1
+ b \type\()_h264_qpel16_mc11
+endfunc
+
+function ff_\type\()_h264_qpel16_mc02_neon, export=1
+ mov x14, x30
+ lowpass_const w3
+ sub x1, x1, x2, lsl #1
+ mov x3, x2
+ bl \type\()_h264_qpel16_v_lowpass_neon
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc12_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+\type\()_h264_qpel16_mc12:
+ lowpass_const w3
+ mov x11, sp
+ sub sp, sp, #(16*16+16*12)
+ sub x1, x1, x2, lsl #1
+ mov x0, sp
+ mov x3, x2
+ bl put_h264_qpel16_v_lowpass_neon_packed
+ mov x4, x0
+ mov x0, x8
+ sub x1, x9, x3, lsl #1
+ sub x1, x1, #2
+ mov x2, x3
+ bl \type\()_h264_qpel16_hv_lowpass_l2_neon
+ mov sp, x11
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc22_neon, export=1
+ mov x14, x30
+ lowpass_const w3
+ mov x11, sp
+ sub x1, x1, x2, lsl #1
+ sub x1, x1, #2
+ mov x3, x2
+ bl \type\()_h264_qpel16_hv_lowpass_neon
+ mov sp, x11 // restore stack
+ ret x14
+endfunc
+
+function ff_\type\()_h264_qpel16_mc32_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, #1
+ b \type\()_h264_qpel16_mc12
+endfunc
+
+function ff_\type\()_h264_qpel16_mc03_neon, export=1
+ mov x14, x30
+ add x12, x1, x2
+ b \type\()_h264_qpel16_mc01
+endfunc
+
+function ff_\type\()_h264_qpel16_mc13_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ b \type\()_h264_qpel16_mc11
+endfunc
+
+function ff_\type\()_h264_qpel16_mc23_neon, export=1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ b \type\()_h264_qpel16_mc21
+endfunc
+
+function ff_\type\()_h264_qpel16_mc33_neon, export=1
+ add x1, x1, #1
+ mov x14, x30
+ mov x8, x0
+ mov x9, x1
+ add x1, x1, x2
+ sub x1, x1, #1
+ b \type\()_h264_qpel16_mc11
+endfunc
+.endm
+
+ h264_qpel16 put
+ h264_qpel16 avg
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_init_aarch64.c
new file mode 100644
index 00000000000..144ae2bcc4e
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_init_aarch64.c
@@ -0,0 +1,123 @@
+/*
+ * ARM NEON optimised DSP functions
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/hpeldsp.h"
+
+void ff_put_pixels16_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_x2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_y2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_xy2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_x2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_y2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_xy2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+void ff_put_pixels16_x2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_y2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_xy2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_x2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_y2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_xy2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+void ff_avg_pixels16_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_x2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_y2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_xy2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels8_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels8_x2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels8_y2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels8_xy2_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+void ff_avg_pixels16_x2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_y2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_xy2_no_rnd_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+av_cold void ff_hpeldsp_init_aarch64(HpelDSPContext *c, int flags)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ c->put_pixels_tab[0][0] = ff_put_pixels16_neon;
+ c->put_pixels_tab[0][1] = ff_put_pixels16_x2_neon;
+ c->put_pixels_tab[0][2] = ff_put_pixels16_y2_neon;
+ c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_neon;
+ c->put_pixels_tab[1][0] = ff_put_pixels8_neon;
+ c->put_pixels_tab[1][1] = ff_put_pixels8_x2_neon;
+ c->put_pixels_tab[1][2] = ff_put_pixels8_y2_neon;
+ c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_neon;
+
+ c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_neon;
+ c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_neon;
+ c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_neon;
+ c->put_no_rnd_pixels_tab[0][3] = ff_put_pixels16_xy2_no_rnd_neon;
+ c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_neon;
+ c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_neon;
+ c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_neon;
+ c->put_no_rnd_pixels_tab[1][3] = ff_put_pixels8_xy2_no_rnd_neon;
+
+ c->avg_pixels_tab[0][0] = ff_avg_pixels16_neon;
+ c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_neon;
+ c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_neon;
+ c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_neon;
+ c->avg_pixels_tab[1][0] = ff_avg_pixels8_neon;
+ c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_neon;
+ c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_neon;
+ c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_neon;
+
+ c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_neon;
+ c->avg_no_rnd_pixels_tab[1] = ff_avg_pixels16_x2_no_rnd_neon;
+ c->avg_no_rnd_pixels_tab[2] = ff_avg_pixels16_y2_no_rnd_neon;
+ c->avg_no_rnd_pixels_tab[3] = ff_avg_pixels16_xy2_no_rnd_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_neon.S
new file mode 100644
index 00000000000..a491c173bbc
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/hpeldsp_neon.S
@@ -0,0 +1,397 @@
+/*
+ * ARM NEON optimised DSP functions
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2013 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+.macro pixels16 rnd=1, avg=0
+ .if \avg
+ mov x12, x0
+ .endif
+1: ld1 {v0.16B}, [x1], x2
+ ld1 {v1.16B}, [x1], x2
+ ld1 {v2.16B}, [x1], x2
+ ld1 {v3.16B}, [x1], x2
+ .if \avg
+ ld1 {v4.16B}, [x12], x2
+ urhadd v0.16B, v0.16B, v4.16B
+ ld1 {v5.16B}, [x12], x2
+ urhadd v1.16B, v1.16B, v5.16B
+ ld1 {v6.16B}, [x12], x2
+ urhadd v2.16B, v2.16B, v6.16B
+ ld1 {v7.16B}, [x12], x2
+ urhadd v3.16B, v3.16B, v7.16B
+ .endif
+ subs w3, w3, #4
+ st1 {v0.16B}, [x0], x2
+ st1 {v1.16B}, [x0], x2
+ st1 {v2.16B}, [x0], x2
+ st1 {v3.16B}, [x0], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro pixels16_x2 rnd=1, avg=0
+1: ld1 {v0.16B, v1.16B}, [x1], x2
+ ld1 {v2.16B, v3.16B}, [x1], x2
+ subs w3, w3, #2
+ ext v1.16B, v0.16B, v1.16B, #1
+ avg v0.16B, v0.16B, v1.16B
+ ext v3.16B, v2.16B, v3.16B, #1
+ avg v2.16B, v2.16B, v3.16B
+ .if \avg
+ ld1 {v1.16B}, [x0], x2
+ ld1 {v3.16B}, [x0]
+ urhadd v0.16B, v0.16B, v1.16B
+ urhadd v2.16B, v2.16B, v3.16B
+ sub x0, x0, x2
+ .endif
+ st1 {v0.16B}, [x0], x2
+ st1 {v2.16B}, [x0], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro pixels16_y2 rnd=1, avg=0
+ sub w3, w3, #2
+ ld1 {v0.16B}, [x1], x2
+ ld1 {v1.16B}, [x1], x2
+1: subs w3, w3, #2
+ avg v2.16B, v0.16B, v1.16B
+ ld1 {v0.16B}, [x1], x2
+ avg v3.16B, v0.16B, v1.16B
+ ld1 {v1.16B}, [x1], x2
+ .if \avg
+ ld1 {v4.16B}, [x0], x2
+ ld1 {v5.16B}, [x0]
+ urhadd v2.16B, v2.16B, v4.16B
+ urhadd v3.16B, v3.16B, v5.16B
+ sub x0, x0, x2
+ .endif
+ st1 {v2.16B}, [x0], x2
+ st1 {v3.16B}, [x0], x2
+ b.ne 1b
+
+ avg v2.16B, v0.16B, v1.16B
+ ld1 {v0.16B}, [x1], x2
+ avg v3.16B, v0.16B, v1.16B
+ .if \avg
+ ld1 {v4.16B}, [x0], x2
+ ld1 {v5.16B}, [x0]
+ urhadd v2.16B, v2.16B, v4.16B
+ urhadd v3.16B, v3.16B, v5.16B
+ sub x0, x0, x2
+ .endif
+ st1 {v2.16B}, [x0], x2
+ st1 {v3.16B}, [x0], x2
+
+ ret
+.endm
+
+.macro pixels16_xy2 rnd=1, avg=0
+ sub w3, w3, #2
+ ld1 {v0.16B, v1.16B}, [x1], x2
+ ld1 {v4.16B, v5.16B}, [x1], x2
+NRND movi v26.8H, #1
+ ext v1.16B, v0.16B, v1.16B, #1
+ ext v5.16B, v4.16B, v5.16B, #1
+ uaddl v16.8H, v0.8B, v1.8B
+ uaddl2 v20.8H, v0.16B, v1.16B
+ uaddl v18.8H, v4.8B, v5.8B
+ uaddl2 v22.8H, v4.16B, v5.16B
+1: subs w3, w3, #2
+ ld1 {v0.16B, v1.16B}, [x1], x2
+ add v24.8H, v16.8H, v18.8H
+NRND add v24.8H, v24.8H, v26.8H
+ ext v30.16B, v0.16B, v1.16B, #1
+ add v1.8H, v20.8H, v22.8H
+ mshrn v28.8B, v24.8H, #2
+NRND add v1.8H, v1.8H, v26.8H
+ mshrn2 v28.16B, v1.8H, #2
+ .if \avg
+ ld1 {v16.16B}, [x0]
+ urhadd v28.16B, v28.16B, v16.16B
+ .endif
+ uaddl v16.8H, v0.8B, v30.8B
+ ld1 {v2.16B, v3.16B}, [x1], x2
+ uaddl2 v20.8H, v0.16B, v30.16B
+ st1 {v28.16B}, [x0], x2
+ add v24.8H, v16.8H, v18.8H
+NRND add v24.8H, v24.8H, v26.8H
+ ext v3.16B, v2.16B, v3.16B, #1
+ add v0.8H, v20.8H, v22.8H
+ mshrn v30.8B, v24.8H, #2
+NRND add v0.8H, v0.8H, v26.8H
+ mshrn2 v30.16B, v0.8H, #2
+ .if \avg
+ ld1 {v18.16B}, [x0]
+ urhadd v30.16B, v30.16B, v18.16B
+ .endif
+ uaddl v18.8H, v2.8B, v3.8B
+ uaddl2 v22.8H, v2.16B, v3.16B
+ st1 {v30.16B}, [x0], x2
+ b.gt 1b
+
+ ld1 {v0.16B, v1.16B}, [x1], x2
+ add v24.8H, v16.8H, v18.8H
+NRND add v24.8H, v24.8H, v26.8H
+ ext v30.16B, v0.16B, v1.16B, #1
+ add v1.8H, v20.8H, v22.8H
+ mshrn v28.8B, v24.8H, #2
+NRND add v1.8H, v1.8H, v26.8H
+ mshrn2 v28.16B, v1.8H, #2
+ .if \avg
+ ld1 {v16.16B}, [x0]
+ urhadd v28.16B, v28.16B, v16.16B
+ .endif
+ uaddl v16.8H, v0.8B, v30.8B
+ uaddl2 v20.8H, v0.16B, v30.16B
+ st1 {v28.16B}, [x0], x2
+ add v24.8H, v16.8H, v18.8H
+NRND add v24.8H, v24.8H, v26.8H
+ add v0.8H, v20.8H, v22.8H
+ mshrn v30.8B, v24.8H, #2
+NRND add v0.8H, v0.8H, v26.8H
+ mshrn2 v30.16B, v0.8H, #2
+ .if \avg
+ ld1 {v18.16B}, [x0]
+ urhadd v30.16B, v30.16B, v18.16B
+ .endif
+ st1 {v30.16B}, [x0], x2
+
+ ret
+.endm
+
+.macro pixels8 rnd=1, avg=0
+1: ld1 {v0.8B}, [x1], x2
+ ld1 {v1.8B}, [x1], x2
+ ld1 {v2.8B}, [x1], x2
+ ld1 {v3.8B}, [x1], x2
+ .if \avg
+ ld1 {v4.8B}, [x0], x2
+ urhadd v0.8B, v0.8B, v4.8B
+ ld1 {v5.8B}, [x0], x2
+ urhadd v1.8B, v1.8B, v5.8B
+ ld1 {v6.8B}, [x0], x2
+ urhadd v2.8B, v2.8B, v6.8B
+ ld1 {v7.8B}, [x0], x2
+ urhadd v3.8B, v3.8B, v7.8B
+ sub x0, x0, x2, lsl #2
+ .endif
+ subs w3, w3, #4
+ st1 {v0.8B}, [x0], x2
+ st1 {v1.8B}, [x0], x2
+ st1 {v2.8B}, [x0], x2
+ st1 {v3.8B}, [x0], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro pixels8_x2 rnd=1, avg=0
+1: ld1 {v0.8B, v1.8B}, [x1], x2
+ ext v1.8B, v0.8B, v1.8B, #1
+ ld1 {v2.8B, v3.8B}, [x1], x2
+ ext v3.8B, v2.8B, v3.8B, #1
+ subs w3, w3, #2
+ avg v0.8B, v0.8B, v1.8B
+ avg v2.8B, v2.8B, v3.8B
+ .if \avg
+ ld1 {v4.8B}, [x0], x2
+ ld1 {v5.8B}, [x0]
+ urhadd v0.8B, v0.8B, v4.8B
+ urhadd v2.8B, v2.8B, v5.8B
+ sub x0, x0, x2
+ .endif
+ st1 {v0.8B}, [x0], x2
+ st1 {v2.8B}, [x0], x2
+ b.ne 1b
+ ret
+.endm
+
+.macro pixels8_y2 rnd=1, avg=0
+ sub w3, w3, #2
+ ld1 {v0.8B}, [x1], x2
+ ld1 {v1.8B}, [x1], x2
+1: subs w3, w3, #2
+ avg v4.8B, v0.8B, v1.8B
+ ld1 {v0.8B}, [x1], x2
+ avg v5.8B, v0.8B, v1.8B
+ ld1 {v1.8B}, [x1], x2
+ .if \avg
+ ld1 {v2.8B}, [x0], x2
+ ld1 {v3.8B}, [x0]
+ urhadd v4.8B, v4.8B, v2.8B
+ urhadd v5.8B, v5.8B, v3.8B
+ sub x0, x0, x2
+ .endif
+ st1 {v4.8B}, [x0], x2
+ st1 {v5.8B}, [x0], x2
+ b.ne 1b
+
+ avg v4.8B, v0.8B, v1.8B
+ ld1 {v0.8B}, [x1], x2
+ avg v5.8B, v0.8B, v1.8B
+ .if \avg
+ ld1 {v2.8B}, [x0], x2
+ ld1 {v3.8B}, [x0]
+ urhadd v4.8B, v4.8B, v2.8B
+ urhadd v5.8B, v5.8B, v3.8B
+ sub x0, x0, x2
+ .endif
+ st1 {v4.8B}, [x0], x2
+ st1 {v5.8B}, [x0], x2
+
+ ret
+.endm
+
+.macro pixels8_xy2 rnd=1, avg=0
+ sub w3, w3, #2
+ ld1 {v0.16B}, [x1], x2
+ ld1 {v1.16B}, [x1], x2
+NRND movi v19.8H, #1
+ ext v4.16B, v0.16B, v4.16B, #1
+ ext v6.16B, v1.16B, v6.16B, #1
+ uaddl v16.8H, v0.8B, v4.8B
+ uaddl v17.8H, v1.8B, v6.8B
+1: subs w3, w3, #2
+ ld1 {v0.16B}, [x1], x2
+ add v18.8H, v16.8H, v17.8H
+ ext v4.16B, v0.16B, v4.16B, #1
+NRND add v18.8H, v18.8H, v19.8H
+ uaddl v16.8H, v0.8B, v4.8B
+ mshrn v5.8B, v18.8H, #2
+ ld1 {v1.16B}, [x1], x2
+ add v18.8H, v16.8H, v17.8H
+ .if \avg
+ ld1 {v7.8B}, [x0]
+ urhadd v5.8B, v5.8B, v7.8B
+ .endif
+NRND add v18.8H, v18.8H, v19.8H
+ st1 {v5.8B}, [x0], x2
+ mshrn v7.8B, v18.8H, #2
+ .if \avg
+ ld1 {v5.8B}, [x0]
+ urhadd v7.8B, v7.8B, v5.8B
+ .endif
+ ext v6.16B, v1.16B, v6.16B, #1
+ uaddl v17.8H, v1.8B, v6.8B
+ st1 {v7.8B}, [x0], x2
+ b.gt 1b
+
+ ld1 {v0.16B}, [x1], x2
+ add v18.8H, v16.8H, v17.8H
+ ext v4.16B, v0.16B, v4.16B, #1
+NRND add v18.8H, v18.8H, v19.8H
+ uaddl v16.8H, v0.8B, v4.8B
+ mshrn v5.8B, v18.8H, #2
+ add v18.8H, v16.8H, v17.8H
+ .if \avg
+ ld1 {v7.8B}, [x0]
+ urhadd v5.8B, v5.8B, v7.8B
+ .endif
+NRND add v18.8H, v18.8H, v19.8H
+ st1 {v5.8B}, [x0], x2
+ mshrn v7.8B, v18.8H, #2
+ .if \avg
+ ld1 {v5.8B}, [x0]
+ urhadd v7.8B, v7.8B, v5.8B
+ .endif
+ st1 {v7.8B}, [x0], x2
+
+ ret
+.endm
+
+.macro pixfunc pfx, name, suf, rnd=1, avg=0
+ .if \rnd
+ .macro avg rd, rn, rm
+ urhadd \rd, \rn, \rm
+ .endm
+ .macro mshrn rd, rn, rm
+ rshrn \rd, \rn, \rm
+ .endm
+ .macro mshrn2 rd, rn, rm
+ rshrn2 \rd, \rn, \rm
+ .endm
+ .macro NRND insn:vararg
+ .endm
+ .else
+ .macro avg rd, rn, rm
+ uhadd \rd, \rn, \rm
+ .endm
+ .macro mshrn rd, rn, rm
+ shrn \rd, \rn, \rm
+ .endm
+ .macro mshrn2 rd, rn, rm
+ shrn2 \rd, \rn, \rm
+ .endm
+ .macro NRND insn:vararg
+ \insn
+ .endm
+ .endif
+function ff_\pfx\name\suf\()_neon, export=1
+ \name \rnd, \avg
+endfunc
+ .purgem avg
+ .purgem mshrn
+ .purgem mshrn2
+ .purgem NRND
+.endm
+
+.macro pixfunc2 pfx, name, avg=0
+ pixfunc \pfx, \name, rnd=1, avg=\avg
+ pixfunc \pfx, \name, _no_rnd, rnd=0, avg=\avg
+.endm
+
+function ff_put_h264_qpel16_mc00_neon, export=1
+ mov w3, #16
+endfunc
+
+ pixfunc put_, pixels16, avg=0
+ pixfunc2 put_, pixels16_x2, avg=0
+ pixfunc2 put_, pixels16_y2, avg=0
+ pixfunc2 put_, pixels16_xy2, avg=0
+
+function ff_avg_h264_qpel16_mc00_neon, export=1
+ mov w3, #16
+endfunc
+
+ pixfunc avg_, pixels16, avg=1
+ pixfunc2 avg_, pixels16_x2, avg=1
+ pixfunc2 avg_, pixels16_y2, avg=1
+ pixfunc2 avg_, pixels16_xy2, avg=1
+
+function ff_put_h264_qpel8_mc00_neon, export=1
+ mov w3, #8
+endfunc
+
+ pixfunc put_, pixels8, avg=0
+ pixfunc2 put_, pixels8_x2, avg=0
+ pixfunc2 put_, pixels8_y2, avg=0
+ pixfunc2 put_, pixels8_xy2, avg=0
+
+function ff_avg_h264_qpel8_mc00_neon, export=1
+ mov w3, #8
+endfunc
+
+ pixfunc avg_, pixels8, avg=1
+ pixfunc avg_, pixels8_x2, avg=1
+ pixfunc avg_, pixels8_y2, avg=1
+ pixfunc avg_, pixels8_xy2, avg=1
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/mdct_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/mdct_neon.S
new file mode 100644
index 00000000000..1fd199c972e
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/mdct_neon.S
@@ -0,0 +1,323 @@
+/*
+ * AArch64 NEON optimised MDCT
+ * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
+ * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+function ff_imdct_half_neon, export=1
+ sub sp, sp, #32
+ stp x19, x20, [sp]
+ str x30, [sp, #16]
+ mov x12, #1
+ ldr w14, [x0, #28] // mdct_bits
+ ldr x4, [x0, #32] // tcos
+ ldr x3, [x0, #8] // revtab
+ lsl x12, x12, x14 // n = 1 << nbits
+ lsr x14, x12, #2 // n4 = n >> 2
+ add x7, x2, x12, lsl #1
+ mov x12, #-16
+ sub x7, x7, #16
+
+ ld2 {v16.2s,v17.2s}, [x7], x12 // d16=x,n1 d17=x,n0
+ ld2 {v0.2s,v1.2s}, [x2], #16 // d0 =m0,x d1 =m1,x
+ rev64 v17.2s, v17.2s
+ ld2 {v2.2s,v3.2s}, [x4], #16 // d2=c0,c1 d3=s0,s2
+ fmul v6.2s, v17.2s, v2.2s
+ fmul v7.2s, v0.2s, v2.2s
+1:
+ subs x14, x14, #2
+ ldr w6, [x3], #4
+ fmul v4.2s, v0.2s, v3.2s
+ fmul v5.2s, v17.2s, v3.2s
+ fsub v4.2s, v6.2s, v4.2s
+ fadd v5.2s, v5.2s, v7.2s
+ ubfm x8, x6, #16, #31
+ ubfm x6, x6, #0, #15
+ add x8, x1, x8, lsl #3
+ add x6, x1, x6, lsl #3
+ b.eq 2f
+ ld2 {v16.2s,v17.2s}, [x7], x12
+ ld2 {v0.2s,v1.2s}, [x2], #16
+ rev64 v17.2s, v17.2s
+ ld2 {v2.2s,v3.2s}, [x4], #16 // d2=c0,c1 d3=s0,s2
+ fmul v6.2s, v17.2s, v2.2s
+ fmul v7.2s, v0.2s, v2.2s
+ st2 {v4.s,v5.s}[0], [x6]
+ st2 {v4.s,v5.s}[1], [x8]
+ b 1b
+2:
+ st2 {v4.s,v5.s}[0], [x6]
+ st2 {v4.s,v5.s}[1], [x8]
+
+ mov x19, x0
+ mov x20, x1
+ bl X(ff_fft_calc_neon)
+
+ mov x12, #1
+ ldr w14, [x19, #28] // mdct_bits
+ ldr x4, [x19, #32] // tcos
+ lsl x12, x12, x14 // n = 1 << nbits
+ lsr x14, x12, #3 // n8 = n >> 3
+
+ add x4, x4, x14, lsl #3
+ add x6, x20, x14, lsl #3
+ sub x1, x4, #16
+ sub x3, x6, #16
+
+ mov x7, #-16
+ mov x8, x6
+ mov x0, x3
+
+ ld2 {v0.2s,v1.2s}, [x3], x7 // d0 =i1,r1 d1 =i0,r0
+ ld2 {v20.2s,v21.2s},[x6], #16 // d20=i2,r2 d21=i3,r3
+ ld2 {v16.2s,v17.2s},[x1], x7 // d16=c1,c0 d18=s1,s0
+3:
+ subs x14, x14, #2
+ fmul v7.2s, v0.2s, v17.2s
+ ld2 {v18.2s,v19.2s},[x4], #16 // d17=c2,c3 d19=s2,s3
+ fmul v4.2s, v1.2s, v17.2s
+ fmul v6.2s, v21.2s, v19.2s
+ fmul v5.2s, v20.2s, v19.2s
+ fmul v22.2s, v1.2s, v16.2s
+ fmul v23.2s, v21.2s, v18.2s
+ fmul v24.2s, v0.2s, v16.2s
+ fmul v25.2s, v20.2s, v18.2s
+ fadd v7.2s, v7.2s, v22.2s
+ fadd v5.2s, v5.2s, v23.2s
+ fsub v4.2s, v4.2s, v24.2s
+ fsub v6.2s, v6.2s, v25.2s
+ b.eq 4f
+ ld2 {v0.2s,v1.2s}, [x3], x7
+ ld2 {v20.2s,v21.2s},[x6], #16
+ ld2 {v16.2s,v17.2s},[x1], x7 // d16=c1,c0 d18=s1,s0
+ rev64 v5.2s, v5.2s
+ rev64 v7.2s, v7.2s
+ st2 {v4.2s,v5.2s}, [x0], x7
+ st2 {v6.2s,v7.2s}, [x8], #16
+ b 3b
+4:
+ rev64 v5.2s, v5.2s
+ rev64 v7.2s, v7.2s
+ st2 {v4.2s,v5.2s}, [x0]
+ st2 {v6.2s,v7.2s}, [x8]
+
+ ldp x19, x20, [sp]
+ ldr x30, [sp, #16]
+ add sp, sp, #32
+
+ ret
+endfunc
+
+function ff_imdct_calc_neon, export=1
+ sub sp, sp, #32
+ stp x19, x20, [sp]
+ str x30, [sp, #16]
+ ldr w3, [x0, #28] // mdct_bits
+ mov x19, #1
+ mov x20, x1
+ lsl x19, x19, x3
+ add x1, x1, x19
+
+ bl X(ff_imdct_half_neon)
+
+ add x0, x20, x19, lsl #2
+ add x1, x20, x19, lsl #1
+ sub x0, x0, #8
+ sub x2, x1, #16
+ mov x3, #-16
+ mov x6, #-8
+1:
+ ld1 {v0.4s}, [x2], x3
+ prfum pldl1keep, [x0, #-16]
+ rev64 v0.4s, v0.4s
+ ld1 {v2.2s,v3.2s}, [x1], #16
+ fneg v4.4s, v0.4s
+ prfum pldl1keep, [x2, #-16]
+ rev64 v2.2s, v2.2s
+ rev64 v3.2s, v3.2s
+ ext v4.16b, v4.16b, v4.16b, #8
+ st1 {v2.2s}, [x0], x6
+ st1 {v3.2s}, [x0], x6
+ st1 {v4.4s}, [x20], #16
+ subs x19, x19, #16
+ b.gt 1b
+
+ ldp x19, x20, [sp], #16
+ ldr x30, [sp], #16
+
+ ret
+endfunc
+
+
+function ff_mdct_calc_neon, export=1
+ sub sp, sp, #32
+ stp x19, x20, [sp]
+ str x30, [sp, #16]
+
+ mov x12, #1
+ ldr w14, [x0, #28] // mdct_bits
+ ldr x4, [x0, #32] // tcos
+ ldr x3, [x0, #8] // revtab
+ lsl x14, x12, x14 // n = 1 << nbits
+ add x7, x2, x14 // in4u
+ sub x9, x7, #16 // in4d
+ add x2, x7, x14, lsl #1 // in3u
+ add x8, x9, x14, lsl #1 // in3d
+ add x5, x4, x14, lsl #1
+ sub x5, x5, #16
+ sub x3, x3, #4
+ mov x12, #-16
+ lsr x13, x14, #1
+
+ ld2 {v16.2s,v17.2s}, [x9], x12 // in0u0,in0u1 in4d1,in4d0
+ ld2 {v18.2s,v19.2s}, [x8], x12 // in2u0,in2u1 in3d1,in3d0
+ ld2 {v0.2s, v1.2s}, [x7], #16 // in4u0,in4u1 in2d1,in2d0
+ rev64 v17.2s, v17.2s // in4d0,in4d1 in3d0,in3d1
+ rev64 v19.2s, v19.2s // in4d0,in4d1 in3d0,in3d1
+ ld2 {v2.2s, v3.2s}, [x2], #16 // in3u0,in3u1 in1d1,in1d0
+ fsub v0.2s, v17.2s, v0.2s // in4d-in4u I
+ ld2 {v20.2s,v21.2s}, [x4], #16 // c0,c1 s0,s1
+ rev64 v1.2s, v1.2s // in2d0,in2d1 in1d0,in1d1
+ rev64 v3.2s, v3.2s // in2d0,in2d1 in1d0,in1d1
+ ld2 {v30.2s,v31.2s}, [x5], x12 // c2,c3 s2,s3
+ fadd v2.2s, v2.2s, v19.2s // in3u+in3d -R
+ fsub v16.2s, v16.2s, v1.2s // in0u-in2d R
+ fadd v18.2s, v18.2s, v3.2s // in2u+in1d -I
+1:
+ fmul v7.2s, v0.2s, v21.2s // I*s
+ ldr w10, [x3, x13]
+ fmul v6.2s, v2.2s, v20.2s // -R*c
+ ldr w6, [x3, #4]!
+ fmul v4.2s, v2.2s, v21.2s // -R*s
+ fmul v5.2s, v0.2s, v20.2s // I*c
+ fmul v24.2s, v16.2s, v30.2s // R*c
+ fmul v25.2s, v18.2s, v31.2s // -I*s
+ fmul v22.2s, v16.2s, v31.2s // R*s
+ fmul v23.2s, v18.2s, v30.2s // I*c
+ subs x14, x14, #16
+ subs x13, x13, #8
+ fsub v6.2s, v6.2s, v7.2s // -R*c-I*s
+ fadd v7.2s, v4.2s, v5.2s // -R*s+I*c
+ fsub v24.2s, v25.2s, v24.2s // I*s-R*c
+ fadd v25.2s, v22.2s, v23.2s // R*s-I*c
+ b.eq 1f
+ mov x12, #-16
+ ld2 {v16.2s,v17.2s}, [x9], x12 // in0u0,in0u1 in4d1,in4d0
+ ld2 {v18.2s,v19.2s}, [x8], x12 // in2u0,in2u1 in3d1,in3d0
+ fneg v7.2s, v7.2s // R*s-I*c
+ ld2 {v0.2s, v1.2s}, [x7], #16 // in4u0,in4u1 in2d1,in2d0
+ rev64 v17.2s, v17.2s // in4d0,in4d1 in3d0,in3d1
+ rev64 v19.2s, v19.2s // in4d0,in4d1 in3d0,in3d1
+ ld2 {v2.2s, v3.2s}, [x2], #16 // in3u0,in3u1 in1d1,in1d0
+ fsub v0.2s, v17.2s, v0.2s // in4d-in4u I
+ ld2 {v20.2s,v21.2s}, [x4], #16 // c0,c1 s0,s1
+ rev64 v1.2s, v1.2s // in2d0,in2d1 in1d0,in1d1
+ rev64 v3.2s, v3.2s // in2d0,in2d1 in1d0,in1d1
+ ld2 {v30.2s,v31.2s}, [x5], x12 // c2,c3 s2,s3
+ fadd v2.2s, v2.2s, v19.2s // in3u+in3d -R
+ fsub v16.2s, v16.2s, v1.2s // in0u-in2d R
+ fadd v18.2s, v18.2s, v3.2s // in2u+in1d -I
+ ubfm x12, x6, #16, #31
+ ubfm x6, x6, #0, #15
+ add x12, x1, x12, lsl #3
+ add x6, x1, x6, lsl #3
+ st2 {v6.s,v7.s}[0], [x6]
+ st2 {v6.s,v7.s}[1], [x12]
+ ubfm x6, x10, #16, #31
+ ubfm x10, x10, #0, #15
+ add x6 , x1, x6, lsl #3
+ add x10, x1, x10, lsl #3
+ st2 {v24.s,v25.s}[0], [x10]
+ st2 {v24.s,v25.s}[1], [x6]
+ b 1b
+1:
+ fneg v7.2s, v7.2s // R*s-I*c
+ ubfm x12, x6, #16, #31
+ ubfm x6, x6, #0, #15
+ add x12, x1, x12, lsl #3
+ add x6, x1, x6, lsl #3
+ st2 {v6.s,v7.s}[0], [x6]
+ st2 {v6.s,v7.s}[1], [x12]
+ ubfm x6, x10, #16, #31
+ ubfm x10, x10, #0, #15
+ add x6 , x1, x6, lsl #3
+ add x10, x1, x10, lsl #3
+ st2 {v24.s,v25.s}[0], [x10]
+ st2 {v24.s,v25.s}[1], [x6]
+
+ mov x19, x0
+ mov x20, x1
+ bl X(ff_fft_calc_neon)
+
+ mov x12, #1
+ ldr w14, [x19, #28] // mdct_bits
+ ldr x4, [x19, #32] // tcos
+ lsl x12, x12, x14 // n = 1 << nbits
+ lsr x14, x12, #3 // n8 = n >> 3
+
+ add x4, x4, x14, lsl #3
+ add x6, x20, x14, lsl #3
+ sub x1, x4, #16
+ sub x3, x6, #16
+
+ mov x7, #-16
+ mov x8, x6
+ mov x0, x3
+
+ ld2 {v0.2s,v1.2s}, [x3], x7 // d0 =r1,i1 d1 =r0,i0
+ ld2 {v20.2s,v21.2s}, [x6], #16 // d20=r2,i2 d21=r3,i3
+ ld2 {v16.2s,v17.2s}, [x1], x7 // c1,c0 s1,s0
+1:
+ subs x14, x14, #2
+ fmul v7.2s, v0.2s, v17.2s // r1*s1,r0*s0
+ ld2 {v18.2s,v19.2s}, [x4], #16 // c2,c3 s2,s3
+ fmul v4.2s, v1.2s, v17.2s // i1*s1,i0*s0
+ fmul v6.2s, v21.2s, v19.2s // i2*s2,i3*s3
+ fmul v5.2s, v20.2s, v19.2s // r2*s2,r3*s3
+ fmul v24.2s, v0.2s, v16.2s // r1*c1,r0*c0
+ fmul v25.2s, v20.2s, v18.2s // r2*c2,r3*c3
+ fmul v22.2s, v21.2s, v18.2s // i2*c2,i3*c3
+ fmul v23.2s, v1.2s, v16.2s // i1*c1,i0*c0
+ fadd v4.2s, v4.2s, v24.2s // i1*s1+r1*c1,i0*s0+r0*c0
+ fadd v6.2s, v6.2s, v25.2s // i2*s2+r2*c2,i3*s3+r3*c3
+ fsub v5.2s, v22.2s, v5.2s // i2*c2-r2*s2,i3*c3-r3*s3
+ fsub v7.2s, v23.2s, v7.2s // i1*c1-r1*s1,i0*c0-r0*s0
+ fneg v4.2s, v4.2s
+ fneg v6.2s, v6.2s
+ b.eq 1f
+ ld2 {v0.2s, v1.2s}, [x3], x7
+ ld2 {v20.2s,v21.2s}, [x6], #16
+ ld2 {v16.2s,v17.2s}, [x1], x7 // c1,c0 s1,s0
+ rev64 v5.2s, v5.2s
+ rev64 v7.2s, v7.2s
+ st2 {v4.2s,v5.2s}, [x0], x7
+ st2 {v6.2s,v7.2s}, [x8], #16
+ b 1b
+1:
+ rev64 v5.2s, v5.2s
+ rev64 v7.2s, v7.2s
+ st2 {v4.2s,v5.2s}, [x0]
+ st2 {v6.2s,v7.2s}, [x8]
+
+ ldp x19, x20, [sp], #16
+ ldr x30, [sp], #16
+ ret
+endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_init.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_init.c
new file mode 100644
index 00000000000..b94514645fb
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_init.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/mpegaudiodsp.h"
+#include "config.h"
+
+void ff_mpadsp_apply_window_fixed_neon(int32_t *synth_buf, int32_t *window,
+ int *dither, int16_t *samples, int incr);
+void ff_mpadsp_apply_window_float_neon(float *synth_buf, float *window,
+ int *dither, float *samples, int incr);
+
+av_cold void ff_mpadsp_init_aarch64(MPADSPContext *s)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ s->apply_window_fixed = ff_mpadsp_apply_window_fixed_neon;
+ s->apply_window_float = ff_mpadsp_apply_window_float_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S
new file mode 100644
index 00000000000..e540eb8c011
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+#define FRAC_BITS 23 // fractional bits for sb_samples and dct
+#define WFRAC_BITS 16 // fractional bits for window
+#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
+
+const tbl_rev128.s align=4
+ .byte 12, 13, 14, 15
+ .byte 8, 9, 10, 11
+ .byte 4, 5, 6, 7
+ .byte 0, 1, 2, 3
+endconst
+
+.macro apply_window type, st
+function ff_mpadsp_apply_window_\type\()_neon, export=1
+ mov x7, x0
+ sxtw x4, w4 // incr
+ add x8, x0, #512<<2
+ ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x7], #64
+ ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x7], #64
+ st1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x8], #64
+ st1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x8], #64
+ movrel x15, tbl_rev128.s
+ ld1 {v27.4s}, [x15]
+.ifc \type, fixed
+ lsl x4, x4, #1
+.else
+ lsl x4, x4, #2
+.endif
+ add x10, x0, #45<<2
+ add x0, x0, #16<<2
+ add x1, x1, #16<<2
+ add x5, x3, x4, lsl #5
+ sub x5, x5, x4 // samples2
+ neg x13, x4 // -incr
+ mov x9, #64<<2
+.ifc \type, fixed
+ ld1r {v16.2s}, [x2] // dither_state
+ sxtl v16.2d, v16.2s
+ movi v29.2d, #0
+ movi v30.2d, #(1<<OUT_SHIFT)-1
+ trn1 v31.2d, v29.2d, v30.2d
+ trn2 v30.2d, v30.2d, v29.2d
+ trn1 v16.2d, v16.2d, v29.2d
+.else
+ movi v16.4s, #0
+ movi v28.4s, #0
+.endif
+ mov x14, #4
+1:
+ mov x8, x0
+ sub x7, x1, #3<<2
+ sub x6, x1, x14, lsl #4
+ add x7, x7, x14, lsl #4
+ add x11, x6, #(32)<<2 // w + 32
+ add x12, x7, #(32)<<2 // w2 + 32
+ mov x15, #8
+ movi v17.2d, #0
+ movi v18.2d, #0
+ movi v19.2d, #0
+2:
+ subs x15, x15, #1
+ ld1 {v0.4s}, [x8], x9
+ ld1 {v1.4s}, [x10], x9
+ ld1 {v2.4s}, [x6], x9
+ ld1 {v3.4s}, [x7], x9
+ tbl v6.16b, {v0.16b}, v27.16b
+ tbl v7.16b, {v1.16b}, v27.16b
+ ld1 {v4.4s}, [x11], x9
+ ld1 {v5.4s}, [x12], x9
+ MLA v16, v2, v0
+ MLA2 v17, v2, v0
+ MLS v18, v3, v6
+ MLS2 v19, v3, v6
+ MLS v16, v4, v7
+ MLS2 v17, v4, v7
+ MLS v18, v5, v1
+ MLS2 v19, v5, v1
+ b.gt 2b
+
+ cmp x14, #4
+ sub x10, x10, #64<<5 // 64 * 8 * sizeof(int32_t)
+
+.ifc \type, fixed
+ and v28.16b, v16.16b, v30.16b
+ ext v28.16b, v29.16b, v28.16b, #8
+
+ b.eq 4f
+ round_sample v19, 1, 1
+4:
+ round_sample v16, 1, 0
+ shrn v16.2s, v16.2d, #OUT_SHIFT
+ round_sample v19, 0, 0
+ shrn v19.2s, v19.2d, #OUT_SHIFT
+ round_sample v17, 0, 1
+ round_sample v18, 1, 1
+ round_sample v17, 1, 0
+ shrn2 v16.4s, v17.2d, #OUT_SHIFT
+ round_sample v18, 0, 0
+ shrn2 v19.4s, v18.2d, #OUT_SHIFT
+ sqxtn v16.4h, v16.4s
+ sqxtn v18.4h, v19.4s
+.else
+ ext v18.16b, v18.16b, v18.16b, #8
+.endif
+
+ st1 {v16.\st\()}[0], [x3], x4
+ b.eq 4f
+ st1 {v18.\st\()}[1], [x5], x13
+4:
+ st1 {v16.\st\()}[1], [x3], x4
+ st1 {v18.\st\()}[0], [x5], x13
+ st1 {v16.\st\()}[2], [x3], x4
+ st1 {v18.\st\()}[3], [x5], x13
+ st1 {v16.\st\()}[3], [x3], x4
+ st1 {v18.\st\()}[2], [x5], x13
+
+ mov v16.16b, v28.16b
+
+ subs x14, x14, #1
+ add x0, x0, #4<<2
+ sub x10, x10, #4<<2
+ b.gt 1b
+
+// comuting samples[16]
+ add x6, x1, #32<<2
+ ld1 {v0.2s}, [x6], x9
+ ld1 {v1.2s}, [x0], x9
+.rept 3
+ ld1 {v2.2s}, [x6], x9
+ ld1 {v3.2s}, [x0], x9
+ MLS v16, v0, v1
+ ld1 {v0.2s}, [x6], x9
+ ld1 {v1.2s}, [x0], x9
+ MLS v16, v2, v3
+.endr
+ ld1 {v2.2s}, [x6], x9
+ ld1 {v3.2s}, [x0], x9
+ MLS v16, v0, v1
+ MLS v16, v2, v3
+
+.ifc \type, fixed
+ and v28.16b, v16.16b, v30.16b
+ shrn v20.2s, v16.2d, #OUT_SHIFT
+ xtn v28.2s, v28.2d
+ sqxtn v20.4h, v20.4s
+ st1 {v28.s}[0], [x2] // save dither_state
+ st1 {v20.h}[0], [x3]
+.else
+ st1 {v16.s}[0], [x3]
+.endif
+
+ ret
+endfunc
+.purgem round_sample
+.purgem MLA
+.purgem MLA2
+.purgem MLS
+.purgem MLS2
+.endm
+
+
+.macro round_sample r, idx, next
+ add \r\().2d, \r\().2d, v28.2d
+.if \idx == 0
+ and v28.16b, \r\().16b, v30.16b
+.else // \idx == 1
+ and v28.16b, \r\().16b, v31.16b
+.endif
+.if \idx != \next
+ .if \next == 0
+ ext v28.16b, v28.16b, v29.16b, #8
+ .else
+ ext v28.16b, v29.16b, v28.16b, #8
+ .endif
+.endif
+.endm
+.macro MLA d, s1, s2
+ smlal \d\().2d, \s1\().2s, \s2\().2s
+.endm
+.macro MLA2 d, s1, s2
+ smlal2 \d\().2d, \s1\().4s, \s2\().4s
+.endm
+.macro MLS d, s1, s2
+ smlsl \d\().2d, \s1\().2s, \s2\().2s
+.endm
+.macro MLS2 d, s1, s2
+ smlsl2 \d\().2d, \s1\().4s, \s2\().4s
+.endm
+apply_window fixed, h
+
+
+// nothing to do for round_sample and ML{A,S}2
+.macro round_sample r, idx, next
+.endm
+.macro MLA2 d, s1, s2
+.endm
+.macro MLS2 d, s1, s2
+.endm
+.macro MLA d, s1, s2
+ fmla \d\().4s, \s1\().4s, \s2\().4s
+.endm
+.macro MLS d, s1, s2
+ fmls \d\().4s, \s1\().4s, \s2\().4s
+.endm
+apply_window float, s
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/neon.S
new file mode 100644
index 00000000000..619aec64269
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/neon.S
@@ -0,0 +1,149 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+.macro transpose_8x8B r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
+ trn1 \r8\().8B, \r0\().8B, \r1\().8B
+ trn2 \r9\().8B, \r0\().8B, \r1\().8B
+ trn1 \r1\().8B, \r2\().8B, \r3\().8B
+ trn2 \r3\().8B, \r2\().8B, \r3\().8B
+ trn1 \r0\().8B, \r4\().8B, \r5\().8B
+ trn2 \r5\().8B, \r4\().8B, \r5\().8B
+ trn1 \r2\().8B, \r6\().8B, \r7\().8B
+ trn2 \r7\().8B, \r6\().8B, \r7\().8B
+
+ trn1 \r4\().4H, \r0\().4H, \r2\().4H
+ trn2 \r2\().4H, \r0\().4H, \r2\().4H
+ trn1 \r6\().4H, \r5\().4H, \r7\().4H
+ trn2 \r7\().4H, \r5\().4H, \r7\().4H
+ trn1 \r5\().4H, \r9\().4H, \r3\().4H
+ trn2 \r9\().4H, \r9\().4H, \r3\().4H
+ trn1 \r3\().4H, \r8\().4H, \r1\().4H
+ trn2 \r8\().4H, \r8\().4H, \r1\().4H
+
+ trn1 \r0\().2S, \r3\().2S, \r4\().2S
+ trn2 \r4\().2S, \r3\().2S, \r4\().2S
+
+ trn1 \r1\().2S, \r5\().2S, \r6\().2S
+ trn2 \r5\().2S, \r5\().2S, \r6\().2S
+
+ trn2 \r6\().2S, \r8\().2S, \r2\().2S
+ trn1 \r2\().2S, \r8\().2S, \r2\().2S
+
+ trn1 \r3\().2S, \r9\().2S, \r7\().2S
+ trn2 \r7\().2S, \r9\().2S, \r7\().2S
+.endm
+
+.macro transpose_8x16B r0, r1, r2, r3, r4, r5, r6, r7, t0, t1
+ trn1 \t0\().16B, \r0\().16B, \r1\().16B
+ trn2 \t1\().16B, \r0\().16B, \r1\().16B
+ trn1 \r1\().16B, \r2\().16B, \r3\().16B
+ trn2 \r3\().16B, \r2\().16B, \r3\().16B
+ trn1 \r0\().16B, \r4\().16B, \r5\().16B
+ trn2 \r5\().16B, \r4\().16B, \r5\().16B
+ trn1 \r2\().16B, \r6\().16B, \r7\().16B
+ trn2 \r7\().16B, \r6\().16B, \r7\().16B
+
+ trn1 \r4\().8H, \r0\().8H, \r2\().8H
+ trn2 \r2\().8H, \r0\().8H, \r2\().8H
+ trn1 \r6\().8H, \r5\().8H, \r7\().8H
+ trn2 \r7\().8H, \r5\().8H, \r7\().8H
+ trn1 \r5\().8H, \t1\().8H, \r3\().8H
+ trn2 \t1\().8H, \t1\().8H, \r3\().8H
+ trn1 \r3\().8H, \t0\().8H, \r1\().8H
+ trn2 \t0\().8H, \t0\().8H, \r1\().8H
+
+ trn1 \r0\().4S, \r3\().4S, \r4\().4S
+ trn2 \r4\().4S, \r3\().4S, \r4\().4S
+
+ trn1 \r1\().4S, \r5\().4S, \r6\().4S
+ trn2 \r5\().4S, \r5\().4S, \r6\().4S
+
+ trn2 \r6\().4S, \t0\().4S, \r2\().4S
+ trn1 \r2\().4S, \t0\().4S, \r2\().4S
+
+ trn1 \r3\().4S, \t1\().4S, \r7\().4S
+ trn2 \r7\().4S, \t1\().4S, \r7\().4S
+.endm
+
+.macro transpose_4x16B r0, r1, r2, r3, t4, t5, t6, t7
+ trn1 \t4\().16B, \r0\().16B, \r1\().16B
+ trn2 \t5\().16B, \r0\().16B, \r1\().16B
+ trn1 \t6\().16B, \r2\().16B, \r3\().16B
+ trn2 \t7\().16B, \r2\().16B, \r3\().16B
+
+ trn1 \r0\().8H, \t4\().8H, \t6\().8H
+ trn2 \r2\().8H, \t4\().8H, \t6\().8H
+ trn1 \r1\().8H, \t5\().8H, \t7\().8H
+ trn2 \r3\().8H, \t5\().8H, \t7\().8H
+.endm
+
+.macro transpose_4x8B r0, r1, r2, r3, t4, t5, t6, t7
+ trn1 \t4\().8B, \r0\().8B, \r1\().8B
+ trn2 \t5\().8B, \r0\().8B, \r1\().8B
+ trn1 \t6\().8B, \r2\().8B, \r3\().8B
+ trn2 \t7\().8B, \r2\().8B, \r3\().8B
+
+ trn1 \r0\().4H, \t4\().4H, \t6\().4H
+ trn2 \r2\().4H, \t4\().4H, \t6\().4H
+ trn1 \r1\().4H, \t5\().4H, \t7\().4H
+ trn2 \r3\().4H, \t5\().4H, \t7\().4H
+.endm
+
+.macro transpose_4x4H r0, r1, r2, r3, r4, r5, r6, r7
+ trn1 \r4\().4H, \r0\().4H, \r1\().4H
+ trn2 \r5\().4H, \r0\().4H, \r1\().4H
+ trn1 \r7\().4H, \r3\().4H, \r2\().4H
+ trn2 \r6\().4H, \r3\().4H, \r2\().4H
+ trn1 \r0\().2S, \r4\().2S, \r7\().2S
+ trn2 \r3\().2S, \r4\().2S, \r7\().2S
+ trn1 \r1\().2S, \r5\().2S, \r6\().2S
+ trn2 \r2\().2S, \r5\().2S, \r6\().2S
+.endm
+
+.macro transpose_8x8H r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
+ trn1 \r8\().8H, \r0\().8H, \r1\().8H
+ trn2 \r9\().8H, \r0\().8H, \r1\().8H
+ trn1 \r1\().8H, \r2\().8H, \r3\().8H
+ trn2 \r3\().8H, \r2\().8H, \r3\().8H
+ trn1 \r0\().8H, \r4\().8H, \r5\().8H
+ trn2 \r5\().8H, \r4\().8H, \r5\().8H
+ trn1 \r2\().8H, \r6\().8H, \r7\().8H
+ trn2 \r7\().8H, \r6\().8H, \r7\().8H
+
+ trn1 \r4\().4S, \r0\().4S, \r2\().4S
+ trn2 \r2\().4S, \r0\().4S, \r2\().4S
+ trn1 \r6\().4S, \r5\().4S, \r7\().4S
+ trn2 \r7\().4S, \r5\().4S, \r7\().4S
+ trn1 \r5\().4S, \r9\().4S, \r3\().4S
+ trn2 \r9\().4S, \r9\().4S, \r3\().4S
+ trn1 \r3\().4S, \r8\().4S, \r1\().4S
+ trn2 \r8\().4S, \r8\().4S, \r1\().4S
+
+ trn1 \r0\().2D, \r3\().2D, \r4\().2D
+ trn2 \r4\().2D, \r3\().2D, \r4\().2D
+
+ trn1 \r1\().2D, \r5\().2D, \r6\().2D
+ trn2 \r5\().2D, \r5\().2D, \r6\().2D
+
+ trn2 \r6\().2D, \r8\().2D, \r2\().2D
+ trn1 \r2\().2D, \r8\().2D, \r2\().2D
+
+ trn1 \r3\().2D, \r9\().2D, \r7\().2D
+ trn2 \r7\().2D, \r9\().2D, \r7\().2D
+
+.endm
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/neontest.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/neontest.c
new file mode 100644
index 00000000000..6e41f3736e5
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/neontest.c
@@ -0,0 +1,79 @@
+/*
+ * check NEON registers for clobbers
+ * Copyright (c) 2013 Martin Storsjo
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avcodec.h"
+#include "libavutil/aarch64/neontest.h"
+
+wrap(avcodec_open2(AVCodecContext *avctx,
+ AVCodec *codec,
+ AVDictionary **options))
+{
+ testneonclobbers(avcodec_open2, avctx, codec, options);
+}
+
+wrap(avcodec_decode_audio4(AVCodecContext *avctx,
+ AVFrame *frame,
+ int *got_frame_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_audio4, avctx, frame,
+ got_frame_ptr, avpkt);
+}
+
+wrap(avcodec_decode_video2(AVCodecContext *avctx,
+ AVFrame *picture,
+ int *got_picture_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_video2, avctx, picture,
+ got_picture_ptr, avpkt);
+}
+
+wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
+ AVSubtitle *sub,
+ int *got_sub_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_subtitle2, avctx, sub,
+ got_sub_ptr, avpkt);
+}
+
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+ AVPacket *avpkt,
+ const AVFrame *frame,
+ int *got_packet_ptr))
+{
+ testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+ got_packet_ptr);
+}
+
+wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
+ uint8_t *buf, int buf_size,
+ const AVSubtitle *sub))
+{
+ testneonclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
+}
+
+wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *frame, int *got_packet_ptr))
+{
+ testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_init.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_init.c
new file mode 100644
index 00000000000..3fa9a11b2f1
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_init.c
@@ -0,0 +1,45 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavutil/internal.h"
+#include "libavcodec/opus_imdct.h"
+
+#include "asm-offsets.h"
+
+AV_CHECK_OFFSET(CeltIMDCTContext, exptab, CELT_EXPTAB);
+AV_CHECK_OFFSET(CeltIMDCTContext, fft_n, CELT_FFT_N);
+AV_CHECK_OFFSET(CeltIMDCTContext, len2, CELT_LEN2);
+AV_CHECK_OFFSET(CeltIMDCTContext, len4, CELT_LEN4);
+AV_CHECK_OFFSET(CeltIMDCTContext, tmp, CELT_TMP);
+AV_CHECK_OFFSET(CeltIMDCTContext, twiddle_exptab, CELT_TWIDDLE);
+
+void ff_celt_imdct_half_neon(CeltIMDCTContext *s, float *dst, const float *src,
+ ptrdiff_t stride, float scale);
+
+void ff_celt_imdct_init_aarch64(CeltIMDCTContext *s)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ s->imdct_half = ff_celt_imdct_half_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_neon.S
new file mode 100644
index 00000000000..ff1f7054a89
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/opus_imdct_neon.S
@@ -0,0 +1,647 @@
+/*
+ * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+#include "asm-offsets.h"
+
+.macro shuffle a, b, c, d
+const shuffle_\a\b\c\d align=4
+ .byte (\a * 4), (\a * 4 + 1), (\a * 4 + 2), (\a * 4 + 3)
+ .byte (\b * 4), (\b * 4 + 1), (\b * 4 + 2), (\b * 4 + 3)
+ .byte (\c * 4), (\c * 4 + 1), (\c * 4 + 2), (\c * 4 + 3)
+ .byte (\d * 4), (\d * 4 + 1), (\d * 4 + 2), (\d * 4 + 3)
+endconst
+.endm
+
+shuffle 0, 2, 1, 3
+shuffle 1, 0, 3, 2
+shuffle 2, 3, 0, 1
+shuffle 3, 1, 2, 0
+
+
+function fft5_neon
+ lsl x2, x2, #3
+ ld1 {v24.2s}, [x1], x2
+ ld2 {v25.s,v26.s}[0], [x1], x2
+ ld2 {v25.s,v26.s}[1], [x1], x2
+ ld2 {v25.s,v26.s}[2], [x1], x2
+ ld2 {v25.s,v26.s}[3], [x1]
+ dup v6.4s, v24.s[0]
+ dup v7.4s, v24.s[1]
+
+ faddp v0.4s, v25.4s, v26.4s
+ // z[][0], z[][3]
+ fmul v16.4s, v25.4s, v15.s[0] // rr
+ fmul v17.4s, v25.4s, v15.s[1] // ri
+ fmul v18.4s, v26.4s, v15.s[0] // ir
+ fmul v19.4s, v26.4s, v15.s[1] // ii
+ faddp v0.4s, v0.4s, v0.4s
+ // z[][1], z[][2]
+ fmul v20.4s, v25.4s, v15.s[2] // rr
+ fmul v21.4s, v25.4s, v15.s[3] // ri
+ fmul v22.4s, v26.4s, v15.s[2] // ir
+ fmul v23.4s, v26.4s, v15.s[3] // ii
+ fadd v0.2s, v24.2s, v0.2s // out[0]
+
+ // z[0123][0], z[0123][3]
+ fsub v24.4s, v16.4s, v19.4s // (c).re = rr - ii;
+ fadd v27.4s, v16.4s, v19.4s // (d).re = rr + ii;
+ ld1 {v16.16b}, [x11]
+ ld1 {v19.16b}, [x14]
+ fadd v28.4s, v17.4s, v18.4s // (c).im = ri + ir;
+ fsub v31.4s, v18.4s, v17.4s // (d).im = -ri + ir;
+ ld1 {v17.16b}, [x12]
+ // z[0123][1], z[0123][2]
+ fsub v25.4s, v20.4s, v23.4s // (c).re = rr - ii;
+ fadd v26.4s, v20.4s, v23.4s // (d).re = rr + ii;
+ ld1 {v18.16b}, [x13]
+ fadd v29.4s, v21.4s, v22.4s // (c).im = ri + ir;
+ fsub v30.4s, v22.4s, v21.4s // (d).im = -ri + ir;
+
+ //real
+ tbl v20.16b, {v24.16b}, v16.16b
+ tbl v21.16b, {v25.16b}, v17.16b
+ tbl v22.16b, {v26.16b}, v18.16b
+ tbl v23.16b, {v27.16b}, v19.16b
+ //imag
+ tbl v16.16b, {v28.16b}, v16.16b
+ tbl v17.16b, {v29.16b}, v17.16b
+ tbl v18.16b, {v30.16b}, v18.16b
+ tbl v19.16b, {v31.16b}, v19.16b
+
+ fadd v6.4s, v6.4s, v20.4s
+ fadd v22.4s, v22.4s, v23.4s
+ fadd v7.4s, v7.4s, v16.4s
+ fadd v18.4s, v18.4s, v19.4s
+
+ fadd v21.4s, v21.4s, v22.4s
+ fadd v17.4s, v17.4s, v18.4s
+ fadd v6.4s, v6.4s, v21.4s
+ fadd v7.4s, v7.4s, v17.4s
+
+ ret
+endfunc
+
+function fft15_neon
+ mov x8, x1
+ mov x9, x30
+ add x2, x3, x3, lsl #1 // 3 * stride
+
+ add x1, x8, x3, lsl #3 // in + 1 * stride
+ bl fft5_neon
+ mov v1.8b, v0.8b
+ mov v2.16b, v6.16b
+ mov v3.16b, v7.16b
+
+ add x1, x8, x3, lsl #4 // in + 2 * stride
+ add x2, x3, x3, lsl #1 // 3 * stride
+ bl fft5_neon
+ zip1 v1.4s, v1.4s, v0.4s
+ mov v4.16b, v6.16b
+ mov v5.16b, v7.16b
+
+ mov x1, x8 // in + 0 * stride
+ add x2, x3, x3, lsl #1 // 3 * stride
+ bl fft5_neon
+
+ faddp v20.4s, v1.4s, v1.4s
+
+ ext v18.16b, v8.16b, v8.16b, #4
+ ext v19.16b, v9.16b, v9.16b, #4
+ mov v16.16b, v6.16b
+ mov v17.16b, v7.16b
+ fadd v20.2s, v20.2s, v0.2s
+
+ uzp1 v18.4s, v18.4s, v10.4s // exp[2,4,6,8].re
+ uzp1 v19.4s, v19.4s, v11.4s // exp[2,4,6,8].im
+
+ st1 {v20.2s}, [x0], #8 // out[0]
+
+ fmla v16.4s, v2.4s, v8.4s
+ fmls v16.4s, v3.4s, v9.4s
+
+ fmla v17.4s, v2.4s, v9.4s
+ fmla v17.4s, v3.4s, v8.4s
+
+ fmla v16.4s, v4.4s, v18.4s
+ fmls v16.4s, v5.4s, v19.4s
+
+ fmla v17.4s, v4.4s, v19.4s
+ fmla v17.4s, v5.4s, v18.4s
+
+ zip1 v18.4s, v16.4s, v17.4s
+ zip2 v19.4s, v16.4s, v17.4s
+
+ rev64 v31.4s, v14.4s
+ trn1 v28.2d, v1.2d, v1.2d
+ trn2 v29.2d, v1.2d, v1.2d
+ zip1 v30.2d, v14.2d, v31.2d
+ zip2 v31.2d, v14.2d, v31.2d
+
+ st1 {v18.4s,v19.4s}, [x0], #32 // out[1-4]
+
+ fmul v16.4s, v28.4s, v30.4s
+ fmul v17.4s, v29.4s, v30.4s
+ fmls v16.4s, v29.4s, v31.4s
+ fmla v17.4s, v28.4s, v31.4s
+ faddp v16.4s, v16.4s, v16.4s
+ faddp v17.4s, v17.4s, v17.4s
+ zip1 v18.2s, v16.2s, v17.2s
+ zip2 v19.2s, v16.2s, v17.2s
+
+ fadd v18.2s, v18.2s, v0.2s
+ fadd v0.2s, v19.2s, v0.2s
+
+ ext v30.16b, v12.16b, v12.16b, #4
+ ext v31.16b, v13.16b, v13.16b, #4
+ mov v16.16b, v6.16b
+ mov v17.16b, v7.16b
+
+ uzp1 v30.4s, v30.4s, v8.4s
+ uzp1 v31.4s, v31.4s, v9.4s
+
+ st1 {v18.2s}, [x0], #8 // out[5]
+
+ fmla v16.4s, v2.4s, v10.4s
+ fmls v16.4s, v3.4s, v11.4s
+
+ fmla v17.4s, v2.4s, v11.4s
+ fmla v17.4s, v3.4s, v10.4s
+
+ fmla v16.4s, v4.4s, v30.4s
+ fmls v16.4s, v5.4s, v31.4s
+
+ fmla v17.4s, v4.4s, v31.4s
+ fmla v17.4s, v5.4s, v30.4s
+
+ zip1 v18.4s, v16.4s, v17.4s
+ zip2 v19.4s, v16.4s, v17.4s
+
+ ext v30.16b, v10.16b, v10.16b, #4
+ ext v31.16b, v11.16b, v11.16b, #4
+
+ fmla v6.4s, v2.4s, v12.4s
+ fmls v6.4s, v3.4s, v13.4s
+
+ st1 {v18.4s,v19.4s}, [x0], #32 // out[6-9]
+
+ uzp1 v30.4s, v30.4s, v12.4s
+ uzp1 v31.4s, v31.4s, v13.4s
+
+ fmla v7.4s, v2.4s, v13.4s
+ fmla v7.4s, v3.4s, v12.4s
+
+ st1 {v0.2s}, [x0], #8 // out[10]
+
+ fmla v6.4s, v4.4s, v30.4s
+ fmls v6.4s, v5.4s, v31.4s
+
+ fmla v7.4s, v4.4s, v31.4s
+ fmla v7.4s, v5.4s, v30.4s
+
+ zip1 v18.4s, v6.4s, v7.4s
+ zip2 v19.4s, v6.4s, v7.4s
+
+ st1 {v18.4s,v19.4s}, [x0], #32 // out[11-14]
+
+ ret x9
+endfunc
+
+// x0: out, x1: out+len2, x2: exptab, x3: len2
+function fft15_pass
+ ands x6, x3, #3
+ mov x4, x0
+ mov x5, x1
+ b.eq 9f
+ ld1 {v0.2s}, [x0], #8
+ ld1 {v1.2s}, [x1], #8
+ sub x3, x3, x6
+ subs x6, x6, #1
+ fadd v2.2s, v0.2s, v1.2s
+ fsub v3.2s, v0.2s, v1.2s
+ add x2, x2, #8
+ st1 {v2.2s}, [x4], #8
+ st1 {v3.2s}, [x5], #8
+ b.eq 9f
+1:
+ subs x6, x6, #1
+ ldp s4, s5, [x2], #8
+ ldp s2, s3, [x1], #8
+ ldp s0, s1, [x0], #8
+
+ fmul s6, s2, s4
+ fmul s7, s2, s5
+ fmls s6, s3, v5.s[0]
+ fmla s7, s3, v4.s[0]
+
+ fsub s2, s0, s6
+ fsub s3, s1, s7
+ fadd s0, s0, s6
+ fadd s1, s1, s7
+
+ stp s2, s3, [x5], #8
+ stp s0, s1, [x4], #8
+ b.gt 1b
+9:
+ ld1 {v4.4s,v5.4s}, [x2], #32
+ ld2 {v2.4s,v3.4s}, [x1], #32
+ uzp1 v6.4s, v4.4s, v5.4s
+ uzp2 v7.4s, v4.4s, v5.4s
+ ld2 {v0.4s,v1.4s}, [x0], #32
+8:
+ subs x3, x3, #8
+
+ fmul v4.4s, v2.4s, v6.4s
+ fmul v5.4s, v2.4s, v7.4s
+ b.lt 4f
+
+ ld1 {v18.4s,v19.4s}, [x2], #32
+
+ fmls v4.4s, v3.4s, v7.4s
+ fmla v5.4s, v3.4s, v6.4s
+
+ ld2 {v22.4s,v23.4s}, [x1], #32
+
+ fsub v2.4s, v0.4s, v4.4s
+ fadd v0.4s, v0.4s, v4.4s
+ fsub v3.4s, v1.4s, v5.4s
+ fadd v1.4s, v1.4s, v5.4s
+
+ uzp1 v16.4s, v18.4s, v19.4s
+ uzp2 v17.4s, v18.4s, v19.4s
+
+ st2 {v2.4s,v3.4s}, [x5], #32
+ st2 {v0.4s,v1.4s}, [x4], #32
+ ld2 {v20.4s,v21.4s}, [x0], #32
+
+ fmul v18.4s, v22.4s, v16.4s
+ fmul v19.4s, v22.4s, v17.4s
+ b.eq 0f
+
+ ld1 {v4.4s,v5.4s}, [x2], #32
+
+ fmls v18.4s, v23.4s, v17.4s
+ fmla v19.4s, v23.4s, v16.4s
+
+ ld2 {v2.4s,v3.4s}, [x1], #32
+
+ fsub v22.4s, v20.4s, v18.4s
+ fadd v20.4s, v20.4s, v18.4s
+ fsub v23.4s, v21.4s, v19.4s
+ fadd v21.4s, v21.4s, v19.4s
+
+ uzp1 v6.4s, v4.4s, v5.4s
+ uzp2 v7.4s, v4.4s, v5.4s
+
+ st2 {v22.4s,v23.4s}, [x5], #32
+ st2 {v20.4s,v21.4s}, [x4], #32
+ ld2 {v0.4s,v1.4s}, [x0], #32
+
+ b 8b
+4:
+ fmls v4.4s, v3.4s, v7.4s
+ fmla v5.4s, v3.4s, v6.4s
+
+ fsub v2.4s, v0.4s, v4.4s
+ fadd v0.4s, v0.4s, v4.4s
+ fsub v3.4s, v1.4s, v5.4s
+ fadd v1.4s, v1.4s, v5.4s
+
+ st2 {v2.4s,v3.4s}, [x5], #32
+ st2 {v0.4s,v1.4s}, [x4], #32
+
+ ret
+0:
+ fmls v18.4s, v23.4s, v17.4s
+ fmla v19.4s, v23.4s, v16.4s
+
+ fsub v22.4s, v20.4s, v18.4s
+ fadd v20.4s, v20.4s, v18.4s
+ fsub v23.4s, v21.4s, v19.4s
+ fadd v21.4s, v21.4s, v19.4s
+
+ st2 {v22.4s,v23.4s}, [x5], #32
+ st2 {v20.4s,v21.4s}, [x4], #32
+
+ ret
+endfunc
+
+function fft30_neon align=6
+ sub sp, sp, #0x20
+ stp x20, x21, [sp]
+ stp x22, x30, [sp, #0x10]
+ mov x21, x1
+ mov x22, x2
+ mov x20, x4
+ mov x0, x21
+ mov x1, x22
+ lsl x3, x20, #1
+ bl fft15_neon
+
+ add x0, x21, #15*8
+ add x1, x22, x20, lsl #3
+ lsl x3, x20, #1
+ bl fft15_neon
+
+ ldr x2, [x10, #(CELT_EXPTAB + 8)] // s->exptab[1]
+ add x0, x21, #0
+ add x1, x21, #15*8
+ mov x3, #15
+ ldp x20, x21, [sp]
+ ldp x22, x30, [sp, #0x10]
+ add sp, sp, #0x20
+ b fft15_pass
+endfunc
+
+.macro def_fft n, n2
+function fft\n\()_neon align=6
+ sub sp, sp, #0x30
+ stp x20, x21, [sp]
+ stp x22, x30, [sp, #0x10]
+ stp x23, x24, [sp, #0x20]
+ mov x21, x1
+ mov x22, x2
+ mov x23, x3
+ mov x20, x4
+ sub x3, x3, #1
+ lsl x4, x4, #1
+ bl fft\n2\()_neon
+
+ add x1, x21, #(\n2 * 8)
+ add x2, x22, x20, lsl #3
+ sub x3, x23, #1
+ lsl x4, x20, #1
+ bl fft\n2\()_neon
+
+ add x5, x10, #CELT_EXPTAB
+ mov x0, x21
+ ldr x2, [x5, x23, lsl #3] // s->exptab[N]
+ add x1, x21, #(\n2 * 8)
+ mov x3, #\n2
+ ldp x20, x21, [sp]
+ ldp x22, x30, [sp, #0x10]
+ ldp x23, x24, [sp, #0x20]
+ add sp, sp, #0x30
+ b fft15_pass
+endfunc
+.endm
+
+ def_fft 60, 30
+ def_fft 120, 60
+ def_fft 240, 120
+ def_fft 480, 240
+ def_fft 960, 480
+
+function fft_b15_calc_neon
+ sub sp, sp, #0x50
+ ldr x8, [x0, #CELT_EXPTAB] // s->exptab[0]
+ movrel x6, fact5
+ movrel x11, shuffle_0213
+ movrel x12, shuffle_1032
+ movrel x13, shuffle_2301
+ movrel x14, shuffle_3120
+ add x8, x8, #8
+ movrel x5, fft_tab_neon
+ stp x20, x30, [sp]
+ stp d8, d9, [sp, #0x10]
+ stp d10, d11, [sp, #0x20]
+ stp d12, d13, [sp, #0x30]
+ stp d14, d15, [sp, #0x40]
+ ld1 {v15.4s}, [x6]
+ ld1 {v0.4s,v1.4s}, [x8], #32
+ ld1 {v6.2s}, [x8], #8
+ ld1 {v2.4s,v3.4s}, [x8], #32
+ ld1 {v7.2s}, [x8], #8
+ ld1 {v4.4s,v5.4s}, [x8], #32
+ uzp1 v8.4s, v0.4s, v1.4s // exp[ 1 - 4].re
+ uzp2 v9.4s, v0.4s, v1.4s // exp[ 1 - 4].im
+ uzp1 v10.4s, v2.4s, v3.4s // exp[ 6 - 9].re
+ uzp2 v11.4s, v2.4s, v3.4s // exp[ 6 - 9].im
+ uzp1 v12.4s, v4.4s, v5.4s // exp[11 - 14].re
+ uzp2 v13.4s, v4.4s, v5.4s // exp[11 - 14].im
+ zip1 v14.4s, v6.4s, v7.4s // exp[5,10].re/exp[5,10].im
+ add x5, x5, x3, lsl #3
+ ldr x5, [x5]
+ mov x10, x0
+ blr x5
+ ldp x20, x30, [sp]
+ ldp d8, d9, [sp, #0x10]
+ ldp d10, d11, [sp, #0x20]
+ ldp d12, d13, [sp, #0x30]
+ ldp d14, d15, [sp, #0x40]
+ add sp, sp, #0x50
+ ret
+endfunc
+
+const fft_tab_neon
+ .quad fft15_neon
+ .quad fft30_neon
+ .quad fft60_neon
+ .quad fft120_neon
+ .quad fft240_neon
+ .quad fft480_neon
+ .quad fft960_neon
+endconst
+
+function ff_celt_imdct_half_neon, export=1
+ sub sp, sp, #0x20
+ stp x21, x30, [sp]
+ str s0, [sp, #0x10]
+
+ ldp w5, w6, [x0, #CELT_LEN2] // CELT_LEN4
+ mov x10, x0
+ mov x21, x1
+ sub w5, w5, #1
+ lsl x7, x3, #3 // 2 * stride * sizeof(float)
+ sub x8, xzr, x3, lsl #3 // -2 * stride * sizeof(float)
+ mul x5, x5, x3
+ ldp x9, x10, [x0, #CELT_TMP] // CELT_TWIDDLE
+ ldr w3, [x0, #CELT_FFT_N]
+ add x5, x2, x5, lsl #2
+ mov x11, x9
+
+ sub w6, w6, #4
+ ld1 {v0.s}[0], [x5], x8
+ ld1 {v1.s}[0], [x2], x7
+ ld1 {v4.4s,v5.4s}, [x10], #32
+ ld1 {v0.s}[1], [x5], x8
+ ld1 {v1.s}[1], [x2], x7
+ uzp1 v2.4s, v4.4s, v5.4s
+ ld1 {v0.s}[2], [x5], x8
+ ld1 {v1.s}[2], [x2], x7
+ uzp2 v3.4s, v4.4s, v5.4s
+ ld1 {v0.s}[3], [x5], x8
+ ld1 {v1.s}[3], [x2], x7
+1:
+ subs w6, w6, #4
+
+ ld1 {v20.s}[0], [x5], x8
+ ld1 {v21.s}[0], [x2], x7
+ ld1 {v4.4s,v5.4s}, [x10], #32
+
+ fmul v6.4s, v0.4s, v2.4s
+ fmul v7.4s, v0.4s, v3.4s
+
+ ld1 {v20.s}[1], [x5], x8
+ ld1 {v21.s}[1], [x2], x7
+
+ fmls v6.4s, v1.4s, v3.4s
+ fmla v7.4s, v1.4s, v2.4s
+
+ ld1 {v20.s}[2], [x5], x8
+ ld1 {v21.s}[2], [x2], x7
+
+ uzp1 v2.4s, v4.4s, v5.4s
+ uzp2 v3.4s, v4.4s, v5.4s
+ ld1 {v20.s}[3], [x5], x8
+ ld1 {v21.s}[3], [x2], x7
+
+ zip1 v4.4s, v6.4s, v7.4s
+ zip2 v5.4s, v6.4s, v7.4s
+
+ fmul v6.4s, v20.4s, v2.4s
+ fmul v7.4s, v20.4s, v3.4s
+
+ st1 {v4.4s,v5.4s}, [x9], #32
+
+ fmls v6.4s, v21.4s, v3.4s
+ fmla v7.4s, v21.4s, v2.4s
+
+ b.eq 3f
+
+ subs w6, w6, #4
+ ld1 {v4.4s,v5.4s}, [x10], #32
+ ld1 {v0.s}[0], [x5], x8
+ ld1 {v1.s}[0], [x2], x7
+ uzp1 v2.4s, v4.4s, v5.4s
+ ld1 {v0.s}[1], [x5], x8
+ ld1 {v1.s}[1], [x2], x7
+ uzp2 v3.4s, v4.4s, v5.4s
+ ld1 {v0.s}[2], [x5], x8
+ ld1 {v1.s}[2], [x2], x7
+ zip1 v4.4s, v6.4s, v7.4s
+ zip2 v5.4s, v6.4s, v7.4s
+ ld1 {v0.s}[3], [x5], x8
+ ld1 {v1.s}[3], [x2], x7
+
+ st1 {v4.4s,v5.4s}, [x9], #32
+
+ b.gt 1b
+
+ fmul v6.4s, v0.4s, v2.4s
+ fmul v7.4s, v0.4s, v3.4s
+ fmls v6.4s, v1.4s, v3.4s
+ fmla v7.4s, v1.4s, v2.4s
+3:
+ zip1 v4.4s, v6.4s, v7.4s
+ zip2 v5.4s, v6.4s, v7.4s
+ st1 {v4.4s,v5.4s}, [x9], #32
+
+ mov x2, x11
+ mov x4, #1
+
+ bl fft_b15_calc_neon
+
+ ldr w5, [x10, #CELT_LEN4]
+ ldr x6, [x10, #CELT_TWIDDLE]
+ ldr s31, [sp, #0x10]
+
+ add x1, x21, x5, lsl #2
+ add x3, x6, x5, lsl #2
+ sub x0, x1, #16
+ sub x2, x3, #16
+ mov x8, #-16
+ mov x7, #16
+ mov x10, x0
+ mov x11, x1
+
+ sub w5, w5, #4
+
+ ld1 {v0.4s}, [x0], x8
+ ld1 {v1.4s}, [x1], x7
+ ld1 {v2.4s}, [x2], x8
+ ld1 {v3.4s}, [x3], x7
+
+ uzp1 v4.4s, v0.4s, v1.4s // z[-i-2, -i-1, +i, i+1].re
+ uzp2 v6.4s, v0.4s, v1.4s // z[-i-2, -i-1, +i, i+1].im
+
+ uzp1 v5.4s, v2.4s, v3.4s // twidlle_exptab[-i-2, -i-1, +i, i+1].re
+ uzp2 v7.4s, v2.4s, v3.4s // twidlle_exptab[-i-2, -i-1, +i, i+1].im
+
+ fmul v1.4s, v6.4s, v5.4s
+ fmul v0.4s, v6.4s, v7.4s
+2:
+ subs w5, w5, #4
+
+ ld1 {v20.4s}, [x0], x8
+
+ fmla v1.4s, v4.4s, v7.4s
+ fmls v0.4s, v4.4s, v5.4s
+
+ ld1 {v21.4s}, [x1], x7
+
+ ext v1.16b, v1.16b, v1.16b, #8
+ fmul v0.4s, v0.4s, v31.s[0]
+
+ ld1 {v2.4s}, [x2], x8
+
+ rev64 v1.4s, v1.4s
+ fmul v1.4s, v1.4s, v31.s[0]
+
+ ld1 {v3.4s}, [x3], x7
+
+ zip1 v5.4s, v0.4s, v1.4s
+ zip2 v7.4s, v0.4s, v1.4s
+
+ uzp1 v4.4s, v20.4s, v21.4s // z[-i-2, -i-1, +i, i+1].re
+ uzp2 v6.4s, v20.4s, v21.4s // z[-i-2, -i-1, +i, i+1].im
+
+ st1 {v5.4s}, [x10], x8
+ st1 {v7.4s}, [x11], x7
+
+ uzp1 v5.4s, v2.4s, v3.4s // twidlle_exptab[-i-2, -i-1, +i, i+1].re
+ uzp2 v7.4s, v2.4s, v3.4s // twidlle_exptab[-i-2, -i-1, +i, i+1].im
+
+ fmul v1.4s, v6.4s, v5.4s
+ fmul v0.4s, v6.4s, v7.4s
+ b.gt 2b
+
+ fmla v1.4s, v4.4s, v7.4s
+ fmls v0.4s, v4.4s, v5.4s
+ ext v1.16b, v1.16b, v1.16b, #8
+ fmul v0.4s, v0.4s, v31.s[0]
+ rev64 v1.4s, v1.4s
+ fmul v1.4s, v1.4s, v31.s[0]
+ zip1 v5.4s, v0.4s, v1.4s
+ zip2 v7.4s, v0.4s, v1.4s
+ st1 {v5.4s}, [x10], x8
+ st1 {v7.4s}, [x11], x7
+
+ ldp x21, x30, [sp]
+ add sp, sp, #0x20
+ ret
+endfunc
+
+// [0] = exp(2 * i * pi / 5), [1] = exp(2 * i * pi * 2 / 5)
+const fact5 align=4
+ .float 0.30901699437494745, 0.95105651629515353
+ .float -0.80901699437494734, 0.58778525229247325
+endconst
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/rv40dsp_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/rv40dsp_init_aarch64.c
new file mode 100644
index 00000000000..764bc1ef391
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/rv40dsp_init_aarch64.c
@@ -0,0 +1,48 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/rv34dsp.h"
+
+#include "config.h"
+
+void ff_put_rv40_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_put_rv40_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+
+void ff_avg_rv40_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_avg_rv40_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+
+av_cold void ff_rv40dsp_init_aarch64(RV34DSPContext *c)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_neon;
+ c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_neon;
+ c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_neon;
+ c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/vc1dsp_init_aarch64.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/vc1dsp_init_aarch64.c
new file mode 100644
index 00000000000..e59e55ec886
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/vc1dsp_init_aarch64.c
@@ -0,0 +1,47 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/vc1dsp.h"
+
+#include "config.h"
+
+void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+
+av_cold void ff_vc1dsp_init_aarch64(VC1DSPContext *dsp)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_neon;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_neon;
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_vc1_chroma_mc4_neon;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_vc1_chroma_mc4_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.h b/chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp.S
index 2ba93549fb3..24067cc2af5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.h
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp.S
@@ -16,13 +16,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_SH4_DSPUTIL_SH4_H
-#define AVCODEC_SH4_DSPUTIL_SH4_H
+#include "libavutil/aarch64/asm.S"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/hpeldsp.h"
-
-void ff_idct_sh4(int16_t *block);
-
-#endif /* AVCODEC_SH4_DSPUTIL_SH4_H */
+function ff_prefetch_aarch64, export=1
+ subs w2, w2, #2
+ prfm pldl1strm, [x0]
+ prfm pldl1strm, [x0, x1]
+ add x0, x0, x1, lsl #1
+ b.gt X(ff_prefetch_aarch64)
+ ret
+endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.h b/chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp_init.c
index d7e2e63ab98..6f667a6d3e6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.h
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/videodsp_init.c
@@ -16,13 +16,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_SPARC_DSPUTIL_VIS_H
-#define AVCODEC_SPARC_DSPUTIL_VIS_H
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/videodsp.h"
-#include <stdint.h>
+void ff_prefetch_aarch64(uint8_t *mem, ptrdiff_t stride, int h);
-void ff_simple_idct_put_vis(uint8_t *dest, int line_size, int16_t *data);
-void ff_simple_idct_add_vis(uint8_t *dest, int line_size, int16_t *data);
-void ff_simple_idct_vis(int16_t *data);
+av_cold void ff_videodsp_init_aarch64(VideoDSPContext *ctx, int bpc)
+{
+ int cpu_flags = av_get_cpu_flags();
-#endif /* AVCODEC_SPARC_DSPUTIL_VIS_H */
+ if (have_armv8(cpu_flags))
+ ctx->prefetch = ff_prefetch_aarch64;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_init.c
new file mode 100644
index 00000000000..c796f95e618
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_init.c
@@ -0,0 +1,34 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/vorbisdsp.h"
+
+void ff_vorbis_inverse_coupling_neon(float *mag, float *ang,
+ intptr_t blocksize);
+
+av_cold void ff_vorbisdsp_init_aarch64(VorbisDSPContext *c)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
+ c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_neon;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_neon.S
new file mode 100644
index 00000000000..e76feebc54f
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aarch64/vorbisdsp_neon.S
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+function ff_vorbis_inverse_coupling_neon, export=1
+ movi v20.4s, #1<<7, lsl #24
+ subs x2, x2, #4
+ mov x3, x0
+ mov x4, x1
+ b.eq 3f
+
+ ld1 {v7.4s}, [x1], #16
+ ld1 {v6.4s}, [x0], #16
+ cmle v4.4s, v7.4s, #0
+ and v5.16b, v6.16b, v20.16b
+ eor v7.16b, v7.16b, v5.16b
+ and v2.16b, v7.16b, v4.16b
+ bic v3.16b, v7.16b, v4.16b
+ fadd v7.4s, v6.4s, v2.4s
+ fsub v6.4s, v6.4s, v3.4s
+1: ld1 {v1.4s}, [x1], #16
+ ld1 {v0.4s}, [x0], #16
+ cmle v4.4s, v1.4s, #0
+ and v5.16b, v0.16b, v20.16b
+ eor v1.16b, v1.16b, v5.16b
+ st1 {v7.4s}, [x3], #16
+ st1 {v6.4s}, [x4], #16
+ and v2.16b, v1.16b, v4.16b
+ bic v3.16b, v1.16b, v4.16b
+ fadd v1.4s, v0.4s, v2.4s
+ fsub v0.4s, v0.4s, v3.4s
+ subs x2, x2, #8
+ b.le 2f
+ ld1 {v7.4s}, [x1], #16
+ ld1 {v6.4s}, [x0], #16
+ cmle v4.4s, v7.4s, #0
+ and v5.16b, v6.16b, v20.16b
+ eor v7.16b, v7.16b, v5.16b
+ st1 {v1.4s}, [x3], #16
+ st1 {v0.4s}, [x4], #16
+ and v2.16b, v7.16b, v4.16b
+ bic v3.16b, v7.16b, v4.16b
+ fadd v7.4s, v6.4s, v2.4s
+ fsub v6.4s, v6.4s, v3.4s
+ b 1b
+
+2: st1 {v1.4s}, [x3], #16
+ st1 {v0.4s}, [x4], #16
+ b.lt ret
+
+3: ld1 {v1.4s}, [x1]
+ ld1 {v0.4s}, [x0]
+ cmle v4.4s, v1.4s, #0
+ and v5.16b, v0.16b, v20.16b
+ eor v1.16b, v1.16b, v5.16b
+ and v2.16b, v1.16b, v4.16b
+ bic v3.16b, v1.16b, v4.16b
+ fadd v1.4s, v0.4s, v2.4s
+ fsub v0.4s, v0.4s, v3.4s
+ st1 {v1.4s}, [x0], #16
+ st1 {v0.4s}, [x1], #16
+ret:
+ ret
+endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3.h b/chromium/third_party/ffmpeg/libavcodec/ac3.h
index e609bb51ce3..542f79d711d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3.h
@@ -51,6 +51,52 @@
#define EXP_D25 2
#define EXP_D45 3
+#ifndef USE_FIXED
+#define USE_FIXED 0
+#endif
+
+#if USE_FIXED
+
+#define FFT_FLOAT 0
+
+#define FIXR(a) ((int)((a) * 0 + 0.5))
+#define FIXR12(a) ((int)((a) * 4096 + 0.5))
+#define FIXR15(a) ((int)((a) * 32768 + 0.5))
+#define ROUND15(x) ((x) + 16384) >> 15
+
+#define AC3_RENAME(x) x ## _fixed
+#define AC3_NORM(norm) (1<<24)/(norm)
+#define AC3_MUL(a,b) ((((int64_t) (a)) * (b))>>12)
+#define AC3_RANGE(x) (x)
+#define AC3_DYNAMIC_RANGE(x) (x)
+#define AC3_SPX_BLEND(x) (x)
+#define AC3_DYNAMIC_RANGE1 0
+
+#define INTFLOAT int
+#define SHORTFLOAT int16_t
+
+#else /* USE_FIXED */
+
+#define FIXR(x) ((float)(x))
+#define FIXR12(x) ((float)(x))
+#define FIXR15(x) ((float)(x))
+#define ROUND15(x) (x)
+
+#define AC3_RENAME(x) x
+#define AC3_NORM(norm) (1.0f/(norm))
+#define AC3_MUL(a,b) ((a) * (b))
+#define AC3_RANGE(x) (dynamic_range_tab[(x)])
+#define AC3_DYNAMIC_RANGE(x) (powf(x, s->drc_scale))
+#define AC3_SPX_BLEND(x) (x)* (1.0f/32)
+#define AC3_DYNAMIC_RANGE1 1.0f
+
+#define INTFLOAT float
+#define SHORTFLOAT float
+
+#endif /* USE_FIXED */
+
+#define AC3_LEVEL(x) ROUND15((x) * FIXR15(0.7071067811865476))
+
/* pre-defined gain values */
#define LEVEL_PLUS_3DB 1.4142135623730950
#define LEVEL_PLUS_1POINT5DB 1.1892071150027209
@@ -82,6 +128,38 @@ typedef enum {
AC3_CHMODE_3F2R
} AC3ChannelMode;
+/** Dolby Surround mode */
+typedef enum AC3DolbySurroundMode {
+ AC3_DSURMOD_NOTINDICATED = 0,
+ AC3_DSURMOD_OFF,
+ AC3_DSURMOD_ON,
+ AC3_DSURMOD_RESERVED
+} AC3DolbySurroundMode;
+
+/** Dolby Surround EX mode */
+typedef enum AC3DolbySurroundEXMode {
+ AC3_DSUREXMOD_NOTINDICATED = 0,
+ AC3_DSUREXMOD_OFF,
+ AC3_DSUREXMOD_ON,
+ AC3_DSUREXMOD_PLIIZ
+} AC3DolbySurroundEXMode;
+
+/** Dolby Headphone mode */
+typedef enum AC3DolbyHeadphoneMode {
+ AC3_DHEADPHONMOD_NOTINDICATED = 0,
+ AC3_DHEADPHONMOD_OFF,
+ AC3_DHEADPHONMOD_ON,
+ AC3_DHEADPHONMOD_RESERVED
+} AC3DolbyHeadphoneMode;
+
+/** Preferred Stereo Downmix mode */
+typedef enum AC3PreferredStereoDownmixMode {
+ AC3_DMIXMOD_NOTINDICATED = 0,
+ AC3_DMIXMOD_LTRT,
+ AC3_DMIXMOD_LORO,
+ AC3_DMIXMOD_DPLII // reserved value in A/52, but used by encoders to indicate DPL2
+} AC3PreferredStereoDownmixMode;
+
typedef struct AC3BitAllocParameters {
int sr_code;
int sr_shift;
@@ -110,6 +188,9 @@ typedef struct AC3HeaderInfo {
int surround_mix_level; ///< Surround mix level index
uint16_t channel_map;
int num_blocks; ///< number of audio blocks
+#if AV_HAVE_INCOMPATIBLE_LIBAV_ABI
+ int dolby_surround_mode;
+#endif
/** @} */
/** @name Derived values
@@ -122,6 +203,9 @@ typedef struct AC3HeaderInfo {
uint16_t frame_size;
uint64_t channel_layout;
/** @} */
+#if !AV_HAVE_INCOMPATIBLE_LIBAV_ABI
+ int dolby_surround_mode;
+#endif
} AC3HeaderInfo;
typedef enum {
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3_parser.c b/chromium/third_party/ffmpeg/libavcodec/ac3_parser.c
index 8dc4c0d4801..dd6d77c9ab2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3_parser.c
@@ -47,9 +47,16 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
+int avpriv_ac3_parse_header2(GetBitContext *gbc, AC3HeaderInfo **phdr)
{
int frame_size_code;
+ AC3HeaderInfo *hdr;
+
+ if (!*phdr)
+ *phdr = av_mallocz(sizeof(AC3HeaderInfo));
+ if (!*phdr)
+ return AVERROR(ENOMEM);
+ hdr = *phdr;
memset(hdr, 0, sizeof(*hdr));
@@ -68,6 +75,9 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
hdr->center_mix_level = 5; // -4.5dB
hdr->surround_mix_level = 6; // -6.0dB
+ /* set default dolby surround mode */
+ hdr->dolby_surround_mode = AC3_DSURMOD_NOTINDICATED;
+
if(hdr->bitstream_id <= 10) {
/* Normal AC-3 */
hdr->crc1 = get_bits(gbc, 16);
@@ -85,7 +95,7 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
hdr->channel_mode = get_bits(gbc, 3);
if(hdr->channel_mode == AC3_CHMODE_STEREO) {
- skip_bits(gbc, 2); // skip dsurmod
+ hdr->dolby_surround_mode = get_bits(gbc, 2);
} else {
if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO)
hdr-> center_mix_level = center_levels[get_bits(gbc, 2)];
@@ -141,6 +151,15 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
return 0;
}
+int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
+{
+ AC3HeaderInfo tmp, *ptmp = &tmp;
+ int ret = avpriv_ac3_parse_header2(gbc, &ptmp);
+
+ memcpy(hdr, ptmp, ((intptr_t)&tmp.channel_layout) - ((intptr_t)&tmp) + sizeof(uint64_t));
+ return ret;
+}
+
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
@@ -149,11 +168,11 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
uint64_t u64;
uint8_t u8[8];
} tmp = { av_be2ne64(state) };
- AC3HeaderInfo hdr;
+ AC3HeaderInfo hdr, *phdr = &hdr;
GetBitContext gbc;
init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
- err = avpriv_ac3_parse_header(&gbc, &hdr);
+ err = avpriv_ac3_parse_header2(&gbc, &phdr);
if(err < 0)
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3_parser.h b/chromium/third_party/ffmpeg/libavcodec/ac3_parser.h
index b5022de2d88..f37387d76c2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3_parser.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3_parser.h
@@ -31,11 +31,14 @@
* Parse the header up to the lfeon element, which is the first 52 or 54 bits
* depending on the audio coding mode.
* @param[in] gbc BitContext containing the first 54 bits of the frame.
- * @param[out] hdr Pointer to struct where header info is written.
+ * @param[out] hdr Pointer to Pointer to struct where header info is written.
+ * will be allocated if NULL
* @return Returns 0 on success, -1 if there is a sync word mismatch,
* -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate)
* element is invalid, or -4 if the frmsizecod (bit rate) element is invalid.
*/
+int avpriv_ac3_parse_header2(GetBitContext *gbc, AC3HeaderInfo **hdr);
+
int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
#endif /* AVCODEC_AC3_PARSER_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dec.c b/chromium/third_party/ffmpeg/libavcodec/ac3dec.c
index 1995412cdc4..c8c4eb6b4ac 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dec.c
@@ -31,6 +31,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
+#include "libavutil/downmix_info.h"
#include "libavutil/opt.h"
#include "internal.h"
#include "aac_ac3_parser.h"
@@ -77,6 +78,15 @@ static const float gain_levels[9] = {
LEVEL_MINUS_9DB
};
+/** Adjustments in dB gain (LFE, +10 to -21 dB) */
+static const float gain_levels_lfe[32] = {
+ 3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
+ 1.412536, 1.258924, 1.122018, 1.000000, 0.891251, 0.794328, 0.707946,
+ 0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
+ 0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
+ 0.125892, 0.112201, 0.100000, 0.089125
+};
+
/**
* Table for default stereo downmixing coefficients
* reference: Section 7.8.2 Downmixing Into Two Channels
@@ -169,14 +179,23 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
ac3_tables_init();
ff_mdct_init(&s->imdct_256, 8, 1, 1.0);
ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
- ff_kbd_window_init(s->window, 5.0, 256);
+ AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
ff_dsputil_init(&s->dsp, avctx);
+
+#if (USE_FIXED)
+ s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & CODEC_FLAG_BITEXACT);
+#else
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
+#endif
+
ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT);
ff_fmt_convert_init(&s->fmt_conv, avctx);
av_lfg_init(&s->dith_state, 0);
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+ if (USE_FIXED)
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
+ else
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
/* allow downmixing to stereo or mono */
#if FF_API_REQUEST_CHANNELS
@@ -227,12 +246,26 @@ static int ac3_parse_header(AC3DecodeContext *s)
skip_bits(gbc, 2); //skip copyright bit and original bitstream bit
- /* skip the timecodes (or extra bitstream information for Alternate Syntax)
- TODO: read & use the xbsi1 downmix levels */
- if (get_bits1(gbc))
- skip_bits(gbc, 14); //skip timecode1 / xbsi1
- if (get_bits1(gbc))
- skip_bits(gbc, 14); //skip timecode2 / xbsi2
+ /* skip the timecodes or parse the Alternate Bit Stream Syntax */
+ if (s->bitstream_id != 6) {
+ if (get_bits1(gbc))
+ skip_bits(gbc, 14); //skip timecode1
+ if (get_bits1(gbc))
+ skip_bits(gbc, 14); //skip timecode2
+ } else {
+ if (get_bits1(gbc)) {
+ s->preferred_downmix = get_bits(gbc, 2);
+ s->center_mix_level_ltrt = get_bits(gbc, 3);
+ s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
+ s->center_mix_level = get_bits(gbc, 3);
+ s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
+ }
+ if (get_bits1(gbc)) {
+ s->dolby_surround_ex_mode = get_bits(gbc, 2);
+ s->dolby_headphone_mode = get_bits(gbc, 2);
+ skip_bits(gbc, 10); // skip adconvtyp (1), xbsi2 (8), encinfo (1)
+ }
+ }
/* skip additional bitstream info */
if (get_bits1(gbc)) {
@@ -250,15 +283,16 @@ static int ac3_parse_header(AC3DecodeContext *s)
*/
static int parse_frame_header(AC3DecodeContext *s)
{
- AC3HeaderInfo hdr;
+ AC3HeaderInfo hdr, *phdr=&hdr;
int err;
- err = avpriv_ac3_parse_header(&s->gbc, &hdr);
+ err = avpriv_ac3_parse_header2(&s->gbc, &phdr);
if (err)
return err;
/* get decoding parameters from header info */
s->bit_alloc_params.sr_code = hdr.sr_code;
+ s->bitstream_id = hdr.bitstream_id;
s->bitstream_mode = hdr.bitstream_mode;
s->channel_mode = hdr.channel_mode;
s->lfe_on = hdr.lfe_on;
@@ -269,11 +303,18 @@ static int parse_frame_header(AC3DecodeContext *s)
s->fbw_channels = s->channels - s->lfe_on;
s->lfe_ch = s->fbw_channels + 1;
s->frame_size = hdr.frame_size;
+ s->preferred_downmix = AC3_DMIXMOD_NOTINDICATED;
s->center_mix_level = hdr.center_mix_level;
+ s->center_mix_level_ltrt = 4; // -3.0dB
s->surround_mix_level = hdr.surround_mix_level;
+ s->surround_mix_level_ltrt = 4; // -3.0dB
+ s->lfe_mix_level_exists = 0;
s->num_blocks = hdr.num_blocks;
s->frame_type = hdr.frame_type;
s->substreamid = hdr.substreamid;
+ s->dolby_surround_mode = hdr.dolby_surround_mode;
+ s->dolby_surround_ex_mode = AC3_DSUREXMOD_NOTINDICATED;
+ s->dolby_headphone_mode = AC3_DHEADPHONMOD_NOTINDICATED;
if (s->lfe_on) {
s->start_freq[s->lfe_ch] = 0;
@@ -282,7 +323,7 @@ static int parse_frame_header(AC3DecodeContext *s)
s->channel_in_cpl[s->lfe_ch] = 0;
}
- if (hdr.bitstream_id <= 10) {
+ if (s->bitstream_id <= 10) {
s->eac3 = 0;
s->snr_offset_strategy = 2;
s->block_switch_syntax = 1;
@@ -313,40 +354,45 @@ static void set_downmix_coeffs(AC3DecodeContext *s)
float cmix = gain_levels[s-> center_mix_level];
float smix = gain_levels[s->surround_mix_level];
float norm0, norm1;
+ float downmix_coeffs[AC3_MAX_CHANNELS][2];
for (i = 0; i < s->fbw_channels; i++) {
- s->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]];
- s->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]];
+ downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]];
+ downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]];
}
if (s->channel_mode > 1 && s->channel_mode & 1) {
- s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = cmix;
+ downmix_coeffs[1][0] = downmix_coeffs[1][1] = cmix;
}
if (s->channel_mode == AC3_CHMODE_2F1R || s->channel_mode == AC3_CHMODE_3F1R) {
int nf = s->channel_mode - 2;
- s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf][1] = smix * LEVEL_MINUS_3DB;
+ downmix_coeffs[nf][0] = downmix_coeffs[nf][1] = smix * LEVEL_MINUS_3DB;
}
if (s->channel_mode == AC3_CHMODE_2F2R || s->channel_mode == AC3_CHMODE_3F2R) {
int nf = s->channel_mode - 4;
- s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf+1][1] = smix;
+ downmix_coeffs[nf][0] = downmix_coeffs[nf+1][1] = smix;
}
/* renormalize */
norm0 = norm1 = 0.0;
for (i = 0; i < s->fbw_channels; i++) {
- norm0 += s->downmix_coeffs[i][0];
- norm1 += s->downmix_coeffs[i][1];
+ norm0 += downmix_coeffs[i][0];
+ norm1 += downmix_coeffs[i][1];
}
norm0 = 1.0f / norm0;
norm1 = 1.0f / norm1;
for (i = 0; i < s->fbw_channels; i++) {
- s->downmix_coeffs[i][0] *= norm0;
- s->downmix_coeffs[i][1] *= norm1;
+ downmix_coeffs[i][0] *= norm0;
+ downmix_coeffs[i][1] *= norm1;
}
if (s->output_mode == AC3_CHMODE_MONO) {
for (i = 0; i < s->fbw_channels; i++)
- s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] +
- s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB;
+ downmix_coeffs[i][0] = (downmix_coeffs[i][0] +
+ downmix_coeffs[i][1]) * LEVEL_MINUS_3DB;
+ }
+ for (i = 0; i < s->fbw_channels; i++) {
+ s->downmix_coeffs[i][0] = FIXR12(downmix_coeffs[i][0]);
+ s->downmix_coeffs[i][1] = FIXR12(downmix_coeffs[i][1]);
}
}
@@ -614,20 +660,30 @@ static inline void do_imdct(AC3DecodeContext *s, int channels)
for (ch = 1; ch <= channels; ch++) {
if (s->block_switch[ch]) {
int i;
- float *x = s->tmp_output + 128;
+ FFTSample *x = s->tmp_output + 128;
for (i = 0; i < 128; i++)
x[i] = s->transform_coeffs[ch][2 * i];
s->imdct_256.imdct_half(&s->imdct_256, s->tmp_output, x);
+#if USE_FIXED
+ s->fdsp->vector_fmul_window_scaled(s->outptr[ch - 1], s->delay[ch - 1],
+ s->tmp_output, s->window, 128, 8);
+#else
s->fdsp.vector_fmul_window(s->outptr[ch - 1], s->delay[ch - 1],
s->tmp_output, s->window, 128);
+#endif
for (i = 0; i < 128; i++)
x[i] = s->transform_coeffs[ch][2 * i + 1];
s->imdct_256.imdct_half(&s->imdct_256, s->delay[ch - 1], x);
} else {
s->imdct_512.imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);
+#if USE_FIXED
+ s->fdsp->vector_fmul_window_scaled(s->outptr[ch - 1], s->delay[ch - 1],
+ s->tmp_output, s->window, 128, 8);
+#else
s->fdsp.vector_fmul_window(s->outptr[ch - 1], s->delay[ch - 1],
s->tmp_output, s->window, 128);
- memcpy(s->delay[ch - 1], s->tmp_output + 128, 128 * sizeof(float));
+#endif
+ memcpy(s->delay[ch - 1], s->tmp_output + 128, 128 * sizeof(FFTSample));
}
}
}
@@ -760,10 +816,15 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
i = !s->channel_mode;
do {
if (get_bits1(gbc)) {
- s->dynamic_range[i] = powf(dynamic_range_tab[get_bits(gbc, 8)],
- s->drc_scale);
+ /* Allow asymmetric application of DRC when drc_scale > 1.
+ Amplification of quiet sounds is enhanced */
+ INTFLOAT range = AC3_RANGE(get_bits(gbc, 8));
+ if (range > 1.0 || s->drc_scale <= 1.0)
+ s->dynamic_range[i] = AC3_DYNAMIC_RANGE(range);
+ else
+ s->dynamic_range[i] = range;
} else if (blk == 0) {
- s->dynamic_range[i] = 1.0f;
+ s->dynamic_range[i] = AC3_DYNAMIC_RANGE1;
}
} while (i--);
@@ -789,6 +850,9 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (start_subband > 7)
start_subband += start_subband - 7;
end_subband = get_bits(gbc, 3) + 5;
+#if USE_FIXED
+ s->spx_dst_end_freq = end_freq_inv_tab[end_subband];
+#endif
if (end_subband > 7)
end_subband += end_subband - 7;
dst_start_freq = dst_start_freq * 12 + 25;
@@ -809,7 +873,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s->spx_dst_start_freq = dst_start_freq;
s->spx_src_start_freq = src_start_freq;
- s->spx_dst_end_freq = dst_end_freq;
+ if (!USE_FIXED)
+ s->spx_dst_end_freq = dst_end_freq;
decode_band_structure(gbc, blk, s->eac3, 0,
start_subband, end_subband,
@@ -829,18 +894,40 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
for (ch = 1; ch <= fbw_channels; ch++) {
if (s->channel_uses_spx[ch]) {
if (s->first_spx_coords[ch] || get_bits1(gbc)) {
- float spx_blend;
+ INTFLOAT spx_blend;
int bin, master_spx_coord;
s->first_spx_coords[ch] = 0;
- spx_blend = get_bits(gbc, 5) * (1.0f/32);
+ spx_blend = AC3_SPX_BLEND(get_bits(gbc, 5));
master_spx_coord = get_bits(gbc, 2) * 3;
bin = s->spx_src_start_freq;
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
int bandsize;
int spx_coord_exp, spx_coord_mant;
- float nratio, sblend, nblend, spx_coord;
+ INTFLOAT nratio, sblend, nblend;
+#if USE_FIXED
+ int64_t accu;
+ /* calculate blending factors */
+ bandsize = s->spx_band_sizes[bnd];
+ accu = (int64_t)((bin << 23) + (bandsize << 22)) * s->spx_dst_end_freq;
+ nratio = (int)(accu >> 32);
+ nratio -= spx_blend << 18;
+
+ if (nratio < 0) {
+ nblend = 0;
+ sblend = 0x800000;
+ } else if (nratio > 0x7fffff) {
+ nblend = 0x800000;
+ sblend = 0;
+ } else {
+ nblend = fixed_sqrt(nratio, 23);
+ accu = (int64_t)nblend * 1859775393;
+ nblend = (int)((accu + (1<<29)) >> 30);
+ sblend = fixed_sqrt(0x800000 - nratio, 23);
+ }
+#else
+ float spx_coord;
/* calculate blending factors */
bandsize = s->spx_band_sizes[bnd];
@@ -849,6 +936,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3)
// to give unity variance
sblend = sqrtf(1.0f - nratio);
+#endif
bin += bandsize;
/* decode spx coordinates */
@@ -857,11 +945,18 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (spx_coord_exp == 15) spx_coord_mant <<= 1;
else spx_coord_mant += 4;
spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
- spx_coord = spx_coord_mant * (1.0f / (1 << 23));
/* multiply noise and signal blending factors by spx coordinate */
+#if USE_FIXED
+ accu = (int64_t)nblend * spx_coord_mant;
+ s->spx_noise_blend[ch][bnd] = (int)((accu + (1<<22)) >> 23);
+ accu = (int64_t)sblend * spx_coord_mant;
+ s->spx_signal_blend[ch][bnd] = (int)((accu + (1<<22)) >> 23);
+#else
+ spx_coord = spx_coord_mant * (1.0f / (1 << 23));
s->spx_noise_blend [ch][bnd] = nblend * spx_coord;
s->spx_signal_blend[ch][bnd] = sblend * spx_coord;
+#endif
}
}
} else {
@@ -1218,14 +1313,19 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
/* apply scaling to coefficients (headroom, dynrng) */
for (ch = 1; ch <= s->channels; ch++) {
- float gain = 1.0 / 4194304.0f;
- if (s->channel_mode == AC3_CHMODE_DUALMONO) {
- gain *= s->dynamic_range[2 - ch];
+ INTFLOAT gain;
+ if(s->channel_mode == AC3_CHMODE_DUALMONO) {
+ gain = s->dynamic_range[2-ch];
} else {
- gain *= s->dynamic_range[0];
+ gain = s->dynamic_range[0];
}
+#if USE_FIXED
+ scale_coefs(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
+#else
+ gain *= 1.0 / 4194304.0f;
s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch],
s->fixed_coeffs[ch], gain, 256);
+#endif
}
/* apply spectral extension to high frequency bins */
@@ -1250,19 +1350,24 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
do_imdct(s, s->channels);
if (downmix_output) {
+#if USE_FIXED
+ ac3_downmix_c_fixed16(s->outptr, s->downmix_coeffs,
+ s->out_channels, s->fbw_channels, 256);
+#else
s->ac3dsp.downmix(s->outptr, s->downmix_coeffs,
s->out_channels, s->fbw_channels, 256);
+#endif
}
} else {
if (downmix_output) {
- s->ac3dsp.downmix(s->xcfptr + 1, s->downmix_coeffs,
- s->out_channels, s->fbw_channels, 256);
+ s->ac3dsp.AC3_RENAME(downmix)(s->xcfptr + 1, s->downmix_coeffs,
+ s->out_channels, s->fbw_channels, 256);
}
if (downmix_output && !s->downmixed) {
s->downmixed = 1;
- s->ac3dsp.downmix(s->dlyptr, s->downmix_coeffs, s->out_channels,
- s->fbw_channels, 128);
+ s->ac3dsp.AC3_RENAME(downmix)(s->dlyptr, s->downmix_coeffs,
+ s->out_channels, s->fbw_channels, 128);
}
do_imdct(s, s->out_channels);
@@ -1283,7 +1388,9 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
AC3DecodeContext *s = avctx->priv_data;
int blk, ch, err, ret;
const uint8_t *channel_map;
- const float *output[AC3_MAX_CHANNELS];
+ const SHORTFLOAT *output[AC3_MAX_CHANNELS];
+ enum AVMatrixEncoding matrix_encoding;
+ AVDownmixInfo *downmix_info;
/* copy input buffer to decoder context to avoid reading past the end
of the buffer, which can be caused by a damaged input stream. */
@@ -1408,7 +1515,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
}
for (ch = 0; ch < s->channels; ch++) {
if (ch < s->out_channels)
- s->outptr[channel_map[ch]] = (float *)frame->data[ch];
+ s->outptr[channel_map[ch]] = (SHORTFLOAT *)frame->data[ch];
}
for (blk = 0; blk < s->num_blocks; blk++) {
if (!err && decode_audio_block(s, blk)) {
@@ -1417,7 +1524,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
}
if (err)
for (ch = 0; ch < s->out_channels; ch++)
- memcpy(((float*)frame->data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], sizeof(**output) * AC3_BLOCK_SIZE);
+ memcpy(((SHORTFLOAT*)frame->data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], AC3_BLOCK_SIZE*sizeof(SHORTFLOAT));
for (ch = 0; ch < s->out_channels; ch++)
output[ch] = s->outptr[channel_map[ch]];
for (ch = 0; ch < s->out_channels; ch++) {
@@ -1430,7 +1537,63 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
/* keep last block for error concealment in next frame */
for (ch = 0; ch < s->out_channels; ch++)
- memcpy(s->output[ch], output[ch], sizeof(**output) * AC3_BLOCK_SIZE);
+ memcpy(s->output[ch], output[ch], AC3_BLOCK_SIZE*sizeof(SHORTFLOAT));
+
+ /*
+ * AVMatrixEncoding
+ *
+ * Check whether the input layout is compatible, and make sure we're not
+ * downmixing (else the matrix encoding is no longer applicable).
+ */
+ matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ if (s->channel_mode == AC3_CHMODE_STEREO &&
+ s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) {
+ if (s->dolby_surround_mode == AC3_DSURMOD_ON)
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
+ else if (s->dolby_headphone_mode == AC3_DHEADPHONMOD_ON)
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBYHEADPHONE;
+ } else if (s->channel_mode >= AC3_CHMODE_2F2R &&
+ s->channel_mode == (s->output_mode & ~AC3_OUTPUT_LFEON)) {
+ switch (s->dolby_surround_ex_mode) {
+ case AC3_DSUREXMOD_ON: // EX or PLIIx
+ matrix_encoding = AV_MATRIX_ENCODING_DOLBYEX;
+ break;
+ case AC3_DSUREXMOD_PLIIZ:
+ matrix_encoding = AV_MATRIX_ENCODING_DPLIIZ;
+ break;
+ default: // not indicated or off
+ break;
+ }
+ }
+ if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0)
+ return ret;
+
+ /* AVDownmixInfo */
+ if ((downmix_info = av_downmix_info_update_side_data(frame))) {
+ switch (s->preferred_downmix) {
+ case AC3_DMIXMOD_LTRT:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
+ break;
+ case AC3_DMIXMOD_LORO:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LORO;
+ break;
+ case AC3_DMIXMOD_DPLII:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_DPLII;
+ break;
+ default:
+ downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_UNKNOWN;
+ break;
+ }
+ downmix_info->center_mix_level = gain_levels[s-> center_mix_level];
+ downmix_info->center_mix_level_ltrt = gain_levels[s-> center_mix_level_ltrt];
+ downmix_info->surround_mix_level = gain_levels[s-> surround_mix_level];
+ downmix_info->surround_mix_level_ltrt = gain_levels[s->surround_mix_level_ltrt];
+ if (s->lfe_mix_level_exists)
+ downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
+ else
+ downmix_info->lfe_mix_level = 0.0; // -inf dB
+ } else
+ return AVERROR(ENOMEM);
*got_frame_ptr = 1;
@@ -1445,66 +1608,12 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
AC3DecodeContext *s = avctx->priv_data;
ff_mdct_end(&s->imdct_512);
ff_mdct_end(&s->imdct_256);
+#if (USE_FIXED)
+ av_freep(&s->fdsp);
+#endif
return 0;
}
#define OFFSET(x) offsetof(AC3DecodeContext, x)
#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
-static const AVOption options[] = {
- { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 1.0, PAR },
-
-{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2, 0, "dmix_mode"},
-{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
-{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
-{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
-{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
-
- { NULL},
-};
-
-static const AVClass ac3_decoder_class = {
- .class_name = "AC3 decoder",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_ac3_decoder = {
- .name = "ac3",
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_AC3,
- .priv_data_size = sizeof (AC3DecodeContext),
- .init = ac3_decode_init,
- .close = ac3_decode_end,
- .decode = ac3_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
- .priv_class = &ac3_decoder_class,
-};
-
-#if CONFIG_EAC3_DECODER
-static const AVClass eac3_decoder_class = {
- .class_name = "E-AC3 decoder",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_eac3_decoder = {
- .name = "eac3",
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_EAC3,
- .priv_data_size = sizeof (AC3DecodeContext),
- .init = ac3_decode_init,
- .close = ac3_decode_end,
- .decode = ac3_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
- .priv_class = &eac3_decoder_class,
-};
-#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dec.h b/chromium/third_party/ffmpeg/libavcodec/ac3dec.h
index fa447c4d6f8..5196d90901f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3dec.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dec.h
@@ -51,6 +51,7 @@
#define AVCODEC_AC3DEC_H
#include "libavutil/float_dsp.h"
+#include "libavutil/fixed_dsp.h"
#include "libavutil/lfg.h"
#include "ac3.h"
#include "ac3dsp.h"
@@ -79,13 +80,22 @@ typedef struct AC3DecodeContext {
int bit_rate; ///< stream bit rate, in bits-per-second
int sample_rate; ///< sample frequency, in Hz
int num_blocks; ///< number of audio blocks
+ int bitstream_id; ///< bitstream id (bsid)
int bitstream_mode; ///< bitstream mode (bsmod)
int channel_mode; ///< channel mode (acmod)
int lfe_on; ///< lfe channel in use
int channel_map; ///< custom channel map
+ int preferred_downmix; ///< Preferred 2-channel downmix mode (dmixmod)
int center_mix_level; ///< Center mix level index
+ int center_mix_level_ltrt; ///< Center mix level index for Lt/Rt (ltrtcmixlev)
int surround_mix_level; ///< Surround mix level index
+ int surround_mix_level_ltrt; ///< Surround mix level index for Lt/Rt (ltrtsurmixlev)
+ int lfe_mix_level_exists; ///< indicates if lfemixlevcod is specified (lfemixlevcode)
+ int lfe_mix_level; ///< LFE mix level index (lfemixlevcod)
int eac3; ///< indicates if current frame is E-AC-3
+ int dolby_surround_mode; ///< dolby surround mode (dsurmod)
+ int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
+ int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
///@}
int preferred_stereo_downmix;
@@ -129,8 +139,8 @@ typedef struct AC3DecodeContext {
int num_spx_bands; ///< number of spx bands (nspxbnds)
uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
- float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
- float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
+ INTFLOAT spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
+ INTFLOAT spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
///@}
///@name Adaptive hybrid transform
@@ -142,15 +152,15 @@ typedef struct AC3DecodeContext {
int fbw_channels; ///< number of full-bandwidth channels
int channels; ///< number of total channels
int lfe_ch; ///< index of LFE channel
- float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients
+ SHORTFLOAT downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients
int downmixed; ///< indicates if coeffs are currently downmixed
int output_mode; ///< output channel configuration
int out_channels; ///< number of output channels
///@}
///@name Dynamic range
- float dynamic_range[2]; ///< dynamic range
- float drc_scale; ///< percentage of dynamic range compression to be applied
+ INTFLOAT dynamic_range[2]; ///< dynamic range
+ INTFLOAT drc_scale; ///< percentage of dynamic range compression to be applied
///@}
///@name Bandwidth
@@ -198,22 +208,26 @@ typedef struct AC3DecodeContext {
///@name Optimization
DSPContext dsp; ///< for optimization
+#if USE_FIXED
+ AVFixedDSPContext *fdsp;
+#else
AVFloatDSPContext fdsp;
+#endif
AC3DSPContext ac3dsp;
FmtConvertContext fmt_conv; ///< optimized conversion functions
///@}
- float *outptr[AC3_MAX_CHANNELS];
- float *xcfptr[AC3_MAX_CHANNELS];
- float *dlyptr[AC3_MAX_CHANNELS];
+ SHORTFLOAT *outptr[AC3_MAX_CHANNELS];
+ INTFLOAT *xcfptr[AC3_MAX_CHANNELS];
+ INTFLOAT *dlyptr[AC3_MAX_CHANNELS];
///@name Aligned arrays
- DECLARE_ALIGNED(16, int32_t, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
- DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
- DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
- DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients
- DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
- DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
+ DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
+ DECLARE_ALIGNED(32, INTFLOAT, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
+ DECLARE_ALIGNED(32, INTFLOAT, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
+ DECLARE_ALIGNED(32, INTFLOAT, window)[AC3_BLOCK_SIZE]; ///< window coefficients
+ DECLARE_ALIGNED(32, INTFLOAT, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
+ DECLARE_ALIGNED(32, SHORTFLOAT, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
///@}
} AC3DecodeContext;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dec_fixed.c b/chromium/third_party/ffmpeg/libavcodec/ac3dec_fixed.c
new file mode 100644
index 00000000000..c6cbeb9b285
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dec_fixed.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2012
+ * MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author: Stanislav Ocovaj (socovaj@mips.com)
+ *
+ * AC3 fixed-point decoder for MIPS platforms
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define FFT_FLOAT 0
+#define USE_FIXED 1
+#define FFT_FIXED_32 1
+#include "ac3dec.h"
+
+
+/**
+ * Table for center mix levels
+ * reference: Section 5.4.2.4 cmixlev
+ */
+static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
+
+/**
+ * Table for surround mix levels
+ * reference: Section 5.4.2.5 surmixlev
+ */
+static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
+
+int end_freq_inv_tab[8] =
+{
+ 50529027, 44278013, 39403370, 32292987, 27356480, 23729101, 20951060, 18755316
+};
+
+static void scale_coefs (
+ int32_t *dst,
+ const int32_t *src,
+ int dynrng,
+ int len)
+{
+ int i, shift, round;
+ int16_t mul;
+ int temp, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
+
+ mul = (dynrng & 0x1f) + 0x20;
+ shift = 4 - ((dynrng << 24) >> 29);
+ round = 1 << (shift-1);
+ for (i=0; i<len; i+=8) {
+
+ temp = src[i] * mul;
+ temp1 = src[i+1] * mul;
+ temp = temp + round;
+ temp2 = src[i+2] * mul;
+
+ temp1 = temp1 + round;
+ dst[i] = temp >> shift;
+ temp3 = src[i+3] * mul;
+ temp2 = temp2 + round;
+
+ dst[i+1] = temp1 >> shift;
+ temp4 = src[i + 4] * mul;
+ temp3 = temp3 + round;
+ dst[i+2] = temp2 >> shift;
+
+ temp5 = src[i+5] * mul;
+ temp4 = temp4 + round;
+ dst[i+3] = temp3 >> shift;
+ temp6 = src[i+6] * mul;
+
+ dst[i+4] = temp4 >> shift;
+ temp5 = temp5 + round;
+ temp7 = src[i+7] * mul;
+ temp6 = temp6 + round;
+
+ dst[i+5] = temp5 >> shift;
+ temp7 = temp7 + round;
+ dst[i+6] = temp6 >> shift;
+ dst[i+7] = temp7 >> shift;
+
+ }
+}
+
+/**
+ * Downmix samples from original signal to stereo or mono (this is for 16-bit samples
+ * and fixed point decoder - original (for 32-bit samples) is in ac3dsp.c).
+ */
+static void ac3_downmix_c_fixed16(int16_t **samples, int16_t (*matrix)[2],
+ int out_ch, int in_ch, int len)
+{
+ int i, j;
+ int v0, v1;
+ if (out_ch == 2) {
+ for (i = 0; i < len; i++) {
+ v0 = v1 = 0;
+ for (j = 0; j < in_ch; j++) {
+ v0 += samples[j][i] * matrix[j][0];
+ v1 += samples[j][i] * matrix[j][1];
+ }
+ samples[0][i] = (v0+2048)>>12;
+ samples[1][i] = (v1+2048)>>12;
+ }
+ } else if (out_ch == 1) {
+ for (i = 0; i < len; i++) {
+ v0 = 0;
+ for (j = 0; j < in_ch; j++)
+ v0 += samples[j][i] * matrix[j][0];
+ samples[0][i] = (v0+2048)>>12;
+ }
+ }
+}
+
+#include "ac3dec.c"
+
+static const AVOption options[] = {
+ { NULL},
+};
+
+static const AVClass ac3_decoder_class = {
+ .class_name = "Fixed-Point AC-3 Decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_ac3_fixed_decoder = {
+ .name = "ac3_fixed",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_AC3,
+ .priv_data_size = sizeof (AC3DecodeContext),
+ .init = ac3_decode_init,
+ .close = ac3_decode_end,
+ .decode = ac3_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
+ AV_SAMPLE_FMT_NONE },
+ .priv_class = &ac3_decoder_class,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dec_float.c b/chromium/third_party/ffmpeg/libavcodec/ac3dec_float.c
new file mode 100644
index 00000000000..7108921701b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dec_float.c
@@ -0,0 +1,89 @@
+/*
+ * AC-3 Audio Decoder
+ * This code was developed as part of Google Summer of Code 2006.
+ * E-AC-3 support was added as part of Google Summer of Code 2007.
+ *
+ * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com)
+ * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
+ * Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * Upmix delay samples from stereo to original channel layout.
+ */
+#include "ac3dec.h"
+#include "ac3dec.c"
+
+static const AVOption options[] = {
+ { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
+
+{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2, 0, "dmix_mode"},
+{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
+{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
+{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
+{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
+
+ { NULL},
+};
+
+static const AVClass ac3_decoder_class = {
+ .class_name = "AC3 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_ac3_decoder = {
+ .name = "ac3",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_AC3,
+ .priv_data_size = sizeof (AC3DecodeContext),
+ .init = ac3_decode_init,
+ .close = ac3_decode_end,
+ .decode = ac3_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_NONE },
+ .priv_class = &ac3_decoder_class,
+};
+
+#if CONFIG_EAC3_DECODER
+static const AVClass eac3_decoder_class = {
+ .class_name = "E-AC3 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_eac3_decoder = {
+ .name = "eac3",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_EAC3,
+ .priv_data_size = sizeof (AC3DecodeContext),
+ .init = ac3_decode_init,
+ .close = ac3_decode_end,
+ .decode = ac3_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_NONE },
+ .priv_class = &eac3_decoder_class,
+};
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dsp.c b/chromium/third_party/ffmpeg/libavcodec/ac3dsp.c
index feda6ddc6e8..b746817c9d9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dsp.c
@@ -1,5 +1,5 @@
/*
- * AC-3 DSP utils
+ * AC-3 DSP functions
* Copyright (c) 2011 Justin Ruggles
*
* This file is part of FFmpeg.
@@ -239,6 +239,31 @@ static void ac3_downmix_c(float **samples, float (*matrix)[2],
}
}
+static void ac3_downmix_c_fixed(int32_t **samples, int16_t (*matrix)[2],
+ int out_ch, int in_ch, int len)
+{
+ int i, j;
+ int64_t v0, v1;
+ if (out_ch == 2) {
+ for (i = 0; i < len; i++) {
+ v0 = v1 = 0;
+ for (j = 0; j < in_ch; j++) {
+ v0 += (int64_t)samples[j][i] * matrix[j][0];
+ v1 += (int64_t)samples[j][i] * matrix[j][1];
+ }
+ samples[0][i] = (v0+2048)>>12;
+ samples[1][i] = (v1+2048)>>12;
+ }
+ } else if (out_ch == 1) {
+ for (i = 0; i < len; i++) {
+ v0 = 0;
+ for (j = 0; j < in_ch; j++)
+ v0 += (int64_t)samples[j][i] * matrix[j][0];
+ samples[0][i] = (v0+2048)>>12;
+ }
+ }
+}
+
static void apply_window_int16_c(int16_t *output, const int16_t *input,
const int16_t *window, unsigned int len)
{
@@ -266,6 +291,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c;
c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c;
c->downmix = ac3_downmix_c;
+ c->downmix_fixed = ac3_downmix_c_fixed;
c->apply_window_int16 = apply_window_int16_c;
if (ARCH_ARM)
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3dsp.h b/chromium/third_party/ffmpeg/libavcodec/ac3dsp.h
index bced5974e1f..ed98c8ce6ae 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3dsp.h
@@ -1,5 +1,5 @@
/*
- * AC-3 DSP utils
+ * AC-3 DSP functions
* Copyright (c) 2011 Justin Ruggles
*
* This file is part of FFmpeg.
@@ -135,6 +135,9 @@ typedef struct AC3DSPContext {
void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
int in_ch, int len);
+ void (*downmix_fixed)(int32_t **samples, int16_t (*matrix)[2], int out_ch,
+ int in_ch, int len);
+
/**
* Apply symmetric window in 16-bit fixed-point.
* @param output destination array
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3enc.c b/chromium/third_party/ffmpeg/libavcodec/ac3enc.c
index 37c496cd15c..c13c50bbafb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3enc.c
@@ -1381,7 +1381,7 @@ static void ac3_output_frame_header(AC3EncodeContext *s)
*/
static void output_audio_block(AC3EncodeContext *s, int blk)
{
- int ch, i, baie, bnd, got_cpl, ch0;
+ int ch, i, baie, bnd, got_cpl, av_uninit(ch0);
AC3Block *block = &s->blocks[blk];
/* block switching */
@@ -2246,7 +2246,7 @@ static av_cold int validate_options(AC3EncodeContext *s)
*/
static av_cold void set_bandwidth(AC3EncodeContext *s)
{
- int blk, ch, cpl_start;
+ int blk, ch, av_uninit(cpl_start);
if (s->cutoff) {
/* calculate bandwidth based on user-specified cutoff frequency */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3enc.h b/chromium/third_party/ffmpeg/libavcodec/ac3enc.h
index a04e704d971..94312ba46fb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3enc.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3enc.h
@@ -31,12 +31,14 @@
#include <stdint.h>
#include "libavutil/float_dsp.h"
+
#include "ac3.h"
#include "ac3dsp.h"
#include "avcodec.h"
#include "dsputil.h"
-#include "put_bits.h"
#include "fft.h"
+#include "mathops.h"
+#include "put_bits.h"
#ifndef CONFIG_AC3ENC_FLOAT
#define CONFIG_AC3ENC_FLOAT 0
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3enc_fixed.c b/chromium/third_party/ffmpeg/libavcodec/ac3enc_fixed.c
index 5194d42aee7..3994c17d3bc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3enc_fixed.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3enc_fixed.c
@@ -26,7 +26,7 @@
* fixed-point AC-3 encoder.
*/
-#define CONFIG_FFT_FLOAT 0
+#define FFT_FLOAT 0
#undef CONFIG_AC3ENC_FLOAT
#include "internal.h"
#include "ac3enc.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3enc_float.c b/chromium/third_party/ffmpeg/libavcodec/ac3enc_float.c
index 35fb4189cd5..55ea422ddf4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3enc_float.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3enc_float.c
@@ -73,7 +73,7 @@ av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s)
n = 1 << 9;
n2 = n >> 1;
- window = av_malloc(n * sizeof(*window));
+ window = av_malloc_array(n, sizeof(*window));
if (!window) {
av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
return AVERROR(ENOMEM);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3enc_template.c b/chromium/third_party/ffmpeg/libavcodec/ac3enc_template.c
index 4689f7020bb..45275191750 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3enc_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3enc_template.c
@@ -28,7 +28,11 @@
#include <stdint.h>
+#include "libavutil/attributes.h"
#include "libavutil/internal.h"
+#include "internal.h"
+#include "ac3enc.h"
+#include "eac3enc.h"
/* prototypes for static functions in ac3enc_fixed.c and ac3enc_float.c */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3tab.c b/chromium/third_party/ffmpeg/libavcodec/ac3tab.c
index 1ae7ddf2a63..d62d8bfbf55 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3tab.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3tab.c
@@ -25,6 +25,8 @@
*/
#include "libavutil/channel_layout.h"
+#include "libavutil/mem.h"
+
#include "avcodec.h"
#include "ac3tab.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/ac3tab.h b/chromium/third_party/ffmpeg/libavcodec/ac3tab.h
index c41a93ecc46..74cbd9ed650 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ac3tab.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ac3tab.h
@@ -22,7 +22,9 @@
#ifndef AVCODEC_AC3TAB_H
#define AVCODEC_AC3TAB_H
-#include "libavutil/common.h"
+#include <stdint.h>
+
+#include "libavutil/internal.h"
#include "ac3.h"
#if CONFIG_HARDCODED_TABLES
diff --git a/chromium/third_party/ffmpeg/libavcodec/adpcm.c b/chromium/third_party/ffmpeg/libavcodec/adpcm.c
index 8e20de2a637..e31242f02c6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/adpcm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/adpcm.c
@@ -471,9 +471,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_
* @param[out] coded_samples set to the number of samples as coded in the
* packet, or 0 if the codec does not encode the
* number of samples in each frame.
+ * @param[out] approx_nb_samples set to non-zero if the number of samples
+ * returned is an approximation.
*/
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
- int buf_size, int *coded_samples)
+ int buf_size, int *coded_samples, int *approx_nb_samples)
{
ADPCMDecodeContext *s = avctx->priv_data;
int nb_samples = 0;
@@ -482,6 +484,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
int header_size;
*coded_samples = 0;
+ *approx_nb_samples = 0;
if(ch <= 0)
return 0;
@@ -561,6 +564,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - header_size) * 2 / ch;
nb_samples -= nb_samples % 28;
+ *approx_nb_samples = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align > 0)
@@ -663,11 +667,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
int16_t **samples_p;
int st; /* stereo */
int count1, count2;
- int nb_samples, coded_samples, ret;
+ int nb_samples, coded_samples, approx_nb_samples, ret;
GetByteContext gb;
bytestream2_init(&gb, buf, buf_size);
- nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples);
+ nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
if (nb_samples <= 0) {
av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
return AVERROR_INVALIDDATA;
@@ -683,7 +687,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
/* use coded_samples when applicable */
/* it is always <= nb_samples, so the output buffer will be large enough */
if (coded_samples) {
- if (coded_samples != nb_samples)
+ if (!approx_nb_samples && coded_samples != nb_samples)
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
frame->nb_samples = nb_samples = coded_samples;
}
@@ -917,6 +921,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
*samples++ = c->status[0].predictor + c->status[1].predictor;
*samples++ = c->status[0].predictor - c->status[1].predictor;
}
+
+ if ((bytestream2_tell(&gb) & 1))
+ bytestream2_skip(&gb, 1);
break;
}
case AV_CODEC_ID_ADPCM_IMA_ISS:
@@ -1310,7 +1317,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
byte & 0x0F, 4, 0);
}
} else if (avctx->codec->id == AV_CODEC_ID_ADPCM_SBPRO_3) {
- for (n = nb_samples / 3; n > 0; n--) {
+ for (n = (nb_samples<<st) / 3; n > 0; n--) {
int byte = bytestream2_get_byteu(&gb);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
byte >> 5 , 3, 0);
diff --git a/chromium/third_party/ffmpeg/libavcodec/adpcm_data.c b/chromium/third_party/ffmpeg/libavcodec/adpcm_data.c
index 1d3e579a893..21092855301 100644
--- a/chromium/third_party/ffmpeg/libavcodec/adpcm_data.c
+++ b/chromium/third_party/ffmpeg/libavcodec/adpcm_data.c
@@ -47,7 +47,7 @@ static const int8_t adpcm_index_table5[32] = {
-1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16,
};
-const int8_t const *ff_adpcm_index_tables[4] = {
+const int8_t * const ff_adpcm_index_tables[4] = {
&adpcm_index_table2[0],
&adpcm_index_table3[0],
&ff_adpcm_index_table[0],
diff --git a/chromium/third_party/ffmpeg/libavcodec/adpcm_data.h b/chromium/third_party/ffmpeg/libavcodec/adpcm_data.h
index a14d5208858..6589bc56c9b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/adpcm_data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/adpcm_data.h
@@ -31,7 +31,7 @@
static const uint8_t ff_adpcm_ima_block_sizes[4] = { 4, 12, 4, 20 };
static const uint8_t ff_adpcm_ima_block_samples[4] = { 16, 32, 8, 32 };
-extern const int8_t const *ff_adpcm_index_tables[4];
+extern const int8_t * const ff_adpcm_index_tables[4];
extern const int8_t ff_adpcm_index_table[16];
extern const int16_t ff_adpcm_step_table[89];
extern const int16_t ff_adpcm_oki_step_table[49];
diff --git a/chromium/third_party/ffmpeg/libavcodec/adx.c b/chromium/third_party/ffmpeg/libavcodec/adx.c
index 94bc386dab1..30e13c0c1c3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/adx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/adx.c
@@ -47,13 +47,8 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
return AVERROR_INVALIDDATA;
offset = AV_RB16(buf + 2) + 4;
- if (offset < 6) {
- av_log(avctx, AV_LOG_ERROR, "offset is prior data\n");
- return AVERROR_INVALIDDATA;
- }
-
/* if copyright string is within the provided data, validate it */
- if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
+ if (bufsize >= offset && offset >= 6 && memcmp(buf + offset - 6, "(c)CRI", 6))
return AVERROR_INVALIDDATA;
/* check for encoding=3 block_size=18, sample_size=4 */
diff --git a/chromium/third_party/ffmpeg/libavcodec/adxdec.c b/chromium/third_party/ffmpeg/libavcodec/adxdec.c
index e59cc929847..ec33e735417 100644
--- a/chromium/third_party/ffmpeg/libavcodec/adxdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/adxdec.c
@@ -157,9 +157,11 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
buf_size -= BLOCK_SIZE;
buf += BLOCK_SIZE;
}
- samples_offset += BLOCK_SAMPLES;
+ if (!c->eof)
+ samples_offset += BLOCK_SAMPLES;
}
+ frame->nb_samples = samples_offset;
*got_frame_ptr = 1;
return buf - avpkt->data;
diff --git a/chromium/third_party/ffmpeg/libavcodec/aic.c b/chromium/third_party/ffmpeg/libavcodec/aic.c
index a7e3691aa08..373cf99a26a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/aic.c
+++ b/chromium/third_party/ffmpeg/libavcodec/aic.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "bytestream.h"
#include "dsputil.h"
@@ -169,7 +171,7 @@ static int aic_decode_header(AICContext *ctx, const uint8_t *src, int size)
width = AV_RB16(src + 6);
height = AV_RB16(src + 8);
if (frame_size > size) {
- av_log(ctx->avctx, AV_LOG_ERROR, "Frame size should be %d got %d\n",
+ av_log(ctx->avctx, AV_LOG_ERROR, "Frame size should be %"PRIu32" got %d\n",
frame_size, size);
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/alac.c b/chromium/third_party/ffmpeg/libavcodec/alac.c
index 3f37f61883e..103d14eadab 100644
--- a/chromium/third_party/ffmpeg/libavcodec/alac.c
+++ b/chromium/third_party/ffmpeg/libavcodec/alac.c
@@ -45,6 +45,8 @@
* 32bit samplerate
*/
+#include <inttypes.h>
+
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "get_bits.h"
@@ -283,7 +285,7 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
else
output_samples = alac->max_samples_per_frame;
if (!output_samples || output_samples > alac->max_samples_per_frame) {
- av_log(avctx, AV_LOG_ERROR, "invalid samples per frame: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "invalid samples per frame: %"PRIu32"\n",
output_samples);
return AVERROR_INVALIDDATA;
}
@@ -294,7 +296,7 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
return ret;
} else if (output_samples != alac->nb_samples) {
- av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n",
+ av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %"PRIu32" != %d\n",
output_samples, alac->nb_samples);
return AVERROR_INVALIDDATA;
}
@@ -490,7 +492,10 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
avpkt->size * 8 - get_bits_count(&alac->gb));
}
- *got_frame_ptr = 1;
+ if (alac->channels == ch)
+ *got_frame_ptr = 1;
+ else
+ av_log(avctx, AV_LOG_WARNING, "Failed to decode all channels\n");
return avpkt->size;
}
@@ -546,7 +551,8 @@ static int alac_set_info(ALACContext *alac)
alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
if (!alac->max_samples_per_frame ||
alac->max_samples_per_frame > INT_MAX / sizeof(int32_t)) {
- av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
+ av_log(alac->avctx, AV_LOG_ERROR,
+ "max samples per frame invalid: %"PRIu32"\n",
alac->max_samples_per_frame);
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/aliaspixdec.c b/chromium/third_party/ffmpeg/libavcodec/aliaspixdec.c
new file mode 100644
index 00000000000..bdc4c72c218
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aliaspixdec.c
@@ -0,0 +1,128 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+ AVPacket *avpkt)
+{
+ AVFrame *f = data;
+ GetByteContext gb;
+ int width, height, ret, bits_pixel, pixel;
+ uint8_t *out_buf;
+ uint8_t count;
+ int x, y;
+
+ bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+ if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ width = bytestream2_get_be16u(&gb);
+ height = bytestream2_get_be16u(&gb);
+ bytestream2_skipu(&gb, 4); // obsolete X, Y offset
+ bits_pixel = bytestream2_get_be16u(&gb);
+
+ if (bits_pixel == 24)
+ avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ else if (bits_pixel == 8)
+ avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+ else {
+ av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ ret = ff_set_dimensions(avctx, width, height);
+ if (ret < 0)
+ return ret;
+
+ ret = ff_get_buffer(avctx, f, 0);
+ if (ret < 0)
+ return ret;
+
+ f->pict_type = AV_PICTURE_TYPE_I;
+ f->key_frame = 1;
+
+ x = 0;
+ y = 1;
+ out_buf = f->data[0];
+ while (bytestream2_get_bytes_left(&gb) > 0) {
+ int i;
+
+ /* set buffer at the right position at every new line */
+ if (x == avctx->width) {
+ x = 0;
+ out_buf = f->data[0] + f->linesize[0] * y++;
+ if (y > avctx->height) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Ended frame decoding with %d bytes left.\n",
+ bytestream2_get_bytes_left(&gb));
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ /* read packet and copy data */
+ count = bytestream2_get_byteu(&gb);
+ if (!count || x + count > avctx->width) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid run length %d.\n", count);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
+ pixel = bytestream2_get_be24(&gb);
+ for (i = 0; i < count; i++) {
+ AV_WB24(out_buf, pixel);
+ out_buf += 3;
+ }
+ } else { // AV_PIX_FMT_GRAY8
+ pixel = bytestream2_get_byte(&gb);
+ for (i = 0; i < count; i++)
+ *out_buf++ = pixel;
+ }
+
+ x += i;
+ }
+
+ if (x != width || y != height) {
+ av_log(avctx, AV_LOG_ERROR, "Picture stopped at %d,%d.\n", x, y);
+ return AVERROR_INVALIDDATA;
+ }
+
+ *got_frame = 1;
+ return avpkt->size;
+}
+
+AVCodec ff_alias_pix_decoder = {
+ .name = "alias_pix",
+ .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_ALIAS_PIX,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/aliaspixenc.c b/chromium/third_party/ffmpeg/libavcodec/aliaspixenc.c
new file mode 100644
index 00000000000..1fcea084159
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/aliaspixenc.c
@@ -0,0 +1,134 @@
+/*
+ * Alias PIX image encoder
+ * Copyright (C) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static av_cold int encode_init(AVCodecContext *avctx)
+{
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
+ return 0;
+}
+
+static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
+{
+ int width, height, bits_pixel, i, j, length, ret;
+ uint8_t *in_buf, *buf;
+
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ avctx->coded_frame->key_frame = 1;
+
+ width = avctx->width;
+ height = avctx->height;
+
+ if (width > 65535 || height > 65535 ||
+ width * height >= INT_MAX / 4 - ALIAS_HEADER_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", width, height);
+ return AVERROR_INVALIDDATA;
+ }
+
+ switch (avctx->pix_fmt) {
+ case AV_PIX_FMT_GRAY8:
+ bits_pixel = 8;
+ break;
+ case AV_PIX_FMT_BGR24:
+ bits_pixel = 24;
+ break;
+ default:
+ return AVERROR(EINVAL);
+ }
+
+ length = ALIAS_HEADER_SIZE + 4 * width * height; // max possible
+ if ((ret = ff_alloc_packet(pkt, length)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", length);
+ return ret;
+ }
+
+ buf = pkt->data;
+
+ /* Encode header. */
+ bytestream_put_be16(&buf, width);
+ bytestream_put_be16(&buf, height);
+ bytestream_put_be32(&buf, 0); /* X, Y offset */
+ bytestream_put_be16(&buf, bits_pixel);
+
+ for (j = 0; j < height; j++) {
+ in_buf = frame->data[0] + frame->linesize[0] * j;
+ for (i = 0; i < width; ) {
+ int count = 0;
+ int pixel;
+
+ if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
+ pixel = *in_buf;
+ while (count < 255 && count + i < width && pixel == *in_buf) {
+ count++;
+ in_buf++;
+ }
+ bytestream_put_byte(&buf, count);
+ bytestream_put_byte(&buf, pixel);
+ } else { /* AV_PIX_FMT_BGR24 */
+ pixel = AV_RB24(in_buf);
+ while (count < 255 && count + i < width &&
+ pixel == AV_RB24(in_buf)) {
+ count++;
+ in_buf += 3;
+ }
+ bytestream_put_byte(&buf, count);
+ bytestream_put_be24(&buf, pixel);
+ }
+ i += count;
+ }
+ }
+
+ /* Total length */
+ av_shrink_packet(pkt, buf - pkt->data);
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
+}
+
+static av_cold int encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
+ return 0;
+}
+
+AVCodec ff_alias_pix_encoder = {
+ .name = "alias_pix",
+ .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_ALIAS_PIX,
+ .init = encode_init,
+ .encode2 = encode_frame,
+ .close = encode_close,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
+ },
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/allcodecs.c b/chromium/third_party/ffmpeg/libavcodec/allcodecs.c
index 6d084acb649..ac0f424d6a1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/allcodecs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/allcodecs.c
@@ -79,8 +79,11 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL(H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL(H264_VDA, h264_vda);
+ REGISTER_HWACCEL(H264_VDA_OLD, h264_vda_old);
REGISTER_HWACCEL(H264_VDPAU, h264_vdpau);
+ REGISTER_HWACCEL(MPEG1_XVMC, mpeg1_xvmc);
REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
+ REGISTER_HWACCEL(MPEG2_XVMC, mpeg2_xvmc);
REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2);
REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau);
@@ -98,6 +101,7 @@ void avcodec_register_all(void)
REGISTER_ENCODER(A64MULTI5, a64multi5);
REGISTER_DECODER(AASC, aasc);
REGISTER_DECODER(AIC, aic);
+ REGISTER_ENCDEC (ALIAS_PIX, alias_pix);
REGISTER_ENCDEC (AMV, amv);
REGISTER_DECODER(ANM, anm);
REGISTER_DECODER(ANSI, ansi);
@@ -120,7 +124,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(CAVS, cavs);
REGISTER_DECODER(CDGRAPHICS, cdgraphics);
REGISTER_DECODER(CDXL, cdxl);
- REGISTER_DECODER(CINEPAK, cinepak);
+ REGISTER_ENCDEC (CINEPAK, cinepak);
REGISTER_ENCDEC (CLJR, cljr);
REGISTER_DECODER(CLLC, cllc);
REGISTER_ENCDEC (COMFORTNOISE, comfortnoise);
@@ -148,6 +152,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(EXR, exr);
REGISTER_ENCDEC (FFV1, ffv1);
REGISTER_ENCDEC (FFVHUFF, ffvhuff);
+ REGISTER_DECODER(FIC, fic);
REGISTER_ENCDEC (FLASHSV, flashsv);
REGISTER_ENCDEC (FLASHSV2, flashsv2);
REGISTER_DECODER(FLIC, flic);
@@ -289,6 +294,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(VP6, vp6);
REGISTER_DECODER(VP6A, vp6a);
REGISTER_DECODER(VP6F, vp6f);
+ REGISTER_DECODER(VP7, vp7);
REGISTER_DECODER(VP8, vp8);
REGISTER_DECODER(VP9, vp9);
REGISTER_DECODER(VQA, vqa);
@@ -318,7 +324,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (AAC, aac);
REGISTER_DECODER(AAC_LATM, aac_latm);
REGISTER_ENCDEC (AC3, ac3);
- REGISTER_ENCODER(AC3_FIXED, ac3_fixed);
+ REGISTER_ENCDEC (AC3_FIXED, ac3_fixed);
REGISTER_ENCDEC (ALAC, alac);
REGISTER_DECODER(ALS, als);
REGISTER_DECODER(AMRNB, amrnb);
@@ -326,11 +332,16 @@ void avcodec_register_all(void)
REGISTER_DECODER(APE, ape);
REGISTER_DECODER(ATRAC1, atrac1);
REGISTER_DECODER(ATRAC3, atrac3);
+ REGISTER_DECODER(ATRAC3P, atrac3p);
REGISTER_DECODER(BINKAUDIO_DCT, binkaudio_dct);
REGISTER_DECODER(BINKAUDIO_RDFT, binkaudio_rdft);
REGISTER_DECODER(BMV_AUDIO, bmv_audio);
REGISTER_DECODER(COOK, cook);
REGISTER_ENCDEC (DCA, dca);
+ REGISTER_DECODER(DSD_LSBF, dsd_lsbf);
+ REGISTER_DECODER(DSD_MSBF, dsd_msbf);
+ REGISTER_DECODER(DSD_LSBF_PLANAR, dsd_lsbf_planar);
+ REGISTER_DECODER(DSD_MSBF_PLANAR, dsd_msbf_planar);
REGISTER_DECODER(DSICINAUDIO, dsicinaudio);
REGISTER_ENCDEC (EAC3, eac3);
REGISTER_DECODER(EVRC, evrc);
@@ -360,6 +371,8 @@ void avcodec_register_all(void)
REGISTER_DECODER(MPC7, mpc7);
REGISTER_DECODER(MPC8, mpc8);
REGISTER_ENCDEC (NELLYMOSER, nellymoser);
+ REGISTER_DECODER(ON2AVC, on2avc);
+ REGISTER_DECODER(OPUS, opus);
REGISTER_DECODER(PAF_AUDIO, paf_audio);
REGISTER_DECODER(QCELP, qcelp);
REGISTER_DECODER(QDM2, qdm2);
@@ -458,6 +471,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(ADPCM_SBPRO_4, adpcm_sbpro_4);
REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf);
REGISTER_DECODER(ADPCM_THP, adpcm_thp);
+ REGISTER_DECODER(ADPCM_VIMA, adpcm_vima);
REGISTER_DECODER(ADPCM_XA, adpcm_xa);
REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha);
REGISTER_DECODER(VIMA, vima);
@@ -509,8 +523,10 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
REGISTER_ENCDEC (LIBVPX_VP9, libvpx_vp9);
REGISTER_ENCODER(LIBWAVPACK, libwavpack);
+ REGISTER_ENCODER(LIBWEBP, libwebp);
REGISTER_ENCODER(LIBX264, libx264);
REGISTER_ENCODER(LIBX264RGB, libx264rgb);
+ REGISTER_ENCODER(LIBX265, libx265);
REGISTER_ENCODER(LIBXAVS, libxavs);
REGISTER_ENCODER(LIBXVID, libxvid);
REGISTER_DECODER(LIBZVBI_TELETEXT, libzvbi_teletext);
@@ -547,6 +563,7 @@ void avcodec_register_all(void)
REGISTER_PARSER(MPEG4VIDEO, mpeg4video);
REGISTER_PARSER(MPEGAUDIO, mpegaudio);
REGISTER_PARSER(MPEGVIDEO, mpegvideo);
+ REGISTER_PARSER(OPUS, opus);
REGISTER_PARSER(PNG, png);
REGISTER_PARSER(PNM, pnm);
REGISTER_PARSER(RV30, rv30);
diff --git a/chromium/third_party/ffmpeg/libavcodec/alsdec.c b/chromium/third_party/ffmpeg/libavcodec/alsdec.c
index 825949f6a73..ace69746cf2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/alsdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/alsdec.c
@@ -25,6 +25,8 @@
* @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "get_bits.h"
#include "unary.h"
@@ -688,7 +690,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
} else {
*bd->opt_order = sconf->max_order;
}
-
+ if (*bd->opt_order > bd->block_length) {
+ *bd->opt_order = bd->block_length;
+ av_log(avctx, AV_LOG_ERROR, "Predictor order too large.\n");
+ return AVERROR_INVALIDDATA;
+ }
opt_order = *bd->opt_order;
if (opt_order) {
@@ -718,7 +724,9 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
int offset = parcor_rice_table[sconf->coef_table][k][0];
quant_cof[k] = decode_rice(gb, rice_param) + offset;
if (quant_cof[k] < -64 || quant_cof[k] > 63) {
- av_log(avctx, AV_LOG_ERROR, "quant_cof %d is out of range.\n", quant_cof[k]);
+ av_log(avctx, AV_LOG_ERROR,
+ "quant_cof %"PRIu32" is out of range.\n",
+ quant_cof[k]);
return AVERROR_INVALIDDATA;
}
}
@@ -1263,14 +1271,16 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
bd->quant_cof = ctx->quant_cof[c];
bd->raw_samples = ctx->raw_samples[c] + offset;
- dep = 0;
- while (!ch[dep].stop_flag) {
+ for (dep = 0; !ch[dep].stop_flag; dep++) {
unsigned int smp;
unsigned int begin = 1;
unsigned int end = bd->block_length - 1;
int64_t y;
int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
+ if (ch[dep].master_channel == c)
+ continue;
+
if (ch[dep].time_diff_flag) {
int t = ch[dep].time_diff_index;
@@ -1302,8 +1312,6 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
bd->raw_samples[smp] += y >> 7;
}
}
-
- dep++;
}
return 0;
@@ -1391,6 +1399,12 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
for (b = 0; b < ctx->num_blocks; b++) {
bd.block_length = div_blocks[b];
+ if (bd.block_length <= 0) {
+ av_log(ctx->avctx, AV_LOG_WARNING,
+ "Invalid block length %u in channel data!\n",
+ bd.block_length);
+ continue;
+ }
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ansi.c b/chromium/third_party/ffmpeg/libavcodec/ansi.c
index 143b0aa12b1..45c307f3170 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ansi.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ansi.c
@@ -420,7 +420,7 @@ static int decode_frame(AVCodecContext *avctx,
switch(buf[0]) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- if (s->nb_args < MAX_NB_ARGS)
+ if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
break;
case ';':
diff --git a/chromium/third_party/ffmpeg/libavcodec/apedec.c b/chromium/third_party/ffmpeg/libavcodec/apedec.c
index 6ec502b796a..1fd41cdd9d4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/apedec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/apedec.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
@@ -527,7 +529,7 @@ static inline int ape_decode_value_3900(APEContext *ctx, APERice *rice)
return AVERROR_INVALIDDATA;
}
x = range_decode_bits(ctx, tmpk);
- } else if (tmpk <= 32) {
+ } else if (tmpk <= 31) {
x = range_decode_bits(ctx, 16);
x |= (range_decode_bits(ctx, tmpk - 16) << 16);
} else {
@@ -603,10 +605,14 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
rice->ksum += out[i];
}
rice->k = av_log2(rice->ksum / 10) + 1;
+ if (rice->k >= 24)
+ return;
for (; i < 64; i++) {
out[i] = get_rice_ook(&ctx->gb, rice->k);
rice->ksum += out[i];
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
+ if (rice->k >= 24)
+ return;
}
ksummax = 1 << rice->k + 7;
ksummin = rice->k ? (1 << rice->k + 6) : 0;
@@ -1434,7 +1440,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
}
if (s->fileversion < 3950) // previous versions overread two bytes
buf_size += 2;
- av_fast_malloc(&s->data, &s->data_size, buf_size);
+ av_fast_padded_malloc(&s->data, &s->data_size, buf_size);
if (!s->data)
return AVERROR(ENOMEM);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
@@ -1465,7 +1471,8 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
}
if (!nblocks || nblocks > INT_MAX) {
- av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
+ av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %"PRIu32".\n",
+ nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/Makefile b/chromium/third_party/ffmpeg/libavcodec/arm/Makefile
index 201f897a610..1b21906fa6a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/Makefile
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/Makefile
@@ -2,19 +2,14 @@ ARCH_HEADERS = mathops.h
OBJS += arm/fmtconvert_init_arm.o
-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_init_arm.o \
- arm/sbrdsp_init_arm.o
OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \
arm/ac3dsp_arm.o
-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o
OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_arm.o \
arm/dsputil_arm.o \
arm/jrevdct_arm.o \
arm/simple_idct_arm.o
OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o \
arm/fft_fixed_init_arm.o
-OBJS-$(CONFIG_FLAC_DECODER) += arm/flacdsp_init_arm.o \
- arm/flacdsp_arm.o
OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o
OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o
OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o
@@ -23,14 +18,25 @@ OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_arm.o \
arm/hpeldsp_arm.o
OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o
OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o
-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o
+OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o
+OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o
OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_init_arm.o
+
+OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_init_arm.o \
+ arm/sbrdsp_init_arm.o
+OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o
+OBJS-$(CONFIG_FLAC_DECODER) += arm/flacdsp_init_arm.o \
+ arm/flacdsp_arm.o
+OBJS-$(CONFIG_FLAC_ENCODER) += arm/flacdsp_init_arm.o
+OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o
+OBJS-$(CONFIG_VC1_DECODER) += arm/vc1dsp_init_arm.o
+OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o
OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_init_arm.o
+OBJS-$(CONFIG_VP7_DECODER) += arm/vp8dsp_init_arm.o
OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_arm.o
OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_init_arm.o
OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_init_arm.o \
arm/rv40dsp_init_arm.o
-OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o \
ARMV5TE-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv5te.o \
arm/simple_idct_armv5te.o
@@ -39,34 +45,39 @@ ARMV5TE-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_armv5te.o \
ARMV5TE-OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_armv5te.o \
arm/videodsp_armv5te.o
-ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv6.o \
- arm/dsputil_armv6.o \
- arm/simple_idct_armv6.o \
+ARMV5TE-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv5te.o
ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o
-ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o
+ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv6.o \
+ arm/dsputil_armv6.o \
+ arm/simple_idct_armv6.o
+ARMV6-OBJS-$(CONFIG_H264DSP) += arm/startcode_armv6.o
ARMV6-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_armv6.o \
arm/hpeldsp_armv6.o
ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o
+
+ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o
+ARMV6-OBJS-$(CONFIG_VC1_DECODER) += arm/startcode_armv6.o
+ARMV6-OBJS-$(CONFIG_VC1_PARSER) += arm/startcode_armv6.o
+ARMV6-OBJS-$(CONFIG_VP7_DECODER) += arm/vp8_armv6.o \
+ arm/vp8dsp_init_armv6.o \
+ arm/vp8dsp_armv6.o
ARMV6-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8_armv6.o \
arm/vp8dsp_init_armv6.o \
arm/vp8dsp_armv6.o
VFP-OBJS += arm/fmtconvert_vfp.o
-VFP-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_vfp.o \
- arm/synth_filter_vfp.o
VFP-OBJS-$(CONFIG_FFT) += arm/fft_vfp.o
VFP-OBJS-$(CONFIG_MDCT) += arm/mdct_vfp.o
VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp_armv6.o
+VFP-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_vfp.o \
+ arm/synth_filter_vfp.o
+
NEON-OBJS += arm/fmtconvert_neon.o
NEON-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_neon.o
-NEON-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_neon.o \
- arm/sbrdsp_neon.o
-NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \
- arm/synth_filter_neon.o
NEON-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_neon.o \
arm/dsputil_neon.o \
arm/int_neon.o \
@@ -85,11 +96,20 @@ NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \
arm/mdct_fixed_neon.o
NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o
NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o
+NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o
+
+NEON-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_neon.o \
+ arm/sbrdsp_neon.o
+NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \
+ arm/synth_filter_neon.o
NEON-OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_neon.o
NEON-OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_neon.o \
arm/rv40dsp_neon.o
+NEON-OBJS-$(CONFIG_VC1_DECODER) += arm/vc1dsp_init_neon.o \
+ arm/vc1dsp_neon.o
NEON-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_neon.o
-NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o
NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_neon.o
+NEON-OBJS-$(CONFIG_VP7_DECODER) += arm/vp8dsp_init_neon.o \
+ arm/vp8dsp_neon.o
NEON-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_neon.o \
arm/vp8dsp_neon.o
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/asm-offsets.h b/chromium/third_party/ffmpeg/libavcodec/arm/asm-offsets.h
index 5cfc5cb10c2..a2174b0a089 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/asm-offsets.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/asm-offsets.h
@@ -21,19 +21,12 @@
#ifndef AVCODEC_ARM_ASM_OFFSETS_H
#define AVCODEC_ARM_ASM_OFFSETS_H
-#ifndef __ASSEMBLER__
-#include <stddef.h>
-#define CHK_OFFS(s, m, o) struct check_##o { \
- int x_##o[offsetof(s, m) == o? 1: -1]; \
- }
-#endif
-
/* MpegEncContext */
-#define Y_DC_SCALE 0xa8
-#define C_DC_SCALE 0xac
-#define AC_PRED 0xb0
-#define BLOCK_LAST_INDEX 0xb4
-#define H263_AIC 0xe4
-#define INTER_SCANTAB_RASTER_END 0x12c
+#define Y_DC_SCALE 0x04
+#define C_DC_SCALE 0x08
+#define AC_PRED 0x0c
+#define BLOCK_LAST_INDEX 0x10
+#define H263_AIC 0x40
+#define INTER_SCANTAB_RASTER_END 0x88
#endif /* AVCODEC_ARM_ASM_OFFSETS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/cabac.h b/chromium/third_party/ffmpeg/libavcodec/arm/cabac.h
new file mode 100644
index 00000000000..fdbf86b45e7
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/cabac.h
@@ -0,0 +1,108 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_ARM_CABAC_H
+#define AVCODEC_ARM_CABAC_H
+
+#include "config.h"
+#if HAVE_ARMV6T2_INLINE
+
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "libavcodec/cabac.h"
+
+#define get_cabac_inline get_cabac_inline_arm
+static av_always_inline int get_cabac_inline_arm(CABACContext *c,
+ uint8_t *const state)
+{
+ int bit;
+ void *reg_b, *reg_c, *tmp;
+
+ __asm__ volatile(
+ "ldrb %[bit] , [%[state]] \n\t"
+ "add %[r_b] , %[tables] , %[lps_off] \n\t"
+ "mov %[tmp] , %[range] \n\t"
+ "and %[range] , %[range] , #0xC0 \n\t"
+ "add %[r_b] , %[r_b] , %[bit] \n\t"
+ "ldrb %[range] , [%[r_b], %[range], lsl #1] \n\t"
+ "add %[r_b] , %[tables] , %[norm_off] \n\t"
+ "sub %[r_c] , %[tmp] , %[range] \n\t"
+ "lsl %[tmp] , %[r_c] , #17 \n\t"
+ "cmp %[tmp] , %[low] \n\t"
+ "it gt \n\t"
+ "movgt %[range] , %[r_c] \n\t"
+ "itt cc \n\t"
+ "mvncc %[bit] , %[bit] \n\t"
+ "subcc %[low] , %[low] , %[tmp] \n\t"
+ "add %[r_c] , %[tables] , %[mlps_off] \n\t"
+ "ldrb %[tmp] , [%[r_b], %[range]] \n\t"
+ "ldrb %[r_b] , [%[r_c], %[bit]] \n\t"
+ "lsl %[low] , %[low] , %[tmp] \n\t"
+ "lsl %[range] , %[range] , %[tmp] \n\t"
+ "uxth %[r_c] , %[low] \n\t"
+ "strb %[r_b] , [%[state]] \n\t"
+ "tst %[r_c] , %[r_c] \n\t"
+ "bne 2f \n\t"
+ "ldr %[r_c] , [%[c], %[byte]] \n\t"
+#if UNCHECKED_BITSTREAM_READER
+ "ldrh %[tmp] , [%[r_c]] \n\t"
+ "add %[r_c] , %[r_c] , #2 \n\t"
+ "str %[r_c] , [%[c], %[byte]] \n\t"
+#else
+ "ldr %[r_b] , [%[c], %[end]] \n\t"
+ "ldrh %[tmp] , [%[r_c]] \n\t"
+ "cmp %[r_c] , %[r_b] \n\t"
+ "itt lt \n\t"
+ "addlt %[r_c] , %[r_c] , #2 \n\t"
+ "strlt %[r_c] , [%[c], %[byte]] \n\t"
+#endif
+ "sub %[r_c] , %[low] , #1 \n\t"
+ "add %[r_b] , %[tables] , %[norm_off] \n\t"
+ "eor %[r_c] , %[low] , %[r_c] \n\t"
+ "rev %[tmp] , %[tmp] \n\t"
+ "lsr %[r_c] , %[r_c] , #15 \n\t"
+ "lsr %[tmp] , %[tmp] , #15 \n\t"
+ "ldrb %[r_c] , [%[r_b], %[r_c]] \n\t"
+ "movw %[r_b] , #0xFFFF \n\t"
+ "sub %[tmp] , %[tmp] , %[r_b] \n\t"
+ "rsb %[r_c] , %[r_c] , #7 \n\t"
+ "lsl %[tmp] , %[tmp] , %[r_c] \n\t"
+ "add %[low] , %[low] , %[tmp] \n\t"
+ "2: \n\t"
+ : [bit]"=&r"(bit),
+ [low]"+&r"(c->low),
+ [range]"+&r"(c->range),
+ [r_b]"=&r"(reg_b),
+ [r_c]"=&r"(reg_c),
+ [tmp]"=&r"(tmp)
+ : [c]"r"(c),
+ [state]"r"(state),
+ [tables]"r"(ff_h264_cabac_tables),
+ [byte]"M"(offsetof(CABACContext, bytestream)),
+ [end]"M"(offsetof(CABACContext, bytestream_end)),
+ [norm_off]"I"(H264_NORM_SHIFT_OFFSET),
+ [lps_off]"I"(H264_LPS_RANGE_OFFSET),
+ [mlps_off]"I"(H264_MLPS_STATE_OFFSET + 128)
+ : "memory", "cc"
+ );
+
+ return bit & 1;
+}
+#endif /* HAVE_ARMV6T2_INLINE */
+
+#endif /* AVCODEC_ARM_CABAC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dca.h b/chromium/third_party/ffmpeg/libavcodec/arm/dca.h
index 35971a8c3f6..6e87111a328 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dca.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dca.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "config.h"
+#include "libavcodec/dcadsp.h"
#include "libavcodec/mathops.h"
#if HAVE_ARMV6_INLINE && AV_GCC_VERSION_AT_LEAST(4,4) && !CONFIG_THUMB
@@ -78,26 +79,4 @@ static inline int decode_blockcodes(int code1, int code2, int levels,
#endif
-#if HAVE_NEON_INLINE && HAVE_ASM_MOD_Y
-
-#define int8x8_fmul_int32 int8x8_fmul_int32
-static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
-{
- __asm__ ("vcvt.f32.s32 %2, %2, #4 \n"
- "vld1.8 {d0}, [%1,:64] \n"
- "vmovl.s8 q0, d0 \n"
- "vmovl.s16 q1, d1 \n"
- "vmovl.s16 q0, d0 \n"
- "vcvt.f32.s32 q0, q0 \n"
- "vcvt.f32.s32 q1, q1 \n"
- "vmul.f32 q0, q0, %y2 \n"
- "vmul.f32 q1, q1, %y2 \n"
- "vst1.32 {q0-q1}, [%m0,:128] \n"
- : "=Um"(*(float (*)[8])dst)
- : "r"(src), "x"(scale)
- : "d0", "d1", "d2", "d3");
-}
-
-#endif
-
#endif /* AVCODEC_ARM_DCA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
index 8893f48368f..a54951584fd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
@@ -24,16 +24,18 @@
#include "libavutil/attributes.h"
#include "libavcodec/dcadsp.h"
-void ff_dca_lfe_fir_vfp(float *out, const float *in, const float *coefs,
- int decifactor, float scale);
+void ff_dca_lfe_fir0_neon(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir1_neon(float *out, const float *in, const float *coefs);
+
+void ff_dca_lfe_fir32_vfp(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir64_vfp(float *out, const float *in, const float *coefs);
+
void ff_dca_qmf_32_subbands_vfp(float samples_in[32][8], int sb_act,
SynthFilterContext *synth, FFTContext *imdct,
float synth_buf_ptr[512],
int *synth_buf_offset, float synth_buf2[32],
const float window[512], float *samples_out,
float raXin[32], float scale);
-void ff_dca_lfe_fir_neon(float *out, const float *in, const float *coefs,
- int decifactor, float scale);
void ff_synth_filter_float_vfp(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
@@ -47,16 +49,26 @@ void ff_synth_filter_float_neon(FFTContext *imdct,
float out[32], const float in[32],
float scale);
+void ff_decode_hf_neon(float dst[DCA_SUBBANDS][8],
+ const int32_t vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int32_t scale[DCA_SUBBANDS][2],
+ intptr_t start, intptr_t end);
+
av_cold void ff_dcadsp_init_arm(DCADSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
if (have_vfp(cpu_flags) && !have_vfpv3(cpu_flags)) {
- s->lfe_fir = ff_dca_lfe_fir_vfp;
+ s->lfe_fir[0] = ff_dca_lfe_fir32_vfp;
+ s->lfe_fir[1] = ff_dca_lfe_fir64_vfp;
s->qmf_32_subbands = ff_dca_qmf_32_subbands_vfp;
}
- if (have_neon(cpu_flags))
- s->lfe_fir = ff_dca_lfe_fir_neon;
+ if (have_neon(cpu_flags)) {
+ s->lfe_fir[0] = ff_dca_lfe_fir0_neon;
+ s->lfe_fir[1] = ff_dca_lfe_fir1_neon;
+ s->decode_hf = ff_decode_hf_neon;
+ }
}
av_cold void ff_synth_filter_init_arm(SynthFilterContext *s)
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_neon.S
index 6a6c77aca81..cdc41367e94 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_neon.S
@@ -20,17 +20,50 @@
#include "libavutil/arm/asm.S"
-function ff_dca_lfe_fir_neon, export=1
+function ff_decode_hf_neon, export=1
+ push {r4-r5,lr}
+ add r2, r2, r3
+ ldr r3, [sp, #12]
+ ldrd r4, r5, [sp, #16]
+ add r3, r3, r4, lsl #3
+ add r1, r1, r4, lsl #2
+ add r0, r0, r4, lsl #5
+
+1: ldr_post lr, r1, #4
+ add r4, r4, #1
+ add lr, r2, lr, lsl #5
+ cmp r4, r5
+ vld1.32 {d7}, [r3]!
+ vld1.8 {d0}, [lr,:64]
+ vcvt.f32.s32 d7, d7, #4
+ vmovl.s8 q1, d0
+ vmovl.s16 q0, d2
+ vmovl.s16 q1, d3
+ vcvt.f32.s32 q0, q0
+ vcvt.f32.s32 q1, q1
+ vmul.f32 q0, q0, d7[0]
+ vmul.f32 q1, q1, d7[0]
+ vst1.32 {q0-q1}, [r0,:128]!
+ bne 1b
+
+ pop {r4-r5,pc}
+endfunc
+
+function ff_dca_lfe_fir0_neon, export=1
push {r4-r6,lr}
+ mov r3, #32 @ decifactor
+ mov r6, #256/32
+ b dca_lfe_fir
+endfunc
+function ff_dca_lfe_fir1_neon, export=1
+ push {r4-r6,lr}
+ mov r3, #64 @ decifactor
+ mov r6, #256/64
+dca_lfe_fir:
add r4, r0, r3, lsl #2 @ out2
add r5, r2, #256*4-16 @ cf1
sub r1, r1, #12
- cmp r3, #32
- ite eq
- moveq r6, #256/32
- movne r6, #256/64
-NOVFP vldr s0, [sp, #16] @ scale
mov lr, #-16
1:
vmov.f32 q2, #0.0 @ v0
@@ -51,8 +84,7 @@ NOVFP vldr s0, [sp, #16] @ scale
subs r3, r3, #1
vadd.f32 d4, d4, d5
vadd.f32 d6, d6, d7
- vpadd.f32 d4, d4, d6
- vmul.f32 d5, d4, d0[0]
+ vpadd.f32 d5, d4, d6
vst1.32 {d5[0]}, [r0,:32]!
vst1.32 {d5[1]}, [r4,:32]!
bne 1b
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_vfp.S b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_vfp.S
index b23ce4ac8a5..2e09f0ee5d4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_vfp.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dcadsp_vfp.S
@@ -24,12 +24,9 @@
POUT .req a1
PIN .req a2
PCOEF .req a3
-DECIFACTOR .req a4
OLDFPSCR .req a4
COUNTER .req ip
-SCALE32 .req s28 @ use vector of 4 in place of 9th scalar when decifactor=32 / JMAX=8
-SCALE64 .req s0 @ spare register in scalar bank when decifactor=64 / JMAX=4
IN0 .req s4
IN1 .req s5
IN2 .req s6
@@ -77,9 +74,6 @@ POST3 .req s27
vldr COEF5, [PCOEF, #X + (1*JMAX + 1) * Y]
vldr COEF6, [PCOEF, #X + (2*JMAX + 1) * Y]
.endif
- .ifnc "\tail",""
- vmul.f POST0, POST0, SCALE\decifactor @ vector operation (SCALE may be scalar)
- .endif
.ifnc "\head",""
vldr COEF7, [PCOEF, #X + (3*JMAX + 1) * Y]
.ifc "\tail",""
@@ -129,10 +123,17 @@ POST3 .req s27
.endm
.macro dca_lfe_fir decifactor
+function ff_dca_lfe_fir\decifactor\()_vfp, export=1
+ fmrx OLDFPSCR, FPSCR
+ ldr ip, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
+ fmxr FPSCR, ip
+ vldr IN0, [PIN, #-0*4]
+ vldr IN1, [PIN, #-1*4]
+ vldr IN2, [PIN, #-2*4]
+ vldr IN3, [PIN, #-3*4]
.if \decifactor == 32
.set JMAX, 8
vpush {s16-s31}
- vmov SCALE32, s0 @ duplicate scalar across vector
vldr IN4, [PIN, #-4*4]
vldr IN5, [PIN, #-5*4]
vldr IN6, [PIN, #-6*4]
@@ -165,37 +166,19 @@ POST3 .req s27
.endif
fmxr FPSCR, OLDFPSCR
bx lr
+endfunc
.endm
-
-/* void ff_dca_lfe_fir_vfp(float *out, const float *in, const float *coefs,
- * int decifactor, float scale)
- */
-function ff_dca_lfe_fir_vfp, export=1
- teq DECIFACTOR, #32
- fmrx OLDFPSCR, FPSCR
- ldr ip, =0x03030000 @ RunFast mode, short vectors of length 4, stride 1
- fmxr FPSCR, ip
-NOVFP vldr s0, [sp]
- vldr IN0, [PIN, #-0*4]
- vldr IN1, [PIN, #-1*4]
- vldr IN2, [PIN, #-2*4]
- vldr IN3, [PIN, #-3*4]
- beq 32f
-64: dca_lfe_fir 64
+ dca_lfe_fir 64
.ltorg
-32: dca_lfe_fir 32
-endfunc
+ dca_lfe_fir 32
.unreq POUT
.unreq PIN
.unreq PCOEF
- .unreq DECIFACTOR
.unreq OLDFPSCR
.unreq COUNTER
- .unreq SCALE32
- .unreq SCALE64
.unreq IN0
.unreq IN1
.unreq IN2
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.S b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.S
index 586a833fc1f..e0a8a2e97f9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.S
@@ -22,13 +22,8 @@
#include "config.h"
#include "libavutil/arm/asm.S"
-#if !HAVE_ARMV5TE_EXTERNAL
-#define pld @
-#endif
-
- .align 5
@ void ff_add_pixels_clamped_arm(int16_t *block, uint8_t *dest, int stride)
-function ff_add_pixels_clamped_arm, export=1
+function ff_add_pixels_clamped_arm, export=1, align=5
push {r4-r10}
mov r10, #8
1:
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.h b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.h
index b7b5bdc0e6a..e1c42ee17f0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_arm.h
@@ -18,15 +18,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_ARM_DSPUTIL_H
-#define AVCODEC_ARM_DSPUTIL_H
+#ifndef AVCODEC_ARM_DSPUTIL_ARM_H
+#define AVCODEC_ARM_DSPUTIL_ARM_H
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
-void ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx);
+void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
-#endif /* AVCODEC_ARM_DSPUTIL_H */
+#endif /* AVCODEC_ARM_DSPUTIL_ARM_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_arm.c
index 68991fa9c52..c3a48cdecf4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_arm.c
@@ -19,8 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
+
#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
#include "dsputil_arm.h"
void ff_j_rev_dct_arm(int16_t *data);
@@ -34,43 +39,47 @@ void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest,
int line_size);
/* XXX: those functions should be suppressed ASAP when all IDCTs are
- converted */
+ * converted */
static void j_rev_dct_arm_put(uint8_t *dest, int line_size, int16_t *block)
{
- ff_j_rev_dct_arm (block);
+ ff_j_rev_dct_arm(block);
ff_put_pixels_clamped(block, dest, line_size);
}
+
static void j_rev_dct_arm_add(uint8_t *dest, int line_size, int16_t *block)
{
- ff_j_rev_dct_arm (block);
+ ff_j_rev_dct_arm(block);
ff_add_pixels_clamped(block, dest, line_size);
}
+
static void simple_idct_arm_put(uint8_t *dest, int line_size, int16_t *block)
{
- ff_simple_idct_arm (block);
+ ff_simple_idct_arm(block);
ff_put_pixels_clamped(block, dest, line_size);
}
+
static void simple_idct_arm_add(uint8_t *dest, int line_size, int16_t *block)
{
- ff_simple_idct_arm (block);
+ ff_simple_idct_arm(block);
ff_add_pixels_clamped(block, dest, line_size);
}
-av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
- if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
- if(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_ARM){
+ if (!avctx->lowres && !high_bit_depth) {
+ if (avctx->idct_algo == FF_IDCT_AUTO ||
+ avctx->idct_algo == FF_IDCT_ARM) {
c->idct_put = j_rev_dct_arm_put;
c->idct_add = j_rev_dct_arm_add;
c->idct = ff_j_rev_dct_arm;
c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
- } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM){
+ } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM) {
c->idct_put = simple_idct_arm_put;
c->idct_add = simple_idct_arm_add;
c->idct = ff_simple_idct_arm;
@@ -80,7 +89,10 @@ av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx)
c->add_pixels_clamped = ff_add_pixels_clamped_arm;
- if (have_armv5te(cpu_flags)) ff_dsputil_init_armv5te(c, avctx);
- if (have_armv6(cpu_flags)) ff_dsputil_init_armv6(c, avctx);
- if (have_neon(cpu_flags)) ff_dsputil_init_neon(c, avctx);
+ if (have_armv5te(cpu_flags))
+ ff_dsputil_init_armv5te(c, avctx, high_bit_depth);
+ if (have_armv6(cpu_flags))
+ ff_dsputil_init_armv6(c, avctx, high_bit_depth);
+ if (have_neon(cpu_flags))
+ ff_dsputil_init_neon(c, avctx, high_bit_depth);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv5te.c b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv5te.c
index 841fbfadcdf..883f6e40ad4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv5te.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv5te.c
@@ -18,15 +18,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
#include "dsputil_arm.h"
void ff_simple_idct_armv5te(int16_t *data);
void ff_simple_idct_put_armv5te(uint8_t *dest, int line_size, int16_t *data);
void ff_simple_idct_add_armv5te(uint8_t *dest, int line_size, int16_t *data);
-av_cold void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
- if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
+ if (!avctx->lowres && !high_bit_depth &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
c->idct_put = ff_simple_idct_put_armv5te;
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv6.c b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv6.c
index 8f383025a25..17d55eaac72 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv6.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_armv6.c
@@ -20,53 +20,55 @@
#include <stdint.h>
+#include "libavutil/attributes.h"
#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
+#include "libavcodec/mpegvideo.h"
#include "dsputil_arm.h"
void ff_simple_idct_armv6(int16_t *data);
void ff_simple_idct_put_armv6(uint8_t *dest, int line_size, int16_t *data);
void ff_simple_idct_add_armv6(uint8_t *dest, int line_size, int16_t *data);
-void ff_add_pixels_clamped_armv6(const int16_t *block,
- uint8_t *restrict pixels,
+void ff_add_pixels_clamped_armv6(const int16_t *block, uint8_t *pixels,
int line_size);
void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, int stride);
void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1,
const uint8_t *s2, int stride);
-int ff_pix_abs16_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
int line_size, int h);
-int ff_pix_abs16_x2_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_x2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
int line_size, int h);
-int ff_pix_abs16_y2_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_y2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
int line_size, int h);
-int ff_pix_abs8_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
- int line_size, int h);
+int ff_pix_abs8_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h);
-int ff_sse16_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
+int ff_sse16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
int line_size, int h);
int ff_pix_norm1_armv6(uint8_t *pix, int line_size);
int ff_pix_sum_armv6(uint8_t *pix, int line_size);
-av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
- if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
- (avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
- c->idct_put = ff_simple_idct_put_armv6;
- c->idct_add = ff_simple_idct_add_armv6;
- c->idct = ff_simple_idct_armv6;
- c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+ if (!avctx->lowres && !high_bit_depth) {
+ if (avctx->idct_algo == FF_IDCT_AUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEARMV6) {
+ c->idct_put = ff_simple_idct_put_armv6;
+ c->idct_add = ff_simple_idct_add_armv6;
+ c->idct = ff_simple_idct_armv6;
+ c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+ }
}
+ c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
if (!high_bit_depth)
c->get_pixels = ff_get_pixels_armv6;
- c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
c->diff_pixels = ff_diff_pixels_armv6;
c->pix_abs[0][0] = ff_pix_abs16_armv6;
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_neon.c b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_neon.c
index c1f250acb62..8da442bf826 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_neon.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/dsputil_init_neon.c
@@ -23,6 +23,7 @@
#include "libavutil/attributes.h"
#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
#include "dsputil_arm.h"
void ff_simple_idct_neon(int16_t *data);
@@ -42,14 +43,14 @@ void ff_vector_clip_int32_neon(int32_t *dst, const int32_t *src, int32_t min,
int32_t max, unsigned int len);
int32_t ff_scalarproduct_int16_neon(const int16_t *v1, const int16_t *v2, int len);
+
int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, const int16_t *v2,
const int16_t *v3, int len, int mul);
-av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
- if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
+ if (!avctx->lowres && !high_bit_depth) {
if (avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLENEON) {
c->idct_put = ff_simple_idct_put_neon;
@@ -59,18 +60,19 @@ av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
}
}
+ c->add_pixels_clamped = ff_add_pixels_clamped_neon;
+ c->put_pixels_clamped = ff_put_pixels_clamped_neon;
+ c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;
+
if (!high_bit_depth) {
c->clear_block = ff_clear_block_neon;
c->clear_blocks = ff_clear_blocks_neon;
}
- c->add_pixels_clamped = ff_add_pixels_clamped_neon;
- c->put_pixels_clamped = ff_put_pixels_clamped_neon;
- c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;
-
- c->vector_clipf = ff_vector_clipf_neon;
- c->vector_clip_int32 = ff_vector_clip_int32_neon;
+ c->vector_clipf = ff_vector_clipf_neon;
+ c->vector_clip_int32 = ff_vector_clip_int32_neon;
c->scalarproduct_int16 = ff_scalarproduct_int16_neon;
+
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_neon;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_init_arm.c
index ef098f4bf1c..b60bb9fa858 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_init_arm.c
@@ -20,7 +20,7 @@
#include "libavutil/arm/cpu.h"
-#define CONFIG_FFT_FLOAT 0
+#define FFT_FLOAT 0
#include "libavcodec/fft.h"
void ff_fft_fixed_calc_neon(FFTContext *s, FFTComplex *z);
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_neon.S
index d4a38a2b96f..57a8cfb557c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/fft_fixed_neon.S
@@ -122,7 +122,7 @@ endfunc
function fft_pass_neon
push {r4,lr}
- movrel lr, coefs+24
+ movrel lr, coefs + 24
vld1.16 {d30}, [lr,:64]
lsl r12, r2, #3
vmov d31, d30
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/flacdsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/flacdsp_init_arm.c
index 9b9394280f9..9ddb26829d3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/flacdsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/flacdsp_init_arm.c
@@ -27,6 +27,6 @@ void ff_flac_lpc_16_arm(int32_t *samples, const int coeffs[32], int order,
av_cold void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt,
int bps)
{
- if (bps <= 16)
+ if (bps <= 16 && CONFIG_FLAC_DECODER)
c->lpc = ff_flac_lpc_16_arm;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/fmtconvert_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/fmtconvert_neon.S
index 55d070e01c1..4662e280b64 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/fmtconvert_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/fmtconvert_neon.S
@@ -70,7 +70,7 @@ function ff_float_to_int16_interleave_neon, export=1
cmp r3, #2
itt lt
ldrlt r1, [r1]
- blt ff_float_to_int16_neon
+ blt X(ff_float_to_int16_neon)
bne 4f
ldr r3, [r1]
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/h264cmc_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/h264cmc_neon.S
index 112d5d6f862..0bcae112042 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/h264cmc_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/h264cmc_neon.S
@@ -39,6 +39,9 @@ function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
add r6, r6, r7, lsl #1
vld1.16 {d22[],d23[]}, [r6,:16]
.endif
+ .ifc \codec,vc1
+ vmov.u16 q11, #28
+ .endif
A muls r7, r4, r5
T mul r7, r4, r5
@@ -183,6 +186,9 @@ function ff_\type\()_\codec\()_chroma_mc4_neon, export=1
add r6, r6, r7, lsl #1
vld1.16 {d22[],d23[]}, [r6,:16]
.endif
+ .ifc \codec,vc1
+ vmov.u16 q11, #28
+ .endif
A muls r7, r4, r5
T mul r7, r4, r5
@@ -396,3 +402,10 @@ endconst
h264_chroma_mc4 put, rv40
h264_chroma_mc4 avg, rv40
#endif
+
+#if CONFIG_VC1_DECODER
+ h264_chroma_mc8 put, vc1
+ h264_chroma_mc8 avg, vc1
+ h264_chroma_mc4 put, vc1
+ h264_chroma_mc4 avg, vc1
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
index 2cafbaf2559..eb6c5147279 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
@@ -24,7 +24,7 @@
#include "libavutil/arm/cpu.h"
#include "libavcodec/h264dsp.h"
-int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size);
+int ff_startcode_find_candidate_armv6(const uint8_t *buf, int size);
void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
int beta, int8_t *tc0);
@@ -75,30 +75,30 @@ static av_cold void h264dsp_init_neon(H264DSPContext *c, const int bit_depth,
{
#if HAVE_NEON
if (bit_depth == 8) {
- c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
- c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;
- if(chroma_format_idc == 1){
- c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
- c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
- }
+ c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
+ c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;
+ if(chroma_format_idc == 1){
+ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
+ c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
+ }
- c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon;
- c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon;
- c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon;
+ c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon;
+ c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon;
+ c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon;
- c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon;
- c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon;
- c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon;
+ c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon;
+ c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon;
+ c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon;
- c->h264_idct_add = ff_h264_idct_add_neon;
- c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
- c->h264_idct_add16 = ff_h264_idct_add16_neon;
- c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
- if (chroma_format_idc == 1)
- c->h264_idct_add8 = ff_h264_idct_add8_neon;
- c->h264_idct8_add = ff_h264_idct8_add_neon;
- c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
- c->h264_idct8_add4 = ff_h264_idct8_add4_neon;
+ c->h264_idct_add = ff_h264_idct_add_neon;
+ c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
+ c->h264_idct_add16 = ff_h264_idct_add16_neon;
+ c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
+ if (chroma_format_idc <= 1)
+ c->h264_idct_add8 = ff_h264_idct_add8_neon;
+ c->h264_idct8_add = ff_h264_idct8_add_neon;
+ c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
+ c->h264_idct8_add4 = ff_h264_idct8_add4_neon;
}
#endif // HAVE_NEON
}
@@ -109,7 +109,7 @@ av_cold void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth,
int cpu_flags = av_get_cpu_flags();
if (have_armv6(cpu_flags))
- c->h264_find_start_code_candidate = ff_h264_find_start_code_candidate_armv6;
+ c->h264_find_start_code_candidate = ff_startcode_find_candidate_armv6;
if (have_neon(cpu_flags))
h264dsp_init_neon(c, bit_depth, chroma_format_idc);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/h264idct_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/h264idct_neon.S
index 2edeca2cbc0..4f68bdb9f55 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/h264idct_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/h264idct_neon.S
@@ -113,8 +113,8 @@ function ff_h264_idct_add16_neon, export=1
movne lr, #0
cmp lr, #0
ite ne
- adrne lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB
- adreq lr, ff_h264_idct_add_neon + CONFIG_THUMB
+ adrne lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB
+ adreq lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB
blx lr
2: subs ip, ip, #1
add r1, r1, #32
@@ -138,8 +138,8 @@ function ff_h264_idct_add16intra_neon, export=1
cmp r8, #0
ldrsh r8, [r1]
iteet ne
- adrne lr, ff_h264_idct_add_neon + CONFIG_THUMB
- adreq lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB
+ adrne lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB
+ adreq lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB
cmpeq r8, #0
blxne lr
subs ip, ip, #1
@@ -166,8 +166,8 @@ function ff_h264_idct_add8_neon, export=1
cmp r8, #0
ldrsh r8, [r1]
iteet ne
- adrne lr, ff_h264_idct_add_neon + CONFIG_THUMB
- adreq lr, ff_h264_idct_dc_add_neon + CONFIG_THUMB
+ adrne lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB
+ adreq lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB
cmpeq r8, #0
blxne lr
add r12, r12, #1
@@ -388,8 +388,8 @@ function ff_h264_idct8_add4_neon, export=1
movne lr, #0
cmp lr, #0
ite ne
- adrne lr, ff_h264_idct8_dc_add_neon + CONFIG_THUMB
- adreq lr, ff_h264_idct8_add_neon + CONFIG_THUMB
+ adrne lr, X(ff_h264_idct8_dc_add_neon) + CONFIG_THUMB
+ adreq lr, X(ff_h264_idct8_add_neon) + CONFIG_THUMB
blx lr
2: subs r12, r12, #4
add r1, r1, #128
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/h264pred_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/h264pred_init_arm.c
index 1562f0bcbe8..6ba7592fe71 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/h264pred_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/h264pred_init_arm.c
@@ -57,10 +57,11 @@ static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
if(chroma_format_idc == 1){
h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon;
h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon;
- if (codec_id != AV_CODEC_ID_VP8)
+ if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon;
h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon;
- if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8) {
+ if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
+ codec_id != AV_CODEC_ID_VP8) {
h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon;
h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon;
h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon;
@@ -77,7 +78,8 @@ static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon;
h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon;
h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon;
- if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8)
+ if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 &&
+ codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;
#endif // HAVE_NEON
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.S b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.S
index 2f3d3114eaf..219f793d992 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.S
@@ -1,5 +1,5 @@
@
-@ ARMv4 optimized DSP utils
+@ ARMv4-optimized halfpel functions
@ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
@
@ This file is part of FFmpeg.
@@ -89,8 +89,7 @@
.endm
@ ----------------------------------------------------------------
- .align 5
-function ff_put_pixels16_arm, export=1
+function ff_put_pixels16_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -141,8 +140,7 @@ function ff_put_pixels16_arm, export=1
endfunc
@ ----------------------------------------------------------------
- .align 5
-function ff_put_pixels8_arm, export=1
+function ff_put_pixels8_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -193,8 +191,7 @@ function ff_put_pixels8_arm, export=1
endfunc
@ ----------------------------------------------------------------
- .align 5
-function ff_put_pixels8_x2_arm, export=1
+function ff_put_pixels8_x2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -252,8 +249,7 @@ function ff_put_pixels8_x2_arm, export=1
pop {r4-r10,pc}
endfunc
- .align 5
-function ff_put_no_rnd_pixels8_x2_arm, export=1
+function ff_put_no_rnd_pixels8_x2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -313,8 +309,7 @@ endfunc
@ ----------------------------------------------------------------
- .align 5
-function ff_put_pixels8_y2_arm, export=1
+function ff_put_pixels8_y2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -411,8 +406,7 @@ function ff_put_pixels8_y2_arm, export=1
pop {r4-r11,pc}
endfunc
- .align 5
-function ff_put_no_rnd_pixels8_y2_arm, export=1
+function ff_put_no_rnd_pixels8_y2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -578,8 +572,7 @@ endfunc
pop {r4-r11,pc}
.endm
- .align 5
-function ff_put_pixels8_xy2_arm, export=1
+function ff_put_pixels8_xy2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
@@ -594,8 +587,7 @@ function ff_put_pixels8_xy2_arm, export=1
4: RND_XY2_EXPAND 3, lsl
endfunc
- .align 5
-function ff_put_no_rnd_pixels8_xy2_arm, export=1
+function ff_put_no_rnd_pixels8_xy2_arm, export=1, align=5
@ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
@ block = word aligned, pixles = unaligned
pld [r1]
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.h b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.h
index 3f18c624d81..5f3c7741c1e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_arm.h
@@ -18,12 +18,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_ARM_HPELDSP_H
-#define AVCODEC_ARM_HPELDSP_H
+#ifndef AVCODEC_ARM_HPELDSP_ARM_H
+#define AVCODEC_ARM_HPELDSP_ARM_H
#include "libavcodec/hpeldsp.h"
void ff_hpeldsp_init_armv6(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_neon(HpelDSPContext *c, int flags);
-#endif /* AVCODEC_ARM_HPELDSP_H */
+#endif /* AVCODEC_ARM_HPELDSP_ARM_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_armv6.S b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_armv6.S
index cd501504da4..a8bd459c207 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_armv6.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_armv6.S
@@ -23,11 +23,11 @@
.macro call_2x_pixels type, subp
function ff_\type\()_pixels16\subp\()_armv6, export=1
push {r0-r3, lr}
- bl ff_\type\()_pixels8\subp\()_armv6
+ bl X(ff_\type\()_pixels8\subp\()_armv6)
pop {r0-r3, lr}
add r0, r0, #8
add r1, r1, #8
- b ff_\type\()_pixels8\subp\()_armv6
+ b X(ff_\type\()_pixels8\subp\()_armv6)
endfunc
.endm
@@ -144,10 +144,11 @@ function ff_put_pixels8_y2_armv6, export=1
eor r7, r5, r7
uadd8 r10, r10, r6
and r7, r7, r12
- ldr_pre r6, r1, r2
+ ldrc_pre ne, r6, r1, r2
uadd8 r11, r11, r7
strd_post r8, r9, r0, r2
- ldr r7, [r1, #4]
+ it ne
+ ldrne r7, [r1, #4]
strd_post r10, r11, r0, r2
bne 1b
@@ -196,9 +197,10 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
uhadd8 r9, r5, r7
ldr r5, [r1, #4]
uhadd8 r12, r4, r6
- ldr_pre r6, r1, r2
+ ldrc_pre ne, r6, r1, r2
uhadd8 r14, r5, r7
- ldr r7, [r1, #4]
+ it ne
+ ldrne r7, [r1, #4]
stm r0, {r8,r9}
add r0, r0, r2
stm r0, {r12,r14}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_init_arm.c
index 2cc2b782b20..1977b1379b2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/hpeldsp_init_arm.c
@@ -1,5 +1,5 @@
/*
- * ARM optimized DSP utils
+ * ARM-optimized halfpel functions
* Copyright (c) 2001 Lionel Ulmer
*
* This file is part of FFmpeg.
@@ -21,8 +21,7 @@
#include "libavutil/arm/cpu.h"
#include "libavutil/attributes.h"
-#include "libavcodec/bit_depth_template.c" // for CALL_2X_PIXELS
-#include "libavcodec/rnd_avg.h"
+#include "libavcodec/pixels.h"
#include "hpeldsp_arm.h"
void ff_put_pixels8_arm(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h);
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/int_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/int_neon.S
index dea1ad51ebd..ba840656fee 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/int_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/int_neon.S
@@ -21,8 +21,6 @@
#include "libavutil/arm/asm.S"
- .fpu neon
-
function ff_scalarproduct_int16_neon, export=1
vmov.i16 q0, #0
vmov.i16 q1, #0
@@ -37,14 +35,14 @@ function ff_scalarproduct_int16_neon, export=1
vmlal.s16 q2, d18, d22
vmlal.s16 q3, d19, d23
subs r2, r2, #16
- bne 1b
+ bgt 1b
vpadd.s32 d16, d0, d1
vpadd.s32 d17, d2, d3
- vpadd.s32 d10, d4, d5
- vpadd.s32 d11, d6, d7
+ vpadd.s32 d18, d4, d5
+ vpadd.s32 d19, d6, d7
vpadd.s32 d0, d16, d17
- vpadd.s32 d1, d10, d11
+ vpadd.s32 d1, d18, d19
vpadd.s32 d2, d0, d1
vpaddl.s32 d3, d2
vmov.32 r0, d3[0]
@@ -77,14 +75,14 @@ function ff_scalarproduct_and_madd_int16_neon, export=1
vst1.16 {q10}, [r12,:128]!
subs r3, r3, #16
vst1.16 {q13}, [r12,:128]!
- bne 1b
+ bgt 1b
vpadd.s32 d16, d0, d1
vpadd.s32 d17, d2, d3
- vpadd.s32 d10, d4, d5
- vpadd.s32 d11, d6, d7
+ vpadd.s32 d18, d4, d5
+ vpadd.s32 d19, d6, d7
vpadd.s32 d0, d16, d17
- vpadd.s32 d1, d10, d11
+ vpadd.s32 d1, d18, d19
vpadd.s32 d2, d0, d1
vpaddl.s32 d3, d2
vmov.32 r0, d3[0]
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mdct_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/mdct_neon.S
index e481cd1307a..a6952fa5716 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/mdct_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mdct_neon.S
@@ -129,7 +129,7 @@ function ff_imdct_calc_neon, export=1
lsl r4, r4, r3
add r1, r1, r4
- bl ff_imdct_half_neon
+ bl X(ff_imdct_half_neon)
add r0, r5, r4, lsl #2
add r1, r5, r4, lsl #1
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv5te.S b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv5te.S
new file mode 100644
index 00000000000..8355cdf3a2b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv5te.S
@@ -0,0 +1,655 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison <bavison@riscosopen.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+#define MAX_CHANNELS 8
+#define MAX_FIR_ORDER 8
+#define MAX_IIR_ORDER 4
+#define MAX_RATEFACTOR 4
+#define MAX_BLOCKSIZE (40 * MAX_RATEFACTOR)
+
+PST .req a1
+PCO .req a2
+AC0 .req a3
+AC1 .req a4
+CO0 .req v1
+CO1 .req v2
+CO2 .req v3
+CO3 .req v4
+ST0 .req v5
+ST1 .req v6
+ST2 .req sl
+ST3 .req fp
+I .req ip
+PSAMP .req lr
+
+
+// Some macros that do loads/multiplies where the register number is determined
+// from an assembly-time expression. Boy is GNU assembler's syntax ugly...
+
+.macro load group, index, base, offset
+ .altmacro
+ load_ \group, %(\index), \base, \offset
+ .noaltmacro
+.endm
+
+.macro load_ group, index, base, offset
+ ldr \group\index, [\base, #\offset]
+.endm
+
+.macro loadd group, index, base, offset
+ .altmacro
+ loadd_ \group, %(\index), %(\index+1), \base, \offset
+ .noaltmacro
+.endm
+
+.macro loadd_ group, index0, index1, base, offset
+A .if \offset >= 256
+A ldr \group\index0, [\base, #\offset]
+A ldr \group\index1, [\base, #(\offset) + 4]
+A .else
+ ldrd \group\index0, \group\index1, [\base, #\offset]
+A .endif
+.endm
+
+.macro multiply index, accumulate, long
+ .altmacro
+ multiply_ %(\index), \accumulate, \long
+ .noaltmacro
+.endm
+
+.macro multiply_ index, accumulate, long
+ .if \long
+ .if \accumulate
+ smlal AC0, AC1, CO\index, ST\index
+ .else
+ smull AC0, AC1, CO\index, ST\index
+ .endif
+ .else
+ .if \accumulate
+ mla AC0, CO\index, ST\index, AC0
+ .else
+ mul AC0, CO\index, ST\index
+ .endif
+ .endif
+.endm
+
+// A macro to update the load register number and load offsets
+
+.macro inc howmany
+ .set LOAD_REG, (LOAD_REG + \howmany) & 3
+ .set OFFSET_CO, OFFSET_CO + 4 * \howmany
+ .set OFFSET_ST, OFFSET_ST + 4 * \howmany
+ .if FIR_REMAIN > 0
+ .set FIR_REMAIN, FIR_REMAIN - \howmany
+ .if FIR_REMAIN == 0
+ .set OFFSET_CO, 4 * MAX_FIR_ORDER
+ .set OFFSET_ST, 4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)
+ .endif
+ .elseif IIR_REMAIN > 0
+ .set IIR_REMAIN, IIR_REMAIN - \howmany
+ .endif
+.endm
+
+// Macro to implement the inner loop for one specific combination of parameters
+
+.macro implement_filter mask_minus1, shift_0, shift_8, iir_taps, fir_taps
+ .set TOTAL_TAPS, \iir_taps + \fir_taps
+
+ // Deal with register allocation...
+ .set DEFINED_SHIFT, 0
+ .set DEFINED_MASK, 0
+ .set SHUFFLE_SHIFT, 0
+ .set SHUFFLE_MASK, 0
+ .set SPILL_SHIFT, 0
+ .set SPILL_MASK, 0
+ .if TOTAL_TAPS == 0
+ // Little register pressure in this case - just keep MASK where it was
+ .if !\mask_minus1
+ MASK .req ST1
+ .set DEFINED_MASK, 1
+ .endif
+ .else
+ .if \shift_0
+ .if !\mask_minus1
+ // AC1 is unused with shift 0
+ MASK .req AC1
+ .set DEFINED_MASK, 1
+ .set SHUFFLE_MASK, 1
+ .endif
+ .elseif \shift_8
+ .if !\mask_minus1
+ .if TOTAL_TAPS <= 4
+ // All coefficients are preloaded (so pointer not needed)
+ MASK .req PCO
+ .set DEFINED_MASK, 1
+ .set SHUFFLE_MASK, 1
+ .else
+ .set SPILL_MASK, 1
+ .endif
+ .endif
+ .else // shift not 0 or 8
+ .if TOTAL_TAPS <= 3
+ // All coefficients are preloaded, and at least one CO register is unused
+ .if \fir_taps & 1
+ SHIFT .req CO0
+ .set DEFINED_SHIFT, 1
+ .set SHUFFLE_SHIFT, 1
+ .else
+ SHIFT .req CO3
+ .set DEFINED_SHIFT, 1
+ .set SHUFFLE_SHIFT, 1
+ .endif
+ .if !\mask_minus1
+ MASK .req PCO
+ .set DEFINED_MASK, 1
+ .set SHUFFLE_MASK, 1
+ .endif
+ .elseif TOTAL_TAPS == 4
+ // All coefficients are preloaded
+ SHIFT .req PCO
+ .set DEFINED_SHIFT, 1
+ .set SHUFFLE_SHIFT, 1
+ .if !\mask_minus1
+ .set SPILL_MASK, 1
+ .endif
+ .else
+ .set SPILL_SHIFT, 1
+ .if !\mask_minus1
+ .set SPILL_MASK, 1
+ .endif
+ .endif
+ .endif
+ .endif
+ .if SPILL_SHIFT
+ SHIFT .req ST0
+ .set DEFINED_SHIFT, 1
+ .endif
+ .if SPILL_MASK
+ MASK .req ST1
+ .set DEFINED_MASK, 1
+ .endif
+
+ // Preload coefficients if possible
+ .if TOTAL_TAPS <= 4
+ .set OFFSET_CO, 0
+ .if \fir_taps & 1
+ .set LOAD_REG, 1
+ .else
+ .set LOAD_REG, 0
+ .endif
+ .rept \fir_taps
+ load CO, LOAD_REG, PCO, OFFSET_CO
+ .set LOAD_REG, (LOAD_REG + 1) & 3
+ .set OFFSET_CO, OFFSET_CO + 4
+ .endr
+ .set OFFSET_CO, 4 * MAX_FIR_ORDER
+ .rept \iir_taps
+ load CO, LOAD_REG, PCO, OFFSET_CO
+ .set LOAD_REG, (LOAD_REG + 1) & 3
+ .set OFFSET_CO, OFFSET_CO + 4
+ .endr
+ .endif
+
+ // Move mask/shift to final positions if necessary
+ // Need to do this after preloading, because in some cases we
+ // reuse the coefficient pointer register
+ .if SHUFFLE_SHIFT
+ mov SHIFT, ST0
+ .endif
+ .if SHUFFLE_MASK
+ mov MASK, ST1
+ .endif
+
+ // Begin loop
+01:
+ .if TOTAL_TAPS == 0
+ // Things simplify a lot in this case
+ // In fact this could be pipelined further if it's worth it...
+ ldr ST0, [PSAMP]
+ subs I, I, #1
+ .if !\mask_minus1
+ and ST0, ST0, MASK
+ .endif
+ str ST0, [PST, #-4]!
+ str ST0, [PST, #4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)]
+ str ST0, [PSAMP], #4 * MAX_CHANNELS
+ bne 01b
+ .else
+ .if \fir_taps & 1
+ .set LOAD_REG, 1
+ .else
+ .set LOAD_REG, 0
+ .endif
+ .set LOAD_BANK, 0
+ .set FIR_REMAIN, \fir_taps
+ .set IIR_REMAIN, \iir_taps
+ .if FIR_REMAIN == 0 // only IIR terms
+ .set OFFSET_CO, 4 * MAX_FIR_ORDER
+ .set OFFSET_ST, 4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)
+ .else
+ .set OFFSET_CO, 0
+ .set OFFSET_ST, 0
+ .endif
+ .set MUL_REG, LOAD_REG
+ .set COUNTER, 0
+ .rept TOTAL_TAPS + 2
+ // Do load(s)
+ .if FIR_REMAIN != 0 || IIR_REMAIN != 0
+ .if COUNTER == 0
+ .if TOTAL_TAPS > 4
+ load CO, LOAD_REG, PCO, OFFSET_CO
+ .endif
+ load ST, LOAD_REG, PST, OFFSET_ST
+ inc 1
+ .elseif COUNTER == 1 && (\fir_taps & 1) == 0
+ .if TOTAL_TAPS > 4
+ load CO, LOAD_REG, PCO, OFFSET_CO
+ .endif
+ load ST, LOAD_REG, PST, OFFSET_ST
+ inc 1
+ .elseif LOAD_BANK == 0
+ .if TOTAL_TAPS > 4
+ .if FIR_REMAIN == 0 && IIR_REMAIN == 1
+ load CO, LOAD_REG, PCO, OFFSET_CO
+ .else
+ loadd CO, LOAD_REG, PCO, OFFSET_CO
+ .endif
+ .endif
+ .set LOAD_BANK, 1
+ .else
+ .if FIR_REMAIN == 0 && IIR_REMAIN == 1
+ load ST, LOAD_REG, PST, OFFSET_ST
+ inc 1
+ .else
+ loadd ST, LOAD_REG, PST, OFFSET_ST
+ inc 2
+ .endif
+ .set LOAD_BANK, 0
+ .endif
+ .endif
+
+ // Do interleaved multiplies, slightly delayed
+ .if COUNTER >= 2
+ multiply MUL_REG, COUNTER > 2, !\shift_0
+ .set MUL_REG, (MUL_REG + 1) & 3
+ .endif
+ .set COUNTER, COUNTER + 1
+ .endr
+
+ // Post-process the result of the multiplies
+ .if SPILL_SHIFT
+ ldr SHIFT, [sp, #9*4 + 0*4]
+ .endif
+ .if SPILL_MASK
+ ldr MASK, [sp, #9*4 + 1*4]
+ .endif
+ ldr ST2, [PSAMP]
+ subs I, I, #1
+ .if \shift_8
+ mov AC0, AC0, lsr #8
+ orr AC0, AC0, AC1, lsl #24
+ .elseif !\shift_0
+ rsb ST3, SHIFT, #32
+ mov AC0, AC0, lsr SHIFT
+A orr AC0, AC0, AC1, lsl ST3
+T mov AC1, AC1, lsl ST3
+T orr AC0, AC0, AC1
+ .endif
+ .if \mask_minus1
+ add ST3, ST2, AC0
+ .else
+ add ST2, ST2, AC0
+ and ST3, ST2, MASK
+ sub ST2, ST3, AC0
+ .endif
+ str ST3, [PST, #-4]!
+ str ST2, [PST, #4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)]
+ str ST3, [PSAMP], #4 * MAX_CHANNELS
+ bne 01b
+ .endif
+ b 99f
+
+ .if DEFINED_SHIFT
+ .unreq SHIFT
+ .endif
+ .if DEFINED_MASK
+ .unreq MASK
+ .endif
+.endm
+
+.macro switch_on_fir_taps mask_minus1, shift_0, shift_8, iir_taps
+A ldr pc, [pc, a3, LSL #2] // firorder is in range 0-(8-iir_taps)
+T tbh [pc, a3, lsl #1]
+0:
+A .word 0, 70f, 71f, 72f, 73f, 74f
+T .hword (70f - 0b) / 2, (71f - 0b) / 2, (72f - 0b) / 2, (73f - 0b) / 2, (74f - 0b) / 2
+ .if \iir_taps <= 3
+A .word 75f
+T .hword (75f - 0b) / 2
+ .if \iir_taps <= 2
+A .word 76f
+T .hword (76f - 0b) / 2
+ .if \iir_taps <= 1
+A .word 77f
+T .hword (77f - 0b) / 2
+ .if \iir_taps == 0
+A .word 78f
+T .hword (78f - 0b) / 2
+ .endif
+ .endif
+ .endif
+ .endif
+70: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 0
+71: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 1
+72: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 2
+73: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 3
+74: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 4
+ .if \iir_taps <= 3
+75: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 5
+ .if \iir_taps <= 2
+76: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 6
+ .if \iir_taps <= 1
+77: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 7
+ .if \iir_taps == 0
+78: implement_filter \mask_minus1, \shift_0, \shift_8, \iir_taps, 8
+ .endif
+ .endif
+ .endif
+ .endif
+.endm
+
+.macro switch_on_iir_taps mask_minus1, shift_0, shift_8
+A ldr pc, [pc, a4, LSL #2] // irorder is in range 0-4
+T tbh [pc, a4, lsl #1]
+0:
+A .word 0, 60f, 61f, 62f, 63f, 64f
+T .hword (60f - 0b) / 2, (61f - 0b) / 2, (62f - 0b) / 2, (63f - 0b) / 2, (64f - 0b) / 2
+60: switch_on_fir_taps \mask_minus1, \shift_0, \shift_8, 0
+61: switch_on_fir_taps \mask_minus1, \shift_0, \shift_8, 1
+62: switch_on_fir_taps \mask_minus1, \shift_0, \shift_8, 2
+63: switch_on_fir_taps \mask_minus1, \shift_0, \shift_8, 3
+64: switch_on_fir_taps \mask_minus1, \shift_0, \shift_8, 4
+.endm
+
+/* void ff_mlp_filter_channel_arm(int32_t *state, const int32_t *coeff,
+ * int firorder, int iirorder,
+ * unsigned int filter_shift, int32_t mask,
+ * int blocksize, int32_t *sample_buffer);
+ */
+function ff_mlp_filter_channel_arm, export=1
+ push {v1-fp,lr}
+ add v1, sp, #9*4 // point at arguments on stack
+ ldm v1, {ST0,ST1,I,PSAMP}
+ cmp ST1, #-1
+ bne 30f
+ movs ST2, ST0, lsl #29 // shift is in range 0-15; we want to special-case 0 and 8
+ bne 20f
+ bcs 10f
+ switch_on_iir_taps 1, 1, 0
+10: switch_on_iir_taps 1, 0, 1
+20: switch_on_iir_taps 1, 0, 0
+30: movs ST2, ST0, lsl #29 // shift is in range 0-15; we want to special-case 0 and 8
+ bne 50f
+ bcs 40f
+ switch_on_iir_taps 0, 1, 0
+40: switch_on_iir_taps 0, 0, 1
+50: switch_on_iir_taps 0, 0, 0
+99: pop {v1-fp,pc}
+endfunc
+
+ .unreq PST
+ .unreq PCO
+ .unreq AC0
+ .unreq AC1
+ .unreq CO0
+ .unreq CO1
+ .unreq CO2
+ .unreq CO3
+ .unreq ST0
+ .unreq ST1
+ .unreq ST2
+ .unreq ST3
+ .unreq I
+ .unreq PSAMP
+
+/********************************************************************/
+
+PSA .req a1 // samples
+PCO .req a2 // coeffs
+PBL .req a3 // bypassed_lsbs
+INDEX .req a4
+CO0 .req v1
+CO1 .req v2
+CO2 .req v3
+CO3 .req v4
+SA0 .req v5
+SA1 .req v6
+SA2 .req sl
+SA3 .req fp
+AC0 .req ip
+AC1 .req lr
+NOISE .req SA0
+LSB .req SA1
+DCH .req SA2 // dest_ch
+MASK .req SA3
+
+ // INDEX is used as follows:
+ // bits 0..6 index2 (values up to 17, but wider so that we can
+ // add to index field without needing to mask)
+ // bits 7..14 i (values up to 160)
+ // bit 15 underflow detect for i
+ // bits 25..31 (if access_unit_size_pow2 == 128) \ index
+ // bits 26..31 (if access_unit_size_pow2 == 64) /
+
+.macro implement_rematrix shift, index_mask, mask_minus1, maxchan
+ .if \maxchan == 1
+ // We can just leave the coefficients in registers in this case
+ ldrd CO0, CO1, [PCO]
+ .endif
+1:
+ .if \maxchan == 1
+ ldrd SA0, SA1, [PSA]
+ smull AC0, AC1, CO0, SA0
+ .elseif \maxchan == 5
+ ldr CO0, [PCO, #0]
+ ldr SA0, [PSA, #0]
+ ldr CO1, [PCO, #4]
+ ldr SA1, [PSA, #4]
+ ldrd CO2, CO3, [PCO, #8]
+ smull AC0, AC1, CO0, SA0
+ ldrd SA2, SA3, [PSA, #8]
+ smlal AC0, AC1, CO1, SA1
+ ldrd CO0, CO1, [PCO, #16]
+ smlal AC0, AC1, CO2, SA2
+ ldrd SA0, SA1, [PSA, #16]
+ smlal AC0, AC1, CO3, SA3
+ smlal AC0, AC1, CO0, SA0
+ .else // \maxchan == 7
+ ldr CO2, [PCO, #0]
+ ldr SA2, [PSA, #0]
+ ldr CO3, [PCO, #4]
+ ldr SA3, [PSA, #4]
+ ldrd CO0, CO1, [PCO, #8]
+ smull AC0, AC1, CO2, SA2
+ ldrd SA0, SA1, [PSA, #8]
+ smlal AC0, AC1, CO3, SA3
+ ldrd CO2, CO3, [PCO, #16]
+ smlal AC0, AC1, CO0, SA0
+ ldrd SA2, SA3, [PSA, #16]
+ smlal AC0, AC1, CO1, SA1
+ ldrd CO0, CO1, [PCO, #24]
+ smlal AC0, AC1, CO2, SA2
+ ldrd SA0, SA1, [PSA, #24]
+ smlal AC0, AC1, CO3, SA3
+ smlal AC0, AC1, CO0, SA0
+ .endif
+ ldm sp, {NOISE, DCH, MASK}
+ smlal AC0, AC1, CO1, SA1
+ .if \shift != 0
+ .if \index_mask == 63
+ add NOISE, NOISE, INDEX, lsr #32-6
+ ldrb LSB, [PBL], #MAX_CHANNELS
+ ldrsb NOISE, [NOISE]
+ add INDEX, INDEX, INDEX, lsl #32-6
+ .else // \index_mask == 127
+ add NOISE, NOISE, INDEX, lsr #32-7
+ ldrb LSB, [PBL], #MAX_CHANNELS
+ ldrsb NOISE, [NOISE]
+ add INDEX, INDEX, INDEX, lsl #32-7
+ .endif
+ sub INDEX, INDEX, #1<<7
+ adds AC0, AC0, NOISE, lsl #\shift + 7
+ adc AC1, AC1, NOISE, asr #31
+ .else
+ ldrb LSB, [PBL], #MAX_CHANNELS
+ sub INDEX, INDEX, #1<<7
+ .endif
+ add PSA, PSA, #MAX_CHANNELS*4
+ mov AC0, AC0, lsr #14
+ orr AC0, AC0, AC1, lsl #18
+ .if !\mask_minus1
+ and AC0, AC0, MASK
+ .endif
+ add AC0, AC0, LSB
+ tst INDEX, #1<<15
+ str AC0, [PSA, DCH, lsl #2] // DCH is precompensated for the early increment of PSA
+ beq 1b
+ b 98f
+.endm
+
+.macro switch_on_maxchan shift, index_mask, mask_minus1
+ cmp v4, #5
+ blo 51f
+ beq 50f
+ implement_rematrix \shift, \index_mask, \mask_minus1, 7
+50: implement_rematrix \shift, \index_mask, \mask_minus1, 5
+51: implement_rematrix \shift, \index_mask, \mask_minus1, 1
+.endm
+
+.macro switch_on_mask shift, index_mask
+ cmp sl, #-1
+ bne 40f
+ switch_on_maxchan \shift, \index_mask, 1
+40: switch_on_maxchan \shift, \index_mask, 0
+.endm
+
+.macro switch_on_au_size shift
+ .if \shift == 0
+ switch_on_mask \shift, undefined
+ .else
+ teq v6, #64
+ bne 30f
+ orr INDEX, INDEX, v1, lsl #32-6
+ switch_on_mask \shift, 63
+30: orr INDEX, INDEX, v1, lsl #32-7
+ switch_on_mask \shift, 127
+ .endif
+.endm
+
+/* void ff_mlp_rematrix_channel_arm(int32_t *samples,
+ * const int32_t *coeffs,
+ * const uint8_t *bypassed_lsbs,
+ * const int8_t *noise_buffer,
+ * int index,
+ * unsigned int dest_ch,
+ * uint16_t blockpos,
+ * unsigned int maxchan,
+ * int matrix_noise_shift,
+ * int access_unit_size_pow2,
+ * int32_t mask);
+ */
+function ff_mlp_rematrix_channel_arm, export=1
+ push {v1-fp,lr}
+ add v1, sp, #9*4 // point at arguments on stack
+ ldm v1, {v1-sl}
+ teq v4, #1
+ itt ne
+ teqne v4, #5
+ teqne v4, #7
+ bne 99f
+ teq v6, #64
+ it ne
+ teqne v6, #128
+ bne 99f
+ sub v2, v2, #MAX_CHANNELS
+ push {a4,v2,sl} // initialise NOISE,DCH,MASK; make sp dword-aligned
+ movs INDEX, v3, lsl #7
+ beq 98f // just in case, do nothing if blockpos = 0
+ subs INDEX, INDEX, #1<<7 // offset by 1 so we borrow at the right time
+ adc lr, v1, v1 // calculate index2 (C was set by preceding subs)
+ orr INDEX, INDEX, lr
+ // Switch on matrix_noise_shift: values 0 and 1 are
+ // disproportionately common so do those in a form the branch
+ // predictor can accelerate. Values can only go up to 15.
+ cmp v5, #1
+ beq 11f
+ blo 10f
+A ldr pc, [pc, v5, lsl #2]
+T tbh [pc, v5, lsl #1]
+0:
+A .word 0, 0, 0, 12f, 13f, 14f, 15f, 16f, 17f, 18f, 19f, 20f, 21f, 22f, 23f, 24f, 25f
+T .hword 0, 0, (12f - 0b) / 2, (13f - 0b) / 2, (14f - 0b) / 2, (15f - 0b) / 2
+T .hword (16f - 0b) / 2, (17f - 0b) / 2, (18f - 0b) / 2, (19f - 0b) / 2
+T .hword (20f - 0b) / 2, (21f - 0b) / 2, (22f - 0b) / 2, (23f - 0b) / 2, (24f - 0b) / 2, (25f - 0b) / 2
+10: switch_on_au_size 0
+11: switch_on_au_size 1
+12: switch_on_au_size 2
+13: switch_on_au_size 3
+14: switch_on_au_size 4
+15: switch_on_au_size 5
+16: switch_on_au_size 6
+17: switch_on_au_size 7
+18: switch_on_au_size 8
+19: switch_on_au_size 9
+20: switch_on_au_size 10
+21: switch_on_au_size 11
+22: switch_on_au_size 12
+23: switch_on_au_size 13
+24: switch_on_au_size 14
+25: switch_on_au_size 15
+
+98: add sp, sp, #3*4
+ pop {v1-fp,pc}
+99: // Can't handle these parameters, drop back to C
+ pop {v1-fp,lr}
+ b X(ff_mlp_rematrix_channel)
+endfunc
+
+ .unreq PSA
+ .unreq PCO
+ .unreq PBL
+ .unreq INDEX
+ .unreq CO0
+ .unreq CO1
+ .unreq CO2
+ .unreq CO3
+ .unreq SA0
+ .unreq SA1
+ .unreq SA2
+ .unreq SA3
+ .unreq AC0
+ .unreq AC1
+ .unreq NOISE
+ .unreq LSB
+ .unreq DCH
+ .unreq MASK
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv6.S b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv6.S
new file mode 100644
index 00000000000..d98f807559c
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_armv6.S
@@ -0,0 +1,533 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison <bavison@riscosopen.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+.macro loadregoffsh2 group, index, base, offgroup, offindex
+ .altmacro
+ loadregoffsh2_ \group, %(\index), \base, \offgroup, %(\offindex)
+ .noaltmacro
+.endm
+
+.macro loadregoffsh2_ group, index, base, offgroup, offindex
+ ldr \group\index, [\base, \offgroup\offindex, lsl #2]
+.endm
+
+.macro eorlslreg check, data, group, index
+ .altmacro
+ eorlslreg_ \check, \data, \group, %(\index)
+ .noaltmacro
+.endm
+
+.macro eorlslreg_ check, data, group, index
+ eor \check, \check, \data, lsl \group\index
+.endm
+
+.macro decr_modulo var, by, modulus
+ .set \var, \var - \by
+ .if \var == 0
+ .set \var, \modulus
+ .endif
+.endm
+
+ .macro load_group1 size, channels, r0, r1, r2, r3, pointer_dead=0
+ .if \size == 2
+ ldrd \r0, \r1, [IN], #(\size + 8 - \channels) * 4
+ .else // size == 4
+ .if IDX1 > 4 || \channels==8
+ ldm IN!, {\r0, \r1, \r2, \r3}
+ .else
+ ldm IN, {\r0, \r1, \r2, \r3}
+ .if !\pointer_dead
+ add IN, IN, #(4 + 8 - \channels) * 4
+ .endif
+ .endif
+ .endif
+ decr_modulo IDX1, \size, \channels
+ .endm
+
+ .macro load_group2 size, channels, r0, r1, r2, r3, pointer_dead=0
+ .if \size == 2
+ .if IDX1 > 2
+ ldm IN!, {\r2, \r3}
+ .else
+//A .ifc \r2, ip
+//A .if \pointer_dead
+//A ldm IN, {\r2, \r3}
+//A .else
+//A ldr \r2, [IN], #4
+//A ldr \r3, [IN], #(\size - 1 + 8 - \channels) * 4
+//A .endif
+//A .else
+ ldrd \r2, \r3, [IN], #(\size + 8 - \channels) * 4
+//A .endif
+ .endif
+ .endif
+ decr_modulo IDX1, \size, \channels
+ .endm
+
+.macro implement_pack inorder, channels, shift
+.if \inorder
+.ifc \shift, mixed
+
+CHECK .req a1
+COUNT .req a2
+IN .req a3
+OUT .req a4
+DAT0 .req v1
+DAT1 .req v2
+DAT2 .req v3
+DAT3 .req v4
+SHIFT0 .req v5
+SHIFT1 .req v6
+SHIFT2 .req sl
+SHIFT3 .req fp
+SHIFT4 .req ip
+SHIFT5 .req lr
+
+ .macro output4words
+ .set SIZE_GROUP1, IDX1
+ .if SIZE_GROUP1 > 4
+ .set SIZE_GROUP1, 4
+ .endif
+ .set SIZE_GROUP2, 4 - SIZE_GROUP1
+ load_group1 SIZE_GROUP1, \channels, DAT0, DAT1, DAT2, DAT3
+ load_group2 SIZE_GROUP2, \channels, DAT0, DAT1, DAT2, DAT3
+ .if \channels == 2
+ lsl DAT0, SHIFT0
+ lsl DAT1, SHIFT1
+ lsl DAT2, SHIFT0
+ lsl DAT3, SHIFT1
+ .elseif \channels == 6
+ .if IDX2 == 6
+ lsl DAT0, SHIFT0
+ lsl DAT1, SHIFT1
+ lsl DAT2, SHIFT2
+ lsl DAT3, SHIFT3
+ .elseif IDX2 == 2
+ lsl DAT0, SHIFT4
+ lsl DAT1, SHIFT5
+ lsl DAT2, SHIFT0
+ lsl DAT3, SHIFT1
+ .else // IDX2 == 4
+ lsl DAT0, SHIFT2
+ lsl DAT1, SHIFT3
+ lsl DAT2, SHIFT4
+ lsl DAT3, SHIFT5
+ .endif
+ .elseif \channels == 8
+ .if IDX2 == 8
+ uxtb SHIFT0, SHIFT4, ror #0
+ uxtb SHIFT1, SHIFT4, ror #8
+ uxtb SHIFT2, SHIFT4, ror #16
+ uxtb SHIFT3, SHIFT4, ror #24
+ .else
+ uxtb SHIFT0, SHIFT5, ror #0
+ uxtb SHIFT1, SHIFT5, ror #8
+ uxtb SHIFT2, SHIFT5, ror #16
+ uxtb SHIFT3, SHIFT5, ror #24
+ .endif
+ lsl DAT0, SHIFT0
+ lsl DAT1, SHIFT1
+ lsl DAT2, SHIFT2
+ lsl DAT3, SHIFT3
+ .endif
+ eor CHECK, CHECK, DAT0, lsr #8 - (\channels - IDX2)
+ eor CHECK, CHECK, DAT1, lsr #7 - (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ eor CHECK, CHECK, DAT2, lsr #8 - (\channels - IDX2)
+ eor CHECK, CHECK, DAT3, lsr #7 - (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ stm OUT!, {DAT0 - DAT3}
+ .endm
+
+ .set WORDS_PER_LOOP, \channels // calculate LCM (channels, 4)
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP * 4
+ .set SAMPLES_PER_LOOP, WORDS_PER_LOOP / \channels
+
+function ff_mlp_pack_output_inorder_\channels\()ch_mixedshift_armv6, export=1
+ .if SAMPLES_PER_LOOP > 1
+ tst COUNT, #SAMPLES_PER_LOOP - 1 // always seems to be in practice
+ it ne
+ bne X(ff_mlp_pack_output) // but just in case, branch to C implementation if not
+ .endif
+ teq COUNT, #0
+ it eq
+ bxeq lr
+ push {v1-v6,sl,fp,lr}
+ ldr SHIFT0, [sp, #(9+1)*4] // get output_shift from stack
+ ldr SHIFT1, =0x08080808
+ ldr SHIFT4, [SHIFT0]
+ .if \channels == 2
+ uadd8 SHIFT4, SHIFT4, SHIFT1 // increase all shifts by 8
+ uxtb SHIFT0, SHIFT4, ror #0
+ uxtb SHIFT1, SHIFT4, ror #8
+ .else
+ ldr SHIFT5, [SHIFT0, #4]
+ uadd8 SHIFT4, SHIFT4, SHIFT1 // increase all shifts by 8
+ uadd8 SHIFT5, SHIFT5, SHIFT1
+ .if \channels == 6
+ uxtb SHIFT0, SHIFT4, ror #0
+ uxtb SHIFT1, SHIFT4, ror #8
+ uxtb SHIFT2, SHIFT4, ror #16
+ uxtb SHIFT3, SHIFT4, ror #24
+ uxtb SHIFT4, SHIFT5, ror #0
+ uxtb SHIFT5, SHIFT5, ror #8
+ .endif
+ .endif
+ .set IDX1, \channels
+ .set IDX2, \channels
+0:
+ .rept WORDS_PER_LOOP / 4
+ output4words
+ .endr
+ subs COUNT, COUNT, #SAMPLES_PER_LOOP
+ bne 0b
+ pop {v1-v6,sl,fp,pc}
+ .ltorg
+endfunc
+ .purgem output4words
+
+ .unreq CHECK
+ .unreq COUNT
+ .unreq IN
+ .unreq OUT
+ .unreq DAT0
+ .unreq DAT1
+ .unreq DAT2
+ .unreq DAT3
+ .unreq SHIFT0
+ .unreq SHIFT1
+ .unreq SHIFT2
+ .unreq SHIFT3
+ .unreq SHIFT4
+ .unreq SHIFT5
+
+.else // not mixed
+
+CHECK .req a1
+COUNT .req a2
+IN .req a3
+OUT .req a4
+DAT0 .req v1
+DAT1 .req v2
+DAT2 .req v3
+DAT3 .req v4
+DAT4 .req v5
+DAT5 .req v6
+DAT6 .req sl // use these rather than the otherwise unused
+DAT7 .req fp // ip and lr so that we can load them usinf LDRD
+
+ .macro output4words tail, head, r0, r1, r2, r3, r4, r5, r6, r7, pointer_dead=0
+ .if \head
+ .set SIZE_GROUP1, IDX1
+ .if SIZE_GROUP1 > 4
+ .set SIZE_GROUP1, 4
+ .endif
+ .set SIZE_GROUP2, 4 - SIZE_GROUP1
+ load_group1 SIZE_GROUP1, \channels, \r0, \r1, \r2, \r3, \pointer_dead
+ .endif
+ .if \tail
+ eor CHECK, CHECK, \r4, lsr #8 - (\channels - IDX2)
+ eor CHECK, CHECK, \r5, lsr #7 - (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ .endif
+ .if \head
+ load_group2 SIZE_GROUP2, \channels, \r0, \r1, \r2, \r3, \pointer_dead
+ .endif
+ .if \tail
+ eor CHECK, CHECK, \r6, lsr #8 - (\channels - IDX2)
+ eor CHECK, CHECK, \r7, lsr #7 - (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ stm OUT!, {\r4, \r5, \r6, \r7}
+ .endif
+ .if \head
+ lsl \r0, #8 + \shift
+ lsl \r1, #8 + \shift
+ lsl \r2, #8 + \shift
+ lsl \r3, #8 + \shift
+ .endif
+ .endm
+
+ .set WORDS_PER_LOOP, \channels // calculate LCM (channels, 8)
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP * 8
+ .set SAMPLES_PER_LOOP, WORDS_PER_LOOP / \channels
+
+function ff_mlp_pack_output_inorder_\channels\()ch_\shift\()shift_armv6, export=1
+ .if SAMPLES_PER_LOOP > 1
+ tst COUNT, #SAMPLES_PER_LOOP - 1 // always seems to be in practice
+ it ne
+ bne X(ff_mlp_pack_output) // but just in case, branch to C implementation if not
+ .endif
+ subs COUNT, COUNT, #SAMPLES_PER_LOOP
+ it lo
+ bxlo lr
+ push {v1-v6,sl,fp,lr}
+ .set IDX1, \channels
+ .set IDX2, \channels
+ output4words 0, 1, DAT0, DAT1, DAT2, DAT3, DAT4, DAT5, DAT6, DAT7
+0: beq 1f
+ .rept WORDS_PER_LOOP / 8
+ output4words 1, 1, DAT4, DAT5, DAT6, DAT7, DAT0, DAT1, DAT2, DAT3
+ output4words 1, 1, DAT0, DAT1, DAT2, DAT3, DAT4, DAT5, DAT6, DAT7
+ .endr
+ subs COUNT, COUNT, #SAMPLES_PER_LOOP
+ bne 0b
+1:
+ .rept WORDS_PER_LOOP / 8 - 1
+ output4words 1, 1, DAT4, DAT5, DAT6, DAT7, DAT0, DAT1, DAT2, DAT3
+ output4words 1, 1, DAT0, DAT1, DAT2, DAT3, DAT4, DAT5, DAT6, DAT7
+ .endr
+ output4words 1, 1, DAT4, DAT5, DAT6, DAT7, DAT0, DAT1, DAT2, DAT3, pointer_dead=1
+ output4words 1, 0, DAT0, DAT1, DAT2, DAT3, DAT4, DAT5, DAT6, DAT7
+ pop {v1-v6,sl,fp,pc}
+endfunc
+ .purgem output4words
+
+ .unreq CHECK
+ .unreq COUNT
+ .unreq IN
+ .unreq OUT
+ .unreq DAT0
+ .unreq DAT1
+ .unreq DAT2
+ .unreq DAT3
+ .unreq DAT4
+ .unreq DAT5
+ .unreq DAT6
+ .unreq DAT7
+
+.endif // mixed
+.else // not inorder
+.ifc \shift, mixed
+
+// This case not currently handled
+
+.else // not mixed
+
+#if !CONFIG_THUMB
+
+CHECK .req a1
+COUNT .req a2
+IN .req a3
+OUT .req a4
+DAT0 .req v1
+DAT1 .req v2
+DAT2 .req v3
+DAT3 .req v4
+CHAN0 .req v5
+CHAN1 .req v6
+CHAN2 .req sl
+CHAN3 .req fp
+CHAN4 .req ip
+CHAN5 .req lr
+
+ .macro output4words
+ .if \channels == 8
+ .if IDX1 == 8
+ uxtb CHAN0, CHAN4, ror #0
+ uxtb CHAN1, CHAN4, ror #8
+ uxtb CHAN2, CHAN4, ror #16
+ uxtb CHAN3, CHAN4, ror #24
+ .else
+ uxtb CHAN0, CHAN5, ror #0
+ uxtb CHAN1, CHAN5, ror #8
+ uxtb CHAN2, CHAN5, ror #16
+ uxtb CHAN3, CHAN5, ror #24
+ .endif
+ ldr DAT0, [IN, CHAN0, lsl #2]
+ ldr DAT1, [IN, CHAN1, lsl #2]
+ ldr DAT2, [IN, CHAN2, lsl #2]
+ ldr DAT3, [IN, CHAN3, lsl #2]
+ .if IDX1 == 4
+ add IN, IN, #8*4
+ .endif
+ decr_modulo IDX1, 4, \channels
+ .else
+ .set SIZE_GROUP1, IDX1
+ .if SIZE_GROUP1 > 4
+ .set SIZE_GROUP1, 4
+ .endif
+ .set SIZE_GROUP2, 4 - SIZE_GROUP1
+ .if SIZE_GROUP1 == 2
+ loadregoffsh2 DAT, 0, IN, CHAN, 0 + (\channels - IDX1)
+ loadregoffsh2 DAT, 1, IN, CHAN, 1 + (\channels - IDX1)
+ add IN, IN, #8*4
+ .else // SIZE_GROUP1 == 4
+ loadregoffsh2 DAT, 0, IN, CHAN, 0 + (\channels - IDX1)
+ loadregoffsh2 DAT, 1, IN, CHAN, 1 + (\channels - IDX1)
+ loadregoffsh2 DAT, 2, IN, CHAN, 2 + (\channels - IDX1)
+ loadregoffsh2 DAT, 3, IN, CHAN, 3 + (\channels - IDX1)
+ .if IDX1 == 4
+ add IN, IN, #8*4
+ .endif
+ .endif
+ decr_modulo IDX1, SIZE_GROUP1, \channels
+ .if SIZE_GROUP2 == 2
+ loadregoffsh2 DAT, 2, IN, CHAN, 0 + (\channels - IDX1)
+ loadregoffsh2 DAT, 3, IN, CHAN, 1 + (\channels - IDX1)
+ .if IDX1 == 2
+ add IN, IN, #8*4
+ .endif
+ .endif
+ decr_modulo IDX1, SIZE_GROUP2, \channels
+ .endif
+ .if \channels == 8 // in this case we can corrupt CHAN0-3
+ rsb CHAN0, CHAN0, #8
+ rsb CHAN1, CHAN1, #8
+ rsb CHAN2, CHAN2, #8
+ rsb CHAN3, CHAN3, #8
+ lsl DAT0, #8 + \shift
+ lsl DAT1, #8 + \shift
+ lsl DAT2, #8 + \shift
+ lsl DAT3, #8 + \shift
+ eor CHECK, CHECK, DAT0, lsr CHAN0
+ eor CHECK, CHECK, DAT1, lsr CHAN1
+ eor CHECK, CHECK, DAT2, lsr CHAN2
+ eor CHECK, CHECK, DAT3, lsr CHAN3
+ .else
+ .if \shift != 0
+ lsl DAT0, #\shift
+ lsl DAT1, #\shift
+ lsl DAT2, #\shift
+ lsl DAT3, #\shift
+ .endif
+ bic DAT0, DAT0, #0xff000000
+ bic DAT1, DAT1, #0xff000000
+ bic DAT2, DAT2, #0xff000000
+ bic DAT3, DAT3, #0xff000000
+ eorlslreg CHECK, DAT0, CHAN, 0 + (\channels - IDX2)
+ eorlslreg CHECK, DAT1, CHAN, 1 + (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ eorlslreg CHECK, DAT2, CHAN, 0 + (\channels - IDX2)
+ eorlslreg CHECK, DAT3, CHAN, 1 + (\channels - IDX2)
+ decr_modulo IDX2, 2, \channels
+ lsl DAT0, #8
+ lsl DAT1, #8
+ lsl DAT2, #8
+ lsl DAT3, #8
+ .endif
+ stm OUT!, {DAT0 - DAT3}
+ .endm
+
+ .set WORDS_PER_LOOP, \channels // calculate LCM (channels, 4)
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .if (WORDS_PER_LOOP % 2) == 0
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP / 2
+ .endif
+ .set WORDS_PER_LOOP, WORDS_PER_LOOP * 4
+ .set SAMPLES_PER_LOOP, WORDS_PER_LOOP / \channels
+
+function ff_mlp_pack_output_outoforder_\channels\()ch_\shift\()shift_armv6, export=1
+ .if SAMPLES_PER_LOOP > 1
+ tst COUNT, #SAMPLES_PER_LOOP - 1 // always seems to be in practice
+ it ne
+ bne X(ff_mlp_pack_output) // but just in case, branch to C implementation if not
+ .endif
+ teq COUNT, #0
+ it eq
+ bxeq lr
+ push {v1-v6,sl,fp,lr}
+ ldr CHAN0, [sp, #(9+0)*4] // get ch_assign from stack
+ ldr CHAN4, [CHAN0]
+ .if \channels == 2
+ uxtb CHAN0, CHAN4, ror #0
+ uxtb CHAN1, CHAN4, ror #8
+ .else
+ ldr CHAN5, [CHAN0, #4]
+ .if \channels == 6
+ uxtb CHAN0, CHAN4, ror #0
+ uxtb CHAN1, CHAN4, ror #8
+ uxtb CHAN2, CHAN4, ror #16
+ uxtb CHAN3, CHAN4, ror #24
+ uxtb CHAN4, CHAN5, ror #0
+ uxtb CHAN5, CHAN5, ror #8
+ .endif
+ .endif
+ .set IDX1, \channels
+ .set IDX2, \channels
+0:
+ .rept WORDS_PER_LOOP / 4
+ output4words
+ .endr
+ subs COUNT, COUNT, #SAMPLES_PER_LOOP
+ bne 0b
+ pop {v1-v6,sl,fp,pc}
+ .ltorg
+endfunc
+ .purgem output4words
+
+ .unreq CHECK
+ .unreq COUNT
+ .unreq IN
+ .unreq OUT
+ .unreq DAT0
+ .unreq DAT1
+ .unreq DAT2
+ .unreq DAT3
+ .unreq CHAN0
+ .unreq CHAN1
+ .unreq CHAN2
+ .unreq CHAN3
+ .unreq CHAN4
+ .unreq CHAN5
+
+#endif // !CONFIG_THUMB
+
+.endif // mixed
+.endif // inorder
+.endm // implement_pack
+
+.macro pack_channels inorder, channels
+ implement_pack \inorder, \channels, 0
+ implement_pack \inorder, \channels, 1
+ implement_pack \inorder, \channels, 2
+ implement_pack \inorder, \channels, 3
+ implement_pack \inorder, \channels, 4
+ implement_pack \inorder, \channels, 5
+ implement_pack \inorder, \channels, mixed
+.endm
+
+.macro pack_order inorder
+ pack_channels \inorder, 2
+ pack_channels \inorder, 6
+ pack_channels \inorder, 8
+.endm
+
+ pack_order 0
+ pack_order 1
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_init_arm.c
new file mode 100644
index 00000000000..34a5f61e1d0
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mlpdsp_init_arm.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison <bavison@riscosopen.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/arm/cpu.h"
+#include "libavutil/attributes.h"
+#include "libavcodec/mlpdsp.h"
+
+void ff_mlp_filter_channel_arm(int32_t *state, const int32_t *coeff,
+ int firorder, int iirorder,
+ unsigned int filter_shift, int32_t mask,
+ int blocksize, int32_t *sample_buffer);
+void ff_mlp_rematrix_channel_arm(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t mask);
+
+#define DECLARE_PACK(order,channels,shift) \
+ int32_t ff_mlp_pack_output_##order##order_##channels##ch_##shift##shift_armv6(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int);
+#define ENUMERATE_PACK(order,channels,shift) \
+ ff_mlp_pack_output_##order##order_##channels##ch_##shift##shift_armv6,
+#define PACK_CHANNELS(macro,order,channels) \
+ macro(order,channels,0) \
+ macro(order,channels,1) \
+ macro(order,channels,2) \
+ macro(order,channels,3) \
+ macro(order,channels,4) \
+ macro(order,channels,5) \
+ macro(order,channels,mixed)
+#define PACK_ORDER(macro,order) \
+ PACK_CHANNELS(macro,order,2) \
+ PACK_CHANNELS(macro,order,6) \
+ PACK_CHANNELS(macro,order,8)
+#define PACK_ALL(macro) \
+ PACK_ORDER(macro,outof) \
+ PACK_ORDER(macro,in)
+PACK_ALL(DECLARE_PACK)
+
+#define ff_mlp_pack_output_outoforder_2ch_mixedshift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_mixedshift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_mixedshift_armv6 0
+#if CONFIG_THUMB
+#define ff_mlp_pack_output_outoforder_2ch_0shift_armv6 0
+#define ff_mlp_pack_output_outoforder_2ch_1shift_armv6 0
+#define ff_mlp_pack_output_outoforder_2ch_2shift_armv6 0
+#define ff_mlp_pack_output_outoforder_2ch_3shift_armv6 0
+#define ff_mlp_pack_output_outoforder_2ch_4shift_armv6 0
+#define ff_mlp_pack_output_outoforder_2ch_5shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_0shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_1shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_2shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_3shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_4shift_armv6 0
+#define ff_mlp_pack_output_outoforder_6ch_5shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_0shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_1shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_2shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_3shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_4shift_armv6 0
+#define ff_mlp_pack_output_outoforder_8ch_5shift_armv6 0
+#endif
+
+static int32_t (*mlp_select_pack_output_armv6(uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int)
+{
+ int ch_index;
+ int shift = output_shift[0] < 0 || output_shift[0] > 5 ? 6 : output_shift[0];
+ int inorder = 1;
+ static int32_t (*const routine[2*3*7])(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int) = {
+ PACK_ALL(ENUMERATE_PACK)
+ };
+ int i;
+
+ if (!is32) // don't support 16-bit output (it's not used by TrueHD)
+ return ff_mlp_pack_output;
+
+ switch (max_matrix_channel) {
+ case 1:
+ ch_index = 0;
+ break;
+ case 5:
+ ch_index = 1;
+ break;
+ case 7:
+ ch_index = 2;
+ break;
+ default:
+ return ff_mlp_pack_output;
+ }
+
+ for (i = 0; i <= max_matrix_channel; i++) {
+ if (shift != 6 && output_shift[i] != shift)
+ shift = 6; // indicate mixed shifts
+ if (ch_assign[i] != i)
+ inorder = 0;
+ }
+#if CONFIG_THUMB
+ if (!inorder)
+ return ff_mlp_pack_output; // can't currently handle an order array except in ARM mode
+#else
+ if (shift == 6 && !inorder)
+ return ff_mlp_pack_output; // can't currently handle both an order array and a shift array
+#endif
+
+ return routine[(inorder*3+ch_index)*7+shift];
+}
+
+av_cold void ff_mlpdsp_init_arm(MLPDSPContext *c)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_armv5te(cpu_flags)) {
+ c->mlp_filter_channel = ff_mlp_filter_channel_arm;
+ c->mlp_rematrix_channel = ff_mlp_rematrix_channel_arm;
+ }
+ if (have_armv6(cpu_flags))
+ c->mlp_select_pack_output = mlp_select_pack_output_armv6;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.c
index 656679809b0..5f5473d28c8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/internal.h"
#include "libavutil/arm/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/mpegvideo.h"
@@ -25,12 +26,13 @@
#include "asm-offsets.h"
#if HAVE_NEON
-CHK_OFFS(MpegEncContext, y_dc_scale, Y_DC_SCALE);
-CHK_OFFS(MpegEncContext, c_dc_scale, C_DC_SCALE);
-CHK_OFFS(MpegEncContext, ac_pred, AC_PRED);
-CHK_OFFS(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
-CHK_OFFS(MpegEncContext, inter_scantable.raster_end, INTER_SCANTAB_RASTER_END);
-CHK_OFFS(MpegEncContext, h263_aic, H263_AIC);
+AV_CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE);
+AV_CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE);
+AV_CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED);
+AV_CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
+AV_CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end,
+ INTER_SCANTAB_RASTER_END);
+AV_CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC);
#endif
void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block,
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.h b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.h
index 4ff93b76b9c..78e07e15c50 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_arm.h
@@ -16,11 +16,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_ARM_MPEGVIDEO_H
-#define AVCODEC_ARM_MPEGVIDEO_H
+#ifndef AVCODEC_ARM_MPEGVIDEO_ARM_H
+#define AVCODEC_ARM_MPEGVIDEO_ARM_H
#include "libavcodec/mpegvideo.h"
void ff_MPV_common_init_armv5te(MpegEncContext *s);
-#endif /* AVCODEC_ARM_MPEGVIDEO_H */
+#endif /* AVCODEC_ARM_MPEGVIDEO_ARM_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_neon.S
index e05df8e7113..1889d7a9121 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/mpegvideo_neon.S
@@ -100,7 +100,7 @@ function ff_dct_unquantize_h263_intra_neon, export=1
smulbb r4, r4, r6
2: lsl r0, r3, #1
add r3, r12, #1
- bl ff_dct_unquantize_h263_neon
+ bl X(ff_dct_unquantize_h263_neon)
vmov.16 d0[0], r4
vst1.16 {d0[0]}, [r5]
pop {r4-r6,pc}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/neontest.c b/chromium/third_party/ffmpeg/libavcodec/arm/neontest.c
new file mode 100644
index 00000000000..a3b5b8e2e37
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/neontest.c
@@ -0,0 +1,79 @@
+/*
+ * check NEON registers for clobbers
+ * Copyright (c) 2013 Martin Storsjo
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avcodec.h"
+#include "libavutil/arm/neontest.h"
+
+wrap(avcodec_open2(AVCodecContext *avctx,
+ AVCodec *codec,
+ AVDictionary **options))
+{
+ testneonclobbers(avcodec_open2, avctx, codec, options);
+}
+
+wrap(avcodec_decode_audio4(AVCodecContext *avctx,
+ AVFrame *frame,
+ int *got_frame_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_audio4, avctx, frame,
+ got_frame_ptr, avpkt);
+}
+
+wrap(avcodec_decode_video2(AVCodecContext *avctx,
+ AVFrame *picture,
+ int *got_picture_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_video2, avctx, picture,
+ got_picture_ptr, avpkt);
+}
+
+wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
+ AVSubtitle *sub,
+ int *got_sub_ptr,
+ AVPacket *avpkt))
+{
+ testneonclobbers(avcodec_decode_subtitle2, avctx, sub,
+ got_sub_ptr, avpkt);
+}
+
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+ AVPacket *avpkt,
+ const AVFrame *frame,
+ int *got_packet_ptr))
+{
+ testneonclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+ got_packet_ptr);
+}
+
+wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
+ uint8_t *buf, int buf_size,
+ const AVSubtitle *sub))
+{
+ testneonclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
+}
+
+wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
+ const AVFrame *frame, int *got_packet_ptr))
+{
+ testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/simple_idct_arm.S b/chromium/third_party/ffmpeg/libavcodec/arm/simple_idct_arm.S
index 50d20c99ee7..c6300737a8a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/simple_idct_arm.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/simple_idct_arm.S
@@ -477,3 +477,4 @@ __end_bef_a_evaluation:
sub r4, r6, r11 @ R4=a0-W2*ROWr16[2] (a3)
add r6, r6, r11 @ R6=a0+W2*ROWr16[2] (a0)
bal __end_a_evaluation
+endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_armv6.S b/chromium/third_party/ffmpeg/libavcodec/arm/startcode_armv6.S
index 93dc69b77a0..a46f0093751 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/h264dsp_armv6.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/startcode_armv6.S
@@ -69,8 +69,8 @@ TMP3 .req lr
andseq TMP3, TMP3, PATTERN
.endm
-/* int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size) */
-function ff_h264_find_start_code_candidate_armv6, export=1
+/* int ff_startcode_find_candidate_armv6(const uint8_t *buf, int size) */
+function ff_startcode_find_candidate_armv6, export=1
push {v1-v6,lr}
mov PTR, BUF
@ Ensure there are at least (PRELOAD_DISTANCE+2) complete cachelines to go
@@ -236,7 +236,7 @@ function ff_h264_find_start_code_candidate_armv6, export=1
@ drop through to 98f
98: setend le
99: pop {v1-v6,pc}
-.endfunc
+endfunc
.unreq RESULT
.unreq BUF
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.h b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp.h
index e832de749ab..cd01ac5384b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp.h
@@ -16,12 +16,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifndef AVCODEC_ARM_VC1DSP_H
+#define AVCODEC_ARM_VC1DSP_H
-#ifndef AVCODEC_BFIN_VP3_BFIN_H
-#define AVCODEC_BFIN_VP3_BFIN_H
+#include "libavcodec/vc1dsp.h"
-#include <stdint.h>
+void ff_vc1dsp_init_neon(VC1DSPContext *dsp);
-void ff_bfin_vp3_idct(int16_t *block);
-
-#endif /* AVCODEC_BFIN_VP3_BFIN_H */
+#endif /* AVCODEC_ARM_VC1DSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_arm.c
new file mode 100644
index 00000000000..4a848484631
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_arm.c
@@ -0,0 +1,36 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/arm/cpu.h"
+#include "libavcodec/vc1dsp.h"
+#include "vc1dsp.h"
+
+int ff_startcode_find_candidate_armv6(const uint8_t *buf, int size);
+
+av_cold void ff_vc1dsp_init_arm(VC1DSPContext *dsp)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_armv6(cpu_flags))
+ dsp->vc1_find_start_code_candidate = ff_startcode_find_candidate_armv6;
+ if (have_neon(cpu_flags))
+ ff_vc1dsp_init_neon(dsp);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_neon.c b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_neon.c
new file mode 100644
index 00000000000..3b280770c54
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_init_neon.c
@@ -0,0 +1,119 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavcodec/vc1dsp.h"
+#include "vc1dsp.h"
+
+void ff_vc1_inv_trans_8x8_neon(int16_t *block);
+void ff_vc1_inv_trans_4x8_neon(uint8_t *dest, int linesize, int16_t *block);
+void ff_vc1_inv_trans_8x4_neon(uint8_t *dest, int linesize, int16_t *block);
+void ff_vc1_inv_trans_4x4_neon(uint8_t *dest, int linesize, int16_t *block);
+
+void ff_vc1_inv_trans_8x8_dc_neon(uint8_t *dest, int linesize, int16_t *block);
+void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, int linesize, int16_t *block);
+void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, int linesize, int16_t *block);
+void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, int linesize, int16_t *block);
+
+void ff_put_pixels8x8_neon(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int rnd);
+
+#define DECL_PUT(X, Y) \
+void ff_put_vc1_mspel_mc##X##Y##_neon(uint8_t *dst, const uint8_t *src, \
+ ptrdiff_t stride, int rnd); \
+static void ff_put_vc1_mspel_mc##X##Y##_16_neon(uint8_t *dst, const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ ff_put_vc1_mspel_mc##X##Y##_neon(dst+0, src+0, stride, rnd); \
+ ff_put_vc1_mspel_mc##X##Y##_neon(dst+8, src+8, stride, rnd); \
+ dst += 8*stride; src += 8*stride; \
+ ff_put_vc1_mspel_mc##X##Y##_neon(dst+0, src+0, stride, rnd); \
+ ff_put_vc1_mspel_mc##X##Y##_neon(dst+8, src+8, stride, rnd); \
+}
+
+DECL_PUT(1, 0)
+DECL_PUT(2, 0)
+DECL_PUT(3, 0)
+
+DECL_PUT(0, 1)
+DECL_PUT(0, 2)
+DECL_PUT(0, 3)
+
+DECL_PUT(1, 1)
+DECL_PUT(1, 2)
+DECL_PUT(1, 3)
+
+DECL_PUT(2, 1)
+DECL_PUT(2, 2)
+DECL_PUT(2, 3)
+
+DECL_PUT(3, 1)
+DECL_PUT(3, 2)
+DECL_PUT(3, 3)
+
+void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x, int y);
+
+#define FN_ASSIGN(X, Y) \
+ dsp->put_vc1_mspel_pixels_tab[0][X+4*Y] = ff_put_vc1_mspel_mc##X##Y##_16_neon; \
+ dsp->put_vc1_mspel_pixels_tab[1][X+4*Y] = ff_put_vc1_mspel_mc##X##Y##_neon
+
+av_cold void ff_vc1dsp_init_neon(VC1DSPContext *dsp)
+{
+ dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_neon;
+ dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_neon;
+ dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_neon;
+ dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_neon;
+ dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_neon;
+ dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_neon;
+ dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_neon;
+ dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_neon;
+
+ dsp->put_vc1_mspel_pixels_tab[1][ 0] = ff_put_pixels8x8_neon;
+ FN_ASSIGN(1, 0);
+ FN_ASSIGN(2, 0);
+ FN_ASSIGN(3, 0);
+
+ FN_ASSIGN(0, 1);
+ FN_ASSIGN(1, 1);
+ FN_ASSIGN(2, 1);
+ FN_ASSIGN(3, 1);
+
+ FN_ASSIGN(0, 2);
+ FN_ASSIGN(1, 2);
+ FN_ASSIGN(2, 2);
+ FN_ASSIGN(3, 2);
+
+ FN_ASSIGN(0, 3);
+ FN_ASSIGN(1, 3);
+ FN_ASSIGN(2, 3);
+ FN_ASSIGN(3, 3);
+
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_neon;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_neon;
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_vc1_chroma_mc4_neon;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_vc1_chroma_mc4_neon;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_neon.S
new file mode 100644
index 00000000000..3fba41fa66a
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vc1dsp_neon.S
@@ -0,0 +1,1170 @@
+/*
+ * VC1 NEON optimisations
+ *
+ * Copyright (c) 2010 Rob Clark <rob@ti.com>
+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+#include "neon.S"
+
+@ Transpose rows into columns of a matrix of 16-bit elements. For 4x4, pass
+@ double-word registers, for 8x4, pass quad-word registers.
+.macro transpose16 r0, r1, r2, r3
+ @ At this point:
+ @ row[0] r0
+ @ row[1] r1
+ @ row[2] r2
+ @ row[3] r3
+
+ vtrn.16 \r0, \r1 @ first and second row
+ vtrn.16 \r2, \r3 @ third and fourth row
+ vtrn.32 \r0, \r2 @ first and third row
+ vtrn.32 \r1, \r3 @ second and fourth row
+
+ @ At this point, if registers are quad-word:
+ @ column[0] d0
+ @ column[1] d2
+ @ column[2] d4
+ @ column[3] d6
+ @ column[4] d1
+ @ column[5] d3
+ @ column[6] d5
+ @ column[7] d7
+
+ @ At this point, if registers are double-word:
+ @ column[0] d0
+ @ column[1] d1
+ @ column[2] d2
+ @ column[3] d3
+.endm
+
+@ ff_vc1_inv_trans_{4,8}x{4,8}_neon and overflow: The input values in the file
+@ are supposed to be in a specific range as to allow for 16-bit math without
+@ causing overflows, but sometimes the input values are just big enough to
+@ barely cause overflow in vadd instructions like:
+@
+@ vadd.i16 q0, q8, q10
+@ vshr.s16 q0, q0, #\rshift
+@
+@ To prevent these borderline cases from overflowing, we just need one more
+@ bit of precision, which is accomplished by replacing the sequence above with:
+@
+@ vhadd.s16 q0, q8, q10
+@ vshr.s16 q0, q0, #(\rshift -1)
+@
+@ This works because vhadd is a single instruction that adds, then shifts to
+@ the right once, all before writing the result to the destination register.
+@
+@ Even with this workaround, there were still some files that caused overflows
+@ in ff_vc1_inv_trans_8x8_neon. See the comments in ff_vc1_inv_trans_8x8_neon
+@ for the additional workaround.
+
+@ Takes 4 columns of 8 values each and operates on it. Modeled after the first
+@ for loop in vc1_inv_trans_4x8_c.
+@ Input columns: q0 q1 q2 q3
+@ Output columns: q0 q1 q2 q3
+@ Trashes: r12 q8 q9 q10 q11 q12 q13
+.macro vc1_inv_trans_4x8_helper add rshift
+ @ Compute temp1, temp2 and setup scalar #17, #22, #10
+ vadd.i16 q12, q0, q2 @ temp1 = src[0] + src[2]
+ movw r12, #17
+ vsub.i16 q13, q0, q2 @ temp2 = src[0] - src[2]
+ movt r12, #22
+ vmov.32 d0[0], r12
+ movw r12, #10
+ vmov.16 d1[0], r12
+
+ vmov.i16 q8, #\add @ t1 will accumulate here
+ vmov.i16 q9, #\add @ t2 will accumulate here
+
+ vmul.i16 q10, q1, d0[1] @ t3 = 22 * (src[1])
+ vmul.i16 q11, q3, d0[1] @ t4 = 22 * (src[3])
+
+ vmla.i16 q8, q12, d0[0] @ t1 = 17 * (temp1) + 4
+ vmla.i16 q9, q13, d0[0] @ t2 = 17 * (temp2) + 4
+
+ vmla.i16 q10, q3, d1[0] @ t3 += 10 * src[3]
+ vmls.i16 q11, q1, d1[0] @ t4 -= 10 * src[1]
+
+ vhadd.s16 q0, q8, q10 @ dst[0] = (t1 + t3) >> 1
+ vhsub.s16 q3, q8, q10 @ dst[3] = (t1 - t3) >> 1
+ vhsub.s16 q1, q9, q11 @ dst[1] = (t2 - t4) >> 1
+ vhadd.s16 q2, q9, q11 @ dst[2] = (t2 + t4) >> 1
+
+ @ Halving add/sub above already did one shift
+ vshr.s16 q0, q0, #(\rshift - 1) @ dst[0] >>= (rshift - 1)
+ vshr.s16 q3, q3, #(\rshift - 1) @ dst[3] >>= (rshift - 1)
+ vshr.s16 q1, q1, #(\rshift - 1) @ dst[1] >>= (rshift - 1)
+ vshr.s16 q2, q2, #(\rshift - 1) @ dst[2] >>= (rshift - 1)
+.endm
+
+@ Takes 8 columns of 4 values each and operates on it. Modeled after the second
+@ for loop in vc1_inv_trans_4x8_c.
+@ Input columns: d0 d2 d4 d6 d1 d3 d5 d7
+@ Output columns: d16 d17 d18 d19 d21 d20 d23 d22
+@ Trashes all NEON registers (and r12) except for: q4 q5 q6 q7
+.macro vc1_inv_trans_8x4_helper add add1beforeshift rshift
+ @ At this point:
+ @ src[0] d0 overwritten later
+ @ src[8] d2
+ @ src[16] d4 overwritten later
+ @ src[24] d6
+ @ src[32] d1 overwritten later
+ @ src[40] d3
+ @ src[48] d5 overwritten later
+ @ src[56] d7
+
+ movw r12, #12
+ vmov.i16 q14, #\add @ t1|t2 will accumulate here
+ movt r12, #6
+
+ vadd.i16 d20, d0, d1 @ temp1 = src[0] + src[32]
+ vsub.i16 d21, d0, d1 @ temp2 = src[0] - src[32]
+ vmov.i32 d0[0], r12 @ 16-bit: d0[0] = #12, d0[1] = #6
+
+ vshl.i16 q15, q2, #4 @ t3|t4 = 16 * (src[16]|src[48])
+ vswp d4, d5 @ q2 = src[48]|src[16]
+ vmla.i16 q14, q10, d0[0] @ t1|t2 = 12 * (temp1|temp2) + 64
+ movw r12, #15
+ movt r12, #9
+ vmov.i32 d0[1], r12 @ 16-bit: d0[2] = #15, d0[3] = #9
+ vneg.s16 d31, d31 @ t4 = -t4
+ vmla.i16 q15, q2, d0[1] @ t3|t4 += 6 * (src[48]|src[16])
+
+ @ At this point:
+ @ d0[2] #15
+ @ d0[3] #9
+ @ q1 src[8]|src[40]
+ @ q3 src[24]|src[56]
+ @ q14 old t1|t2
+ @ q15 old t3|t4
+
+ vshl.i16 q8, q1, #4 @ t1|t2 = 16 * (src[8]|src[40])
+ vswp d2, d3 @ q1 = src[40]|src[8]
+ vshl.i16 q12, q3, #4 @ temp3a|temp4a = 16 * src[24]|src[56]
+ vswp d6, d7 @ q3 = src[56]|src[24]
+ vshl.i16 q13, q1, #2 @ temp3b|temp4b = 4 * (src[40]|src[8])
+ vshl.i16 q2, q3, #2 @ temp1|temp2 = 4 * (src[56]|src[24])
+ vswp d3, d6 @ q1 = src[40]|src[56], q3 = src[8]|src[24]
+ vsub.i16 q9, q13, q12 @ t3|t4 = - (temp3a|temp4a) + (temp3b|temp4b)
+ vadd.i16 q8, q8, q2 @ t1|t2 += temp1|temp2
+ vmul.i16 q12, q3, d0[3] @ temp3|temp4 = 9 * src[8]|src[24]
+ vmla.i16 q8, q1, d0[3] @ t1|t2 += 9 * (src[40]|src[56])
+ vswp d6, d7 @ q3 = src[24]|src[8]
+ vswp d2, d3 @ q1 = src[56]|src[40]
+
+ vsub.i16 q11, q14, q15 @ t8|t7 = old t1|t2 - old t3|t4
+ vadd.i16 q10, q14, q15 @ t5|t6 = old t1|t2 + old t3|t4
+ .if \add1beforeshift
+ vmov.i16 q15, #1
+ .endif
+
+ vadd.i16 d18, d18, d24 @ t3 += temp3
+ vsub.i16 d19, d19, d25 @ t4 -= temp4
+
+ vswp d22, d23 @ q11 = t7|t8
+
+ vneg.s16 d17, d17 @ t2 = -t2
+ vmla.i16 q9, q1, d0[2] @ t3|t4 += 15 * src[56]|src[40]
+ vmla.i16 q8, q3, d0[2] @ t1|t2 += 15 * src[24]|src[8]
+
+ @ At this point:
+ @ t1 d16
+ @ t2 d17
+ @ t3 d18
+ @ t4 d19
+ @ t5 d20
+ @ t6 d21
+ @ t7 d22
+ @ t8 d23
+ @ #1 q15
+
+ .if \add1beforeshift
+ vadd.i16 q3, q15, q10 @ line[7,6] = t5|t6 + 1
+ vadd.i16 q2, q15, q11 @ line[5,4] = t7|t8 + 1
+ .endif
+
+ @ Sometimes this overflows, so to get one additional bit of precision, use
+ @ a single instruction that both adds and shifts right (halving).
+ vhadd.s16 q1, q9, q11 @ line[2,3] = (t3|t4 + t7|t8) >> 1
+ vhadd.s16 q0, q8, q10 @ line[0,1] = (t1|t2 + t5|t6) >> 1
+ .if \add1beforeshift
+ vhsub.s16 q2, q2, q9 @ line[5,4] = (t7|t8 - t3|t4 + 1) >> 1
+ vhsub.s16 q3, q3, q8 @ line[7,6] = (t5|t6 - t1|t2 + 1) >> 1
+ .else
+ vhsub.s16 q2, q11, q9 @ line[5,4] = (t7|t8 - t3|t4) >> 1
+ vhsub.s16 q3, q10, q8 @ line[7,6] = (t5|t6 - t1|t2) >> 1
+ .endif
+
+ vshr.s16 q9, q1, #(\rshift - 1) @ one shift is already done by vhadd/vhsub above
+ vshr.s16 q8, q0, #(\rshift - 1)
+ vshr.s16 q10, q2, #(\rshift - 1)
+ vshr.s16 q11, q3, #(\rshift - 1)
+
+ @ At this point:
+ @ dst[0] d16
+ @ dst[1] d17
+ @ dst[2] d18
+ @ dst[3] d19
+ @ dst[4] d21
+ @ dst[5] d20
+ @ dst[6] d23
+ @ dst[7] d22
+.endm
+
+@ This is modeled after the first and second for loop in vc1_inv_trans_8x8_c.
+@ Input columns: q8, q9, q10, q11, q12, q13, q14, q15
+@ Output columns: q8, q9, q10, q11, q12, q13, q14, q15
+@ Trashes all NEON registers (and r12) except for: q4 q5 q6 q7
+.macro vc1_inv_trans_8x8_helper add add1beforeshift rshift
+ @ This actually computes half of t1, t2, t3, t4, as explained below
+ @ near `tNhalf`.
+ vmov.i16 q0, #(6 / 2) @ q0 = #6/2
+ vshl.i16 q1, q10, #3 @ t3 = 16/2 * src[16]
+ vshl.i16 q3, q14, #3 @ temp4 = 16/2 * src[48]
+ vmul.i16 q2, q10, q0 @ t4 = 6/2 * src[16]
+ vmla.i16 q1, q14, q0 @ t3 += 6/2 * src[48]
+ @ unused: q0, q10, q14
+ vmov.i16 q0, #(12 / 2) @ q0 = #12/2
+ vadd.i16 q10, q8, q12 @ temp1 = src[0] + src[32]
+ vsub.i16 q14, q8, q12 @ temp2 = src[0] - src[32]
+ @ unused: q8, q12
+ vmov.i16 q8, #(\add / 2) @ t1 will accumulate here
+ vmov.i16 q12, #(\add / 2) @ t2 will accumulate here
+ movw r12, #15
+ vsub.i16 q2, q2, q3 @ t4 = 6/2 * src[16] - 16/2 * src[48]
+ movt r12, #9
+ @ unused: q3
+ vmla.i16 q8, q10, q0 @ t1 = 12/2 * temp1 + add
+ vmla.i16 q12, q14, q0 @ t2 = 12/2 * temp2 + add
+ vmov.i32 d0[0], r12
+ @ unused: q3, q10, q14
+
+ @ At this point:
+ @ q0 d0=#15|#9
+ @ q1 old t3
+ @ q2 old t4
+ @ q3
+ @ q8 old t1
+ @ q9 src[8]
+ @ q10
+ @ q11 src[24]
+ @ q12 old t2
+ @ q13 src[40]
+ @ q14
+ @ q15 src[56]
+
+ @ unused: q3, q10, q14
+ movw r12, #16
+ vshl.i16 q3, q9, #4 @ t1 = 16 * src[8]
+ movt r12, #4
+ vshl.i16 q10, q9, #2 @ t4 = 4 * src[8]
+ vmov.i32 d1[0], r12
+ vmul.i16 q14, q9, d0[0] @ t2 = 15 * src[8]
+ vmul.i16 q9, q9, d0[1] @ t3 = 9 * src[8]
+ @ unused: none
+ vmla.i16 q3, q11, d0[0] @ t1 += 15 * src[24]
+ vmls.i16 q10, q11, d0[1] @ t4 -= 9 * src[24]
+ vmls.i16 q14, q11, d1[1] @ t2 -= 4 * src[24]
+ vmls.i16 q9, q11, d1[0] @ t3 -= 16 * src[24]
+ @ unused: q11
+ vmla.i16 q3, q13, d0[1] @ t1 += 9 * src[40]
+ vmla.i16 q10, q13, d0[0] @ t4 += 15 * src[40]
+ vmls.i16 q14, q13, d1[0] @ t2 -= 16 * src[40]
+ vmla.i16 q9, q13, d1[1] @ t3 += 4 * src[40]
+ @ unused: q11, q13
+
+ @ Compute t5, t6, t7, t8 from old t1, t2, t3, t4. Actually, it computes
+ @ half of t5, t6, t7, t8 since t1, t2, t3, t4 are halved.
+ vadd.i16 q11, q8, q1 @ t5 = t1 + t3
+ vsub.i16 q1, q8, q1 @ t8 = t1 - t3
+ vadd.i16 q13, q12, q2 @ t6 = t2 + t4
+ vsub.i16 q2, q12, q2 @ t7 = t2 - t4
+ @ unused: q8, q12
+
+ .if \add1beforeshift
+ vmov.i16 q12, #1
+ .endif
+
+ @ unused: q8
+ vmla.i16 q3, q15, d1[1] @ t1 += 4 * src[56]
+ vmls.i16 q14, q15, d0[1] @ t2 -= 9 * src[56]
+ vmla.i16 q9, q15, d0[0] @ t3 += 15 * src[56]
+ vmls.i16 q10, q15, d1[0] @ t4 -= 16 * src[56]
+ @ unused: q0, q8, q15
+
+ @ At this point:
+ @ t1 q3
+ @ t2 q14
+ @ t3 q9
+ @ t4 q10
+ @ t5half q11
+ @ t6half q13
+ @ t7half q2
+ @ t8half q1
+ @ #1 q12
+ @
+ @ tNhalf is half of the value of tN (as described in vc1_inv_trans_8x8_c).
+ @ This is done because sometimes files have input that causes tN + tM to
+ @ overflow. To avoid this overflow, we compute tNhalf, then compute
+ @ tNhalf + tM (which doesn't overflow), and then we use vhadd to compute
+ @ (tNhalf + (tNhalf + tM)) >> 1 which does not overflow because it is
+ @ one instruction.
+
+ @ For each pair of tN and tM, do:
+ @ lineA = t5half + t1
+ @ if add1beforeshift: t1 -= 1
+ @ lineA = (t5half + lineA) >> 1
+ @ lineB = t5half - t1
+ @ lineB = (t5half + lineB) >> 1
+ @ lineA >>= rshift - 1
+ @ lineB >>= rshift - 1
+
+ vadd.i16 q8, q11, q3 @ q8 = t5half + t1
+ .if \add1beforeshift
+ vsub.i16 q3, q3, q12 @ q3 = t1 - 1
+ .endif
+
+ vadd.i16 q0, q13, q14 @ q0 = t6half + t2
+ .if \add1beforeshift
+ vsub.i16 q14, q14, q12 @ q14 = t2 - 1
+ .endif
+
+ vadd.i16 q15, q2, q9 @ q15 = t7half + t3
+ .if \add1beforeshift
+ vsub.i16 q9, q9, q12 @ q9 = t3 - 1
+ .endif
+ @ unused: none
+
+ vhadd.s16 q8, q11, q8 @ q8 = (t5half + t5half + t1) >> 1
+ vsub.i16 q3, q11, q3 @ q3 = t5half - t1 + 1
+
+ vhadd.s16 q0, q13, q0 @ q0 = (t6half + t6half + t2) >> 1
+ vsub.i16 q14, q13, q14 @ q14 = t6half - t2 + 1
+
+ vhadd.s16 q15, q2, q15 @ q15 = (t7half + t7half + t3) >> 1
+ vsub.i16 q9, q2, q9 @ q9 = t7half - t3 + 1
+
+ vhadd.s16 q3, q11, q3 @ q3 = (t5half + t5half - t1 + 1) >> 1
+ @ unused: q11
+
+ vadd.i16 q11, q1, q10 @ q11 = t8half + t4
+ .if \add1beforeshift
+ vsub.i16 q10, q10, q12 @ q10 = t4 - 1
+ .endif
+ @ unused: q12
+
+ vhadd.s16 q14, q13, q14 @ q14 = (t6half + t6half - t2 + 1) >> 1
+ @ unused: q12, q13
+ vhadd.s16 q13, q2, q9 @ q9 = (t7half + t7half - t3 + 1) >> 1
+ @ unused: q12, q2, q9
+
+ vsub.i16 q10, q1, q10 @ q10 = t8half - t4 + 1
+ vhadd.s16 q11, q1, q11 @ q11 = (t8half + t8half + t4) >> 1
+
+ vshr.s16 q8, q8, #(\rshift - 1) @ q8 = line[0]
+ vhadd.s16 q12, q1, q10 @ q12 = (t8half + t8half - t4 + 1) >> 1
+ vshr.s16 q9, q0, #(\rshift - 1) @ q9 = line[1]
+ vshr.s16 q10, q15, #(\rshift - 1) @ q10 = line[2]
+ vshr.s16 q11, q11, #(\rshift - 1) @ q11 = line[3]
+ vshr.s16 q12, q12, #(\rshift - 1) @ q12 = line[4]
+ vshr.s16 q13, q13, #(\rshift - 1) @ q13 = line[5]
+ vshr.s16 q14, q14, #(\rshift - 1) @ q14 = line[6]
+ vshr.s16 q15, q3, #(\rshift - 1) @ q15 = line[7]
+.endm
+
+@ (int16_t *block [r0])
+function ff_vc1_inv_trans_8x8_neon, export=1
+ vld1.64 {q8-q9}, [r0,:128]!
+ vld1.64 {q10-q11}, [r0,:128]!
+ vld1.64 {q12-q13}, [r0,:128]!
+ vld1.64 {q14-q15}, [r0,:128]
+ sub r0, r0, #(16 * 2 * 3) @ restore r0
+
+ @ At this point:
+ @ src[0] q8
+ @ src[8] q9
+ @ src[16] q10
+ @ src[24] q11
+ @ src[32] q12
+ @ src[40] q13
+ @ src[48] q14
+ @ src[56] q15
+
+ vc1_inv_trans_8x8_helper add=4 add1beforeshift=0 rshift=3
+
+ @ Transpose result matrix of 8x8
+ swap4 d17, d19, d21, d23, d24, d26, d28, d30
+ transpose16_4x4 q8, q9, q10, q11, q12, q13, q14, q15
+
+ vc1_inv_trans_8x8_helper add=64 add1beforeshift=1 rshift=7
+
+ vst1.64 {q8-q9}, [r0,:128]!
+ vst1.64 {q10-q11}, [r0,:128]!
+ vst1.64 {q12-q13}, [r0,:128]!
+ vst1.64 {q14-q15}, [r0,:128]
+
+ bx lr
+endfunc
+
+@ (uint8_t *dest [r0], int linesize [r1], int16_t *block [r2])
+function ff_vc1_inv_trans_8x4_neon, export=1
+ vld1.64 {q0-q1}, [r2,:128]! @ load 8 * 4 * 2 = 64 bytes / 16 bytes per quad = 4 quad registers
+ vld1.64 {q2-q3}, [r2,:128]
+
+ transpose16 q0 q1 q2 q3 @ transpose rows to columns
+
+ @ At this point:
+ @ src[0] d0
+ @ src[1] d2
+ @ src[2] d4
+ @ src[3] d6
+ @ src[4] d1
+ @ src[5] d3
+ @ src[6] d5
+ @ src[7] d7
+
+ vc1_inv_trans_8x4_helper add=4 add1beforeshift=0 rshift=3
+
+ @ Move output to more standardized registers
+ vmov d0, d16
+ vmov d2, d17
+ vmov d4, d18
+ vmov d6, d19
+ vmov d1, d21
+ vmov d3, d20
+ vmov d5, d23
+ vmov d7, d22
+
+ @ At this point:
+ @ dst[0] d0
+ @ dst[1] d2
+ @ dst[2] d4
+ @ dst[3] d6
+ @ dst[4] d1
+ @ dst[5] d3
+ @ dst[6] d5
+ @ dst[7] d7
+
+ transpose16 q0 q1 q2 q3 @ turn columns into rows
+
+ @ At this point:
+ @ row[0] q0
+ @ row[1] q1
+ @ row[2] q2
+ @ row[3] q3
+
+ vc1_inv_trans_4x8_helper add=64 rshift=7
+
+ @ At this point:
+ @ line[0].l d0
+ @ line[0].h d1
+ @ line[1].l d2
+ @ line[1].h d3
+ @ line[2].l d4
+ @ line[2].h d5
+ @ line[3].l d6
+ @ line[3].h d7
+
+ @ unused registers: q12, q13, q14, q15
+
+ vld1.64 {d28}, [r0,:64], r1 @ read dest
+ vld1.64 {d29}, [r0,:64], r1
+ vld1.64 {d30}, [r0,:64], r1
+ vld1.64 {d31}, [r0,:64], r1
+ sub r0, r0, r1, lsl #2 @ restore original r0 value
+
+ vaddw.u8 q0, q0, d28 @ line[0] += dest[0]
+ vaddw.u8 q1, q1, d29 @ line[1] += dest[1]
+ vaddw.u8 q2, q2, d30 @ line[2] += dest[2]
+ vaddw.u8 q3, q3, d31 @ line[3] += dest[3]
+
+ vqmovun.s16 d0, q0 @ line[0]
+ vqmovun.s16 d1, q1 @ line[1]
+ vqmovun.s16 d2, q2 @ line[2]
+ vqmovun.s16 d3, q3 @ line[3]
+
+ vst1.64 {d0}, [r0,:64], r1 @ write dest
+ vst1.64 {d1}, [r0,:64], r1
+ vst1.64 {d2}, [r0,:64], r1
+ vst1.64 {d3}, [r0,:64]
+
+ bx lr
+endfunc
+
+@ (uint8_t *dest [r0], int linesize [r1], int16_t *block [r2])
+function ff_vc1_inv_trans_4x8_neon, export=1
+ mov r12, #(8 * 2) @ 8 elements per line, each element 2 bytes
+ vld4.16 {d0[], d2[], d4[], d6[]}, [r2,:64], r12 @ read each column into a q register
+ vld4.16 {d0[1], d2[1], d4[1], d6[1]}, [r2,:64], r12
+ vld4.16 {d0[2], d2[2], d4[2], d6[2]}, [r2,:64], r12
+ vld4.16 {d0[3], d2[3], d4[3], d6[3]}, [r2,:64], r12
+ vld4.16 {d1[], d3[], d5[], d7[]}, [r2,:64], r12
+ vld4.16 {d1[1], d3[1], d5[1], d7[1]}, [r2,:64], r12
+ vld4.16 {d1[2], d3[2], d5[2], d7[2]}, [r2,:64], r12
+ vld4.16 {d1[3], d3[3], d5[3], d7[3]}, [r2,:64]
+
+ vc1_inv_trans_4x8_helper add=4 rshift=3
+
+ @ At this point:
+ @ dst[0] = q0
+ @ dst[1] = q1
+ @ dst[2] = q2
+ @ dst[3] = q3
+
+ transpose16 q0 q1 q2 q3 @ Transpose rows (registers) into columns
+
+ vc1_inv_trans_8x4_helper add=64 add1beforeshift=1 rshift=7
+
+ vld1.32 {d28[]}, [r0,:32], r1 @ read dest
+ vld1.32 {d28[1]}, [r0,:32], r1
+ vld1.32 {d29[]}, [r0,:32], r1
+ vld1.32 {d29[1]}, [r0,:32], r1
+
+ vld1.32 {d30[]}, [r0,:32], r1
+ vld1.32 {d30[0]}, [r0,:32], r1
+ vld1.32 {d31[]}, [r0,:32], r1
+ vld1.32 {d31[0]}, [r0,:32], r1
+ sub r0, r0, r1, lsl #3 @ restore original r0 value
+
+ vaddw.u8 q8, q8, d28 @ line[0,1] += dest[0,1]
+ vaddw.u8 q9, q9, d29 @ line[2,3] += dest[2,3]
+ vaddw.u8 q10, q10, d30 @ line[5,4] += dest[5,4]
+ vaddw.u8 q11, q11, d31 @ line[7,6] += dest[7,6]
+
+ vqmovun.s16 d16, q8 @ clip(line[0,1])
+ vqmovun.s16 d18, q9 @ clip(line[2,3])
+ vqmovun.s16 d20, q10 @ clip(line[5,4])
+ vqmovun.s16 d22, q11 @ clip(line[7,6])
+
+ vst1.32 {d16[0]}, [r0,:32], r1 @ write dest
+ vst1.32 {d16[1]}, [r0,:32], r1
+ vst1.32 {d18[0]}, [r0,:32], r1
+ vst1.32 {d18[1]}, [r0,:32], r1
+
+ vst1.32 {d20[1]}, [r0,:32], r1
+ vst1.32 {d20[0]}, [r0,:32], r1
+ vst1.32 {d22[1]}, [r0,:32], r1
+ vst1.32 {d22[0]}, [r0,:32]
+
+ bx lr
+endfunc
+
+@ Setup constants in registers which are used by vc1_inv_trans_4x4_helper
+.macro vc1_inv_trans_4x4_helper_setup
+ vmov.i16 q13, #17
+ vmov.i16 q14, #22
+ vmov.i16 d30, #10 @ only need double-word, not quad-word
+.endm
+
+@ This is modeled after the first for loop in vc1_inv_trans_4x4_c.
+.macro vc1_inv_trans_4x4_helper add rshift
+ vmov.i16 q2, #\add @ t1|t2 will accumulate here
+
+ vadd.i16 d16, d0, d1 @ temp1 = src[0] + src[2]
+ vsub.i16 d17, d0, d1 @ temp2 = src[0] - src[2]
+ vmul.i16 q3, q14, q1 @ t3|t4 = 22 * (src[1]|src[3])
+ vmla.i16 q2, q13, q8 @ t1|t2 = 17 * (temp1|temp2) + add
+ vmla.i16 d6, d30, d3 @ t3 += 10 * src[3]
+ vmls.i16 d7, d30, d2 @ t4 -= 10 * src[1]
+
+ vadd.i16 q0, q2, q3 @ dst[0,2] = (t1|t2 + t3|t4)
+ vsub.i16 q1, q2, q3 @ dst[3,1] = (t1|t2 - t3|t4)
+ vshr.s16 q0, q0, #\rshift @ dst[0,2] >>= rshift
+ vshr.s16 q1, q1, #\rshift @ dst[3,1] >>= rshift
+.endm
+
+@ (uint8_t *dest [r0], int linesize [r1], int16_t *block [r2])
+function ff_vc1_inv_trans_4x4_neon, export=1
+ mov r12, #(8 * 2) @ 8 elements per line, each element 2 bytes
+ vld4.16 {d0[], d1[], d2[], d3[]}, [r2,:64], r12 @ read each column into a register
+ vld4.16 {d0[1], d1[1], d2[1], d3[1]}, [r2,:64], r12
+ vld4.16 {d0[2], d1[2], d2[2], d3[2]}, [r2,:64], r12
+ vld4.16 {d0[3], d1[3], d2[3], d3[3]}, [r2,:64]
+
+ vswp d1, d2 @ so that we can later access column 1 and column 3 as a single q1 register
+
+ vc1_inv_trans_4x4_helper_setup
+
+ @ At this point:
+ @ src[0] = d0
+ @ src[1] = d2
+ @ src[2] = d1
+ @ src[3] = d3
+
+ vc1_inv_trans_4x4_helper add=4 rshift=3 @ compute t1, t2, t3, t4 and combine them into dst[0-3]
+
+ @ At this point:
+ @ dst[0] = d0
+ @ dst[1] = d3
+ @ dst[2] = d1
+ @ dst[3] = d2
+
+ transpose16 d0 d3 d1 d2 @ Transpose rows (registers) into columns
+
+ @ At this point:
+ @ src[0] = d0
+ @ src[8] = d3
+ @ src[16] = d1
+ @ src[24] = d2
+
+ vswp d2, d3 @ so that we can later access column 1 and column 3 in order as a single q1 register
+
+ @ At this point:
+ @ src[0] = d0
+ @ src[8] = d2
+ @ src[16] = d1
+ @ src[24] = d3
+
+ vc1_inv_trans_4x4_helper add=64 rshift=7 @ compute t1, t2, t3, t4 and combine them into dst[0-3]
+
+ @ At this point:
+ @ line[0] = d0
+ @ line[1] = d3
+ @ line[2] = d1
+ @ line[3] = d2
+
+ vld1.32 {d18[]}, [r0,:32], r1 @ read dest
+ vld1.32 {d19[]}, [r0,:32], r1
+ vld1.32 {d18[1]}, [r0,:32], r1
+ vld1.32 {d19[0]}, [r0,:32], r1
+ sub r0, r0, r1, lsl #2 @ restore original r0 value
+
+ vaddw.u8 q0, q0, d18 @ line[0,2] += dest[0,2]
+ vaddw.u8 q1, q1, d19 @ line[3,1] += dest[3,1]
+
+ vqmovun.s16 d0, q0 @ clip(line[0,2])
+ vqmovun.s16 d1, q1 @ clip(line[3,1])
+
+ vst1.32 {d0[0]}, [r0,:32], r1 @ write dest
+ vst1.32 {d1[1]}, [r0,:32], r1
+ vst1.32 {d0[1]}, [r0,:32], r1
+ vst1.32 {d1[0]}, [r0,:32]
+
+ bx lr
+endfunc
+
+@ The absolute value of multiplication constants from vc1_mspel_filter and vc1_mspel_{ver,hor}_filter_16bits.
+@ The sign is embedded in the code below that carries out the multiplication (mspel_filter{,.16}).
+#define MSPEL_MODE_1_MUL_CONSTANTS 4 53 18 3
+#define MSPEL_MODE_2_MUL_CONSTANTS 1 9 9 1
+#define MSPEL_MODE_3_MUL_CONSTANTS 3 18 53 4
+
+@ These constants are from reading the source code of vc1_mspel_mc and determining the value that
+@ is added to `rnd` to result in the variable `r`, and the value of the variable `shift`.
+#define MSPEL_MODES_11_ADDSHIFT_CONSTANTS 15 5
+#define MSPEL_MODES_12_ADDSHIFT_CONSTANTS 3 3
+#define MSPEL_MODES_13_ADDSHIFT_CONSTANTS 15 5
+#define MSPEL_MODES_21_ADDSHIFT_CONSTANTS MSPEL_MODES_12_ADDSHIFT_CONSTANTS
+#define MSPEL_MODES_22_ADDSHIFT_CONSTANTS 0 1
+#define MSPEL_MODES_23_ADDSHIFT_CONSTANTS 3 3
+#define MSPEL_MODES_31_ADDSHIFT_CONSTANTS MSPEL_MODES_13_ADDSHIFT_CONSTANTS
+#define MSPEL_MODES_32_ADDSHIFT_CONSTANTS MSPEL_MODES_23_ADDSHIFT_CONSTANTS
+#define MSPEL_MODES_33_ADDSHIFT_CONSTANTS 15 5
+
+@ The addition and shift constants from vc1_mspel_filter.
+#define MSPEL_MODE_1_ADDSHIFT_CONSTANTS 32 6
+#define MSPEL_MODE_2_ADDSHIFT_CONSTANTS 8 4
+#define MSPEL_MODE_3_ADDSHIFT_CONSTANTS 32 6
+
+@ Setup constants in registers for a subsequent use of mspel_filter{,.16}.
+.macro mspel_constants typesize reg_a reg_b reg_c reg_d filter_a filter_b filter_c filter_d reg_add filter_add_register
+ @ Define double-word register aliases. Typesize should be i8 or i16.
+ ra .dn \reg_a\().\typesize
+ rb .dn \reg_b\().\typesize
+ rc .dn \reg_c\().\typesize
+ rd .dn \reg_d\().\typesize
+
+ @ Only set the register if the value is not 1 and unique
+ .if \filter_a != 1
+ vmov ra, #\filter_a @ ra = filter_a
+ .endif
+ vmov rb, #\filter_b @ rb = filter_b
+ .if \filter_b != \filter_c
+ vmov rc, #\filter_c @ rc = filter_c
+ .endif
+ .if \filter_d != 1
+ vmov rd, #\filter_d @ rd = filter_d
+ .endif
+ @ vdup to double the size of typesize
+ .ifc \typesize,i8
+ vdup.16 \reg_add, \filter_add_register @ reg_add = filter_add_register
+ .else
+ vdup.32 \reg_add, \filter_add_register @ reg_add = filter_add_register
+ .endif
+
+ .unreq ra
+ .unreq rb
+ .unreq rc
+ .unreq rd
+.endm
+
+@ After mspel_constants has been used, do the filtering.
+.macro mspel_filter acc dest src0 src1 src2 src3 filter_a filter_b filter_c filter_d reg_a reg_b reg_c reg_d reg_add filter_shift narrow=1
+ .if \filter_a != 1
+ @ If filter_a != 1, then we need a move and subtract instruction
+ vmov \acc, \reg_add @ acc = reg_add
+ vmlsl.u8 \acc, \reg_a, \src0 @ acc -= filter_a * src[-stride]
+ .else
+ @ If filter_a is 1, then just subtract without an extra move
+ vsubw.u8 \acc, \reg_add, \src0 @ acc = reg_add - src[-stride] @ since filter_a == 1
+ .endif
+ vmlal.u8 \acc, \reg_b, \src1 @ acc += filter_b * src[0]
+ .if \filter_b != \filter_c
+ vmlal.u8 \acc, \reg_c, \src2 @ acc += filter_c * src[stride]
+ .else
+ @ If filter_b is the same as filter_c, use the same reg_b register
+ vmlal.u8 \acc, \reg_b, \src2 @ acc += filter_c * src[stride] @ where filter_c == filter_b
+ .endif
+ .if \filter_d != 1
+ @ If filter_d != 1, then do a multiply accumulate
+ vmlsl.u8 \acc, \reg_d, \src3 @ acc -= filter_d * src[stride * 2]
+ .else
+ @ If filter_d is 1, then just do a subtract
+ vsubw.u8 \acc, \acc, \src3 @ acc -= src[stride * 2] @ since filter_d == 1
+ .endif
+ .if \narrow
+ vqshrun.s16 \dest, \acc, #\filter_shift @ dest = clip_uint8(acc >> filter_shift)
+ .else
+ vshr.s16 \dest, \acc, #\filter_shift @ dest = acc >> filter_shift
+ .endif
+.endm
+
+@ This is similar to mspel_filter, but the input is 16-bit instead of 8-bit and narrow=0 is not supported.
+.macro mspel_filter.16 acc0 acc1 acc0_0 acc0_1 dest src0 src1 src2 src3 src4 src5 src6 src7 filter_a filter_b filter_c filter_d reg_a reg_b reg_c reg_d reg_add filter_shift
+ .if \filter_a != 1
+ vmov \acc0, \reg_add
+ vmov \acc1, \reg_add
+ vmlsl.s16 \acc0, \reg_a, \src0
+ vmlsl.s16 \acc1, \reg_a, \src1
+ .else
+ vsubw.s16 \acc0, \reg_add, \src0
+ vsubw.s16 \acc1, \reg_add, \src1
+ .endif
+ vmlal.s16 \acc0, \reg_b, \src2
+ vmlal.s16 \acc1, \reg_b, \src3
+ .if \filter_b != \filter_c
+ vmlal.s16 \acc0, \reg_c, \src4
+ vmlal.s16 \acc1, \reg_c, \src5
+ .else
+ vmlal.s16 \acc0, \reg_b, \src4
+ vmlal.s16 \acc1, \reg_b, \src5
+ .endif
+ .if \filter_d != 1
+ vmlsl.s16 \acc0, \reg_d, \src6
+ vmlsl.s16 \acc1, \reg_d, \src7
+ .else
+ vsubw.s16 \acc0, \acc0, \src6
+ vsubw.s16 \acc1, \acc1, \src7
+ .endif
+ @ Use acc0_0 and acc0_1 as temp space
+ vqshrun.s32 \acc0_0, \acc0, #\filter_shift @ Shift and narrow with saturation from s32 to u16
+ vqshrun.s32 \acc0_1, \acc1, #\filter_shift
+ vqmovn.u16 \dest, \acc0 @ Narrow with saturation from u16 to u8
+.endm
+
+@ Register usage for put_vc1_mspel_mc functions. Registers marked 'hv' are only used in put_vc1_mspel_mc_hv.
+@
+@ r0 adjusted dst
+@ r1 adjusted src
+@ r2 stride
+@ r3 adjusted rnd
+@ r4 [hv] tmp
+@ r11 [hv] sp saved
+@ r12 loop counter
+@ d0 src[-stride]
+@ d1 src[0]
+@ d2 src[stride]
+@ d3 src[stride * 2]
+@ q0 [hv] src[-stride]
+@ q1 [hv] src[0]
+@ q2 [hv] src[stride]
+@ q3 [hv] src[stride * 2]
+@ d21 often result from mspel_filter
+@ q11 accumulator 0
+@ q12 [hv] accumulator 1
+@ q13 accumulator initial value
+@ d28 filter_a
+@ d29 filter_b
+@ d30 filter_c
+@ d31 filter_d
+
+@ (uint8_t *dst [r0], const uint8_t *src [r1], ptrdiff_t stride [r2], int rnd [r3])
+.macro put_vc1_mspel_mc_hv hmode vmode filter_h_a filter_h_b filter_h_c filter_h_d filter_v_a filter_v_b filter_v_c filter_v_d filter_add filter_shift
+function ff_put_vc1_mspel_mc\hmode\()\vmode\()_neon, export=1
+ push {r4, r11, lr}
+ mov r11, sp @ r11 = stack pointer before realignmnet
+A bic sp, sp, #15 @ sp = round down to multiple of 16 bytes
+T bic r4, r11, #15
+T mov sp, r4
+ sub sp, sp, #(8*2*16) @ make space for 8 rows * 2 byte per element * 16 elements per row (to fit 11 actual elements per row)
+ mov r4, sp @ r4 = int16_t tmp[8 * 16]
+
+ sub r1, r1, #1 @ src -= 1
+ .if \filter_add != 0
+ add r3, r3, #\filter_add @ r3 = filter_add + rnd
+ .endif
+ mov r12, #8 @ loop counter
+ sub r1, r1, r2 @ r1 = &src[-stride] @ slide back
+
+ @ Do vertical filtering from src into tmp
+ mspel_constants i8 d28 d29 d30 d31 \filter_v_a \filter_v_b \filter_v_c \filter_v_d q13 r3
+
+ vld1.64 {d0,d1}, [r1], r2
+ vld1.64 {d2,d3}, [r1], r2
+ vld1.64 {d4,d5}, [r1], r2
+
+1:
+ subs r12, r12, #4
+
+ vld1.64 {d6,d7}, [r1], r2
+ mspel_filter q11 q11 d0 d2 d4 d6 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ mspel_filter q12 q12 d1 d3 d5 d7 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ vst1.64 {q11,q12}, [r4,:128]! @ store and increment
+
+ vld1.64 {d0,d1}, [r1], r2
+ mspel_filter q11 q11 d2 d4 d6 d0 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ mspel_filter q12 q12 d3 d5 d7 d1 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ vst1.64 {q11,q12}, [r4,:128]! @ store and increment
+
+ vld1.64 {d2,d3}, [r1], r2
+ mspel_filter q11 q11 d4 d6 d0 d2 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ mspel_filter q12 q12 d5 d7 d1 d3 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ vst1.64 {q11,q12}, [r4,:128]! @ store and increment
+
+ vld1.64 {d4,d5}, [r1], r2
+ mspel_filter q11 q11 d6 d0 d2 d4 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ mspel_filter q12 q12 d7 d1 d3 d5 \filter_v_a \filter_v_b \filter_v_c \filter_v_d d28 d29 d30 d31 q13 \filter_shift narrow=0
+ vst1.64 {q11,q12}, [r4,:128]! @ store and increment
+
+ bne 1b
+
+ rsb r3, r3, #(64 + \filter_add) @ r3 = (64 + filter_add) - r3
+ mov r12, #8 @ loop counter
+ mov r4, sp @ r4 = tmp
+
+ @ Do horizontal filtering from temp to dst
+ mspel_constants i16 d28 d29 d30 d31 \filter_h_a \filter_h_b \filter_h_c \filter_h_d q13 r3
+
+2:
+ subs r12, r12, #1
+
+ vld1.64 {q0,q1}, [r4,:128]! @ read one line of tmp
+ vext.16 q2, q0, q1, #2
+ vext.16 q3, q0, q1, #3
+ vext.16 q1, q0, q1, #1 @ do last because it writes to q1 which is read by the other vext instructions
+
+ mspel_filter.16 q11 q12 d22 d23 d21 d0 d1 d2 d3 d4 d5 d6 d7 \filter_h_a \filter_h_b \filter_h_c \filter_h_d d28 d29 d30 d31 q13 7
+
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ bne 2b
+
+ mov sp, r11
+ pop {r4, r11, pc}
+endfunc
+.endm
+
+@ Use C preprocessor and assembler macros to expand to functions for horizontal and vertical filtering.
+#define PUT_VC1_MSPEL_MC_HV(hmode, vmode) \
+ put_vc1_mspel_mc_hv hmode vmode \
+ MSPEL_MODE_ ## hmode ## _MUL_CONSTANTS \
+ MSPEL_MODE_ ## vmode ## _MUL_CONSTANTS \
+ MSPEL_MODES_ ## hmode ## vmode ## _ADDSHIFT_CONSTANTS
+
+PUT_VC1_MSPEL_MC_HV(1, 1)
+PUT_VC1_MSPEL_MC_HV(1, 2)
+PUT_VC1_MSPEL_MC_HV(1, 3)
+PUT_VC1_MSPEL_MC_HV(2, 1)
+PUT_VC1_MSPEL_MC_HV(2, 2)
+PUT_VC1_MSPEL_MC_HV(2, 3)
+PUT_VC1_MSPEL_MC_HV(3, 1)
+PUT_VC1_MSPEL_MC_HV(3, 2)
+PUT_VC1_MSPEL_MC_HV(3, 3)
+
+#undef PUT_VC1_MSPEL_MC_HV
+
+.macro put_vc1_mspel_mc_h_only hmode filter_a filter_b filter_c filter_d filter_add filter_shift
+function ff_put_vc1_mspel_mc\hmode\()0_neon, export=1
+ rsb r3, r3, #\filter_add @ r3 = filter_add - r = filter_add - rnd
+ mov r12, #8 @ loop counter
+ sub r1, r1, #1 @ slide back, using immediate
+
+ mspel_constants i8 d28 d29 d30 d31 \filter_a \filter_b \filter_c \filter_d q13 r3
+
+1:
+ subs r12, r12, #1
+
+ vld1.64 {d0,d1}, [r1], r2 @ read 16 bytes even though we only need 11, also src += stride
+ vext.8 d2, d0, d1, #2
+ vext.8 d3, d0, d1, #3
+ vext.8 d1, d0, d1, #1 @ do last because it writes to d1 which is read by the other vext instructions
+
+ mspel_filter q11 d21 d0 d1 d2 d3 \filter_a \filter_b \filter_c \filter_d d28 d29 d30 d31 q13 \filter_shift
+
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ bne 1b
+
+ bx lr
+endfunc
+.endm
+
+@ Use C preprocessor and assembler macros to expand to functions for horizontal only filtering.
+#define PUT_VC1_MSPEL_MC_H_ONLY(hmode) \
+ put_vc1_mspel_mc_h_only hmode MSPEL_MODE_ ## hmode ## _MUL_CONSTANTS MSPEL_MODE_ ## hmode ## _ADDSHIFT_CONSTANTS
+
+PUT_VC1_MSPEL_MC_H_ONLY(1)
+PUT_VC1_MSPEL_MC_H_ONLY(2)
+PUT_VC1_MSPEL_MC_H_ONLY(3)
+
+#undef PUT_VC1_MSPEL_MC_H_ONLY
+
+@ (uint8_t *dst [r0], const uint8_t *src [r1], ptrdiff_t stride [r2], int rnd [r3])
+.macro put_vc1_mspel_mc_v_only vmode filter_a filter_b filter_c filter_d filter_add filter_shift
+function ff_put_vc1_mspel_mc0\vmode\()_neon, export=1
+ add r3, r3, #\filter_add - 1 @ r3 = filter_add - r = filter_add - (1 - rnd) = filter_add - 1 + rnd
+ mov r12, #8 @ loop counter
+ sub r1, r1, r2 @ r1 = &src[-stride] @ slide back
+
+ mspel_constants i8 d28 d29 d30 d31 \filter_a \filter_b \filter_c \filter_d q13 r3
+
+ vld1.64 {d0}, [r1], r2 @ d0 = src[-stride]
+ vld1.64 {d1}, [r1], r2 @ d1 = src[0]
+ vld1.64 {d2}, [r1], r2 @ d2 = src[stride]
+
+1:
+ subs r12, r12, #4
+
+ vld1.64 {d3}, [r1], r2 @ d3 = src[stride * 2]
+ mspel_filter q11 d21 d0 d1 d2 d3 \filter_a \filter_b \filter_c \filter_d d28 d29 d30 d31 q13 \filter_shift
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ vld1.64 {d0}, [r1], r2 @ d0 = next line
+ mspel_filter q11 d21 d1 d2 d3 d0 \filter_a \filter_b \filter_c \filter_d d28 d29 d30 d31 q13 \filter_shift
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ vld1.64 {d1}, [r1], r2 @ d1 = next line
+ mspel_filter q11 d21 d2 d3 d0 d1 \filter_a \filter_b \filter_c \filter_d d28 d29 d30 d31 q13 \filter_shift
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ vld1.64 {d2}, [r1], r2 @ d2 = next line
+ mspel_filter q11 d21 d3 d0 d1 d2 \filter_a \filter_b \filter_c \filter_d d28 d29 d30 d31 q13 \filter_shift
+ vst1.64 {d21}, [r0,:64], r2 @ store and increment dst
+
+ bne 1b
+
+ bx lr
+endfunc
+.endm
+
+@ Use C preprocessor and assembler macros to expand to functions for vertical only filtering.
+#define PUT_VC1_MSPEL_MC_V_ONLY(vmode) \
+ put_vc1_mspel_mc_v_only vmode MSPEL_MODE_ ## vmode ## _MUL_CONSTANTS MSPEL_MODE_ ## vmode ## _ADDSHIFT_CONSTANTS
+
+PUT_VC1_MSPEL_MC_V_ONLY(1)
+PUT_VC1_MSPEL_MC_V_ONLY(2)
+PUT_VC1_MSPEL_MC_V_ONLY(3)
+
+#undef PUT_VC1_MSPEL_MC_V_ONLY
+
+function ff_put_pixels8x8_neon, export=1
+ vld1.64 {d0}, [r1], r2
+ vld1.64 {d1}, [r1], r2
+ vld1.64 {d2}, [r1], r2
+ vld1.64 {d3}, [r1], r2
+ vld1.64 {d4}, [r1], r2
+ vld1.64 {d5}, [r1], r2
+ vld1.64 {d6}, [r1], r2
+ vld1.64 {d7}, [r1]
+ vst1.64 {d0}, [r0,:64], r2
+ vst1.64 {d1}, [r0,:64], r2
+ vst1.64 {d2}, [r0,:64], r2
+ vst1.64 {d3}, [r0,:64], r2
+ vst1.64 {d4}, [r0,:64], r2
+ vst1.64 {d5}, [r0,:64], r2
+ vst1.64 {d6}, [r0,:64], r2
+ vst1.64 {d7}, [r0,:64]
+ bx lr
+endfunc
+
+function ff_vc1_inv_trans_8x8_dc_neon, export=1
+ ldrsh r2, [r2] @ int dc = block[0];
+
+ vld1.64 {d0}, [r0,:64], r1
+ vld1.64 {d1}, [r0,:64], r1
+ vld1.64 {d4}, [r0,:64], r1
+ vld1.64 {d5}, [r0,:64], r1
+
+ add r2, r2, r2, lsl #1 @ dc = (3 * dc + 1) >> 1;
+ vld1.64 {d6}, [r0,:64], r1
+ add r2, r2, #1
+ vld1.64 {d7}, [r0,:64], r1
+ vld1.64 {d16}, [r0,:64], r1
+ vld1.64 {d17}, [r0,:64], r1
+ asr r2, r2, #1
+
+ sub r0, r0, r1, lsl #3 @ restore r0 to original value
+
+ add r2, r2, r2, lsl #1 @ dc = (3 * dc + 16) >> 5;
+ add r2, r2, #16
+ asr r2, r2, #5
+
+ vdup.16 q1, r2 @ dc
+
+ vaddw.u8 q9, q1, d0
+ vaddw.u8 q10, q1, d1
+ vaddw.u8 q11, q1, d4
+ vaddw.u8 q12, q1, d5
+ vqmovun.s16 d0, q9
+ vqmovun.s16 d1, q10
+ vqmovun.s16 d4, q11
+ vst1.64 {d0}, [r0,:64], r1
+ vqmovun.s16 d5, q12
+ vst1.64 {d1}, [r0,:64], r1
+ vaddw.u8 q13, q1, d6
+ vst1.64 {d4}, [r0,:64], r1
+ vaddw.u8 q14, q1, d7
+ vst1.64 {d5}, [r0,:64], r1
+ vaddw.u8 q15, q1, d16
+ vaddw.u8 q1, q1, d17 @ this destroys q1
+ vqmovun.s16 d6, q13
+ vqmovun.s16 d7, q14
+ vqmovun.s16 d16, q15
+ vqmovun.s16 d17, q1
+ vst1.64 {d6}, [r0,:64], r1
+ vst1.64 {d7}, [r0,:64], r1
+ vst1.64 {d16}, [r0,:64], r1
+ vst1.64 {d17}, [r0,:64]
+ bx lr
+endfunc
+
+function ff_vc1_inv_trans_8x4_dc_neon, export=1
+ ldrsh r2, [r2] @ int dc = block[0];
+
+ vld1.64 {d0}, [r0,:64], r1
+ vld1.64 {d1}, [r0,:64], r1
+ vld1.64 {d4}, [r0,:64], r1
+ vld1.64 {d5}, [r0,:64], r1
+
+ add r2, r2, r2, lsl #1 @ dc = ( 3 * dc + 1) >> 1;
+
+ sub r0, r0, r1, lsl #2 @ restore r0 to original value
+
+ add r2, r2, #1
+ asr r2, r2, #1
+
+ add r2, r2, r2, lsl #4 @ dc = (17 * dc + 64) >> 7;
+ add r2, r2, #64
+ asr r2, r2, #7
+
+ vdup.16 q1, r2 @ dc
+
+ vaddw.u8 q3, q1, d0
+ vaddw.u8 q8, q1, d1
+ vaddw.u8 q9, q1, d4
+ vaddw.u8 q10, q1, d5
+ vqmovun.s16 d0, q3
+ vqmovun.s16 d1, q8
+ vqmovun.s16 d4, q9
+ vst1.64 {d0}, [r0,:64], r1
+ vqmovun.s16 d5, q10
+ vst1.64 {d1}, [r0,:64], r1
+ vst1.64 {d4}, [r0,:64], r1
+ vst1.64 {d5}, [r0,:64]
+ bx lr
+endfunc
+
+function ff_vc1_inv_trans_4x8_dc_neon, export=1
+ ldrsh r2, [r2] @ int dc = block[0];
+
+ vld1.32 {d0[]}, [r0,:32], r1
+ vld1.32 {d1[]}, [r0,:32], r1
+ vld1.32 {d0[1]}, [r0,:32], r1
+ vld1.32 {d1[1]}, [r0,:32], r1
+
+ add r2, r2, r2, lsl #4 @ dc = (17 * dc + 4) >> 3;
+ vld1.32 {d4[]}, [r0,:32], r1
+ add r2, r2, #4
+ vld1.32 {d5[]}, [r0,:32], r1
+ vld1.32 {d4[1]}, [r0,:32], r1
+ asr r2, r2, #3
+ vld1.32 {d5[1]}, [r0,:32], r1
+
+ add r2, r2, r2, lsl #1 @ dc = (12 * dc + 64) >> 7;
+
+ sub r0, r0, r1, lsl #3 @ restore r0 to original value
+
+ lsl r2, r2, #2
+ add r2, r2, #64
+ asr r2, r2, #7
+
+ vdup.16 q1, r2 @ dc
+
+ vaddw.u8 q3, q1, d0
+ vaddw.u8 q8, q1, d1
+ vaddw.u8 q9, q1, d4
+ vaddw.u8 q10, q1, d5
+ vqmovun.s16 d0, q3
+ vst1.32 {d0[0]}, [r0,:32], r1
+ vqmovun.s16 d1, q8
+ vst1.32 {d1[0]}, [r0,:32], r1
+ vqmovun.s16 d4, q9
+ vst1.32 {d0[1]}, [r0,:32], r1
+ vqmovun.s16 d5, q10
+ vst1.32 {d1[1]}, [r0,:32], r1
+ vst1.32 {d4[0]}, [r0,:32], r1
+ vst1.32 {d5[0]}, [r0,:32], r1
+ vst1.32 {d4[1]}, [r0,:32], r1
+ vst1.32 {d5[1]}, [r0,:32]
+ bx lr
+endfunc
+
+function ff_vc1_inv_trans_4x4_dc_neon, export=1
+ ldrsh r2, [r2] @ int dc = block[0];
+
+ vld1.32 {d0[]}, [r0,:32], r1
+ vld1.32 {d1[]}, [r0,:32], r1
+ vld1.32 {d0[1]}, [r0,:32], r1
+ vld1.32 {d1[1]}, [r0,:32], r1
+
+ add r2, r2, r2, lsl #4 @ dc = (17 * dc + 4) >> 3;
+
+ sub r0, r0, r1, lsl #2 @ restore r0 to original value
+
+ add r2, r2, #4
+ asr r2, r2, #3
+
+ add r2, r2, r2, lsl #4 @ dc = (17 * dc + 64) >> 7;
+ add r2, r2, #64
+ asr r2, r2, #7
+
+ vdup.16 q1, r2 @ dc
+
+ vaddw.u8 q2, q1, d0
+ vaddw.u8 q3, q1, d1
+ vqmovun.s16 d0, q2
+ vst1.32 {d0[0]}, [r0,:32], r1
+ vqmovun.s16 d1, q3
+ vst1.32 {d1[0]}, [r0,:32], r1
+ vst1.32 {d0[1]}, [r0,:32], r1
+ vst1.32 {d1[1]}, [r0,:32]
+ bx lr
+endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/videodsp_armv5te.S b/chromium/third_party/ffmpeg/libavcodec/arm/videodsp_armv5te.S
index 48a6c3ba83b..55bcce5cb65 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/videodsp_armv5te.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/videodsp_armv5te.S
@@ -1,5 +1,5 @@
@
-@ ARMv5te optimized DSP utils
+@ ARMv5te-optimized core video DSP functions
@ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
@
@ This file is part of FFmpeg
@@ -26,6 +26,6 @@ function ff_prefetch_arm, export=1
subs r2, r2, #1
pld [r0]
add r0, r0, r1
- bne ff_prefetch_arm
+ bne X(ff_prefetch_arm)
bx lr
endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_init_arm.c
index 5af795bc29a..d9246365dfe 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_init_arm.c
@@ -21,12 +21,11 @@
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
-#include "libavcodec/dsputil.h"
#include "libavcodec/vp3dsp.h"
void ff_vp3_idct_put_neon(uint8_t *dest, int line_size, int16_t *data);
void ff_vp3_idct_add_neon(uint8_t *dest, int line_size, int16_t *data);
-void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, const int16_t *data);
+void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, int16_t *data);
void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *);
void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_neon.S
index f133905efec..2942d488f54 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp3dsp_neon.S
@@ -355,7 +355,7 @@ function ff_vp3_idct_dc_add_neon, export=1
mov r3, r0
add r12, r12, #15
vdup.16 q15, r12
- mov r12, 0
+ mov r12, #0
strh r12, [r2]
vshr.s16 q15, q15, #5
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8.h b/chromium/third_party/ffmpeg/libavcodec/arm/vp8.h
index ddaa1203fd4..965342d93bd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8.h
@@ -26,7 +26,7 @@
#include "libavcodec/vp8.h"
#if HAVE_ARMV6_EXTERNAL
-#define decode_block_coeffs_internal ff_decode_block_coeffs_armv6
+#define vp8_decode_block_coeffs_internal ff_decode_block_coeffs_armv6
int ff_decode_block_coeffs_armv6(VP56RangeCoder *rc, int16_t block[16],
uint8_t probs[8][3][NUM_DCT_TOKENS-1],
int i, uint8_t *token_prob, int16_t qmul[2]);
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp.h b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp.h
index 6041ef13d12..7281d0bfb13 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp.h
@@ -21,6 +21,8 @@
#include "libavcodec/vp8dsp.h"
+void ff_vp78dsp_init_armv6(VP8DSPContext *dsp);
+void ff_vp78dsp_init_neon(VP8DSPContext *dsp);
void ff_vp8dsp_init_armv6(VP8DSPContext *dsp);
void ff_vp8dsp_init_neon(VP8DSPContext *dsp);
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_armv6.S b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_armv6.S
index a14b188b21a..1adcbbdbb10 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_armv6.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_armv6.S
@@ -359,14 +359,14 @@ endfunc
function ff_vp8_idct_dc_add4uv_armv6, export=1
push {r4, lr}
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, r2, lsl #2
sub r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
pop {r4, pc}
endfunc
@@ -375,13 +375,13 @@ endfunc
function ff_vp8_idct_dc_add4y_armv6, export=1
push {r4, lr}
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
add r0, r0, #4
- bl ff_vp8_idct_dc_add_armv6
+ bl X(ff_vp8_idct_dc_add_armv6)
pop {r4, pc}
endfunc
@@ -1204,7 +1204,7 @@ function ff_put_vp8_\name\size\()_\hv\()_armv6, export=1
mov r4, #\size
stm r12, {r4, r5}
orr r12, r6, r7
- b vp8_put_\name\()_\hv\()_armv6 + 4
+ b bl_put_\name\()_\hv\()_armv6
endfunc
.endm
@@ -1300,6 +1300,7 @@ vp8_mc_hv bilin, 4, h, v, 2
function vp8_put_epel_h6_armv6
push {r1, r4-r11, lr}
+bl_put_epel_h6_armv6:
sub r2, r2, #2
movrel lr, sixtap_filters_13245600 - 16
add lr, lr, r12, lsl #3
@@ -1358,6 +1359,7 @@ endfunc
function vp8_put_epel_v6_armv6
push {r1, r4-r11, lr}
+bl_put_epel_v6_armv6:
movrel lr, sixtap_filters_13245600 - 16
add lr, lr, r12, lsl #3
str r3, [sp, #48]
@@ -1437,6 +1439,7 @@ endfunc
function vp8_put_epel_h4_armv6
push {r1, r4-r11, lr}
+bl_put_epel_h4_armv6:
subs r2, r2, #1
movrel lr, fourtap_filters_1324 - 4
add lr, lr, r12, lsl #2
@@ -1483,6 +1486,7 @@ endfunc
function vp8_put_epel_v4_armv6
push {r1, r4-r11, lr}
+bl_put_epel_v4_armv6:
movrel lr, fourtap_filters_1324 - 4
add lr, lr, r12, lsl #2
ldm lr, {r5, r6}
@@ -1544,6 +1548,7 @@ endfunc
function vp8_put_bilin_h_armv6
push {r1, r4-r11, lr}
+bl_put_bilin_h_armv6:
rsb r5, r12, r12, lsl #16
ldr r12, [sp, #44]
sub r3, r3, r4
@@ -1589,6 +1594,7 @@ endfunc
function vp8_put_bilin_v_armv6
push {r1, r4-r11, lr}
+bl_put_bilin_v_armv6:
rsb r5, r12, r12, lsl #16
ldr r12, [sp, #44]
add r5, r5, #8
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c
index d360ae3e6dc..8b801766d7a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_arm.c
@@ -23,6 +23,16 @@
#include "libavcodec/vp8dsp.h"
#include "vp8dsp.h"
+av_cold void ff_vp78dsp_init_arm(VP8DSPContext *dsp)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_armv6(cpu_flags))
+ ff_vp78dsp_init_armv6(dsp);
+ if (have_neon(cpu_flags))
+ ff_vp78dsp_init_neon(dsp);
+}
+
av_cold void ff_vp8dsp_init_arm(VP8DSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_armv6.c b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_armv6.c
index 563268e862a..a5bcd733e0f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_armv6.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_armv6.c
@@ -40,29 +40,8 @@ VP8_BILIN(16, armv6);
VP8_BILIN(8, armv6);
VP8_BILIN(4, armv6);
-av_cold void ff_vp8dsp_init_armv6(VP8DSPContext *dsp)
+av_cold void ff_vp78dsp_init_armv6(VP8DSPContext *dsp)
{
- dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_armv6;
- dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_armv6;
-
- dsp->vp8_idct_add = ff_vp8_idct_add_armv6;
- dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_armv6;
- dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_armv6;
- dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_armv6;
-
- dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_armv6;
- dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_armv6;
- dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_armv6;
- dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_armv6;
-
- dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_armv6;
- dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_armv6;
- dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_armv6;
- dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_armv6;
-
- dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_armv6;
- dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_armv6;
-
dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_armv6;
dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_armv6;
dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_armv6;
@@ -118,3 +97,27 @@ av_cold void ff_vp8dsp_init_armv6(VP8DSPContext *dsp)
dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_armv6;
dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_armv6;
}
+
+av_cold void ff_vp8dsp_init_armv6(VP8DSPContext *dsp)
+{
+ dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_armv6;
+ dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_armv6;
+
+ dsp->vp8_idct_add = ff_vp8_idct_add_armv6;
+ dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_armv6;
+ dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_armv6;
+ dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_armv6;
+
+ dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_armv6;
+ dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_armv6;
+ dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_armv6;
+ dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_armv6;
+
+ dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_armv6;
+ dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_armv6;
+ dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_armv6;
+ dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_armv6;
+
+ dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_armv6;
+ dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_armv6;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_neon.c b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_neon.c
index ae045a63f24..53f1f233801 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_neon.c
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_init_neon.c
@@ -39,28 +39,8 @@ VP8_BILIN(16, neon);
VP8_BILIN(8, neon);
VP8_BILIN(4, neon);
-av_cold void ff_vp8dsp_init_neon(VP8DSPContext *dsp)
+av_cold void ff_vp78dsp_init_neon(VP8DSPContext *dsp)
{
- dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_neon;
-
- dsp->vp8_idct_add = ff_vp8_idct_add_neon;
- dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_neon;
- dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_neon;
- dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_neon;
-
- dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_neon;
- dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_neon;
- dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_neon;
- dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_neon;
-
- dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_neon;
- dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_neon;
- dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_neon;
- dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_neon;
-
- dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_neon;
- dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_neon;
-
dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_neon;
dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_neon;
dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_neon;
@@ -114,3 +94,26 @@ av_cold void ff_vp8dsp_init_neon(VP8DSPContext *dsp)
dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_neon;
dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_neon;
}
+
+av_cold void ff_vp8dsp_init_neon(VP8DSPContext *dsp)
+{
+ dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_neon;
+
+ dsp->vp8_idct_add = ff_vp8_idct_add_neon;
+ dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_neon;
+ dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_neon;
+ dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_neon;
+
+ dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_neon;
+ dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_neon;
+ dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_neon;
+ dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_neon;
+
+ dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_neon;
+ dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_neon;
+ dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_neon;
+ dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_neon;
+
+ dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_neon;
+ dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_neon;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_neon.S b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_neon.S
index 436b340330b..5319346951b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_neon.S
+++ b/chromium/third_party/ffmpeg/libavcodec/arm/vp8dsp_neon.S
@@ -1576,12 +1576,11 @@ endconst
/* Bilinear MC */
function ff_put_vp8_bilin16_h_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
1:
subs r12, r12, #2
vld1.8 {d2-d4}, [r2], r3
@@ -1604,16 +1603,15 @@ function ff_put_vp8_bilin16_h_neon, export=1
vst1.8 {q3}, [r0,:128], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin16_v_neon, export=1
- push {lr}
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.8 {q1}, [r2], r3
1:
subs r12, r12, #2
@@ -1635,20 +1633,19 @@ function ff_put_vp8_bilin16_v_neon, export=1
vst1.8 {q3}, [r0,:128], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin16_hv_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d2, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d2, r12
+ rsb r12, r12, #8
vdup.8 d3, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.8 {d4-d6}, [r2], r3
vext.8 q3, q2, q3, #1
@@ -1692,16 +1689,15 @@ function ff_put_vp8_bilin16_hv_neon, export=1
vst1.8 {q10}, [r0,:128], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin8_h_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
1:
subs r12, r12, #2
vld1.8 {q1}, [r2], r3
@@ -1718,16 +1714,15 @@ function ff_put_vp8_bilin8_h_neon, export=1
vst1.8 {d16}, [r0,:64], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin8_v_neon, export=1
- push {lr}
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.8 {d2}, [r2], r3
1:
subs r12, r12, #2
@@ -1743,20 +1738,19 @@ function ff_put_vp8_bilin8_v_neon, export=1
vst1.8 {d6}, [r0,:64], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin8_hv_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d2, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d2, r12
+ rsb r12, r12, #8
vdup.8 d3, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.8 {q2}, [r2], r3
vext.8 d5, d4, d5, #1
@@ -1785,16 +1779,15 @@ function ff_put_vp8_bilin8_hv_neon, export=1
vst1.8 {d23}, [r0,:64], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin4_h_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
1:
subs r12, r12, #2
vld1.8 {d2}, [r2], r3
@@ -1809,16 +1802,15 @@ function ff_put_vp8_bilin4_h_neon, export=1
vst1.32 {d4[1]}, [r0,:32], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin4_v_neon, export=1
- push {lr}
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.32 {d2[]}, [r2], r3
1:
vld1.32 {d3[]}, [r2]
@@ -1833,20 +1825,19 @@ function ff_put_vp8_bilin4_v_neon, export=1
subs r12, r12, #2
bgt 1b
- pop {pc}
+ bx lr
endfunc
function ff_put_vp8_bilin4_hv_neon, export=1
- push {lr}
- ldr lr, [sp, #8] @ mx
- rsb r12, lr, #8
- vdup.8 d0, lr
+ ldr r12, [sp, #4] @ mx
+ vdup.8 d0, r12
+ rsb r12, r12, #8
vdup.8 d1, r12
- ldr lr, [sp, #12] @ my
- rsb r12, lr, #8
- vdup.8 d2, lr
+ ldr r12, [sp, #8] @ my
+ vdup.8 d2, r12
+ rsb r12, r12, #8
vdup.8 d3, r12
- ldr r12, [sp, #4] @ h
+ ldr r12, [sp] @ h
vld1.8 {d4}, [r2], r3
vext.8 d5, d4, d4, #1
@@ -1872,5 +1863,5 @@ function ff_put_vp8_bilin4_hv_neon, export=1
vst1.32 {d20[1]}, [r0,:32], r1
bgt 1b
- pop {pc}
+ bx lr
endfunc
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac1data.h b/chromium/third_party/ffmpeg/libavcodec/atrac1data.h
index 08f835747a7..62c218b7906 100644
--- a/chromium/third_party/ffmpeg/libavcodec/atrac1data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac1data.h
@@ -43,7 +43,7 @@ static const uint8_t bfu_bands_t[4] = {0, 20, 36, 52};
*/
static const uint8_t specs_per_bfu[52] = {
8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, // low band
- 6, 6, 6, 6, 7, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, // midle band
+ 6, 6, 6, 6, 7, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, // middle band
12, 12, 12, 12, 12, 12, 12, 12, 20, 20, 20, 20, 20, 20, 20, 20 // high band
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac3plus.c b/chromium/third_party/ffmpeg/libavcodec/atrac3plus.c
new file mode 100644
index 00000000000..08c90cde98b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac3plus.c
@@ -0,0 +1,1818 @@
+/*
+ * ATRAC3+ compatible decoder
+ *
+ * Copyright (c) 2010-2013 Maxim Poliakovski
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Bitstream parser for ATRAC3+ decoder.
+ */
+
+#include "libavutil/avassert.h"
+#include "avcodec.h"
+#include "get_bits.h"
+#include "atrac3plus.h"
+#include "atrac3plus_data.h"
+
+static VLC_TYPE tables_data[154276][2];
+static VLC wl_vlc_tabs[4];
+static VLC sf_vlc_tabs[8];
+static VLC ct_vlc_tabs[4];
+static VLC spec_vlc_tabs[112];
+static VLC gain_vlc_tabs[11];
+static VLC tone_vlc_tabs[7];
+
+#define GET_DELTA(gb, delta_bits) \
+ ((delta_bits) ? get_bits((gb), (delta_bits)) : 0)
+
+/**
+ * Generate canonical VLC table from given descriptor.
+ *
+ * @param[in] cb ptr to codebook descriptor
+ * @param[in] xlat ptr to translation table or NULL
+ * @param[in,out] tab_offset starting offset to the generated vlc table
+ * @param[out] out_vlc ptr to vlc table to be generated
+ */
+static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat,
+ int *tab_offset, VLC *out_vlc)
+{
+ int i, b;
+ uint16_t codes[256];
+ uint8_t bits[256];
+ unsigned code = 0;
+ int index = 0;
+ int min_len = *cb++; // get shortest codeword length
+ int max_len = *cb++; // get longest codeword length
+
+ for (b = min_len; b <= max_len; b++) {
+ for (i = *cb++; i > 0; i--) {
+ av_assert0(index < 256);
+ bits[index] = b;
+ codes[index] = code++;
+ index++;
+ }
+ code <<= 1;
+ }
+
+ out_vlc->table = &tables_data[*tab_offset];
+ out_vlc->table_allocated = 1 << max_len;
+
+ ff_init_vlc_sparse(out_vlc, max_len, index, bits, 1, 1, codes, 2, 2,
+ xlat, 1, 1, INIT_VLC_USE_NEW_STATIC);
+
+ *tab_offset += 1 << max_len;
+}
+
+av_cold void ff_atrac3p_init_vlcs(void)
+{
+ int i, wl_vlc_offs, ct_vlc_offs, sf_vlc_offs, tab_offset;
+
+ static int wl_nb_bits[4] = { 2, 3, 5, 5 };
+ static int wl_nb_codes[4] = { 3, 5, 8, 8 };
+ static const uint8_t *wl_bits[4] = {
+ atrac3p_wl_huff_bits1, atrac3p_wl_huff_bits2,
+ atrac3p_wl_huff_bits3, atrac3p_wl_huff_bits4
+ };
+ static const uint8_t *wl_codes[4] = {
+ atrac3p_wl_huff_code1, atrac3p_wl_huff_code2,
+ atrac3p_wl_huff_code3, atrac3p_wl_huff_code4
+ };
+ static const uint8_t *wl_xlats[4] = {
+ atrac3p_wl_huff_xlat1, atrac3p_wl_huff_xlat2, NULL, NULL
+ };
+
+ static int ct_nb_bits[4] = { 3, 4, 4, 4 };
+ static int ct_nb_codes[4] = { 4, 8, 8, 8 };
+ static const uint8_t *ct_bits[4] = {
+ atrac3p_ct_huff_bits1, atrac3p_ct_huff_bits2,
+ atrac3p_ct_huff_bits2, atrac3p_ct_huff_bits3
+ };
+ static const uint8_t *ct_codes[4] = {
+ atrac3p_ct_huff_code1, atrac3p_ct_huff_code2,
+ atrac3p_ct_huff_code2, atrac3p_ct_huff_code3
+ };
+ static const uint8_t *ct_xlats[4] = {
+ NULL, NULL, atrac3p_ct_huff_xlat1, NULL
+ };
+
+ static int sf_nb_bits[8] = { 9, 9, 9, 9, 6, 6, 7, 7 };
+ static int sf_nb_codes[8] = { 64, 64, 64, 64, 16, 16, 16, 16 };
+ static const uint8_t *sf_bits[8] = {
+ atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits1, atrac3p_sf_huff_bits2,
+ atrac3p_sf_huff_bits3, atrac3p_sf_huff_bits4, atrac3p_sf_huff_bits4,
+ atrac3p_sf_huff_bits5, atrac3p_sf_huff_bits6
+ };
+ static const uint16_t *sf_codes[8] = {
+ atrac3p_sf_huff_code1, atrac3p_sf_huff_code1, atrac3p_sf_huff_code2,
+ atrac3p_sf_huff_code3, atrac3p_sf_huff_code4, atrac3p_sf_huff_code4,
+ atrac3p_sf_huff_code5, atrac3p_sf_huff_code6
+ };
+ static const uint8_t *sf_xlats[8] = {
+ atrac3p_sf_huff_xlat1, atrac3p_sf_huff_xlat2, NULL, NULL,
+ atrac3p_sf_huff_xlat4, atrac3p_sf_huff_xlat5, NULL, NULL
+ };
+
+ static const uint8_t *gain_cbs[11] = {
+ atrac3p_huff_gain_npoints1_cb, atrac3p_huff_gain_npoints1_cb,
+ atrac3p_huff_gain_lev1_cb, atrac3p_huff_gain_lev2_cb,
+ atrac3p_huff_gain_lev3_cb, atrac3p_huff_gain_lev4_cb,
+ atrac3p_huff_gain_loc3_cb, atrac3p_huff_gain_loc1_cb,
+ atrac3p_huff_gain_loc4_cb, atrac3p_huff_gain_loc2_cb,
+ atrac3p_huff_gain_loc5_cb
+ };
+ static const uint8_t *gain_xlats[11] = {
+ NULL, atrac3p_huff_gain_npoints2_xlat, atrac3p_huff_gain_lev1_xlat,
+ atrac3p_huff_gain_lev2_xlat, atrac3p_huff_gain_lev3_xlat,
+ atrac3p_huff_gain_lev4_xlat, atrac3p_huff_gain_loc3_xlat,
+ atrac3p_huff_gain_loc1_xlat, atrac3p_huff_gain_loc4_xlat,
+ atrac3p_huff_gain_loc2_xlat, atrac3p_huff_gain_loc5_xlat
+ };
+
+ static const uint8_t *tone_cbs[7] = {
+ atrac3p_huff_tonebands_cb, atrac3p_huff_numwavs1_cb,
+ atrac3p_huff_numwavs2_cb, atrac3p_huff_wav_ampsf1_cb,
+ atrac3p_huff_wav_ampsf2_cb, atrac3p_huff_wav_ampsf3_cb,
+ atrac3p_huff_freq_cb
+ };
+ static const uint8_t *tone_xlats[7] = {
+ NULL, NULL, atrac3p_huff_numwavs2_xlat, atrac3p_huff_wav_ampsf1_xlat,
+ atrac3p_huff_wav_ampsf2_xlat, atrac3p_huff_wav_ampsf3_xlat,
+ atrac3p_huff_freq_xlat
+ };
+
+ for (i = 0, wl_vlc_offs = 0, ct_vlc_offs = 2508; i < 4; i++) {
+ wl_vlc_tabs[i].table = &tables_data[wl_vlc_offs];
+ wl_vlc_tabs[i].table_allocated = 1 << wl_nb_bits[i];
+ ct_vlc_tabs[i].table = &tables_data[ct_vlc_offs];
+ ct_vlc_tabs[i].table_allocated = 1 << ct_nb_bits[i];
+
+ ff_init_vlc_sparse(&wl_vlc_tabs[i], wl_nb_bits[i], wl_nb_codes[i],
+ wl_bits[i], 1, 1,
+ wl_codes[i], 1, 1,
+ wl_xlats[i], 1, 1,
+ INIT_VLC_USE_NEW_STATIC);
+
+ ff_init_vlc_sparse(&ct_vlc_tabs[i], ct_nb_bits[i], ct_nb_codes[i],
+ ct_bits[i], 1, 1,
+ ct_codes[i], 1, 1,
+ ct_xlats[i], 1, 1,
+ INIT_VLC_USE_NEW_STATIC);
+
+ wl_vlc_offs += wl_vlc_tabs[i].table_allocated;
+ ct_vlc_offs += ct_vlc_tabs[i].table_allocated;
+ }
+
+ for (i = 0, sf_vlc_offs = 76; i < 8; i++) {
+ sf_vlc_tabs[i].table = &tables_data[sf_vlc_offs];
+ sf_vlc_tabs[i].table_allocated = 1 << sf_nb_bits[i];
+
+ ff_init_vlc_sparse(&sf_vlc_tabs[i], sf_nb_bits[i], sf_nb_codes[i],
+ sf_bits[i], 1, 1,
+ sf_codes[i], 2, 2,
+ sf_xlats[i], 1, 1,
+ INIT_VLC_USE_NEW_STATIC);
+ sf_vlc_offs += sf_vlc_tabs[i].table_allocated;
+ }
+
+ tab_offset = 2564;
+
+ /* build huffman tables for spectrum decoding */
+ for (i = 0; i < 112; i++) {
+ if (atrac3p_spectra_tabs[i].cb)
+ build_canonical_huff(atrac3p_spectra_tabs[i].cb,
+ atrac3p_spectra_tabs[i].xlat,
+ &tab_offset, &spec_vlc_tabs[i]);
+ else
+ spec_vlc_tabs[i].table = 0;
+ }
+
+ /* build huffman tables for gain data decoding */
+ for (i = 0; i < 11; i++)
+ build_canonical_huff(gain_cbs[i], gain_xlats[i], &tab_offset, &gain_vlc_tabs[i]);
+
+ /* build huffman tables for tone decoding */
+ for (i = 0; i < 7; i++)
+ build_canonical_huff(tone_cbs[i], tone_xlats[i], &tab_offset, &tone_vlc_tabs[i]);
+}
+
+/**
+ * Decode number of coded quantization units.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] chan ptr to the channel parameters
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int num_coded_units(GetBitContext *gb, Atrac3pChanParams *chan,
+ Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx)
+{
+ chan->fill_mode = get_bits(gb, 2);
+ if (!chan->fill_mode) {
+ chan->num_coded_vals = ctx->num_quant_units;
+ } else {
+ chan->num_coded_vals = get_bits(gb, 5);
+ if (chan->num_coded_vals > ctx->num_quant_units) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid number of transmitted units!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (chan->fill_mode == 3)
+ chan->split_point = get_bits(gb, 2) + (chan->ch_num << 1) + 1;
+ }
+
+ return 0;
+}
+
+/**
+ * Add weighting coefficients to the decoded word-length information.
+ *
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in,out] chan ptr to the channel parameters
+ * @param[in] wtab_idx index of the table of weights
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int add_wordlen_weights(Atrac3pChanUnitCtx *ctx,
+ Atrac3pChanParams *chan, int wtab_idx,
+ AVCodecContext *avctx)
+{
+ int i;
+ const int8_t *weights_tab =
+ &atrac3p_wl_weights[chan->ch_num * 3 + wtab_idx - 1][0];
+
+ for (i = 0; i < ctx->num_quant_units; i++) {
+ chan->qu_wordlen[i] += weights_tab[i];
+ if (chan->qu_wordlen[i] < 0 || chan->qu_wordlen[i] > 7) {
+ av_log(avctx, AV_LOG_ERROR,
+ "WL index out of range: pos=%d, val=%d!\n",
+ i, chan->qu_wordlen[i]);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Subtract weighting coefficients from decoded scalefactors.
+ *
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in,out] chan ptr to the channel parameters
+ * @param[in] wtab_idx index of table of weights
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int subtract_sf_weights(Atrac3pChanUnitCtx *ctx,
+ Atrac3pChanParams *chan, int wtab_idx,
+ AVCodecContext *avctx)
+{
+ int i;
+ const int8_t *weights_tab = &atrac3p_sf_weights[wtab_idx - 1][0];
+
+ for (i = 0; i < ctx->used_quant_units; i++) {
+ chan->qu_sf_idx[i] -= weights_tab[i];
+ if (chan->qu_sf_idx[i] < 0 || chan->qu_sf_idx[i] > 63) {
+ av_log(avctx, AV_LOG_ERROR,
+ "SF index out of range: pos=%d, val=%d!\n",
+ i, chan->qu_sf_idx[i]);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Unpack vector quantization tables.
+ *
+ * @param[in] start_val start value for the unpacked table
+ * @param[in] shape_vec ptr to table to unpack
+ * @param[out] dst ptr to output array
+ * @param[in] num_values number of values to unpack
+ */
+static inline void unpack_vq_shape(int start_val, const int8_t *shape_vec,
+ int *dst, int num_values)
+{
+ int i;
+
+ if (num_values) {
+ dst[0] = dst[1] = dst[2] = start_val;
+ for (i = 3; i < num_values; i++)
+ dst[i] = start_val - shape_vec[atrac3p_qu_num_to_seg[i] - 1];
+ }
+}
+
+#define UNPACK_SF_VQ_SHAPE(gb, dst, num_vals) \
+ start_val = get_bits((gb), 6); \
+ unpack_vq_shape(start_val, &atrac3p_sf_shapes[get_bits((gb), 6)][0], \
+ (dst), (num_vals))
+
+/**
+ * Decode word length for each quantization unit of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, AVCodecContext *avctx)
+{
+ int i, weight_idx = 0, delta, diff, pos, delta_bits, min_val, flag,
+ ret, start_val;
+ VLC *vlc_tab;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ chan->fill_mode = 0;
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* coded using constant number of bits */
+ for (i = 0; i < ctx->num_quant_units; i++)
+ chan->qu_wordlen[i] = get_bits(gb, 3);
+ break;
+ case 1:
+ if (ch_num) {
+ if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
+ return ret;
+
+ if (chan->num_coded_vals) {
+ vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
+
+ for (i = 0; i < chan->num_coded_vals; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_wordlen[i] = (ref_chan->qu_wordlen[i] + delta) & 7;
+ }
+ }
+ } else {
+ weight_idx = get_bits(gb, 2);
+ if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
+ return ret;
+
+ if (chan->num_coded_vals) {
+ pos = get_bits(gb, 5);
+ if (pos > chan->num_coded_vals) {
+ av_log(avctx, AV_LOG_ERROR,
+ "WL mode 1: invalid position!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ delta_bits = get_bits(gb, 2);
+ min_val = get_bits(gb, 3);
+
+ for (i = 0; i < pos; i++)
+ chan->qu_wordlen[i] = get_bits(gb, 3);
+
+ for (i = pos; i < chan->num_coded_vals; i++)
+ chan->qu_wordlen[i] = (min_val + GET_DELTA(gb, delta_bits)) & 7;
+ }
+ }
+ break;
+ case 2:
+ if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
+ return ret;
+
+ if (ch_num && chan->num_coded_vals) {
+ vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_wordlen[0] = (ref_chan->qu_wordlen[0] + delta) & 7;
+
+ for (i = 1; i < chan->num_coded_vals; i++) {
+ diff = ref_chan->qu_wordlen[i] - ref_chan->qu_wordlen[i - 1];
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_wordlen[i] = (chan->qu_wordlen[i - 1] + diff + delta) & 7;
+ }
+ } else if (chan->num_coded_vals) {
+ flag = get_bits(gb, 1);
+ vlc_tab = &wl_vlc_tabs[get_bits(gb, 1)];
+
+ start_val = get_bits(gb, 3);
+ unpack_vq_shape(start_val,
+ &atrac3p_wl_shapes[start_val][get_bits(gb, 4)][0],
+ chan->qu_wordlen, chan->num_coded_vals);
+
+ if (!flag) {
+ for (i = 0; i < chan->num_coded_vals; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_wordlen[i] = (chan->qu_wordlen[i] + delta) & 7;
+ }
+ } else {
+ for (i = 0; i < (chan->num_coded_vals & - 2); i += 2)
+ if (!get_bits1(gb)) {
+ chan->qu_wordlen[i] = (chan->qu_wordlen[i] +
+ get_vlc2(gb, vlc_tab->table,
+ vlc_tab->bits, 1)) & 7;
+ chan->qu_wordlen[i + 1] = (chan->qu_wordlen[i + 1] +
+ get_vlc2(gb, vlc_tab->table,
+ vlc_tab->bits, 1)) & 7;
+ }
+
+ if (chan->num_coded_vals & 1)
+ chan->qu_wordlen[i] = (chan->qu_wordlen[i] +
+ get_vlc2(gb, vlc_tab->table,
+ vlc_tab->bits, 1)) & 7;
+ }
+ }
+ break;
+ case 3:
+ weight_idx = get_bits(gb, 2);
+ if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
+ return ret;
+
+ if (chan->num_coded_vals) {
+ vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
+
+ /* first coefficient is coded directly */
+ chan->qu_wordlen[0] = get_bits(gb, 3);
+
+ for (i = 1; i < chan->num_coded_vals; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_wordlen[i] = (chan->qu_wordlen[i - 1] + delta) & 7;
+ }
+ }
+ break;
+ }
+
+ if (chan->fill_mode == 2) {
+ for (i = chan->num_coded_vals; i < ctx->num_quant_units; i++)
+ chan->qu_wordlen[i] = ch_num ? get_bits1(gb) : 1;
+ } else if (chan->fill_mode == 3) {
+ pos = ch_num ? chan->num_coded_vals + chan->split_point
+ : ctx->num_quant_units - chan->split_point;
+ for (i = chan->num_coded_vals; i < pos; i++)
+ chan->qu_wordlen[i] = 1;
+ }
+
+ if (weight_idx)
+ return add_wordlen_weights(ctx, chan, weight_idx, avctx);
+
+ return 0;
+}
+
+/**
+ * Decode scale factor indexes for each quant unit of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, AVCodecContext *avctx)
+{
+ int i, weight_idx = 0, delta, diff, num_long_vals,
+ delta_bits, min_val, vlc_sel, start_val;
+ VLC *vlc_tab;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* coded using constant number of bits */
+ for (i = 0; i < ctx->used_quant_units; i++)
+ chan->qu_sf_idx[i] = get_bits(gb, 6);
+ break;
+ case 1:
+ if (ch_num) {
+ vlc_tab = &sf_vlc_tabs[get_bits(gb, 2)];
+
+ for (i = 0; i < ctx->used_quant_units; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_sf_idx[i] = (ref_chan->qu_sf_idx[i] + delta) & 0x3F;
+ }
+ } else {
+ weight_idx = get_bits(gb, 2);
+ if (weight_idx == 3) {
+ UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
+
+ num_long_vals = get_bits(gb, 5);
+ delta_bits = get_bits(gb, 2);
+ min_val = get_bits(gb, 4) - 7;
+
+ for (i = 0; i < num_long_vals; i++)
+ chan->qu_sf_idx[i] = (chan->qu_sf_idx[i] +
+ get_bits(gb, 4) - 7) & 0x3F;
+
+ /* all others are: min_val + delta */
+ for (i = num_long_vals; i < ctx->used_quant_units; i++)
+ chan->qu_sf_idx[i] = (chan->qu_sf_idx[i] + min_val +
+ GET_DELTA(gb, delta_bits)) & 0x3F;
+ } else {
+ num_long_vals = get_bits(gb, 5);
+ delta_bits = get_bits(gb, 3);
+ min_val = get_bits(gb, 6);
+ if (num_long_vals > ctx->used_quant_units || delta_bits == 7) {
+ av_log(avctx, AV_LOG_ERROR,
+ "SF mode 1: invalid parameters!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ /* read full-precision SF indexes */
+ for (i = 0; i < num_long_vals; i++)
+ chan->qu_sf_idx[i] = get_bits(gb, 6);
+
+ /* all others are: min_val + delta */
+ for (i = num_long_vals; i < ctx->used_quant_units; i++)
+ chan->qu_sf_idx[i] = (min_val +
+ GET_DELTA(gb, delta_bits)) & 0x3F;
+ }
+ }
+ break;
+ case 2:
+ if (ch_num) {
+ vlc_tab = &sf_vlc_tabs[get_bits(gb, 2)];
+
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_sf_idx[0] = (ref_chan->qu_sf_idx[0] + delta) & 0x3F;
+
+ for (i = 1; i < ctx->used_quant_units; i++) {
+ diff = ref_chan->qu_sf_idx[i] - ref_chan->qu_sf_idx[i - 1];
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_sf_idx[i] = (chan->qu_sf_idx[i - 1] + diff + delta) & 0x3F;
+ }
+ } else {
+ vlc_tab = &sf_vlc_tabs[get_bits(gb, 2) + 4];
+
+ UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
+
+ for (i = 0; i < ctx->used_quant_units; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_sf_idx[i] = (chan->qu_sf_idx[i] +
+ sign_extend(delta, 4)) & 0x3F;
+ }
+ }
+ break;
+ case 3:
+ if (ch_num) {
+ /* copy coefficients from reference channel */
+ for (i = 0; i < ctx->used_quant_units; i++)
+ chan->qu_sf_idx[i] = ref_chan->qu_sf_idx[i];
+ } else {
+ weight_idx = get_bits(gb, 2);
+ vlc_sel = get_bits(gb, 2);
+ vlc_tab = &sf_vlc_tabs[vlc_sel];
+
+ if (weight_idx == 3) {
+ vlc_tab = &sf_vlc_tabs[vlc_sel + 4];
+
+ UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
+
+ diff = (get_bits(gb, 4) + 56) & 0x3F;
+ chan->qu_sf_idx[0] = (chan->qu_sf_idx[0] + diff) & 0x3F;
+
+ for (i = 1; i < ctx->used_quant_units; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ diff = (diff + sign_extend(delta, 4)) & 0x3F;
+ chan->qu_sf_idx[i] = (diff + chan->qu_sf_idx[i]) & 0x3F;
+ }
+ } else {
+ /* 1st coefficient is coded directly */
+ chan->qu_sf_idx[0] = get_bits(gb, 6);
+
+ for (i = 1; i < ctx->used_quant_units; i++) {
+ delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+ chan->qu_sf_idx[i] = (chan->qu_sf_idx[i - 1] + delta) & 0x3F;
+ }
+ }
+ }
+ break;
+ }
+
+ if (weight_idx && weight_idx < 3)
+ return subtract_sf_weights(ctx, chan, weight_idx, avctx);
+
+ return 0;
+}
+
+/**
+ * Decode word length information for each channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_quant_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch_num, i, ret;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ memset(ctx->channels[ch_num].qu_wordlen, 0,
+ sizeof(ctx->channels[ch_num].qu_wordlen));
+
+ if ((ret = decode_channel_wordlen(gb, ctx, ch_num, avctx)) < 0)
+ return ret;
+ }
+
+ /* scan for last non-zero coeff in both channels and
+ * set number of quant units having coded spectrum */
+ for (i = ctx->num_quant_units - 1; i >= 0; i--)
+ if (ctx->channels[0].qu_wordlen[i] ||
+ (num_channels == 2 && ctx->channels[1].qu_wordlen[i]))
+ break;
+ ctx->used_quant_units = i + 1;
+
+ return 0;
+}
+
+/**
+ * Decode scale factor indexes for each channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_scale_factors(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch_num, ret;
+
+ if (!ctx->used_quant_units)
+ return 0;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ memset(ctx->channels[ch_num].qu_sf_idx, 0,
+ sizeof(ctx->channels[ch_num].qu_sf_idx));
+
+ if ((ret = decode_channel_sf_idx(gb, ctx, ch_num, avctx)) < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * Decode number of code table values.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int get_num_ct_values(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ AVCodecContext *avctx)
+{
+ int num_coded_vals;
+
+ if (get_bits1(gb)) {
+ num_coded_vals = get_bits(gb, 5);
+ if (num_coded_vals > ctx->used_quant_units) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid number of code table indexes: %d!\n", num_coded_vals);
+ return AVERROR_INVALIDDATA;
+ }
+ return num_coded_vals;
+ } else
+ return ctx->used_quant_units;
+}
+
+#define DEC_CT_IDX_COMMON(OP) \
+ num_vals = get_num_ct_values(gb, ctx, avctx); \
+ if (num_vals < 0) \
+ return num_vals; \
+ \
+ for (i = 0; i < num_vals; i++) { \
+ if (chan->qu_wordlen[i]) { \
+ chan->qu_tab_idx[i] = OP; \
+ } else if (ch_num && ref_chan->qu_wordlen[i]) \
+ /* get clone master flag */ \
+ chan->qu_tab_idx[i] = get_bits1(gb); \
+ }
+
+#define CODING_DIRECT get_bits(gb, num_bits)
+
+#define CODING_VLC get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)
+
+#define CODING_VLC_DELTA \
+ (!i) ? CODING_VLC \
+ : (pred + get_vlc2(gb, delta_vlc->table, \
+ delta_vlc->bits, 1)) & mask; \
+ pred = chan->qu_tab_idx[i]
+
+#define CODING_VLC_DIFF \
+ (ref_chan->qu_tab_idx[i] + \
+ get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)) & mask
+
+/**
+ * Decode code table indexes for each quant unit of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_channel_code_tab(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, AVCodecContext *avctx)
+{
+ int i, num_vals, num_bits, pred;
+ int mask = ctx->use_full_table ? 7 : 3; /* mask for modular arithmetic */
+ VLC *vlc_tab, *delta_vlc;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ chan->table_type = get_bits1(gb);
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* directly coded */
+ num_bits = ctx->use_full_table + 2;
+ DEC_CT_IDX_COMMON(CODING_DIRECT);
+ break;
+ case 1: /* entropy-coded */
+ vlc_tab = ctx->use_full_table ? &ct_vlc_tabs[1]
+ : ct_vlc_tabs;
+ DEC_CT_IDX_COMMON(CODING_VLC);
+ break;
+ case 2: /* entropy-coded delta */
+ if (ctx->use_full_table) {
+ vlc_tab = &ct_vlc_tabs[1];
+ delta_vlc = &ct_vlc_tabs[2];
+ } else {
+ vlc_tab = ct_vlc_tabs;
+ delta_vlc = ct_vlc_tabs;
+ }
+ pred = 0;
+ DEC_CT_IDX_COMMON(CODING_VLC_DELTA);
+ break;
+ case 3: /* entropy-coded difference to master */
+ if (ch_num) {
+ vlc_tab = ctx->use_full_table ? &ct_vlc_tabs[3]
+ : ct_vlc_tabs;
+ DEC_CT_IDX_COMMON(CODING_VLC_DIFF);
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * Decode code table indexes for each channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch_num, ret;
+
+ if (!ctx->used_quant_units)
+ return 0;
+
+ ctx->use_full_table = get_bits1(gb);
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ memset(ctx->channels[ch_num].qu_tab_idx, 0,
+ sizeof(ctx->channels[ch_num].qu_tab_idx));
+
+ if ((ret = decode_channel_code_tab(gb, ctx, ch_num, avctx)) < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * Decode huffman-coded spectral lines for a given quant unit.
+ *
+ * This is a generalized version for all known coding modes.
+ * Its speed can be improved by creating separate functions for each mode.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in] tab code table telling how to decode spectral lines
+ * @param[in] vlc_tab ptr to the huffman table associated with the code table
+ * @param[out] out pointer to buffer where decoded data should be stored
+ * @param[in] num_specs number of spectral lines to decode
+ */
+static void decode_qu_spectra(GetBitContext *gb, const Atrac3pSpecCodeTab *tab,
+ VLC *vlc_tab, int16_t *out, const int num_specs)
+{
+ int i, j, pos, cf;
+ int group_size = tab->group_size;
+ int num_coeffs = tab->num_coeffs;
+ int bits = tab->bits;
+ int is_signed = tab->is_signed;
+ unsigned val, mask = (1 << bits) - 1;
+
+ for (pos = 0; pos < num_specs;) {
+ if (group_size == 1 || get_bits1(gb)) {
+ for (j = 0; j < group_size; j++) {
+ val = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
+
+ for (i = 0; i < num_coeffs; i++) {
+ cf = val & mask;
+ if (is_signed)
+ cf = sign_extend(cf, bits);
+ else if (cf && get_bits1(gb))
+ cf = -cf;
+
+ out[pos++] = cf;
+ val >>= bits;
+ }
+ }
+ } else /* group skipped */
+ pos += group_size * num_coeffs;
+ }
+}
+
+/**
+ * Decode huffman-coded IMDCT spectrum for all channels.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ */
+static void decode_spectrum(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int i, ch_num, qu, wordlen, codetab, tab_index, num_specs;
+ const Atrac3pSpecCodeTab *tab;
+ Atrac3pChanParams *chan;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ chan = &ctx->channels[ch_num];
+
+ memset(chan->spectrum, 0, sizeof(chan->spectrum));
+
+ /* set power compensation level to disabled */
+ memset(chan->power_levs, ATRAC3P_POWER_COMP_OFF, sizeof(chan->power_levs));
+
+ for (qu = 0; qu < ctx->used_quant_units; qu++) {
+ num_specs = ff_atrac3p_qu_to_spec_pos[qu + 1] -
+ ff_atrac3p_qu_to_spec_pos[qu];
+
+ wordlen = chan->qu_wordlen[qu];
+ codetab = chan->qu_tab_idx[qu];
+ if (wordlen) {
+ if (!ctx->use_full_table)
+ codetab = atrac3p_ct_restricted_to_full[chan->table_type][wordlen - 1][codetab];
+
+ tab_index = (chan->table_type * 8 + codetab) * 7 + wordlen - 1;
+ tab = &atrac3p_spectra_tabs[tab_index];
+
+ /* this allows reusing VLC tables */
+ if (tab->redirect >= 0)
+ tab_index = tab->redirect;
+
+ decode_qu_spectra(gb, tab, &spec_vlc_tabs[tab_index],
+ &chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]],
+ num_specs);
+ } else if (ch_num && ctx->channels[0].qu_wordlen[qu] && !codetab) {
+ /* copy coefficients from master */
+ memcpy(&chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]],
+ &ctx->channels[0].spectrum[ff_atrac3p_qu_to_spec_pos[qu]],
+ num_specs *
+ sizeof(chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]]));
+ chan->qu_wordlen[qu] = ctx->channels[0].qu_wordlen[qu];
+ }
+ }
+
+ /* Power compensation levels only present in the bitstream
+ * if there are more than 2 quant units. The lowest two units
+ * correspond to the frequencies 0...351 Hz, whose shouldn't
+ * be affected by the power compensation. */
+ if (ctx->used_quant_units > 2) {
+ num_specs = atrac3p_subband_to_num_powgrps[ctx->num_coded_subbands - 1];
+ for (i = 0; i < num_specs; i++)
+ chan->power_levs[i] = get_bits(gb, 4);
+ }
+ }
+}
+
+/**
+ * Retrieve specified amount of flag bits from the input bitstream.
+ * The data can be shortened in the case of the following two common conditions:
+ * if all bits are zero then only one signal bit = 0 will be stored,
+ * if all bits are ones then two signal bits = 1,0 will be stored.
+ * Otherwise, all necessary bits will be directly stored
+ * prefixed by two signal bits = 1,1.
+ *
+ * @param[in] gb ptr to the GetBitContext
+ * @param[out] out where to place decoded flags
+ * @param[in] num_flags number of flags to process
+ * @return: 0 = all flag bits are zero, 1 = there is at least one non-zero flag bit
+ */
+static int get_subband_flags(GetBitContext *gb, uint8_t *out, int num_flags)
+{
+ int i, result;
+
+ memset(out, 0, num_flags);
+
+ result = get_bits1(gb);
+ if (result) {
+ if (get_bits1(gb))
+ for (i = 0; i < num_flags; i++)
+ out[i] = get_bits1(gb);
+ else
+ memset(out, 1, num_flags);
+ }
+
+ return result;
+}
+
+/**
+ * Decode mdct window shape flags for all channels.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ */
+static void decode_window_shape(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels)
+{
+ int ch_num;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++)
+ get_subband_flags(gb, ctx->channels[ch_num].wnd_shape,
+ ctx->num_subbands);
+}
+
+/**
+ * Decode number of gain control points.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] coded_subbands number of subbands to process
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_gainc_npoints(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int coded_subbands)
+{
+ int i, delta, delta_bits, min_val;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* fixed-length coding */
+ for (i = 0; i < coded_subbands; i++)
+ chan->gain_data[i].num_points = get_bits(gb, 3);
+ break;
+ case 1: /* variable-length coding */
+ for (i = 0; i < coded_subbands; i++)
+ chan->gain_data[i].num_points =
+ get_vlc2(gb, gain_vlc_tabs[0].table,
+ gain_vlc_tabs[0].bits, 1);
+ break;
+ case 2:
+ if (ch_num) { /* VLC modulo delta to master channel */
+ for (i = 0; i < coded_subbands; i++) {
+ delta = get_vlc2(gb, gain_vlc_tabs[1].table,
+ gain_vlc_tabs[1].bits, 1);
+ chan->gain_data[i].num_points =
+ (ref_chan->gain_data[i].num_points + delta) & 7;
+ }
+ } else { /* VLC modulo delta to previous */
+ chan->gain_data[0].num_points =
+ get_vlc2(gb, gain_vlc_tabs[0].table,
+ gain_vlc_tabs[0].bits, 1);
+
+ for (i = 1; i < coded_subbands; i++) {
+ delta = get_vlc2(gb, gain_vlc_tabs[1].table,
+ gain_vlc_tabs[1].bits, 1);
+ chan->gain_data[i].num_points =
+ (chan->gain_data[i - 1].num_points + delta) & 7;
+ }
+ }
+ break;
+ case 3:
+ if (ch_num) { /* copy data from master channel */
+ for (i = 0; i < coded_subbands; i++)
+ chan->gain_data[i].num_points =
+ ref_chan->gain_data[i].num_points;
+ } else { /* shorter delta to min */
+ delta_bits = get_bits(gb, 2);
+ min_val = get_bits(gb, 3);
+
+ for (i = 0; i < coded_subbands; i++) {
+ chan->gain_data[i].num_points = min_val + GET_DELTA(gb, delta_bits);
+ if (chan->gain_data[i].num_points > 7)
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Implements coding mode 3 (slave) for gain compensation levels.
+ *
+ * @param[out] dst ptr to the output array
+ * @param[in] ref ptr to the reference channel
+ */
+static inline void gainc_level_mode3s(AtracGainInfo *dst, AtracGainInfo *ref)
+{
+ int i;
+
+ for (i = 0; i < dst->num_points; i++)
+ dst->lev_code[i] = (i >= ref->num_points) ? 7 : ref->lev_code[i];
+}
+
+/**
+ * Implements coding mode 1 (master) for gain compensation levels.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in] ctx ptr to the channel unit context
+ * @param[out] dst ptr to the output array
+ */
+static inline void gainc_level_mode1m(GetBitContext *gb,
+ Atrac3pChanUnitCtx *ctx,
+ AtracGainInfo *dst)
+{
+ int i, delta;
+
+ if (dst->num_points > 0)
+ dst->lev_code[0] = get_vlc2(gb, gain_vlc_tabs[2].table,
+ gain_vlc_tabs[2].bits, 1);
+
+ for (i = 1; i < dst->num_points; i++) {
+ delta = get_vlc2(gb, gain_vlc_tabs[3].table,
+ gain_vlc_tabs[3].bits, 1);
+ dst->lev_code[i] = (dst->lev_code[i - 1] + delta) & 0xF;
+ }
+}
+
+/**
+ * Decode level code for each gain control point.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] coded_subbands number of subbands to process
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_gainc_levels(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int coded_subbands)
+{
+ int sb, i, delta, delta_bits, min_val, pred;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* fixed-length coding */
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++)
+ chan->gain_data[sb].lev_code[i] = get_bits(gb, 4);
+ break;
+ case 1:
+ if (ch_num) { /* VLC modulo delta to master channel */
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++) {
+ delta = get_vlc2(gb, gain_vlc_tabs[5].table,
+ gain_vlc_tabs[5].bits, 1);
+ pred = (i >= ref_chan->gain_data[sb].num_points)
+ ? 7 : ref_chan->gain_data[sb].lev_code[i];
+ chan->gain_data[sb].lev_code[i] = (pred + delta) & 0xF;
+ }
+ } else { /* VLC modulo delta to previous */
+ for (sb = 0; sb < coded_subbands; sb++)
+ gainc_level_mode1m(gb, ctx, &chan->gain_data[sb]);
+ }
+ break;
+ case 2:
+ if (ch_num) { /* VLC modulo delta to previous or clone master */
+ for (sb = 0; sb < coded_subbands; sb++)
+ if (chan->gain_data[sb].num_points > 0) {
+ if (get_bits1(gb))
+ gainc_level_mode1m(gb, ctx, &chan->gain_data[sb]);
+ else
+ gainc_level_mode3s(&chan->gain_data[sb],
+ &ref_chan->gain_data[sb]);
+ }
+ } else { /* VLC modulo delta to lev_codes of previous subband */
+ if (chan->gain_data[0].num_points > 0)
+ gainc_level_mode1m(gb, ctx, &chan->gain_data[0]);
+
+ for (sb = 1; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++) {
+ delta = get_vlc2(gb, gain_vlc_tabs[4].table,
+ gain_vlc_tabs[4].bits, 1);
+ pred = (i >= chan->gain_data[sb - 1].num_points)
+ ? 7 : chan->gain_data[sb - 1].lev_code[i];
+ chan->gain_data[sb].lev_code[i] = (pred + delta) & 0xF;
+ }
+ }
+ break;
+ case 3:
+ if (ch_num) { /* clone master */
+ for (sb = 0; sb < coded_subbands; sb++)
+ gainc_level_mode3s(&chan->gain_data[sb],
+ &ref_chan->gain_data[sb]);
+ } else { /* shorter delta to min */
+ delta_bits = get_bits(gb, 2);
+ min_val = get_bits(gb, 4);
+
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++) {
+ chan->gain_data[sb].lev_code[i] = min_val + GET_DELTA(gb, delta_bits);
+ if (chan->gain_data[sb].lev_code[i] > 15)
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * Implements coding mode 0 for gain compensation locations.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in] ctx ptr to the channel unit context
+ * @param[out] dst ptr to the output array
+ * @param[in] pos position of the value to be processed
+ */
+static inline void gainc_loc_mode0(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ AtracGainInfo *dst, int pos)
+{
+ int delta_bits;
+
+ if (!pos || dst->loc_code[pos - 1] < 15)
+ dst->loc_code[pos] = get_bits(gb, 5);
+ else if (dst->loc_code[pos - 1] >= 30)
+ dst->loc_code[pos] = 31;
+ else {
+ delta_bits = av_log2(30 - dst->loc_code[pos - 1]) + 1;
+ dst->loc_code[pos] = dst->loc_code[pos - 1] +
+ get_bits(gb, delta_bits) + 1;
+ }
+}
+
+/**
+ * Implements coding mode 1 for gain compensation locations.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in] ctx ptr to the channel unit context
+ * @param[out] dst ptr to the output array
+ */
+static inline void gainc_loc_mode1(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ AtracGainInfo *dst)
+{
+ int i;
+ VLC *tab;
+
+ if (dst->num_points > 0) {
+ /* 1st coefficient is stored directly */
+ dst->loc_code[0] = get_bits(gb, 5);
+
+ for (i = 1; i < dst->num_points; i++) {
+ /* switch VLC according to the curve direction
+ * (ascending/descending) */
+ tab = (dst->lev_code[i] <= dst->lev_code[i - 1])
+ ? &gain_vlc_tabs[7]
+ : &gain_vlc_tabs[9];
+ dst->loc_code[i] = dst->loc_code[i - 1] +
+ get_vlc2(gb, tab->table, tab->bits, 1);
+ }
+ }
+}
+
+/**
+ * Decode location code for each gain control point.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] coded_subbands number of subbands to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_gainc_loc_codes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int coded_subbands,
+ AVCodecContext *avctx)
+{
+ int sb, i, delta, delta_bits, min_val, pred, more_than_ref;
+ AtracGainInfo *dst, *ref;
+ VLC *tab;
+ Atrac3pChanParams *chan = &ctx->channels[ch_num];
+ Atrac3pChanParams *ref_chan = &ctx->channels[0];
+
+ switch (get_bits(gb, 2)) { /* switch according to coding mode */
+ case 0: /* sequence of numbers in ascending order */
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++)
+ gainc_loc_mode0(gb, ctx, &chan->gain_data[sb], i);
+ break;
+ case 1:
+ if (ch_num) {
+ for (sb = 0; sb < coded_subbands; sb++) {
+ if (chan->gain_data[sb].num_points <= 0)
+ continue;
+ dst = &chan->gain_data[sb];
+ ref = &ref_chan->gain_data[sb];
+
+ /* 1st value is vlc-coded modulo delta to master */
+ delta = get_vlc2(gb, gain_vlc_tabs[10].table,
+ gain_vlc_tabs[10].bits, 1);
+ pred = ref->num_points > 0 ? ref->loc_code[0] : 0;
+ dst->loc_code[0] = (pred + delta) & 0x1F;
+
+ for (i = 1; i < dst->num_points; i++) {
+ more_than_ref = i >= ref->num_points;
+ if (dst->lev_code[i] > dst->lev_code[i - 1]) {
+ /* ascending curve */
+ if (more_than_ref) {
+ delta =
+ get_vlc2(gb, gain_vlc_tabs[9].table,
+ gain_vlc_tabs[9].bits, 1);
+ dst->loc_code[i] = dst->loc_code[i - 1] + delta;
+ } else {
+ if (get_bits1(gb))
+ gainc_loc_mode0(gb, ctx, dst, i); // direct coding
+ else
+ dst->loc_code[i] = ref->loc_code[i]; // clone master
+ }
+ } else { /* descending curve */
+ tab = more_than_ref ? &gain_vlc_tabs[7]
+ : &gain_vlc_tabs[10];
+ delta = get_vlc2(gb, tab->table, tab->bits, 1);
+ if (more_than_ref)
+ dst->loc_code[i] = dst->loc_code[i - 1] + delta;
+ else
+ dst->loc_code[i] = (ref->loc_code[i] + delta) & 0x1F;
+ }
+ }
+ }
+ } else /* VLC delta to previous */
+ for (sb = 0; sb < coded_subbands; sb++)
+ gainc_loc_mode1(gb, ctx, &chan->gain_data[sb]);
+ break;
+ case 2:
+ if (ch_num) {
+ for (sb = 0; sb < coded_subbands; sb++) {
+ if (chan->gain_data[sb].num_points <= 0)
+ continue;
+ dst = &chan->gain_data[sb];
+ ref = &ref_chan->gain_data[sb];
+ if (dst->num_points > ref->num_points || get_bits1(gb))
+ gainc_loc_mode1(gb, ctx, dst);
+ else /* clone master for the whole subband */
+ for (i = 0; i < chan->gain_data[sb].num_points; i++)
+ dst->loc_code[i] = ref->loc_code[i];
+ }
+ } else {
+ /* data for the first subband is coded directly */
+ for (i = 0; i < chan->gain_data[0].num_points; i++)
+ gainc_loc_mode0(gb, ctx, &chan->gain_data[0], i);
+
+ for (sb = 1; sb < coded_subbands; sb++) {
+ if (chan->gain_data[sb].num_points <= 0)
+ continue;
+ dst = &chan->gain_data[sb];
+
+ /* 1st value is vlc-coded modulo delta to the corresponding
+ * value of the previous subband if any or zero */
+ delta = get_vlc2(gb, gain_vlc_tabs[6].table,
+ gain_vlc_tabs[6].bits, 1);
+ pred = dst[-1].num_points > 0
+ ? dst[-1].loc_code[0] : 0;
+ dst->loc_code[0] = (pred + delta) & 0x1F;
+
+ for (i = 1; i < dst->num_points; i++) {
+ more_than_ref = i >= dst[-1].num_points;
+ /* Select VLC table according to curve direction and
+ * presence of prediction. */
+ tab = &gain_vlc_tabs[(dst->lev_code[i] > dst->lev_code[i - 1]) *
+ 2 + more_than_ref + 6];
+ delta = get_vlc2(gb, tab->table, tab->bits, 1);
+ if (more_than_ref)
+ dst->loc_code[i] = dst->loc_code[i - 1] + delta;
+ else
+ dst->loc_code[i] = (dst[-1].loc_code[i] + delta) & 0x1F;
+ }
+ }
+ }
+ break;
+ case 3:
+ if (ch_num) { /* clone master or direct or direct coding */
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++) {
+ if (i >= ref_chan->gain_data[sb].num_points)
+ gainc_loc_mode0(gb, ctx, &chan->gain_data[sb], i);
+ else
+ chan->gain_data[sb].loc_code[i] =
+ ref_chan->gain_data[sb].loc_code[i];
+ }
+ } else { /* shorter delta to min */
+ delta_bits = get_bits(gb, 2) + 1;
+ min_val = get_bits(gb, 5);
+
+ for (sb = 0; sb < coded_subbands; sb++)
+ for (i = 0; i < chan->gain_data[sb].num_points; i++)
+ chan->gain_data[sb].loc_code[i] = min_val + i +
+ get_bits(gb, delta_bits);
+ }
+ break;
+ }
+
+ /* Validate decoded information */
+ for (sb = 0; sb < coded_subbands; sb++) {
+ dst = &chan->gain_data[sb];
+ for (i = 0; i < chan->gain_data[sb].num_points; i++) {
+ if (dst->loc_code[i] < 0 || dst->loc_code[i] > 31 ||
+ (i && dst->loc_code[i] <= dst->loc_code[i - 1])) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid gain location: ch=%d, sb=%d, pos=%d, val=%d\n",
+ ch_num, sb, i, dst->loc_code[i]);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Decode gain control data for all channels.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_gainc_data(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch_num, coded_subbands, sb, ret;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ memset(ctx->channels[ch_num].gain_data, 0,
+ sizeof(*ctx->channels[ch_num].gain_data) * ATRAC3P_SUBBANDS);
+
+ if (get_bits1(gb)) { /* gain control data present? */
+ coded_subbands = get_bits(gb, 4) + 1;
+ if (get_bits1(gb)) /* is high band gain data replication on? */
+ ctx->channels[ch_num].num_gain_subbands = get_bits(gb, 4) + 1;
+ else
+ ctx->channels[ch_num].num_gain_subbands = coded_subbands;
+
+ if ((ret = decode_gainc_npoints(gb, ctx, ch_num, coded_subbands)) < 0 ||
+ (ret = decode_gainc_levels(gb, ctx, ch_num, coded_subbands)) < 0 ||
+ (ret = decode_gainc_loc_codes(gb, ctx, ch_num, coded_subbands, avctx)) < 0)
+ return ret;
+
+ if (coded_subbands > 0) { /* propagate gain data if requested */
+ for (sb = coded_subbands; sb < ctx->channels[ch_num].num_gain_subbands; sb++)
+ ctx->channels[ch_num].gain_data[sb] =
+ ctx->channels[ch_num].gain_data[sb - 1];
+ }
+ } else {
+ ctx->channels[ch_num].num_gain_subbands = 0;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Decode envelope for all tones of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] band_has_tones ptr to an array of per-band-flags:
+ * 1 - tone data present
+ */
+static void decode_tones_envelope(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int band_has_tones[])
+{
+ int sb;
+ Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
+ Atrac3pWavesData *ref = ctx->channels[0].tones_info;
+
+ if (!ch_num || !get_bits1(gb)) { /* mode 0: fixed-length coding */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb])
+ continue;
+ dst[sb].pend_env.has_start_point = get_bits1(gb);
+ dst[sb].pend_env.start_pos = dst[sb].pend_env.has_start_point
+ ? get_bits(gb, 5) : -1;
+ dst[sb].pend_env.has_stop_point = get_bits1(gb);
+ dst[sb].pend_env.stop_pos = dst[sb].pend_env.has_stop_point
+ ? get_bits(gb, 5) : 32;
+ }
+ } else { /* mode 1(slave only): copy master */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb])
+ continue;
+ dst[sb].pend_env.has_start_point = ref[sb].pend_env.has_start_point;
+ dst[sb].pend_env.has_stop_point = ref[sb].pend_env.has_stop_point;
+ dst[sb].pend_env.start_pos = ref[sb].pend_env.start_pos;
+ dst[sb].pend_env.stop_pos = ref[sb].pend_env.stop_pos;
+ }
+ }
+}
+
+/**
+ * Decode number of tones for each subband of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] band_has_tones ptr to an array of per-band-flags:
+ * 1 - tone data present
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_band_numwavs(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int band_has_tones[],
+ AVCodecContext *avctx)
+{
+ int mode, sb, delta;
+ Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
+ Atrac3pWavesData *ref = ctx->channels[0].tones_info;
+
+ mode = get_bits(gb, ch_num + 1);
+ switch (mode) {
+ case 0: /** fixed-length coding */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
+ if (band_has_tones[sb])
+ dst[sb].num_wavs = get_bits(gb, 4);
+ break;
+ case 1: /** variable-length coding */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
+ if (band_has_tones[sb])
+ dst[sb].num_wavs =
+ get_vlc2(gb, tone_vlc_tabs[1].table,
+ tone_vlc_tabs[1].bits, 1);
+ break;
+ case 2: /** VLC modulo delta to master (slave only) */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
+ if (band_has_tones[sb]) {
+ delta = get_vlc2(gb, tone_vlc_tabs[2].table,
+ tone_vlc_tabs[2].bits, 1);
+ delta = sign_extend(delta, 3);
+ dst[sb].num_wavs = (ref[sb].num_wavs + delta) & 0xF;
+ }
+ break;
+ case 3: /** copy master (slave only) */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
+ if (band_has_tones[sb])
+ dst[sb].num_wavs = ref[sb].num_wavs;
+ break;
+ }
+
+ /** initialize start tone index for each subband */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
+ if (band_has_tones[sb]) {
+ if (ctx->waves_info->tones_index + dst[sb].num_wavs > 48) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Too many tones: %d (max. 48), frame: %d!\n",
+ ctx->waves_info->tones_index + dst[sb].num_wavs,
+ avctx->frame_number);
+ return AVERROR_INVALIDDATA;
+ }
+ dst[sb].start_index = ctx->waves_info->tones_index;
+ ctx->waves_info->tones_index += dst[sb].num_wavs;
+ }
+
+ return 0;
+}
+
+/**
+ * Decode frequency information for each subband of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] band_has_tones ptr to an array of per-band-flags:
+ * 1 - tone data present
+ */
+static void decode_tones_frequency(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int band_has_tones[])
+{
+ int sb, i, direction, nbits, pred, delta;
+ Atrac3pWaveParam *iwav, *owav;
+ Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
+ Atrac3pWavesData *ref = ctx->channels[0].tones_info;
+
+ if (!ch_num || !get_bits1(gb)) { /* mode 0: fixed-length coding */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ iwav = &ctx->waves_info->waves[dst[sb].start_index];
+ direction = (dst[sb].num_wavs > 1) ? get_bits1(gb) : 0;
+ if (direction) { /** packed numbers in descending order */
+ if (dst[sb].num_wavs)
+ iwav[dst[sb].num_wavs - 1].freq_index = get_bits(gb, 10);
+ for (i = dst[sb].num_wavs - 2; i >= 0 ; i--) {
+ nbits = av_log2(iwav[i+1].freq_index) + 1;
+ iwav[i].freq_index = get_bits(gb, nbits);
+ }
+ } else { /** packed numbers in ascending order */
+ for (i = 0; i < dst[sb].num_wavs; i++) {
+ if (!i || iwav[i - 1].freq_index < 512)
+ iwav[i].freq_index = get_bits(gb, 10);
+ else {
+ nbits = av_log2(1023 - iwav[i - 1].freq_index) + 1;
+ iwav[i].freq_index = get_bits(gb, nbits) +
+ 1024 - (1 << nbits);
+ }
+ }
+ }
+ }
+ } else { /* mode 1: VLC modulo delta to master (slave only) */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ iwav = &ctx->waves_info->waves[ref[sb].start_index];
+ owav = &ctx->waves_info->waves[dst[sb].start_index];
+ for (i = 0; i < dst[sb].num_wavs; i++) {
+ delta = get_vlc2(gb, tone_vlc_tabs[6].table,
+ tone_vlc_tabs[6].bits, 1);
+ delta = sign_extend(delta, 8);
+ pred = (i < ref[sb].num_wavs) ? iwav[i].freq_index :
+ (ref[sb].num_wavs ? iwav[ref[sb].num_wavs - 1].freq_index : 0);
+ owav[i].freq_index = (pred + delta) & 0x3FF;
+ }
+ }
+ }
+}
+
+/**
+ * Decode amplitude information for each subband of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] band_has_tones ptr to an array of per-band-flags:
+ * 1 - tone data present
+ */
+static void decode_tones_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int band_has_tones[])
+{
+ int mode, sb, j, i, diff, maxdiff, fi, delta, pred;
+ Atrac3pWaveParam *wsrc, *wref;
+ int refwaves[48];
+ Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
+ Atrac3pWavesData *ref = ctx->channels[0].tones_info;
+
+ if (ch_num) {
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ wsrc = &ctx->waves_info->waves[dst[sb].start_index];
+ wref = &ctx->waves_info->waves[ref[sb].start_index];
+ for (j = 0; j < dst[sb].num_wavs; j++) {
+ for (i = 0, fi = 0, maxdiff = 1024; i < ref[sb].num_wavs; i++) {
+ diff = FFABS(wsrc[j].freq_index - wref[i].freq_index);
+ if (diff < maxdiff) {
+ maxdiff = diff;
+ fi = i;
+ }
+ }
+
+ if (maxdiff < 8)
+ refwaves[dst[sb].start_index + j] = fi + ref[sb].start_index;
+ else if (j < ref[sb].num_wavs)
+ refwaves[dst[sb].start_index + j] = j + ref[sb].start_index;
+ else
+ refwaves[dst[sb].start_index + j] = -1;
+ }
+ }
+ }
+
+ mode = get_bits(gb, ch_num + 1);
+
+ switch (mode) {
+ case 0: /** fixed-length coding */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ if (ctx->waves_info->amplitude_mode)
+ for (i = 0; i < dst[sb].num_wavs; i++)
+ ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = get_bits(gb, 6);
+ else
+ ctx->waves_info->waves[dst[sb].start_index].amp_sf = get_bits(gb, 6);
+ }
+ break;
+ case 1: /** min + VLC delta */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ if (ctx->waves_info->amplitude_mode)
+ for (i = 0; i < dst[sb].num_wavs; i++)
+ ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
+ get_vlc2(gb, tone_vlc_tabs[3].table,
+ tone_vlc_tabs[3].bits, 1) + 20;
+ else
+ ctx->waves_info->waves[dst[sb].start_index].amp_sf =
+ get_vlc2(gb, tone_vlc_tabs[4].table,
+ tone_vlc_tabs[4].bits, 1) + 24;
+ }
+ break;
+ case 2: /** VLC modulo delta to master (slave only) */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb] || !dst[sb].num_wavs)
+ continue;
+ for (i = 0; i < dst[sb].num_wavs; i++) {
+ delta = get_vlc2(gb, tone_vlc_tabs[5].table,
+ tone_vlc_tabs[5].bits, 1);
+ delta = sign_extend(delta, 5);
+ pred = refwaves[dst[sb].start_index + i] >= 0 ?
+ ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf : 34;
+ ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = (pred + delta) & 0x3F;
+ }
+ }
+ break;
+ case 3: /** clone master (slave only) */
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb])
+ continue;
+ for (i = 0; i < dst[sb].num_wavs; i++)
+ ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
+ refwaves[dst[sb].start_index + i] >= 0
+ ? ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf
+ : 32;
+ }
+ break;
+ }
+}
+
+/**
+ * Decode phase information for each subband of a channel.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] ch_num channel to process
+ * @param[in] band_has_tones ptr to an array of per-band-flags:
+ * 1 - tone data present
+ */
+static void decode_tones_phase(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int ch_num, int band_has_tones[])
+{
+ int sb, i;
+ Atrac3pWaveParam *wparam;
+ Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
+
+ for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
+ if (!band_has_tones[sb])
+ continue;
+ wparam = &ctx->waves_info->waves[dst[sb].start_index];
+ for (i = 0; i < dst[sb].num_wavs; i++)
+ wparam[i].phase_index = get_bits(gb, 5);
+ }
+}
+
+/**
+ * Decode tones info for all channels.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+static int decode_tones_info(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch_num, i, ret;
+ int band_has_tones[16];
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++)
+ memset(ctx->channels[ch_num].tones_info, 0,
+ sizeof(*ctx->channels[ch_num].tones_info) * ATRAC3P_SUBBANDS);
+
+ ctx->waves_info->tones_present = get_bits1(gb);
+ if (!ctx->waves_info->tones_present)
+ return 0;
+
+ memset(ctx->waves_info->waves, 0, sizeof(ctx->waves_info->waves));
+
+ ctx->waves_info->amplitude_mode = get_bits1(gb);
+ if (!ctx->waves_info->amplitude_mode) {
+ avpriv_report_missing_feature(avctx, "GHA amplitude mode 0");
+ return AVERROR_PATCHWELCOME;
+ }
+
+ ctx->waves_info->num_tone_bands =
+ get_vlc2(gb, tone_vlc_tabs[0].table,
+ tone_vlc_tabs[0].bits, 1) + 1;
+
+ if (num_channels == 2) {
+ get_subband_flags(gb, ctx->waves_info->tone_sharing, ctx->waves_info->num_tone_bands);
+ get_subband_flags(gb, ctx->waves_info->tone_master, ctx->waves_info->num_tone_bands);
+ if (get_subband_flags(gb, ctx->waves_info->phase_shift,
+ ctx->waves_info->num_tone_bands)) {
+ avpriv_report_missing_feature(avctx, "GHA Phase shifting");
+ return AVERROR_PATCHWELCOME;
+ }
+ }
+
+ ctx->waves_info->tones_index = 0;
+
+ for (ch_num = 0; ch_num < num_channels; ch_num++) {
+ for (i = 0; i < ctx->waves_info->num_tone_bands; i++)
+ band_has_tones[i] = !ch_num ? 1 : !ctx->waves_info->tone_sharing[i];
+
+ decode_tones_envelope(gb, ctx, ch_num, band_has_tones);
+ if ((ret = decode_band_numwavs(gb, ctx, ch_num, band_has_tones,
+ avctx)) < 0)
+ return ret;
+
+ decode_tones_frequency(gb, ctx, ch_num, band_has_tones);
+ decode_tones_amplitude(gb, ctx, ch_num, band_has_tones);
+ decode_tones_phase(gb, ctx, ch_num, band_has_tones);
+ }
+
+ if (num_channels == 2) {
+ for (i = 0; i < ctx->waves_info->num_tone_bands; i++) {
+ if (ctx->waves_info->tone_sharing[i])
+ ctx->channels[1].tones_info[i] = ctx->channels[0].tones_info[i];
+
+ if (ctx->waves_info->tone_master[i])
+ FFSWAP(Atrac3pWavesData, ctx->channels[0].tones_info[i],
+ ctx->channels[1].tones_info[i]);
+ }
+ }
+
+ return 0;
+}
+
+int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ret;
+
+ /* parse sound header */
+ ctx->num_quant_units = get_bits(gb, 5) + 1;
+ if (ctx->num_quant_units > 28 && ctx->num_quant_units < 32) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid number of quantization units: %d!\n",
+ ctx->num_quant_units);
+ return AVERROR_INVALIDDATA;
+ }
+
+ ctx->mute_flag = get_bits1(gb);
+
+ /* decode various sound parameters */
+ if ((ret = decode_quant_wordlen(gb, ctx, num_channels, avctx)) < 0)
+ return ret;
+
+ ctx->num_subbands = atrac3p_qu_to_subband[ctx->num_quant_units - 1] + 1;
+ ctx->num_coded_subbands = ctx->used_quant_units
+ ? atrac3p_qu_to_subband[ctx->used_quant_units - 1] + 1
+ : 0;
+
+ if ((ret = decode_scale_factors(gb, ctx, num_channels, avctx)) < 0)
+ return ret;
+
+ if ((ret = decode_code_table_indexes(gb, ctx, num_channels, avctx)) < 0)
+ return ret;
+
+ decode_spectrum(gb, ctx, num_channels, avctx);
+
+ if (num_channels == 2) {
+ get_subband_flags(gb, ctx->swap_channels, ctx->num_coded_subbands);
+ get_subband_flags(gb, ctx->negate_coeffs, ctx->num_coded_subbands);
+ }
+
+ decode_window_shape(gb, ctx, num_channels);
+
+ if ((ret = decode_gainc_data(gb, ctx, num_channels, avctx)) < 0)
+ return ret;
+
+ if ((ret = decode_tones_info(gb, ctx, num_channels, avctx)) < 0)
+ return ret;
+
+ /* decode global noise info */
+ ctx->noise_present = get_bits1(gb);
+ if (ctx->noise_present) {
+ ctx->noise_level_index = get_bits(gb, 4);
+ ctx->noise_table_index = get_bits(gb, 4);
+ }
+
+ return 0;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac3plus.h b/chromium/third_party/ffmpeg/libavcodec/atrac3plus.h
new file mode 100644
index 00000000000..1b001fae6d6
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac3plus.h
@@ -0,0 +1,240 @@
+/*
+ * ATRAC3+ compatible decoder
+ *
+ * Copyright (c) 2010-2013 Maxim Poliakovski
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Global structures, constants and data for ATRAC3+ decoder.
+ */
+
+#ifndef AVCODEC_ATRAC3PLUS_H
+#define AVCODEC_ATRAC3PLUS_H
+
+#include <stdint.h>
+
+#include "libavutil/float_dsp.h"
+#include "atrac.h"
+#include "avcodec.h"
+#include "fft.h"
+#include "get_bits.h"
+
+/** Global unit sizes */
+#define ATRAC3P_SUBBANDS 16 ///< number of PQF subbands
+#define ATRAC3P_SUBBAND_SAMPLES 128 ///< number of samples per subband
+#define ATRAC3P_FRAME_SAMPLES (ATRAC3P_SUBBAND_SAMPLES * ATRAC3P_SUBBANDS)
+
+#define ATRAC3P_PQF_FIR_LEN 12 ///< length of the prototype FIR of the PQF
+
+/** Global constants */
+#define ATRAC3P_POWER_COMP_OFF 15 ///< disable power compensation
+
+/** ATRAC3+ channel unit types */
+enum Atrac3pChannelUnitTypes {
+ CH_UNIT_MONO = 0, ///< unit containing one coded channel
+ CH_UNIT_STEREO = 1, ///< unit containing two jointly-coded channels
+ CH_UNIT_EXTENSION = 2, ///< unit containing extension information
+ CH_UNIT_TERMINATOR = 3 ///< unit sequence terminator
+};
+
+/** Per-channel IPQF history */
+typedef struct Atrac3pIPQFChannelCtx {
+ DECLARE_ALIGNED(32, float, buf1)[ATRAC3P_PQF_FIR_LEN * 2][8];
+ DECLARE_ALIGNED(32, float, buf2)[ATRAC3P_PQF_FIR_LEN * 2][8];
+ int pos;
+} Atrac3pIPQFChannelCtx;
+
+/** Amplitude envelope of a group of sine waves */
+typedef struct Atrac3pWaveEnvelope {
+ int has_start_point; ///< indicates start point within the GHA window
+ int has_stop_point; ///< indicates stop point within the GHA window
+ int start_pos; ///< start position expressed in n*4 samples
+ int stop_pos; ///< stop position expressed in n*4 samples
+} Atrac3pWaveEnvelope;
+
+/** Parameters of a group of sine waves */
+typedef struct Atrac3pWavesData {
+ Atrac3pWaveEnvelope pend_env; ///< pending envelope from the previous frame
+ Atrac3pWaveEnvelope curr_env; ///< group envelope from the current frame
+ int num_wavs; ///< number of sine waves in the group
+ int start_index; ///< start index into global tones table for that subband
+} Atrac3pWavesData;
+
+/** Parameters of a single sine wave */
+typedef struct Atrac3pWaveParam {
+ int freq_index; ///< wave frequency index
+ int amp_sf; ///< quantized amplitude scale factor
+ int amp_index; ///< quantized amplitude index
+ int phase_index; ///< quantized phase index
+} Atrac3pWaveParam;
+
+/** Sound channel parameters */
+typedef struct Atrac3pChanParams {
+ int ch_num;
+ int num_coded_vals; ///< number of transmitted quant unit values
+ int fill_mode;
+ int split_point;
+ int table_type; ///< table type: 0 - tone?, 1- noise?
+ int qu_wordlen[32]; ///< array of word lengths for each quant unit
+ int qu_sf_idx[32]; ///< array of scale factor indexes for each quant unit
+ int qu_tab_idx[32]; ///< array of code table indexes for each quant unit
+ int16_t spectrum[2048]; ///< decoded IMDCT spectrum
+ uint8_t power_levs[5]; ///< power compensation levels
+
+ /* imdct window shape history (2 frames) for overlapping. */
+ uint8_t wnd_shape_hist[2][ATRAC3P_SUBBANDS]; ///< IMDCT window shape, 0=sine/1=steep
+ uint8_t *wnd_shape; ///< IMDCT window shape for current frame
+ uint8_t *wnd_shape_prev; ///< IMDCT window shape for previous frame
+
+ /* gain control data history (2 frames) for overlapping. */
+ AtracGainInfo gain_data_hist[2][ATRAC3P_SUBBANDS]; ///< gain control data for all subbands
+ AtracGainInfo *gain_data; ///< gain control data for next frame
+ AtracGainInfo *gain_data_prev; ///< gain control data for previous frame
+ int num_gain_subbands; ///< number of subbands with gain control data
+
+ /* tones data history (2 frames) for overlapping. */
+ Atrac3pWavesData tones_info_hist[2][ATRAC3P_SUBBANDS];
+ Atrac3pWavesData *tones_info;
+ Atrac3pWavesData *tones_info_prev;
+} Atrac3pChanParams;
+
+/* Per-unit sine wave parameters */
+typedef struct Atrac3pWaveSynthParams {
+ int tones_present; ///< 1 - tones info present
+ int amplitude_mode; ///< 1 - low range, 0 - high range
+ int num_tone_bands; ///< number of PQF bands with tones
+ uint8_t tone_sharing[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise tone sharing flags
+ uint8_t tone_master[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise tone channel swapping
+ uint8_t phase_shift[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise 180° phase shifting
+ int tones_index; ///< total sum of tones in this unit
+ Atrac3pWaveParam waves[48];
+} Atrac3pWaveSynthParams;
+
+/** Channel unit parameters */
+typedef struct Atrac3pChanUnitCtx {
+ /* channel unit variables */
+ int unit_type; ///< unit type (mono/stereo)
+ int num_quant_units;
+ int num_subbands;
+ int used_quant_units; ///< number of quant units with coded spectrum
+ int num_coded_subbands; ///< number of subbands with coded spectrum
+ int mute_flag; ///< mute flag
+ int use_full_table; ///< 1 - full table list, 0 - restricted one
+ int noise_present; ///< 1 - global noise info present
+ int noise_level_index; ///< global noise level index
+ int noise_table_index; ///< global noise RNG table index
+ uint8_t swap_channels[ATRAC3P_SUBBANDS]; ///< 1 - perform subband-wise channel swapping
+ uint8_t negate_coeffs[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise IMDCT coefficients negation
+ Atrac3pChanParams channels[2];
+
+ /* Variables related to GHA tones */
+ Atrac3pWaveSynthParams wave_synth_hist[2]; ///< waves synth history for two frames
+ Atrac3pWaveSynthParams *waves_info;
+ Atrac3pWaveSynthParams *waves_info_prev;
+
+ Atrac3pIPQFChannelCtx ipqf_ctx[2];
+ DECLARE_ALIGNED(32, float, prev_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< overlapping buffer
+} Atrac3pChanUnitCtx;
+
+/**
+ * Initialize VLC tables for bitstream parsing.
+ */
+void ff_atrac3p_init_vlcs(void);
+
+/**
+ * Decode bitstream data of a channel unit.
+ *
+ * @param[in] gb the GetBit context
+ * @param[in,out] ctx ptr to the channel unit context
+ * @param[in] num_channels number of channels to process
+ * @param[in] avctx ptr to the AVCodecContext
+ * @return result code: 0 = OK, otherwise - error code
+ */
+int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
+ int num_channels, AVCodecContext *avctx);
+
+/**
+ * Initialize IMDCT transform.
+ *
+ * @param[in] avctx ptr to the AVCodecContext
+ * @param[in] mdct_ctx pointer to MDCT transform context
+ */
+void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx);
+
+/**
+ * Initialize sine waves synthesizer.
+ */
+void ff_atrac3p_init_wave_synth(void);
+
+/**
+ * Synthesize sine waves for a particular subband.
+ *
+ * @param[in] ch_unit pointer to the channel unit context
+ * @param[in] fdsp pointer to float DSP context
+ * @param[in] ch_num which channel to process
+ * @param[in] sb which subband to process
+ * @param[out] out receives processed data
+ */
+void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *fdsp,
+ int ch_num, int sb, float *out);
+
+/**
+ * Perform power compensation aka noise dithering.
+ *
+ * @param[in] ctx ptr to the channel context
+ * @param[in] ch_index which channel to process
+ * @param[in,out] sp ptr to channel spectrum to process
+ * @param[in] rng_index indicates which RNG table to use
+ * @param[in] sb_num which subband to process
+ */
+void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index,
+ float *sp, int rng_index, int sb_num);
+
+/**
+ * Regular IMDCT and windowing without overlapping,
+ * with spectrum reversal in the odd subbands.
+ *
+ * @param[in] fdsp pointer to float DSP context
+ * @param[in] mdct_ctx pointer to MDCT transform context
+ * @param[in] pIn float input
+ * @param[out] pOut float output
+ * @param[in] wind_id which MDCT window to apply
+ * @param[in] sb subband number
+ */
+void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
+ float *pOut, int wind_id, int sb);
+
+/**
+ * Subband synthesis filter based on the polyphase quadrature (pseudo-QMF)
+ * filter bank.
+ *
+ * @param[in] dct_ctx ptr to the pre-initialized IDCT context
+ * @param[in,out] hist ptr to the filter history
+ * @param[in] in input data to process
+ * @param[out] out receives processed data
+ */
+void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
+ const float *in, float *out);
+
+extern const uint16_t ff_atrac3p_qu_to_spec_pos[33];
+extern const float ff_atrac3p_sf_tab[64];
+extern const float ff_atrac3p_mant_tab[8];
+
+#endif /* AVCODEC_ATRAC3PLUS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac3plus_data.h b/chromium/third_party/ffmpeg/libavcodec/atrac3plus_data.h
new file mode 100644
index 00000000000..2a107eef1fa
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac3plus_data.h
@@ -0,0 +1,1914 @@
+/*
+ * ATRAC3+ compatible decoder
+ *
+ * Copyright (c) 2010-2013 Maxim Poliakovski
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_ATRAC3PLUS_DATA_H
+#define AVCODEC_ATRAC3PLUS_DATA_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/** VLC tables for wordlen */
+static const uint8_t atrac3p_wl_huff_code1[3] = { 0, 2, 3 };
+
+static const uint8_t atrac3p_wl_huff_bits1[3] = { 1, 2, 2 };
+
+static const uint8_t atrac3p_wl_huff_xlat1[3] = { 0, 1, 7 };
+
+static const uint8_t atrac3p_wl_huff_code2[5] = { 0, 4, 5, 6, 7 };
+
+static const uint8_t atrac3p_wl_huff_bits2[5] = { 1, 3, 3, 3, 3 };
+
+static const uint8_t atrac3p_wl_huff_xlat2[5] = { 0, 1, 2, 6, 7 };
+
+static const uint8_t atrac3p_wl_huff_code3[8] = {
+ 0, 4, 0xC, 0x1E, 0x1F, 0xD, 0xE, 5
+};
+
+static const uint8_t atrac3p_wl_huff_bits3[8] = { 1, 3, 4, 5, 5, 4, 4, 3 };
+
+static const uint8_t atrac3p_wl_huff_code4[8] = {
+ 0, 4, 0xC, 0xD, 0x1E, 0x1F, 0xE, 5
+};
+
+static const uint8_t atrac3p_wl_huff_bits4[8] = { 1, 3, 4, 4, 5, 5, 4, 3 };
+
+/** VLC tables for scale factor indexes */
+static const uint16_t atrac3p_sf_huff_code1[64] = {
+ 0, 2, 3, 4, 5, 0xC, 0xD, 0xE0,
+ 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0x1CE, 0x1CF,
+ 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7,
+ 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF,
+ 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7,
+ 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF,
+ 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7,
+ 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF
+};
+
+static const uint8_t atrac3p_sf_huff_bits1[64] = {
+ 2, 3, 3, 3, 3, 4, 4, 8, 8, 8, 8, 8, 8, 8, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9
+};
+
+static const uint8_t atrac3p_sf_huff_xlat1[64] = {
+ 0, 1, 61, 62, 63, 2, 60, 3, 4, 5, 6, 57, 58, 59, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56
+};
+
+static const uint8_t atrac3p_sf_huff_xlat2[64] = {
+ 0, 1, 2, 62, 63, 3, 61, 4, 5, 6, 57, 58, 59, 60, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56
+};
+
+static const uint16_t atrac3p_sf_huff_code2[64] = {
+ 0, 4, 0x18, 0x19, 0x70, 0x1CA, 0x1CB, 0x1CC,
+ 0x1CD, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4,
+ 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC,
+ 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4,
+ 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC,
+ 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4,
+ 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC,
+ 0x1FD, 0x1FE, 0x1FF, 0xE4, 0x71, 0x1A, 0x1B, 5
+};
+
+static const uint8_t atrac3p_sf_huff_bits2[64] = {
+ 1, 3, 5, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 5, 5, 3
+};
+
+static const uint16_t atrac3p_sf_huff_code3[64] = {
+ 0, 2, 3, 0x18, 0x19, 0x70, 0x1CC, 0x1CD,
+ 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5,
+ 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD,
+ 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5,
+ 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED,
+ 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5,
+ 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD,
+ 0x1FE, 0x1FF, 0x71, 0x72, 0x1A, 0x1B, 4, 5
+};
+
+static const uint8_t atrac3p_sf_huff_bits3[64] = {
+ 2, 3, 3, 5, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 5, 5, 3, 3
+};
+
+static const uint16_t atrac3p_sf_huff_code4[16] = {
+ 0, 2, 3, 4, 5, 0xC, 0xD, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0, 0x3D, 0x3E, 0x3F
+};
+
+static const uint8_t atrac3p_sf_huff_bits4[16] = {
+ 2, 3, 3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 0, 6, 6, 6
+};
+
+static const uint8_t atrac3p_sf_huff_xlat4[16] = {
+ 0, 1, 13, 14, 15, 2, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11
+};
+
+static const uint8_t atrac3p_sf_huff_xlat5[16] = {
+ 0, 1, 2, 14, 15, 3, 13, 4, 5, 6, 7, 9, 8, 10, 11, 12
+};
+
+static const uint16_t atrac3p_sf_huff_code5[16] = {
+ 0, 4, 0xC, 0x1C, 0x78, 0x79, 0x7A, 0x7B,
+ 0, 0x7C, 0x7D, 0x7E, 0x7F, 0x1D, 0xD, 5
+};
+
+static const uint8_t atrac3p_sf_huff_bits5[16] = {
+ 1, 3, 4, 5, 7, 7, 7, 7, 0, 7, 7, 7, 7, 5, 4, 3
+};
+
+static const uint16_t atrac3p_sf_huff_code6[16] = {
+ 0, 2, 3, 0xC, 0x1C, 0x3C, 0x7C, 0x7D, 0, 0x7E, 0x7F, 0x3D, 0x1D, 0xD, 4, 5
+};
+
+static const uint8_t atrac3p_sf_huff_bits6[16] = {
+ 2, 3, 3, 4, 5, 6, 7, 7, 0, 7, 7, 6, 5, 4, 3, 3
+};
+
+/** VLC tables for code table indexes */
+static const uint8_t atrac3p_ct_huff_code1[4] = { 0, 2, 6, 7 };
+
+static const uint8_t atrac3p_ct_huff_bits1[4] = { 1, 2, 3, 3 };
+
+static const uint8_t atrac3p_ct_huff_code2[8] = { 0, 2, 3, 4, 5, 6, 0xE, 0xF };
+
+static const uint8_t atrac3p_ct_huff_bits2[8] = { 2, 3, 3, 3, 3, 3, 4, 4 };
+
+static const uint8_t atrac3p_ct_huff_xlat1[8] = { 0, 1, 2, 3, 6, 7, 4, 5 };
+
+static const uint8_t atrac3p_ct_huff_code3[8] = {
+ 0, 4, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF
+};
+
+static const uint8_t atrac3p_ct_huff_bits3[8] = { 1, 3, 4, 4, 4, 4, 4, 4 };
+
+/* weights for quantized word lengths */
+static const int8_t atrac3p_wl_weights[6][32] = {
+ { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
+ { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 6, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 2, 2, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+};
+
+/* weights for quantized scale factors
+ * sf_weights[i] = i / (tab_idx + 1)
+ * where tab_idx = [1,2] */
+static const int8_t atrac3p_sf_weights[2][32] = {
+ { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
+ 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 },
+ { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5,
+ 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10 }
+};
+
+/** Ungroup table for word length segments.
+ * Numbers in this table tell which coeff belongs to which segment. */
+static const uint8_t atrac3p_qu_num_to_seg[32] = {
+ 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5,
+ 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9
+};
+
+/** Map quant unit number to subband number */
+static const uint8_t atrac3p_qu_to_subband[32] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+};
+
+/** Map subband number to number of power compensation groups */
+static const int atrac3p_subband_to_num_powgrps[16] = {
+ 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5
+};
+
+/** 3D base shape tables. The values are grouped together as follows:
+ * [num_start_values = 8][num_shape_tables = 16][num_seg_coeffs = 9]
+ * For each of the 8 start values there are 16 different shapes each
+ * 9 coefficients long. */
+static const int8_t atrac3p_wl_shapes[8][16][9] = {
+ { { 0, 0, 0, 0, 0, 0, 0, -2, -1 },
+ { 0, 0, 0, 0, 0, 0, 0, -5, -1 },
+ { 0, 0, 0, -7, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, -7, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, -5, 0, 0 },
+ { 0, 0, 0, 0, -5, 0, 0, 0, 0 },
+ { -7, -7, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, -7, 0, 0, 0, 0, 0, 0, 0 },
+ { -2, -2, -5, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, -2, -5, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, -2, -5, 0, 0 },
+ { 0, 0, 0, -5, 0, 0, 0, 0, 0 },
+ { 0, -2, -7, -2, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, -2, -5, 0, 0, 0 },
+ { 0, 0, 0, -5, -5, 0, 0, 0, 0 },
+ { 0, 0, 0, -5, -2, 0, 0, 0, 0 } },
+ { { -1, -5, -3, -2, -1, -1, 0, 0, 0 },
+ { -2, -5, -3, -3, -2, -1, -1, 0, 0 },
+ { 0, -1, -1, -1, 0, 0, 0, 0, 0 },
+ { -1, -3, 0, 0, 0, 0, 0, 0, 0 },
+ { -1, -2, 0, 0, 0, 0, 0, 0, 0 },
+ { -1, -3, -1, 0, 0, 0, 0, 1, 1 },
+ { -1, -5, -3, -3, -2, -1, 0, 0, 0 },
+ { -1, -1, -4, -2, -2, -1, -1, 0, 0 },
+ { -1, -1, -3, -2, -3, -1, -1, -1, 0 },
+ { -1, -4, -2, -3, -1, 0, 0, 0, 0 },
+ { 0, -1, -2, -2, -1, -1, 0, 0, 0 },
+ { 0, -2, -1, 0, 0, 0, 0, 0, 0 },
+ { -1, -1, 0, 0, 0, 0, 0, 0, 0 },
+ { -1, -1, -3, -2, -2, -1, -1, -1, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, -1, -3, -2, -2, -1, -1, -1, 0 }, },
+ { { -1, -2, 0, 1, 1, 1, 1, 1, 1 },
+ { 0, -1, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, -2, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, -2, 0, 1, 1, 1, 1, 1, 1 },
+ { -1, -1, 0, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, -1, 0, 1, 1, 1, 1, 1 },
+ { -1, -1, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, -1, 1, 1, 1, 1, 1, 1 },
+ { 0, -1, 0, 1, 1, 1, 1, 1, 1 },
+ { -1, -1, -1, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, 0, 0, 1, 1, 1, 1, 1 },
+ { 0, 0, 0, 1, 1, 1, 1, 1, 1 },
+ { 0, -1, -1, 1, 1, 1, 1, 1, 1 },
+ { 0, 1, 0, 1, 1, 1, 1, 1, 1 },
+ { 0, -3, -2, 1, 1, 1, 1, 2, 2 },
+ { -3, -5, -3, 2, 2, 2, 2, 2, 2 }, },
+ { { -1, -2, 0, 2, 2, 2, 2, 2, 2 },
+ { -1, -2, 0, 1, 2, 2, 2, 2, 2 },
+ { 0, -2, 0, 2, 2, 2, 2, 2, 2 },
+ { -1, 0, 1, 2, 2, 2, 2, 2, 2 },
+ { 0, 0, 1, 2, 2, 2, 2, 2, 2 },
+ { 0, -2, 0, 1, 2, 2, 2, 2, 2 },
+ { 0, -1, 1, 2, 2, 2, 2, 2, 2 },
+ { -1, -1, 0, 2, 2, 2, 2, 2, 2 },
+ { -1, -1, 0, 1, 2, 2, 2, 2, 2 },
+ { -1, -2, -1, 2, 2, 2, 2, 2, 2 },
+ { 0, -1, 0, 2, 2, 2, 2, 2, 2 },
+ { 1, 1, 0, 1, 2, 2, 2, 2, 2 },
+ { 0, 1, 2, 2, 2, 2, 2, 2, 2 },
+ { 1, 0, 0, 1, 2, 2, 2, 2, 2 },
+ { 0, 0, 0, 1, 2, 2, 2, 2, 2 },
+ { -1, -1, -1, 1, 2, 2, 2, 2, 2 }, },
+ { { 0, 1, 2, 3, 3, 3, 3, 3, 3 },
+ { 1, 1, 2, 3, 3, 3, 3, 3, 3 },
+ { -1, 0, 1, 2, 3, 3, 3, 3, 3 },
+ { 0, 0, 2, 3, 3, 3, 3, 3, 3 },
+ { -1, 0, 1, 3, 3, 3, 3, 3, 3 },
+ { 0, 0, 1, 3, 3, 3, 3, 3, 3 },
+ { 1, 2, 3, 3, 3, 3, 3, 3, 3 },
+ { 1, 2, 2, 3, 3, 3, 3, 3, 3 },
+ { 0, 1, 1, 3, 3, 3, 3, 3, 3 },
+ { 0, 0, 1, 2, 3, 3, 3, 3, 3 },
+ { -1, 1, 2, 3, 3, 3, 3, 3, 3 },
+ { -1, 0, 2, 3, 3, 3, 3, 3, 3 },
+ { 2, 2, 3, 3, 3, 3, 3, 3, 3 },
+ { 1, 1, 3, 3, 3, 3, 3, 3, 3 },
+ { 0, 2, 3, 3, 3, 3, 3, 3, 3 },
+ { 0, 1, 1, 2, 3, 3, 3, 3, 3 }, },
+ { { 0, 1, 2, 3, 4, 4, 4, 4, 4 },
+ { 1, 2, 3, 4, 4, 4, 4, 4, 4 },
+ { 0, 0, 2, 3, 4, 4, 4, 4, 4 },
+ { 1, 1, 2, 4, 4, 4, 4, 4, 4 },
+ { 0, 1, 2, 4, 4, 4, 4, 4, 4 },
+ { -1, 0, 1, 3, 4, 4, 4, 4, 4 },
+ { 0, 0, 1, 3, 4, 4, 4, 4, 4 },
+ { 1, 1, 2, 3, 4, 4, 4, 4, 4 },
+ { 0, 1, 1, 3, 4, 4, 4, 4, 4 },
+ { 2, 2, 3, 4, 4, 4, 4, 4, 4 },
+ { 1, 1, 3, 4, 4, 4, 4, 4, 4 },
+ { 1, 2, 2, 4, 4, 4, 4, 4, 4 },
+ { -1, 0, 2, 3, 4, 4, 4, 4, 4 },
+ { 0, 1, 3, 4, 4, 4, 4, 4, 4 },
+ { 1, 2, 2, 3, 4, 4, 4, 4, 4 },
+ { 0, 2, 3, 4, 4, 4, 4, 4, 4 }, },
+ { { 1, 2, 3, 4, 5, 5, 5, 5, 5 },
+ { 0, 1, 2, 3, 4, 5, 5, 5, 5 },
+ { 0, 1, 2, 3, 5, 5, 5, 5, 5 },
+ { 1, 1, 3, 4, 5, 5, 5, 5, 5 },
+ { 1, 1, 2, 4, 5, 5, 5, 5, 5 },
+ { 1, 2, 2, 4, 5, 5, 5, 5, 5 },
+ { 1, 1, 2, 3, 5, 5, 5, 5, 5 },
+ { 2, 2, 3, 4, 5, 5, 5, 5, 5 },
+ { 0, 1, 2, 4, 5, 5, 5, 5, 5 },
+ { 2, 2, 3, 5, 5, 5, 5, 5, 5 },
+ { 1, 2, 3, 5, 5, 5, 5, 5, 5 },
+ { 0, 1, 3, 4, 5, 5, 5, 5, 5 },
+ { 1, 2, 2, 3, 5, 5, 5, 5, 5 },
+ { 2, 3, 4, 5, 5, 5, 5, 5, 5 },
+ { 0, 2, 3, 4, 5, 5, 5, 5, 5 },
+ { 1, 1, 1, 3, 4, 5, 5, 5, 5 }, },
+ { { 1, 2, 3, 4, 5, 5, 5, 6, 6 },
+ { 1, 2, 3, 4, 5, 6, 6, 6, 6 },
+ { 2, 3, 4, 5, 6, 6, 6, 6, 6 },
+ { 1, 2, 3, 4, 6, 6, 6, 6, 6 },
+ { 2, 2, 3, 4, 5, 5, 5, 6, 6 },
+ { 1, 2, 3, 4, 5, 5, 6, 6, 6 },
+ { 2, 2, 3, 4, 6, 6, 6, 6, 6 },
+ { 2, 2, 3, 4, 5, 6, 6, 6, 6 },
+ { 2, 2, 4, 5, 6, 6, 6, 6, 6 },
+ { 2, 2, 3, 5, 6, 6, 6, 6, 6 },
+ { 1, 2, 3, 5, 6, 6, 6, 6, 6 },
+ { 2, 3, 3, 5, 6, 6, 6, 6, 6 },
+ { 1, 2, 4, 5, 6, 6, 6, 6, 6 },
+ { 2, 2, 3, 4, 5, 5, 6, 6, 6 },
+ { 2, 3, 3, 4, 6, 6, 6, 6, 6 },
+ { 1, 3, 4, 5, 6, 6, 6, 6, 6 } }
+};
+
+/** 2D base shape tables for scale factor coding.
+ * The values are grouped together as follows:
+ * [num_shape_tables = 64][num_seg_coeffs = 9] */
+static const int8_t atrac3p_sf_shapes[64][9] = {
+ { -3, -2, -1, 0, 3, 5, 6, 8, 40 },
+ { -3, -2, 0, 1, 7, 9, 11, 13, 20 },
+ { -1, 0, 0, 1, 6, 8, 10, 13, 41 },
+ { 0, 0, 0, 2, 5, 5, 6, 8, 14 },
+ { 0, 0, 0, 2, 6, 7, 8, 11, 47 },
+ { 0, 0, 1, 2, 5, 7, 8, 10, 32 },
+ { 0, 0, 1, 3, 8, 10, 12, 14, 47 },
+ { 0, 0, 2, 4, 9, 10, 12, 14, 40 },
+ { 0, 0, 3, 5, 9, 10, 12, 14, 22 },
+ { 0, 1, 3, 5, 10, 14, 18, 22, 31 },
+ { 0, 2, 5, 6, 10, 10, 10, 12, 46 },
+ { 0, 2, 5, 7, 12, 14, 15, 18, 44 },
+ { 1, 1, 4, 5, 7, 7, 8, 9, 15 },
+ { 1, 2, 2, 2, 4, 5, 7, 9, 26 },
+ { 1, 2, 2, 3, 6, 7, 7, 8, 47 },
+ { 1, 2, 2, 3, 6, 8, 10, 13, 22 },
+ { 1, 3, 4, 7, 13, 17, 21, 24, 41 },
+ { 1, 4, 0, 4, 10, 12, 13, 14, 17 },
+ { 2, 3, 3, 3, 6, 8, 10, 13, 48 },
+ { 2, 3, 3, 4, 9, 12, 14, 17, 47 },
+ { 2, 3, 3, 5, 10, 12, 14, 17, 25 },
+ { 2, 3, 5, 7, 8, 9, 9, 9, 13 },
+ { 2, 3, 5, 9, 16, 21, 25, 28, 33 },
+ { 2, 4, 5, 8, 12, 14, 17, 19, 26 },
+ { 2, 4, 6, 8, 12, 13, 13, 15, 20 },
+ { 2, 4, 7, 12, 20, 26, 30, 32, 35 },
+ { 3, 3, 5, 6, 12, 14, 16, 19, 34 },
+ { 3, 4, 4, 5, 7, 9, 10, 11, 48 },
+ { 3, 4, 5, 6, 8, 9, 10, 11, 16 },
+ { 3, 5, 5, 5, 7, 9, 10, 13, 35 },
+ { 3, 5, 5, 7, 10, 12, 13, 15, 49 },
+ { 3, 5, 7, 7, 8, 7, 9, 12, 21 },
+ { 3, 5, 7, 8, 12, 14, 15, 15, 24 },
+ { 3, 5, 7, 10, 16, 21, 24, 27, 44 },
+ { 3, 5, 8, 14, 21, 26, 28, 29, 42 },
+ { 3, 6, 10, 13, 18, 19, 20, 22, 27 },
+ { 3, 6, 11, 16, 24, 27, 28, 29, 31 },
+ { 4, 5, 4, 3, 4, 6, 8, 11, 18 },
+ { 4, 6, 5, 6, 9, 10, 12, 14, 20 },
+ { 4, 6, 7, 6, 6, 6, 7, 8, 46 },
+ { 4, 6, 7, 9, 13, 16, 18, 20, 48 },
+ { 4, 6, 7, 9, 14, 17, 20, 23, 31 },
+ { 4, 6, 9, 11, 14, 15, 15, 17, 21 },
+ { 4, 8, 13, 20, 27, 32, 35, 36, 38 },
+ { 5, 6, 6, 4, 5, 6, 7, 6, 6 },
+ { 5, 7, 7, 8, 9, 9, 10, 12, 49 },
+ { 5, 8, 9, 9, 10, 11, 12, 13, 42 },
+ { 5, 8, 10, 12, 15, 16, 17, 19, 42 },
+ { 5, 8, 12, 17, 26, 31, 32, 33, 44 },
+ { 5, 9, 13, 16, 20, 22, 23, 23, 35 },
+ { 6, 8, 8, 7, 6, 5, 6, 8, 15 },
+ { 6, 8, 8, 8, 9, 10, 12, 16, 24 },
+ { 6, 8, 8, 9, 10, 10, 11, 11, 13 },
+ { 6, 8, 10, 13, 19, 21, 24, 26, 32 },
+ { 6, 9, 10, 11, 13, 13, 14, 16, 49 },
+ { 7, 9, 9, 10, 13, 14, 16, 19, 27 },
+ { 7, 10, 12, 13, 16, 16, 17, 17, 27 },
+ { 7, 10, 12, 14, 17, 19, 20, 22, 48 },
+ { 8, 9, 10, 9, 10, 11, 11, 11, 19 },
+ { 8, 11, 12, 12, 13, 13, 13, 13, 17 },
+ { 8, 11, 13, 14, 16, 17, 19, 20, 27 },
+ { 8, 12, 17, 22, 26, 28, 29, 30, 33 },
+ { 10, 14, 16, 19, 21, 22, 22, 24, 28 },
+ { 10, 15, 17, 18, 21, 22, 23, 25, 43 }
+};
+
+static const uint8_t atrac3p_ct_restricted_to_full[2][7][4] = {
+ { { 0, 5, 4, 1 },
+ { 0, 1, 2, 3 },
+ { 3, 0, 4, 2 },
+ { 4, 0, 1, 2 },
+ { 1, 0, 4, 3 },
+ { 3, 0, 2, 1 },
+ { 0, 3, 1, 2 } },
+ { { 4, 0, 1, 2 },
+ { 0, 3, 2, 1 },
+ { 0, 1, 2, 3 },
+ { 0, 1, 2, 4 },
+ { 0, 1, 2, 3 },
+ { 1, 4, 2, 0 },
+ { 0, 1, 2, 3 } }
+};
+
+/** Tables for spectrum coding */
+static const uint8_t huff_a01_cb[14] = {
+ 1, 12, 1, 0, 0, 1, 7, 0, 19, 5, 13, 21, 6, 8
+};
+
+static const uint8_t huff_a01_xlat[81] = {
+ 0x00, 0x03, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x50, 0xD0, 0x70,
+ 0xF0, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0x41, 0xC1, 0x31, 0x05, 0x0D,
+ 0xC3, 0x13, 0x07, 0x0F, 0x44, 0xCC, 0x11, 0x43, 0x33, 0x54, 0x74, 0xDC,
+ 0xFC, 0x71, 0x15, 0x4D, 0xCD, 0x1D, 0xD3, 0xC7, 0x37, 0x3F, 0xD4, 0xF4,
+ 0x5C, 0x7C, 0x51, 0xD1, 0xF1, 0x45, 0xC5, 0x35, 0xDD, 0x3D, 0x53, 0x73,
+ 0xF3, 0x47, 0x17, 0x77, 0x4F, 0xCF, 0x1F, 0x55, 0xF5, 0x7D, 0xD7, 0x5F,
+ 0xFF, 0xD5, 0x75, 0x5D, 0xFD, 0x57, 0xF7, 0xDF, 0x7F
+};
+
+static const uint8_t huff_a02_cb[13] = {
+ 2, 12, 1, 0, 4, 11, 0, 1, 29, 6, 20, 7, 2
+};
+
+static const uint8_t huff_a02_xlat[81] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x90, 0x80, 0x20, 0x60, 0x84, 0x94, 0x24, 0x64,
+ 0x08, 0x48, 0x18, 0x58, 0x81, 0x91, 0x21, 0x85, 0x95, 0x65, 0x09, 0x49,
+ 0x19, 0x59, 0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56, 0x88, 0x61,
+ 0x25, 0x29, 0x69, 0x5A, 0xA0, 0xA4, 0x98, 0x28, 0x68, 0xA1, 0xA5, 0x89,
+ 0x99, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x96, 0x26, 0x66, 0x0A, 0x4A, 0x1A,
+ 0xA8, 0x86, 0xA6, 0x8A, 0x9A, 0x2A, 0x6A, 0xA2, 0xAA
+};
+
+static const uint8_t huff_a03_cb[9] = { 3, 9, 1, 8, 0, 13, 18, 7, 2 };
+
+static const uint8_t huff_a03_xlat[49] = {
+ 0x00, 0x08, 0x38, 0x01, 0x09, 0x39, 0x07, 0x0F, 0x3F, 0x10, 0x30, 0x11,
+ 0x31, 0x02, 0x0A, 0x3A, 0x05, 0x06, 0x0E, 0x3E, 0x17, 0x37, 0x18, 0x28,
+ 0x19, 0x29, 0x2A, 0x32, 0x03, 0x0B, 0x33, 0x3B, 0x0D, 0x15, 0x3D, 0x16,
+ 0x1E, 0x36, 0x1F, 0x2F, 0x12, 0x1A, 0x13, 0x2B, 0x1D, 0x35, 0x2E, 0x1B,
+ 0x2D
+};
+
+static const uint8_t huff_a04_cb[4] = { 2, 3, 2, 4 };
+static const uint8_t huff_a04_xlat[6] = { 1, 2, 0, 3, 4, 5 };
+
+static const uint8_t huff_a05_cb[12] = {
+ 3, 12, 1, 3, 5, 8, 12, 23, 72, 68, 31, 2
+};
+
+static const uint8_t huff_a05_xlat[225] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x11, 0xF1, 0x0F, 0x1F, 0xFF, 0x20, 0xE0, 0xE1,
+ 0x02, 0xF2, 0x0E, 0x1E, 0x2F, 0x30, 0xD0, 0x21, 0x12, 0x22, 0xE2, 0x03,
+ 0x0D, 0x2E, 0xEE, 0xFE, 0xEF, 0x40, 0xC0, 0x31, 0xC1, 0xD1, 0x32, 0xD2,
+ 0x13, 0x23, 0xE3, 0xF3, 0x04, 0xF4, 0x0C, 0x1C, 0x1D, 0x2D, 0xED, 0xFD,
+ 0x3E, 0xDE, 0x3F, 0xDF, 0x50, 0x60, 0x70, 0x90, 0xA0, 0xB0, 0x41, 0x51,
+ 0x61, 0x71, 0x91, 0xA1, 0xB1, 0x42, 0x62, 0x92, 0xA2, 0xC2, 0x33, 0xC3,
+ 0xD3, 0x14, 0x24, 0x34, 0xD4, 0xE4, 0x05, 0x15, 0xF5, 0x06, 0x16, 0x26,
+ 0xE6, 0xF6, 0x07, 0x17, 0xE7, 0xF7, 0x09, 0x19, 0x29, 0xF9, 0x0A, 0x1A,
+ 0x2A, 0xEA, 0xFA, 0x0B, 0x1B, 0xFB, 0x2C, 0x3C, 0xDC, 0xEC, 0xFC, 0x3D,
+ 0x4D, 0xCD, 0xDD, 0x4E, 0x6E, 0x7E, 0xAE, 0xCE, 0x4F, 0x5F, 0x6F, 0x7F,
+ 0x9F, 0xAF, 0xBF, 0xCF, 0x52, 0x72, 0xB2, 0x43, 0x53, 0x63, 0x73, 0x93,
+ 0xA3, 0xB3, 0x44, 0x64, 0x74, 0x94, 0xA4, 0xB4, 0xC4, 0x25, 0x35, 0xA5,
+ 0xC5, 0xD5, 0xE5, 0x36, 0x46, 0xB6, 0xC6, 0xD6, 0x27, 0x37, 0x47, 0xB7,
+ 0xC7, 0xD7, 0x39, 0x49, 0x59, 0xC9, 0xD9, 0xE9, 0x3A, 0x4A, 0x5A, 0xCA,
+ 0xDA, 0x2B, 0x3B, 0x4B, 0x6B, 0x7B, 0xDB, 0xEB, 0x4C, 0x5C, 0x6C, 0x7C,
+ 0x9C, 0xAC, 0xCC, 0x5D, 0x6D, 0x7D, 0x9D, 0xAD, 0xBD, 0x5E, 0x9E, 0xBE,
+ 0x54, 0x45, 0x55, 0x65, 0x75, 0x95, 0xB5, 0x56, 0x66, 0x76, 0x96, 0xA6,
+ 0x57, 0x67, 0x97, 0xA7, 0x69, 0x79, 0xA9, 0xB9, 0x6A, 0x7A, 0x9A, 0xAA,
+ 0xBA, 0x5B, 0x9B, 0xAB, 0xBB, 0xCB, 0xBC, 0x77, 0x99
+};
+
+static const uint8_t huff_a06_cb[7] = {
+ 2, 6, 1, 3, 2, 6, 4
+};
+
+static const uint8_t huff_a06_xlat[16] = {
+ 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14, 10, 11, 12, 15
+};
+
+static const uint8_t huff_a07_cb[11] = {
+ 2, 10, 1, 2, 2, 2, 6, 14, 21, 13, 2
+};
+
+static const uint8_t huff_a07_xlat[63] = {
+ 0, 1, 63, 2, 62, 3, 61, 4, 5, 6, 58, 59, 60, 7, 8, 9,
+ 10, 26, 27, 28, 36, 37, 38, 54, 55, 56, 57, 11, 12, 13, 14, 15,
+ 16, 25, 29, 30, 31, 33, 34, 35, 39, 47, 48, 49, 50, 51, 52, 53,
+ 17, 18, 19, 20, 21, 22, 23, 41, 42, 43, 44, 45, 46, 24, 40
+};
+
+static const uint8_t huff_a11_cb[13] = {
+ 1, 11, 1, 0, 0, 0, 8, 1, 18, 9, 22, 10, 12
+};
+
+static const uint8_t huff_a11_xlat[81] = {
+ 0x00, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x03, 0xD0, 0x50, 0x70,
+ 0xF0, 0xC4, 0x34, 0x4C, 0xCC, 0x1C, 0x41, 0xC1, 0x31, 0x05, 0x0D, 0x43,
+ 0xC3, 0x13, 0x07, 0x0F, 0x44, 0x14, 0x74, 0xDC, 0x3C, 0x11, 0x1D, 0x33,
+ 0x37, 0x54, 0xD4, 0xF4, 0x5C, 0x7C, 0xFC, 0xD1, 0x71, 0xF1, 0x15, 0x35,
+ 0x4D, 0xCD, 0xDD, 0x3D, 0xD3, 0x73, 0x47, 0xC7, 0x17, 0x77, 0x3F, 0x51,
+ 0x45, 0xC5, 0x55, 0x53, 0xF3, 0x4F, 0xCF, 0x1F, 0xFF, 0xD5, 0x75, 0xF5,
+ 0x5D, 0x7D, 0xFD, 0x57, 0xD7, 0xF7, 0x5F, 0xDF, 0x7F
+};
+
+static const uint8_t huff_a12_cb[8] = { 5, 10, 16, 11, 32, 19, 1, 2 };
+
+static const uint8_t huff_a12_xlat[81] = {
+ 0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54, 0x01, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x90, 0x94, 0x58, 0x91, 0x95, 0x19, 0x59, 0x06,
+ 0x46, 0x16, 0x56, 0x80, 0x60, 0x84, 0x24, 0x64, 0xA4, 0x08, 0x48, 0x18,
+ 0x68, 0x81, 0x21, 0x61, 0xA1, 0x85, 0x25, 0x65, 0xA5, 0x09, 0x49, 0x99,
+ 0x69, 0xA9, 0x02, 0x42, 0x12, 0x52, 0x96, 0x26, 0x66, 0x1A, 0x5A, 0x20,
+ 0xA0, 0x88, 0x98, 0x28, 0xA8, 0x89, 0x29, 0x82, 0x92, 0x22, 0x62, 0x86,
+ 0xA6, 0x0A, 0x4A, 0x9A, 0x6A, 0xAA, 0xA2, 0x8A, 0x2A
+};
+
+static const uint8_t huff_a13_cb[12] = {
+ 1, 10, 1, 0, 0, 4, 2, 2, 9, 15, 12, 4
+};
+
+static const uint8_t huff_a13_xlat[49] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x39, 0x0F, 0x09, 0x3F, 0x10, 0x30, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x3E, 0x17, 0x18, 0x28, 0x11, 0x29, 0x0A, 0x32,
+ 0x03, 0x0B, 0x3B, 0x05, 0x0D, 0x3D, 0x16, 0x1F, 0x37, 0x19, 0x12, 0x1A,
+ 0x2A, 0x13, 0x33, 0x15, 0x35, 0x1E, 0x2E, 0x36, 0x2F, 0x1B, 0x2B, 0x1D,
+ 0x2D
+};
+
+static const uint8_t huff_a14_cb[12] = {
+ 2, 11, 1, 0, 4, 3, 5, 16, 28, 34, 26, 4
+};
+
+static const uint8_t huff_a14_xlat[121] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x11, 0x02,
+ 0x0E, 0x30, 0x50, 0xB0, 0xD0, 0x21, 0xE1, 0x12, 0xF2, 0x03, 0x05, 0x0B,
+ 0x0D, 0x1E, 0xFE, 0x2F, 0xEF, 0x40, 0xC0, 0x31, 0x51, 0xB1, 0xC1, 0xD1,
+ 0x22, 0x52, 0xE2, 0x13, 0xF3, 0x04, 0x15, 0xF5, 0x1B, 0xEB, 0xFB, 0x0C,
+ 0x1D, 0xFD, 0x2E, 0x5E, 0xEE, 0x3F, 0x5F, 0xBF, 0xDF, 0x41, 0x32, 0x42,
+ 0xB2, 0xD2, 0x23, 0x53, 0xB3, 0xE3, 0x14, 0x24, 0xE4, 0xF4, 0x25, 0x35,
+ 0xD5, 0xE5, 0x2B, 0x3B, 0xDB, 0x1C, 0x2C, 0xBC, 0xEC, 0xFC, 0x2D, 0xBD,
+ 0xED, 0x3E, 0x4E, 0xBE, 0xDE, 0x4F, 0xCF, 0xC2, 0x33, 0x43, 0xC3, 0xD3,
+ 0x34, 0x44, 0x54, 0xB4, 0xD4, 0x45, 0x55, 0xC5, 0x4B, 0xCB, 0x3C, 0x4C,
+ 0x5C, 0xCC, 0xDC, 0x3D, 0x4D, 0x5D, 0xCD, 0xDD, 0xCE, 0xC4, 0xB5, 0x5B,
+ 0xBB
+};
+
+static const uint8_t huff_a15_cb[9] = { 5, 11, 9, 12, 16, 44, 98, 42, 4 };
+
+static const uint8_t huff_a15_xlat[225] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x11, 0xF1, 0x0F, 0x1F, 0xFF, 0x20, 0xE0, 0x21,
+ 0xE1, 0x02, 0x12, 0xF2, 0x0E, 0x1E, 0xFE, 0x2F, 0xEF, 0x30, 0xD0, 0x31,
+ 0xD1, 0x22, 0xE2, 0x03, 0x13, 0xF3, 0x0D, 0x1D, 0xFD, 0x2E, 0xEE, 0x3F,
+ 0xDF, 0x40, 0x60, 0x70, 0x90, 0xA0, 0xC0, 0x41, 0xC1, 0x32, 0x42, 0xC2,
+ 0xD2, 0x23, 0x33, 0xD3, 0xE3, 0x04, 0x14, 0x24, 0xE4, 0xF4, 0x06, 0x16,
+ 0xF6, 0x07, 0x09, 0x0A, 0x1A, 0xFA, 0x0C, 0x1C, 0x2C, 0xEC, 0xFC, 0x2D,
+ 0x3D, 0xDD, 0xED, 0x3E, 0x4E, 0xCE, 0xDE, 0x4F, 0xCF, 0x50, 0xB0, 0x51,
+ 0x61, 0x71, 0x91, 0xA1, 0xB1, 0x52, 0x62, 0x72, 0x92, 0xA2, 0xB2, 0x43,
+ 0x53, 0x63, 0x73, 0x93, 0xA3, 0xC3, 0x34, 0x44, 0x64, 0xA4, 0xC4, 0xD4,
+ 0x05, 0x15, 0x25, 0x35, 0xD5, 0xE5, 0xF5, 0x26, 0x36, 0x46, 0xC6, 0xD6,
+ 0xE6, 0x17, 0x27, 0x37, 0xC7, 0xD7, 0xE7, 0xF7, 0x19, 0x29, 0x39, 0xC9,
+ 0xD9, 0xE9, 0xF9, 0x2A, 0x3A, 0x4A, 0x5A, 0xCA, 0xDA, 0xEA, 0x0B, 0x1B,
+ 0x2B, 0x3B, 0xCB, 0xDB, 0xEB, 0xFB, 0x3C, 0x4C, 0x6C, 0x7C, 0x9C, 0xAC,
+ 0xBC, 0xCC, 0xDC, 0x4D, 0x5D, 0x6D, 0x7D, 0x9D, 0xAD, 0xBD, 0xCD, 0x5E,
+ 0x6E, 0x7E, 0x9E, 0xAE, 0xBE, 0x5F, 0x6F, 0x7F, 0x9F, 0xAF, 0xBF, 0xB3,
+ 0x54, 0x74, 0x94, 0xB4, 0x45, 0x55, 0x65, 0x75, 0x95, 0xA5, 0xB5, 0xC5,
+ 0x56, 0x66, 0x76, 0x96, 0xA6, 0xB6, 0x47, 0x57, 0x67, 0xA7, 0xB7, 0x49,
+ 0x59, 0x69, 0xA9, 0xB9, 0x6A, 0x7A, 0x9A, 0xAA, 0xBA, 0x4B, 0x5B, 0x6B,
+ 0x7B, 0x9B, 0xAB, 0xBB, 0x5C, 0x77, 0x97, 0x79, 0x99
+};
+
+static const uint8_t huff_a16_cb[13] = {
+ 2, 12, 1, 1, 2, 2, 5, 7, 21, 54, 85, 62, 16
+};
+
+static const uint8_t huff_a16_xlat[256] = {
+ 0x00, 0x01, 0x10, 0x11, 0x21, 0x12, 0x20, 0x31, 0x02, 0x22, 0x13, 0x30,
+ 0x41, 0x32, 0x03, 0x23, 0x14, 0x24, 0x40, 0x51, 0x61, 0xD1, 0xE1, 0x42,
+ 0x52, 0xD2, 0x33, 0x43, 0xD3, 0x04, 0x34, 0x05, 0x15, 0x25, 0x16, 0x1D,
+ 0x2D, 0x1E, 0x2E, 0x50, 0x60, 0xD0, 0xE0, 0xF0, 0x71, 0x81, 0xF1, 0x62,
+ 0x72, 0xE2, 0xF2, 0x53, 0x63, 0xE3, 0xF3, 0x44, 0x54, 0xD4, 0xE4, 0xF4,
+ 0x35, 0x45, 0x55, 0xD5, 0xE5, 0xF5, 0x06, 0x26, 0x36, 0xD6, 0x07, 0x17,
+ 0x27, 0x37, 0xD7, 0x18, 0x28, 0x1C, 0x0D, 0x3D, 0x4D, 0x5D, 0x6D, 0x8D,
+ 0x0E, 0x3E, 0x4E, 0x5E, 0x0F, 0x1F, 0x2F, 0x3F, 0x5F, 0x70, 0x80, 0x90,
+ 0xC0, 0x91, 0xA1, 0xB1, 0xC1, 0x82, 0x92, 0xA2, 0xC2, 0x73, 0x83, 0x93,
+ 0xA3, 0xC3, 0x64, 0x74, 0x84, 0x94, 0xA4, 0xC4, 0x65, 0x75, 0x85, 0x46,
+ 0x56, 0x66, 0xC6, 0xE6, 0xF6, 0x47, 0x57, 0xE7, 0xF7, 0x08, 0x38, 0x48,
+ 0x58, 0x68, 0xD8, 0xE8, 0xF8, 0x09, 0x19, 0x29, 0x39, 0x59, 0xD9, 0xE9,
+ 0xF9, 0x1A, 0x2A, 0x3A, 0xDA, 0xEA, 0xFA, 0x1B, 0x2B, 0xDB, 0xEB, 0xFB,
+ 0x0C, 0x2C, 0x3C, 0xDC, 0xEC, 0x7D, 0x9D, 0xAD, 0xBD, 0xCD, 0x6E, 0x7E,
+ 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0x4F, 0x6F, 0x7F, 0x8F, 0xAF, 0xA0, 0xB2,
+ 0xB3, 0xB4, 0x95, 0xA5, 0xB5, 0xC5, 0x76, 0x86, 0x96, 0xA6, 0xB6, 0x67,
+ 0x77, 0x87, 0x97, 0xC7, 0x78, 0x88, 0x98, 0xC8, 0x49, 0x69, 0x79, 0x89,
+ 0x99, 0xC9, 0x0A, 0x4A, 0x5A, 0x6A, 0x7A, 0xCA, 0x0B, 0x3B, 0x4B, 0x5B,
+ 0x6B, 0xCB, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xFC,
+ 0xDD, 0xED, 0xFD, 0xDE, 0xEE, 0xFE, 0x9F, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF,
+ 0xB0, 0xA7, 0xB7, 0xA8, 0xB8, 0xA9, 0xB9, 0x8A, 0x9A, 0xAA, 0xBA, 0x7B,
+ 0x8B, 0x9B, 0xAB, 0xBB
+};
+
+static const uint8_t huff_a17_cb[9] = { 3, 9, 3, 2, 5, 7, 17, 23, 6 };
+
+static const uint8_t huff_a17_xlat[63] = {
+ 0, 1, 63, 2, 62, 3, 4, 59, 60, 61, 5, 6, 7, 8, 56, 57,
+ 58, 9, 10, 11, 12, 13, 14, 26, 27, 36, 37, 38, 50, 51, 52, 53,
+ 54, 55, 15, 16, 17, 18, 19, 20, 21, 25, 28, 29, 30, 31, 33, 34,
+ 35, 39, 43, 44, 45, 46, 47, 48, 49, 22, 23, 24, 40, 41, 42
+};
+
+static const uint8_t huff_a21_cb[14] = {
+ 1, 12, 1, 0, 0, 2, 6, 0, 7, 21, 15, 17, 8, 4
+};
+
+static const uint8_t huff_a21_xlat[81] = {
+ 0x00, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x03, 0xD0, 0x70, 0x34,
+ 0x1C, 0x0D, 0x13, 0x07, 0x50, 0xF0, 0x44, 0xC4, 0x14, 0x74, 0x4C, 0xCC,
+ 0xDC, 0x3C, 0x41, 0xC1, 0x11, 0x31, 0x05, 0x1D, 0x43, 0xC3, 0x33, 0x37,
+ 0x0F, 0x54, 0xF4, 0xFC, 0xD1, 0x71, 0x15, 0x4D, 0xCD, 0xDD, 0xD3, 0x73,
+ 0x47, 0xC7, 0x77, 0x3F, 0xD4, 0x5C, 0x7C, 0x51, 0xF1, 0x45, 0xC5, 0x55,
+ 0x35, 0x3D, 0x53, 0xF3, 0x17, 0x4F, 0xCF, 0x1F, 0xFF, 0x75, 0xF5, 0x5D,
+ 0x7D, 0xD7, 0xF7, 0x5F, 0xDF, 0xD5, 0xFD, 0x57, 0x7F
+};
+
+static const uint8_t huff_a22_cb[10] = { 2, 9, 1, 4, 0, 4, 3, 8, 3, 2 };
+
+static const uint8_t huff_a22_xlat[25] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x09, 0x39, 0x0F, 0x3F, 0x10, 0x02, 0x06,
+ 0x30, 0x11, 0x31, 0x0A, 0x3A, 0x0E, 0x17, 0x37, 0x32, 0x16, 0x3E, 0x12,
+ 0x36
+};
+
+static const uint8_t huff_a23_cb[9] = { 3, 9, 5, 0, 4, 6, 10, 16, 8 };
+
+static const uint8_t huff_a23_xlat[49] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x09, 0x39, 0x0F, 0x3F, 0x10, 0x30, 0x02,
+ 0x3A, 0x06, 0x0E, 0x18, 0x28, 0x11, 0x31, 0x0A, 0x03, 0x05, 0x3E, 0x17,
+ 0x37, 0x19, 0x29, 0x12, 0x2A, 0x32, 0x0B, 0x33, 0x3B, 0x0D, 0x15, 0x3D,
+ 0x16, 0x1E, 0x36, 0x1F, 0x2F, 0x1A, 0x13, 0x1B, 0x2B, 0x1D, 0x2D, 0x35,
+ 0x2E
+};
+
+static const uint8_t huff_a24_cb[5] = { 2, 4, 3, 1, 2 };
+
+static const uint8_t huff_a25_cb[5] = { 2, 4, 1, 5, 2 };
+
+static const uint8_t huff_a25_xlat[8] = { 1, 0, 2, 3, 4, 5, 6, 7 };
+
+static const uint8_t huff_a26_cb[10] = { 4, 11, 3, 4, 12, 15, 34, 83, 75, 30 };
+
+static const uint8_t huff_a26_xlat[256] = {
+ 0x00, 0x01, 0x11, 0x10, 0x21, 0x12, 0x22, 0x20, 0x30, 0x31, 0x41, 0x02,
+ 0x32, 0x03, 0x13, 0x23, 0x33, 0x14, 0x24, 0x40, 0x51, 0x61, 0x42, 0x52,
+ 0x43, 0x53, 0x04, 0x34, 0x44, 0x15, 0x25, 0x35, 0x16, 0x26, 0x50, 0x60,
+ 0x71, 0x81, 0xD1, 0x62, 0x72, 0x82, 0xD2, 0x63, 0x73, 0xD3, 0x54, 0x64,
+ 0x05, 0x45, 0x55, 0x65, 0x06, 0x36, 0x46, 0x56, 0x17, 0x27, 0x37, 0x47,
+ 0x18, 0x28, 0x38, 0x19, 0x1D, 0x2D, 0x3D, 0x1E, 0x70, 0x80, 0x90, 0xD0,
+ 0xE0, 0x91, 0xA1, 0xB1, 0xC1, 0xE1, 0xF1, 0x92, 0xA2, 0xC2, 0xE2, 0xF2,
+ 0x83, 0x93, 0xA3, 0xC3, 0xE3, 0xF3, 0x74, 0x84, 0x94, 0xA4, 0xC4, 0xD4,
+ 0xE4, 0xF4, 0x75, 0x85, 0x95, 0xD5, 0xE5, 0x66, 0x76, 0x86, 0xD6, 0xE6,
+ 0x07, 0x57, 0x67, 0x77, 0xD7, 0x08, 0x48, 0x58, 0x68, 0xD8, 0x09, 0x29,
+ 0x39, 0x49, 0x59, 0x69, 0x1A, 0x2A, 0x3A, 0x4A, 0x1B, 0x2B, 0x1C, 0x2C,
+ 0x3C, 0x4C, 0x0D, 0x4D, 0x5D, 0x6D, 0x7D, 0x8D, 0x0E, 0x2E, 0x3E, 0x4E,
+ 0x5E, 0x6E, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0xA0, 0xB0, 0xC0, 0xF0, 0xB2,
+ 0xB3, 0xB4, 0xA5, 0xB5, 0xC5, 0xF5, 0x96, 0xA6, 0xB6, 0xC6, 0xF6, 0x87,
+ 0x97, 0xA7, 0xB7, 0xC7, 0xE7, 0xF7, 0x78, 0x88, 0x98, 0xA8, 0xC8, 0xE8,
+ 0xF8, 0x79, 0x89, 0x99, 0xC9, 0xD9, 0xE9, 0xF9, 0x0A, 0x5A, 0x6A, 0x7A,
+ 0x8A, 0xDA, 0xEA, 0xFA, 0x0B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x8B, 0xDB,
+ 0x0C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xDC, 0x9D, 0xAD, 0xBD, 0xCD, 0x7E,
+ 0x8E, 0x9E, 0xAE, 0xBE, 0x0F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xB8, 0xA9,
+ 0xB9, 0x9A, 0xAA, 0xBA, 0xCA, 0x9B, 0xAB, 0xBB, 0xCB, 0xEB, 0xFB, 0xAC,
+ 0xBC, 0xCC, 0xEC, 0xFC, 0xDD, 0xED, 0xFD, 0xCE, 0xDE, 0xEE, 0xFE, 0xBF,
+ 0xCF, 0xDF, 0xEF, 0xFF
+};
+
+static const uint8_t huff_a27_cb[7] = { 4, 8, 3, 14, 10, 20, 16 };
+
+static const uint8_t huff_a27_xlat[63] = {
+ 0, 2, 3, 1, 5, 6, 7, 9, 54, 55, 56, 58, 59, 60, 61, 62,
+ 63, 4, 8, 10, 11, 12, 14, 49, 52, 53, 57, 13, 15, 16, 17, 18,
+ 19, 22, 23, 25, 26, 30, 39, 43, 44, 45, 46, 47, 48, 50, 51, 20,
+ 21, 24, 27, 28, 29, 31, 33, 34, 35, 36, 37, 38, 40, 41, 42
+};
+
+static const uint8_t huff_a31_cb[8] = { 1, 6, 1, 0, 3, 1, 0, 4 };
+
+static const uint8_t huff_a31_xlat[9] = {
+ 0x00, 0x04, 0x0C, 0x01, 0x03, 0x05, 0x0D, 0x07, 0x0F
+};
+
+static const uint8_t huff_a32_cb[13] = {
+ 1, 11, 1, 0, 0, 2, 2, 6, 12, 18, 19, 15, 6
+};
+
+static const uint8_t huff_a32_xlat[81] = {
+ 0x00, 0x40, 0x01, 0x10, 0x04, 0x80, 0x50, 0x20, 0x14, 0x05, 0x02, 0x90,
+ 0x60, 0x44, 0x54, 0x24, 0x08, 0x18, 0x41, 0x11, 0x15, 0x09, 0x06, 0xA0,
+ 0x84, 0x94, 0x64, 0xA4, 0x48, 0x58, 0x28, 0x51, 0x21, 0x45, 0x55, 0x25,
+ 0x19, 0x12, 0x16, 0x0A, 0x1A, 0x68, 0xA8, 0x81, 0x91, 0x61, 0xA1, 0x85,
+ 0x95, 0x65, 0xA5, 0x49, 0x59, 0x29, 0x69, 0x42, 0x52, 0x46, 0x56, 0x2A,
+ 0x88, 0x98, 0x89, 0x99, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x86, 0x26, 0x66,
+ 0x4A, 0x5A, 0x6A, 0xA2, 0x96, 0xA6, 0x8A, 0x9A, 0xAA
+};
+
+static const uint8_t huff_a33_cb[12] = {
+ 3, 12, 1, 1, 13, 1, 14, 28, 33, 81, 32, 52
+};
+
+static const uint8_t huff_a33_xlat[256] = {
+ 0x00, 0x10, 0x40, 0x50, 0x04, 0x44, 0x14, 0x54, 0x01, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x90, 0x20, 0x94, 0x64, 0x18, 0x21, 0x95, 0x19,
+ 0x69, 0x02, 0x52, 0x06, 0x46, 0x16, 0x80, 0x60, 0x84, 0xD4, 0x24, 0x08,
+ 0x48, 0x58, 0x68, 0x81, 0x91, 0x61, 0x85, 0x25, 0x65, 0xA5, 0x09, 0x49,
+ 0x59, 0x29, 0x42, 0x12, 0x56, 0x96, 0xA6, 0x0A, 0x17, 0x1B, 0xD0, 0xC4,
+ 0x74, 0xF4, 0x88, 0xC8, 0x28, 0xA1, 0x71, 0xC5, 0xD5, 0x75, 0x99, 0xB9,
+ 0x4D, 0x1D, 0x2D, 0x6D, 0x22, 0x62, 0x66, 0x4A, 0x1A, 0x9A, 0x6A, 0x8E,
+ 0x5E, 0x43, 0x23, 0x07, 0x47, 0x57, 0x6B, 0xC0, 0xA0, 0xE0, 0x70, 0xB0,
+ 0xA4, 0xE4, 0x34, 0xB4, 0x98, 0xD8, 0xA8, 0x38, 0x78, 0x0C, 0x4C, 0x1C,
+ 0x5C, 0x9C, 0x6C, 0x7C, 0xC1, 0xD1, 0xE1, 0x31, 0xE5, 0x35, 0xB5, 0xF5,
+ 0x89, 0xA9, 0x79, 0xF9, 0x0D, 0xCD, 0x9D, 0xDD, 0xAD, 0x3D, 0x7D, 0x82,
+ 0xC2, 0x92, 0xD2, 0xE2, 0x72, 0xF2, 0x86, 0xD6, 0xE6, 0x76, 0xB6, 0x8A,
+ 0x5A, 0xDA, 0xEA, 0xFA, 0x4E, 0x1E, 0x9E, 0xEE, 0x03, 0x13, 0x53, 0x97,
+ 0xB7, 0x0B, 0x4B, 0x8B, 0x5B, 0x9B, 0xEB, 0x7B, 0x0F, 0x4F, 0x1F, 0x5F,
+ 0x9F, 0x2F, 0x3F, 0xBF, 0xE8, 0xB8, 0xF8, 0x8C, 0x2C, 0x3C, 0xFC, 0xB1,
+ 0xC9, 0xD9, 0xE9, 0x39, 0x5D, 0xED, 0xBD, 0xA2, 0x32, 0x26, 0x36, 0x2A,
+ 0xAA, 0xBA, 0x0E, 0x2E, 0x6E, 0x83, 0xC3, 0x93, 0x63, 0xB3, 0xA7, 0x37,
+ 0x30, 0xF0, 0xCC, 0xDC, 0xAC, 0xEC, 0xBC, 0xF1, 0x8D, 0xFD, 0xB2, 0xC6,
+ 0xF6, 0xCA, 0x3A, 0x7A, 0xCE, 0xDE, 0xAE, 0x3E, 0x7E, 0xBE, 0xFE, 0xD3,
+ 0xA3, 0xE3, 0x33, 0x73, 0xF3, 0x87, 0xC7, 0xD7, 0x27, 0x67, 0xE7, 0x77,
+ 0xF7, 0xCB, 0xDB, 0x2B, 0xAB, 0x3B, 0xBB, 0xFB, 0x8F, 0xCF, 0xDF, 0x6F,
+ 0xAF, 0xEF, 0x7F, 0xFF
+};
+
+static const uint8_t huff_a34_cb[7] = { 1, 5, 1, 1, 1, 1, 2 };
+
+static const uint8_t huff_a34_xlat[6] = { 1, 0, 2, 3, 4, 5 };
+
+static const uint8_t huff_a35_cb[11] = { 2, 10, 1, 0, 2, 3, 6, 19, 9, 75, 110 };
+
+static const uint8_t huff_a35_xlat[225] = {
+ 0x00, 0xF0, 0x0F, 0x10, 0x01, 0xFF, 0x20, 0xE0, 0x11, 0xF1, 0x0E, 0x1F,
+ 0x30, 0x40, 0xD0, 0x21, 0xE1, 0x02, 0x12, 0x22, 0xE2, 0xF2, 0x03, 0x13,
+ 0x1E, 0x2E, 0x3E, 0xEE, 0xFE, 0x2F, 0xEF, 0xD2, 0x43, 0xF3, 0x04, 0x0D,
+ 0x2D, 0x3D, 0x3F, 0xDF, 0x50, 0x60, 0x70, 0x90, 0xB0, 0x31, 0x41, 0x91,
+ 0xA1, 0xC1, 0xD1, 0x42, 0xA2, 0xC2, 0x23, 0x33, 0xE3, 0x24, 0x34, 0xB4,
+ 0xD4, 0xF4, 0x05, 0x15, 0x45, 0xE5, 0x16, 0x36, 0x56, 0xA6, 0xC6, 0xD6,
+ 0xF6, 0x57, 0xC7, 0xF7, 0x09, 0x29, 0x49, 0x59, 0x69, 0xF9, 0x0A, 0x2A,
+ 0x3A, 0x4A, 0xDA, 0xEA, 0xFA, 0x0B, 0x2B, 0xAB, 0xEB, 0xFB, 0x0C, 0x1C,
+ 0x2C, 0x3C, 0x4C, 0x5C, 0xCC, 0xDC, 0xFC, 0x1D, 0x4D, 0x6D, 0xBD, 0xCD,
+ 0xED, 0xFD, 0x4E, 0x6E, 0xCE, 0xDE, 0x7F, 0xA0, 0xC0, 0x51, 0x61, 0x71,
+ 0xB1, 0x32, 0x52, 0x62, 0x72, 0x92, 0xB2, 0x53, 0x63, 0x73, 0x93, 0xA3,
+ 0xB3, 0xC3, 0xD3, 0x14, 0x44, 0x54, 0x64, 0x74, 0x94, 0xA4, 0xC4, 0xE4,
+ 0x25, 0x35, 0x55, 0x65, 0x75, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xF5, 0x06,
+ 0x26, 0x46, 0x66, 0x76, 0x96, 0xB6, 0xE6, 0x07, 0x17, 0x27, 0x37, 0x47,
+ 0x67, 0x77, 0x97, 0xA7, 0xB7, 0xD7, 0xE7, 0x19, 0x39, 0x79, 0x99, 0xA9,
+ 0xB9, 0xC9, 0xD9, 0xE9, 0x1A, 0x5A, 0x6A, 0x7A, 0x9A, 0xAA, 0xBA, 0xCA,
+ 0x1B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x9B, 0xBB, 0xCB, 0xDB, 0x6C, 0x7C,
+ 0x9C, 0xAC, 0xBC, 0xEC, 0x5D, 0x7D, 0x9D, 0xAD, 0xDD, 0x5E, 0x7E, 0x9E,
+ 0xAE, 0xBE, 0x4F, 0x5F, 0x6F, 0x9F, 0xAF, 0xBF, 0xCF
+};
+
+static const uint8_t huff_a36_cb[12] = {
+ 3, 12, 1, 3, 5, 5, 13, 27, 69, 96, 35, 2
+};
+
+static const uint8_t huff_a36_xlat[256] = {
+ 0x00, 0x10, 0x01, 0x11, 0x20, 0x21, 0x02, 0x12, 0x22, 0x31, 0x41, 0x32,
+ 0x13, 0x23, 0x30, 0x40, 0x51, 0x42, 0x03, 0x33, 0x43, 0x04, 0x14, 0x24,
+ 0x34, 0x15, 0x25, 0x50, 0x61, 0x71, 0xD1, 0x52, 0x62, 0x72, 0xD2, 0x53,
+ 0x63, 0xD3, 0x44, 0x54, 0x64, 0x05, 0x35, 0x45, 0x55, 0x16, 0x26, 0x36,
+ 0x46, 0x17, 0x27, 0x1D, 0x2D, 0x3D, 0x60, 0x70, 0xD0, 0x81, 0x91, 0xA1,
+ 0xC1, 0xE1, 0xF1, 0x82, 0x92, 0xC2, 0xE2, 0xF2, 0x73, 0x83, 0xE3, 0xF3,
+ 0x74, 0x84, 0xC4, 0xD4, 0xE4, 0xF4, 0x65, 0x75, 0x85, 0xD5, 0xE5, 0x06,
+ 0x56, 0x66, 0xD6, 0xE6, 0x07, 0x37, 0x47, 0x57, 0x67, 0xD7, 0xE7, 0x18,
+ 0x28, 0x38, 0x48, 0x58, 0xD8, 0x19, 0x29, 0x2A, 0x1C, 0x2C, 0x0D, 0x4D,
+ 0x5D, 0x6D, 0x7D, 0x8D, 0x9D, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,
+ 0x1F, 0x2F, 0x3F, 0x80, 0x90, 0xA0, 0xC0, 0xE0, 0xF0, 0xB1, 0xA2, 0xB2,
+ 0x93, 0xA3, 0xB3, 0xC3, 0x94, 0xA4, 0xB4, 0x95, 0xA5, 0xB5, 0xC5, 0xF5,
+ 0x76, 0x86, 0x96, 0xA6, 0xC6, 0xF6, 0x77, 0x87, 0x97, 0xA7, 0xC7, 0xF7,
+ 0x08, 0x68, 0x78, 0x88, 0x98, 0xC8, 0xE8, 0xF8, 0x09, 0x39, 0x49, 0x59,
+ 0x69, 0x79, 0x89, 0xD9, 0xE9, 0xF9, 0x0A, 0x1A, 0x3A, 0x4A, 0x5A, 0x6A,
+ 0xDA, 0xEA, 0xFA, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0xDB, 0xEB, 0xFB, 0x0C,
+ 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xDC, 0xEC, 0xAD, 0xBD, 0xCD,
+ 0xDD, 0xED, 0x0E, 0x8E, 0x9E, 0xAE, 0xBE, 0x0F, 0x4F, 0x5F, 0x6F, 0x7F,
+ 0x8F, 0x9F, 0xAF, 0xB0, 0xB6, 0xB7, 0xA8, 0xB8, 0x99, 0xA9, 0xB9, 0xC9,
+ 0x7A, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0x0B, 0x6B, 0x7B, 0x8B, 0x9B, 0xCB,
+ 0xAC, 0xBC, 0xCC, 0xFC, 0xFD, 0xCE, 0xDE, 0xEE, 0xFE, 0xBF, 0xCF, 0xDF,
+ 0xEF, 0xFF, 0xAB, 0xBB
+};
+
+static const uint8_t huff_a37_cb[7] = { 4, 8, 7, 6, 8, 22, 20 };
+
+static const uint8_t huff_a37_xlat[63] = {
+ 0, 1, 2, 3, 61, 62, 63, 4, 5, 6, 58, 59, 60, 7, 8, 9,
+ 10, 54, 55, 56, 57, 11, 12, 13, 14, 15, 16, 25, 26, 27, 28, 29,
+ 30, 35, 36, 37, 38, 48, 49, 50, 51, 52, 53, 17, 18, 19, 20, 21,
+ 22, 23, 24, 31, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 47
+};
+
+static const uint8_t huff_a41_cb[14] = {
+ 1, 12, 1, 0, 0, 6, 2, 0, 0, 0, 19, 9, 24, 20
+};
+
+static const uint8_t huff_a41_xlat[81] = {
+ 0x00, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x03, 0x50, 0xD0, 0x70,
+ 0xF0, 0xC4, 0x34, 0x4C, 0xCC, 0x1C, 0x41, 0xC1, 0x31, 0x05, 0x0D, 0x43,
+ 0xC3, 0x13, 0x07, 0x0F, 0x44, 0x14, 0x74, 0xDC, 0x3C, 0x11, 0x1D, 0x33,
+ 0x37, 0x54, 0xD4, 0xF4, 0x5C, 0x7C, 0xFC, 0xD1, 0x71, 0xF1, 0xC5, 0x15,
+ 0x35, 0x4D, 0xCD, 0xDD, 0x3D, 0xD3, 0x73, 0x47, 0xC7, 0x17, 0x77, 0x1F,
+ 0x3F, 0x51, 0x45, 0x55, 0xD5, 0x75, 0xF5, 0x5D, 0x7D, 0xFD, 0x53, 0xF3,
+ 0x57, 0xD7, 0xF7, 0x4F, 0xCF, 0x5F, 0xDF, 0x7F, 0xFF
+};
+
+static const uint8_t huff_a42_cb[10] = { 3, 10, 1, 2, 13, 1, 31, 13, 16, 4 };
+
+static const uint8_t huff_a42_xlat[81] = {
+ 0x00, 0x40, 0x01, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x59, 0x80, 0x90, 0x20, 0x60, 0x84, 0x94, 0x24,
+ 0x64, 0x08, 0x48, 0x18, 0x58, 0x81, 0x91, 0x21, 0x61, 0x85, 0x95, 0x25,
+ 0x65, 0x09, 0x49, 0x19, 0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56,
+ 0xA0, 0xA4, 0x68, 0xA1, 0xA5, 0x99, 0x29, 0x69, 0x96, 0x66, 0x4A, 0x1A,
+ 0x5A, 0x88, 0x98, 0x28, 0x89, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x86, 0x26,
+ 0xA6, 0x0A, 0x9A, 0x2A, 0x6A, 0xA8, 0xA2, 0x8A, 0xAA
+};
+
+static const uint8_t huff_a43_cb[5] = { 2, 4, 2, 3, 2 };
+
+static const uint8_t huff_a43_xlat[7] = { 0, 7, 1, 2, 6, 3, 5 };
+
+static const uint8_t huff_a44_cb[9] = { 4, 10, 5, 4, 12, 17, 47, 24, 12 };
+
+static const uint8_t huff_a44_xlat[121] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x11, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x21,
+ 0xE1, 0x02, 0x12, 0xF2, 0x0E, 0x1E, 0xFE, 0x2F, 0xEF, 0x30, 0x50, 0xD0,
+ 0xD1, 0x22, 0xE2, 0x03, 0x13, 0xF3, 0x0D, 0x1D, 0x2D, 0xFD, 0x2E, 0xEE,
+ 0x3F, 0xDF, 0x40, 0xB0, 0xC0, 0x31, 0x41, 0x51, 0xB1, 0xC1, 0x32, 0xB2,
+ 0xC2, 0xD2, 0x23, 0xB3, 0xD3, 0xE3, 0x04, 0x14, 0xE4, 0xF4, 0x05, 0x15,
+ 0xD5, 0xE5, 0xF5, 0x0B, 0x1B, 0x2B, 0x3B, 0xEB, 0xFB, 0x0C, 0x1C, 0x2C,
+ 0xFC, 0x3D, 0x5D, 0xED, 0x3E, 0x4E, 0x5E, 0xBE, 0xDE, 0x4F, 0x5F, 0xBF,
+ 0xCF, 0x42, 0x52, 0x33, 0x53, 0xC3, 0x24, 0xB4, 0xD4, 0x25, 0x35, 0xC5,
+ 0x4B, 0xCB, 0xDB, 0x3C, 0x4C, 0x5C, 0xDC, 0xEC, 0x4D, 0xBD, 0xCD, 0xDD,
+ 0xCE, 0x43, 0x34, 0x44, 0x54, 0xC4, 0x45, 0x55, 0xB5, 0x5B, 0xBB, 0xBC,
+ 0xCC
+};
+
+static const uint8_t huff_a45_cb[5] = { 2, 4, 2, 2, 4 };
+
+static const uint8_t huff_a45_xlat[8] = { 1, 2, 0, 3, 4, 5, 6, 7 };
+
+static const uint8_t huff_a46_cb[7] = { 5, 9, 1, 16, 31, 36, 172 };
+
+static const uint8_t huff_a46_xlat[256] = {
+ 0x02, 0x00, 0x30, 0x21, 0x31, 0x41, 0x61, 0x12, 0x22, 0x42, 0x62, 0x43,
+ 0x53, 0x24, 0x45, 0x26, 0x27, 0x10, 0x40, 0xB0, 0x01, 0x11, 0x81, 0x32,
+ 0x52, 0x72, 0x92, 0x03, 0x13, 0x33, 0x63, 0x14, 0x34, 0x54, 0x64, 0x74,
+ 0x05, 0x15, 0x25, 0x35, 0x55, 0x65, 0x06, 0x46, 0x56, 0x57, 0x67, 0x88,
+ 0x20, 0x51, 0x91, 0xD1, 0xF2, 0x23, 0x83, 0x93, 0x04, 0x44, 0x84, 0x94,
+ 0x75, 0x85, 0xC5, 0x36, 0x66, 0x96, 0xB6, 0x07, 0x37, 0x97, 0x08, 0x28,
+ 0x38, 0x48, 0x68, 0x09, 0x69, 0x79, 0x0A, 0x2A, 0x1B, 0x9B, 0x2C, 0x4D,
+ 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xC0, 0xD0, 0xE0, 0xF0, 0x71, 0xA1,
+ 0xB1, 0xC1, 0xE1, 0xF1, 0x82, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0x73, 0xA3,
+ 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, 0x95,
+ 0xA5, 0xB5, 0xD5, 0xE5, 0xF5, 0x16, 0x76, 0x86, 0xA6, 0xC6, 0xD6, 0xE6,
+ 0xF6, 0x17, 0x47, 0x77, 0x87, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, 0x18,
+ 0x58, 0x78, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, 0x19, 0x29, 0x39,
+ 0x49, 0x59, 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, 0x1A, 0x3A,
+ 0x4A, 0x5A, 0x6A, 0x7A, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,
+ 0x0B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x8B, 0xAB, 0xBB, 0xCB, 0xDB,
+ 0xEB, 0xFB, 0x0C, 0x1C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xAC,
+ 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, 0x0D, 0x1D, 0x2D, 0x3D, 0x5D, 0x6D, 0x7D,
+ 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, 0x0E, 0x1E, 0x2E, 0x3E,
+ 0x4E, 0x5E, 0x6E, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,
+ 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF,
+ 0xCF, 0xDF, 0xEF, 0xFF
+};
+
+static const uint8_t huff_a47_cb[8] = { 4, 9, 5, 12, 9, 12, 15, 10 };
+
+static const uint8_t huff_a47_xlat[63] = {
+ 0, 1, 2, 62, 63, 3, 4, 5, 6, 8, 54, 56, 57, 58, 59, 60,
+ 61, 7, 9, 10, 11, 12, 13, 14, 53, 55, 15, 16, 17, 18, 19, 20,
+ 21, 36, 37, 39, 42, 52, 22, 25, 28, 35, 38, 40, 41, 43, 45, 46,
+ 47, 48, 49, 50, 51, 23, 24, 26, 27, 29, 30, 31, 33, 34, 44
+};
+
+static const uint8_t huff_a51_cb[12] = {
+ 2, 11, 1, 0, 6, 2, 6, 18, 4, 26, 6, 12
+};
+
+static const uint8_t huff_a51_xlat[81] = {
+ 0x00, 0x40, 0xC0, 0x30, 0x04, 0x01, 0x03, 0x10, 0x0C, 0xD0, 0x70, 0x34,
+ 0x1C, 0x0D, 0x07, 0x50, 0xF0, 0x44, 0xC4, 0x14, 0x4C, 0xCC, 0x3C, 0x41,
+ 0xC1, 0x11, 0x31, 0x05, 0x43, 0xC3, 0x13, 0x33, 0x0F, 0x74, 0xDC, 0x1D,
+ 0x37, 0x54, 0xD4, 0xF4, 0x5C, 0x7C, 0xFC, 0xD1, 0x71, 0xF1, 0xC5, 0x15,
+ 0x35, 0x4D, 0xCD, 0xDD, 0x3D, 0x53, 0xD3, 0x73, 0x47, 0xC7, 0x17, 0x77,
+ 0x4F, 0x1F, 0x3F, 0x51, 0x45, 0x55, 0xF3, 0xCF, 0xFF, 0xD5, 0x75, 0xF5,
+ 0x5D, 0x7D, 0xFD, 0x57, 0xD7, 0xF7, 0x5F, 0xDF, 0x7F
+};
+
+static const uint8_t huff_a52_cb[12] = { 1, 10, 1, 0, 2, 2, 0, 4, 3, 8, 3, 2 };
+
+static const uint8_t huff_a52_xlat[25] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x09, 0x39, 0x0F, 0x3F, 0x10, 0x02, 0x06,
+ 0x30, 0x11, 0x31, 0x0A, 0x3A, 0x0E, 0x17, 0x37, 0x32, 0x16, 0x3E, 0x12,
+ 0x36
+};
+
+static const uint8_t huff_a53_xlat[7] = { 0, 1, 2, 6, 7, 3, 5 };
+
+static const uint8_t huff_a54_cb[8] = { 4, 9, 4, 7, 12, 19, 21, 58 };
+
+static const uint8_t huff_a54_xlat[121] = {
+ 0x00, 0x01, 0x0F, 0x1F, 0x10, 0xE0, 0xF0, 0x11, 0xF1, 0x2F, 0xFF, 0x20,
+ 0x21, 0xE1, 0x02, 0x12, 0xF2, 0x03, 0xF3, 0x0E, 0x2E, 0xFE, 0x3F, 0x30,
+ 0x40, 0xD0, 0xC1, 0xD1, 0x22, 0xC2, 0x33, 0xE3, 0x0C, 0xCC, 0x0D, 0x1D,
+ 0x2D, 0xFD, 0x1E, 0x3E, 0x5E, 0xEF, 0xC0, 0x52, 0xB2, 0xD2, 0x43, 0xC3,
+ 0xD3, 0x24, 0x45, 0xF5, 0x4B, 0x5B, 0xFB, 0x1C, 0x3D, 0xBD, 0xDD, 0xEE,
+ 0xBF, 0xCF, 0xDF, 0x50, 0xB0, 0x31, 0x41, 0x51, 0xB1, 0x32, 0x42, 0xE2,
+ 0x13, 0x23, 0x53, 0xB3, 0x04, 0x14, 0x34, 0x44, 0x54, 0xB4, 0xC4, 0xD4,
+ 0xE4, 0xF4, 0x05, 0x15, 0x25, 0x35, 0x55, 0xB5, 0xC5, 0xD5, 0xE5, 0x0B,
+ 0x1B, 0x2B, 0x3B, 0xBB, 0xCB, 0xDB, 0xEB, 0x2C, 0x3C, 0x4C, 0x5C, 0xBC,
+ 0xDC, 0xEC, 0xFC, 0x4D, 0x5D, 0xCD, 0xED, 0x4E, 0xBE, 0xCE, 0xDE, 0x4F,
+ 0x5F
+};
+
+static const uint8_t huff_a55_cb[8] = { 1, 6, 1, 1, 1, 0, 3, 2 };
+
+static const uint8_t huff_a55_xlat[8] = { 0, 1, 2, 3, 6, 7, 4, 5 };
+
+static const uint8_t huff_a56_cb[7] = { 3, 7, 1, 8, 6, 8, 8 };
+
+static const uint8_t huff_a56_xlat[31] = {
+ 4, 0, 1, 2, 3, 28, 29, 30, 31, 5, 6, 7, 24, 25, 27, 8,
+ 9, 14, 19, 21, 22, 23, 26, 10, 11, 12, 13, 15, 17, 18, 20
+};
+
+static const uint8_t huff_a57_cb[9] = { 3, 9, 1, 5, 7, 8, 16, 22, 4 };
+
+static const uint8_t huff_a57_xlat[63] = {
+ 0, 1, 2, 61, 62, 63, 3, 4, 5, 6, 58, 59,
+ 60, 7, 8, 9, 10, 54, 55, 56, 57, 11, 12, 13,
+ 14, 15, 26, 27, 28, 36, 37, 38, 49, 50, 51, 52,
+ 53, 16, 17, 18, 19, 20, 21, 23, 24, 25, 29, 30,
+ 31, 33, 34, 35, 39, 43, 44, 45, 46, 47, 48, 22,
+ 40, 41, 42
+};
+
+static const uint8_t huff_a61_cb[12] = {
+ 2, 11, 1, 0, 8, 0, 1, 16, 10, 29, 12, 4
+};
+
+static const uint8_t huff_a61_xlat[81] = {
+ 0x00, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x03, 0x70, 0x50, 0xD0,
+ 0xF0, 0x44, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0x31, 0x05, 0x0D, 0x13,
+ 0x07, 0x0F, 0x74, 0xCC, 0xDC, 0xFC, 0x41, 0xC1, 0x11, 0x43, 0xC3, 0x33,
+ 0x54, 0xD4, 0xF4, 0x5C, 0x7C, 0x51, 0xD1, 0x71, 0xF1, 0x45, 0xC5, 0x15,
+ 0x35, 0x4D, 0xCD, 0x1D, 0x3D, 0x53, 0xD3, 0x73, 0xF3, 0x47, 0xC7, 0x17,
+ 0x37, 0x4F, 0xCF, 0x1F, 0x3F, 0x55, 0xD5, 0x75, 0xF5, 0x5D, 0xDD, 0xFD,
+ 0x57, 0xD7, 0x77, 0xF7, 0xFF, 0x7D, 0x5F, 0xDF, 0x7F
+};
+
+static const uint8_t huff_a62_cb[8] = { 3, 8, 5, 2, 2, 9, 5, 2 };
+
+static const uint8_t huff_a62_xlat[25] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x39, 0x0F, 0x09, 0x3F, 0x10, 0x30, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x17, 0x37, 0x11, 0x0A, 0x32, 0x16, 0x3E, 0x12,
+ 0x36
+};
+
+static const uint8_t huff_a63_cb[11] = {
+ 3, 11, 1, 1, 10, 4, 16, 29, 46, 75, 74
+};
+
+static const uint8_t huff_a63_xlat[256] = {
+ 0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x01, 0x41, 0x05, 0x45, 0x55,
+ 0x54, 0x11, 0x51, 0x15, 0x80, 0x90, 0x60, 0x24, 0x64, 0xA4, 0x48, 0x61,
+ 0x95, 0x25, 0xA5, 0x02, 0x42, 0x52, 0x16, 0x56, 0x20, 0x84, 0x94, 0x18,
+ 0x58, 0x81, 0x91, 0x85, 0x65, 0x09, 0x49, 0x19, 0x59, 0x99, 0x29, 0x69,
+ 0x79, 0x5D, 0x12, 0x62, 0x06, 0x46, 0x86, 0x66, 0x1A, 0x5A, 0x6A, 0x47,
+ 0x17, 0xC0, 0xA0, 0xE0, 0xC4, 0xD4, 0x74, 0x08, 0x78, 0x0C, 0x4C, 0x1C,
+ 0x5C, 0xD1, 0x21, 0xE1, 0x71, 0xC5, 0xE5, 0x75, 0xB5, 0x89, 0xBD, 0x92,
+ 0x22, 0x96, 0xA6, 0x36, 0x0A, 0x4A, 0x8A, 0x9A, 0x2A, 0x7A, 0xDE, 0x6E,
+ 0x43, 0x13, 0x53, 0x23, 0x07, 0x77, 0x4B, 0x1B, 0x9B, 0x6B, 0x2F, 0xD0,
+ 0x30, 0x70, 0xE4, 0x34, 0xF4, 0xC8, 0x98, 0x28, 0x68, 0xA8, 0xE8, 0x38,
+ 0xB8, 0xF8, 0x9C, 0x2C, 0x6C, 0x7C, 0xA1, 0xB1, 0xD5, 0x35, 0xC9, 0xD9,
+ 0xA9, 0xE9, 0x39, 0xB9, 0xF9, 0xCD, 0x1D, 0x2D, 0xAD, 0x7D, 0xC2, 0xD2,
+ 0xA2, 0xB2, 0xF2, 0xC6, 0x26, 0x76, 0xB6, 0xDA, 0xAA, 0xEA, 0x3A, 0xFA,
+ 0x0E, 0x4E, 0x2E, 0x7E, 0xBE, 0xFE, 0x03, 0x83, 0x63, 0xA3, 0xB3, 0x87,
+ 0x57, 0x97, 0xD7, 0x27, 0x0B, 0x8B, 0x5B, 0x2B, 0xAB, 0xCF, 0x1F, 0x9F,
+ 0x7F, 0xBF, 0xB0, 0xF0, 0xB4, 0x88, 0xD8, 0x8C, 0xCC, 0xDC, 0xAC, 0xEC,
+ 0x3C, 0xBC, 0xFC, 0xC1, 0x31, 0xF1, 0xF5, 0x0D, 0x4D, 0x8D, 0x9D, 0xDD,
+ 0x6D, 0xED, 0x3D, 0xFD, 0x82, 0xE2, 0x32, 0x72, 0xD6, 0xE6, 0xF6, 0xCA,
+ 0xBA, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xAE, 0xEE, 0x3E, 0xC3, 0x93, 0xD3,
+ 0xE3, 0x33, 0x73, 0xF3, 0xC7, 0x67, 0xA7, 0xE7, 0x37, 0xB7, 0xF7, 0xCB,
+ 0xDB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, 0x0F, 0x4F, 0x8F, 0x5F, 0xDF, 0x6F,
+ 0xAF, 0xEF, 0x3F, 0xFF
+};
+
+static const uint8_t huff_a64_cb[8] = { 4, 9, 1, 7, 12, 36, 63, 2 };
+
+static const uint8_t huff_a64_xlat[121] = {
+ 0x00, 0x10, 0x20, 0xE0, 0xF0, 0x02, 0x0E, 0xEF, 0x30, 0x01, 0x11, 0x21,
+ 0x31, 0xF1, 0x12, 0xF2, 0x1E, 0xEE, 0xDF, 0xFF, 0x40, 0xC0, 0xD0, 0xD1,
+ 0xE1, 0x22, 0x32, 0x42, 0xD2, 0xE2, 0x03, 0x13, 0x23, 0xB3, 0xC3, 0xE3,
+ 0xF3, 0xE4, 0x05, 0xF5, 0x2B, 0x0C, 0xFC, 0x1D, 0x2D, 0xBD, 0xDD, 0xFD,
+ 0x2E, 0x4E, 0xDE, 0xFE, 0x0F, 0x1F, 0x2F, 0x3F, 0x50, 0xB0, 0x41, 0x51,
+ 0xB1, 0xC1, 0x52, 0xB2, 0xC2, 0x33, 0x43, 0x53, 0xD3, 0x04, 0x14, 0x24,
+ 0x34, 0x44, 0x54, 0xB4, 0xC4, 0xD4, 0xF4, 0x15, 0x25, 0x35, 0x45, 0x55,
+ 0xB5, 0xC5, 0xD5, 0xE5, 0x0B, 0x1B, 0x3B, 0x4B, 0x5B, 0xBB, 0xCB, 0xDB,
+ 0xEB, 0xFB, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0xBC, 0xCC, 0xDC, 0xEC, 0x0D,
+ 0x3D, 0x4D, 0x5D, 0xCD, 0xED, 0x3E, 0x5E, 0xBE, 0xCE, 0x4F, 0xCF, 0x5F,
+ 0xBF
+};
+
+static const uint8_t huff_a65_cb[8] = { 2, 7, 3, 0, 1, 3, 4, 4 };
+
+static const uint8_t huff_a65_xlat[15] = {
+ 0, 1, 15, 14, 2, 3, 13, 4, 6, 10, 12, 5, 7, 9, 11
+};
+
+static const uint8_t huff_a66_cb[11] = { 2, 10, 1, 2, 2, 6, 8, 6, 3, 1, 2 };
+
+static const uint8_t huff_a66_xlat[31] = {
+ 0, 1, 31, 2, 30, 3, 4, 15, 17, 28, 29, 5, 6, 7, 8, 24,
+ 25, 26, 27, 9, 10, 11, 21, 22, 23, 12, 19, 20, 13, 14, 18
+};
+
+static const uint8_t huff_a67_cb[10] = { 2, 9, 1, 1, 3, 4, 6, 13, 25, 10 };
+
+static const uint8_t huff_a67_xlat[63] = {
+ 0, 1, 2, 62, 63, 3, 4, 60, 61, 5, 6, 7, 57, 58, 59, 8,
+ 9, 10, 11, 12, 13, 26, 38, 52, 53, 54, 55, 56, 14, 15, 16, 17,
+ 18, 19, 25, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 39, 45, 46,
+ 47, 48, 49, 50, 51, 20, 21, 22, 23, 24, 40, 41, 42, 43, 44
+};
+
+static const uint8_t huff_a71_cb[5] = { 1, 3, 1, 1, 2 };
+
+static const uint8_t huff_a72_cb[12] = {
+ 2, 11, 1, 0, 4, 8, 3, 8, 24, 17, 12, 4
+};
+
+static const uint8_t huff_a72_xlat[81] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x05,
+ 0x15, 0x51, 0x45, 0x55, 0x80, 0x90, 0x20, 0x64, 0x08, 0x19, 0x02, 0x06,
+ 0x60, 0x84, 0x94, 0x24, 0x48, 0x18, 0x58, 0x81, 0x91, 0x21, 0x61, 0x85,
+ 0x95, 0x25, 0x65, 0x09, 0x49, 0x59, 0x42, 0x12, 0x52, 0x46, 0x16, 0x56,
+ 0xA0, 0xA4, 0x98, 0x28, 0x68, 0xA1, 0xA5, 0x99, 0x29, 0x69, 0x96, 0x26,
+ 0x66, 0x0A, 0x4A, 0x1A, 0x5A, 0x88, 0xA8, 0x89, 0xA9, 0x82, 0x92, 0x22,
+ 0x62, 0x86, 0xA6, 0x2A, 0x6A, 0xA2, 0x8A, 0x9A, 0xAA
+};
+
+static const uint8_t huff_a73_cb[11] = { 2, 10, 1, 1, 5, 2, 8, 7, 13, 8, 4 };
+
+static const uint8_t huff_a73_xlat[49] = {
+ 0x00, 0x08, 0x38, 0x01, 0x39, 0x07, 0x0F, 0x09, 0x3F, 0x10, 0x30, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x17, 0x11, 0x0A, 0x32, 0x0D, 0x16, 0x3E, 0x37,
+ 0x18, 0x28, 0x19, 0x29, 0x12, 0x2A, 0x03, 0x3B, 0x05, 0x15, 0x1E, 0x1F,
+ 0x2F, 0x1A, 0x0B, 0x2B, 0x33, 0x35, 0x3D, 0x2E, 0x36, 0x13, 0x1B, 0x1D,
+ 0x2D
+};
+
+static const uint8_t huff_a74_cb[14] = {
+ 1, 12, 1, 0, 0, 4, 0, 4, 5, 9, 30, 45, 21, 2
+};
+
+static const uint8_t huff_a74_xlat[121] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x11, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x02,
+ 0xF2, 0x0E, 0x21, 0xE1, 0x12, 0xE2, 0x1E, 0x2E, 0xFE, 0x2F, 0xEF, 0x30,
+ 0x50, 0xB0, 0xC0, 0xD0, 0x31, 0xB1, 0xD1, 0x22, 0xD2, 0x03, 0x13, 0xE3,
+ 0xF3, 0xF4, 0x05, 0xE5, 0xF5, 0x0B, 0x1B, 0x0C, 0x0D, 0x1D, 0x2D, 0xFD,
+ 0x3E, 0xEE, 0x3F, 0x5F, 0xDF, 0x40, 0x41, 0x51, 0xC1, 0x32, 0x42, 0x52,
+ 0xB2, 0xC2, 0x23, 0x33, 0xB3, 0xC3, 0xD3, 0x04, 0x14, 0x24, 0xD4, 0xE4,
+ 0x15, 0x25, 0xC5, 0xD5, 0x2B, 0x3B, 0xEB, 0xFB, 0x1C, 0x2C, 0x3C, 0x5C,
+ 0xEC, 0xFC, 0x3D, 0x5D, 0xDD, 0xED, 0x4E, 0x5E, 0xBE, 0xCE, 0xDE, 0x4F,
+ 0xBF, 0xCF, 0x43, 0x53, 0x34, 0x54, 0xB4, 0xC4, 0x35, 0x45, 0x55, 0xB5,
+ 0x4B, 0x5B, 0xCB, 0xDB, 0x4C, 0xBC, 0xCC, 0xDC, 0x4D, 0xBD, 0xCD, 0x44,
+ 0xBB
+};
+
+static const uint8_t huff_a75_cb[7] = { 2, 6, 1, 3, 3, 4, 4 };
+
+static const uint8_t huff_a75_xlat[15] = {
+ 0, 1, 14, 15, 2, 3, 13, 4, 6, 10, 12, 5, 7, 9, 11
+};
+
+static const uint8_t huff_a76_cb[12] = {
+ 3, 12, 1, 3, 4, 8, 10, 36, 60, 78, 48, 8
+};
+
+static const uint8_t huff_a76_xlat[256] = {
+ 0x00, 0x10, 0x01, 0x11, 0x20, 0x21, 0x02, 0x12, 0x30, 0x31, 0x41, 0x22,
+ 0x03, 0x13, 0x23, 0x14, 0x40, 0x51, 0x61, 0x32, 0x42, 0x33, 0x04, 0x24,
+ 0x15, 0x16, 0x50, 0x60, 0xD0, 0x71, 0x81, 0xD1, 0xE1, 0xF1, 0x52, 0x62,
+ 0x72, 0xD2, 0x43, 0x53, 0x63, 0xD3, 0x34, 0x44, 0x54, 0x05, 0x25, 0x35,
+ 0x45, 0x06, 0x26, 0x36, 0x17, 0x27, 0x18, 0x0D, 0x1D, 0x2D, 0x3D, 0x1E,
+ 0x2E, 0x1F, 0x70, 0x80, 0xE0, 0xF0, 0x91, 0xA1, 0xC1, 0x82, 0x92, 0xC2,
+ 0xE2, 0xF2, 0x73, 0x83, 0x93, 0xE3, 0xF3, 0x64, 0x74, 0x84, 0xD4, 0xE4,
+ 0xF4, 0x55, 0x65, 0xD5, 0xE5, 0xF5, 0x46, 0x56, 0x66, 0xD6, 0x07, 0x37,
+ 0x47, 0x57, 0x08, 0x28, 0x38, 0x48, 0x19, 0x29, 0x39, 0x1A, 0x2A, 0x1B,
+ 0x1C, 0x2C, 0x3C, 0x4D, 0x5D, 0x6D, 0x0E, 0x3E, 0x4E, 0x5E, 0x0F, 0x2F,
+ 0x3F, 0x4F, 0x90, 0xA0, 0xB0, 0xC0, 0xB1, 0xA2, 0xB2, 0xA3, 0xB3, 0xC3,
+ 0x94, 0xA4, 0xB4, 0xC4, 0x75, 0x85, 0x95, 0xA5, 0xC5, 0x76, 0x86, 0x96,
+ 0xE6, 0xF6, 0x67, 0x77, 0x87, 0xD7, 0xE7, 0xF7, 0x58, 0x68, 0x78, 0x88,
+ 0xD8, 0xE8, 0xF8, 0x09, 0x49, 0x59, 0x69, 0xD9, 0xE9, 0xF9, 0x0A, 0x3A,
+ 0x4A, 0x5A, 0xDA, 0xEA, 0x0B, 0x2B, 0x3B, 0x4B, 0xDB, 0x0C, 0x4C, 0x5C,
+ 0x6C, 0xDC, 0x7D, 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0x6E, 0x7E, 0x8E, 0x9E,
+ 0xAE, 0xBE, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xB5, 0xA6, 0xB6, 0xC6,
+ 0x97, 0xA7, 0xC7, 0x98, 0xA8, 0xB8, 0xC8, 0x79, 0x89, 0x99, 0xA9, 0xB9,
+ 0xC9, 0x6A, 0x7A, 0x8A, 0x9A, 0xAA, 0xCA, 0xFA, 0x5B, 0x6B, 0x7B, 0x8B,
+ 0xCB, 0xEB, 0xFB, 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xEC, 0xFC, 0xDD, 0xED,
+ 0xFD, 0xCE, 0xDE, 0xEE, 0xFE, 0xBF, 0xCF, 0xDF, 0xB7, 0xBA, 0x9B, 0xAB,
+ 0xBB, 0xCC, 0xEF, 0xFF
+};
+
+static const uint8_t huff_b01_cb[14] = {
+ 1, 12, 1, 0, 0, 2, 6, 0, 11, 13, 12, 24, 4, 8
+};
+
+static const uint8_t huff_b01_xlat[81] = {
+ 0x00, 0x01, 0x03, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x50, 0xD0, 0x70,
+ 0xF0, 0x34, 0x1C, 0x05, 0x0D, 0x13, 0x07, 0x0F, 0x44, 0xC4, 0x14, 0x4C,
+ 0xCC, 0x3C, 0x41, 0xC1, 0x11, 0x31, 0x43, 0xC3, 0x33, 0x54, 0x74, 0xDC,
+ 0xFC, 0x71, 0x15, 0x4D, 0x1D, 0xD3, 0xC7, 0x37, 0x3F, 0xD4, 0xF4, 0x5C,
+ 0x7C, 0x51, 0xD1, 0xF1, 0x45, 0xC5, 0x55, 0x35, 0xCD, 0xDD, 0x3D, 0x53,
+ 0x73, 0xF3, 0x47, 0x17, 0x77, 0x4F, 0xCF, 0x1F, 0xFF, 0xF5, 0x7D, 0xD7,
+ 0x5F, 0xD5, 0x75, 0x5D, 0xFD, 0x57, 0xF7, 0xDF, 0x7F
+};
+
+static const uint8_t huff_b02_cb[14] = {
+ 1, 12, 1, 0, 0, 4, 0, 8, 4, 9, 19, 13, 13, 10
+};
+
+static const uint8_t huff_b02_xlat[81] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x05,
+ 0x15, 0x80, 0x51, 0x45, 0x55, 0x90, 0x20, 0x60, 0x24, 0x08, 0x18, 0x09,
+ 0x02, 0x06, 0x84, 0x94, 0x64, 0x48, 0x58, 0x81, 0x91, 0x21, 0x61, 0x95,
+ 0x25, 0x65, 0x19, 0x59, 0x42, 0x12, 0x46, 0x16, 0x56, 0xA0, 0xA4, 0x28,
+ 0x68, 0x85, 0xA5, 0x49, 0x29, 0x69, 0x52, 0x0A, 0x1A, 0x5A, 0x88, 0x98,
+ 0xA1, 0x89, 0x99, 0xA9, 0x22, 0x62, 0x96, 0x26, 0x66, 0x4A, 0x6A, 0xA8,
+ 0x82, 0x92, 0xA2, 0x86, 0xA6, 0x8A, 0x9A, 0x2A, 0xAA
+};
+
+static const uint8_t huff_b03_cb[11] = { 1, 9, 1, 0, 0, 4, 0, 5, 12, 13, 14 };
+
+static const uint8_t huff_b03_xlat[49] = {
+ 0x00, 0x08, 0x38, 0x01, 0x07, 0x30, 0x09, 0x39, 0x0F, 0x3F, 0x10, 0x18,
+ 0x28, 0x31, 0x02, 0x3A, 0x03, 0x05, 0x06, 0x0E, 0x17, 0x37, 0x11, 0x19,
+ 0x29, 0x0A, 0x32, 0x0B, 0x3B, 0x0D, 0x15, 0x3D, 0x3E, 0x1F, 0x2F, 0x12,
+ 0x1A, 0x2A, 0x13, 0x1B, 0x2B, 0x33, 0x1D, 0x2D, 0x35, 0x16, 0x1E, 0x2E,
+ 0x36
+};
+
+static const uint8_t huff_b04_cb[12] = {
+ 2, 11, 1, 0, 4, 4, 5, 9, 30, 45, 21, 2
+};
+
+static const uint8_t huff_b04_xlat[121] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x11, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x02,
+ 0xF2, 0x0E, 0x21, 0xE1, 0x12, 0xE2, 0x1E, 0x2E, 0xFE, 0x2F, 0xEF, 0x30,
+ 0x50, 0xB0, 0xC0, 0xD0, 0x31, 0xB1, 0xD1, 0x22, 0xD2, 0x03, 0x13, 0xE3,
+ 0xF3, 0xF4, 0x05, 0xE5, 0xF5, 0x0B, 0x1B, 0x0C, 0x0D, 0x1D, 0x2D, 0xFD,
+ 0x3E, 0xEE, 0x3F, 0x5F, 0xDF, 0x40, 0x41, 0x51, 0xC1, 0x32, 0x42, 0x52,
+ 0xB2, 0xC2, 0x23, 0x33, 0xB3, 0xC3, 0xD3, 0x04, 0x14, 0x24, 0xD4, 0xE4,
+ 0x15, 0x25, 0xC5, 0xD5, 0x2B, 0x3B, 0xEB, 0xFB, 0x1C, 0x2C, 0x3C, 0x5C,
+ 0xEC, 0xFC, 0x3D, 0x5D, 0xDD, 0xED, 0x4E, 0x5E, 0xBE, 0xCE, 0xDE, 0x4F,
+ 0xBF, 0xCF, 0x43, 0x53, 0x34, 0x54, 0xB4, 0xC4, 0x35, 0x45, 0x55, 0xB5,
+ 0x4B, 0x5B, 0xCB, 0xDB, 0x4C, 0xBC, 0xCC, 0xDC, 0x4D, 0xBD, 0xCD, 0x44,
+ 0xBB
+};
+
+static const uint8_t huff_b05_cb[11] = {
+ 3, 11, 1, 4, 4, 4, 12, 30, 73, 75, 22
+};
+
+static const uint8_t huff_b05_xlat[225] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x11, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x02,
+ 0x0E, 0x30, 0xD0, 0x21, 0xE1, 0x12, 0xF2, 0x03, 0x0D, 0x1E, 0xFE, 0x2F,
+ 0xEF, 0x40, 0x60, 0x70, 0x90, 0xA0, 0xC0, 0x31, 0xD1, 0x22, 0x32, 0xD2,
+ 0xE2, 0x13, 0x23, 0xE3, 0xF3, 0x04, 0x06, 0x07, 0x09, 0x0A, 0x0C, 0x1D,
+ 0x2D, 0xFD, 0x2E, 0x3E, 0xEE, 0x3F, 0xDF, 0x50, 0xB0, 0x41, 0x51, 0x61,
+ 0x71, 0x91, 0xA1, 0xB1, 0xC1, 0x42, 0x62, 0x72, 0x92, 0xA2, 0xC2, 0x33,
+ 0x93, 0xA3, 0xD3, 0x14, 0x24, 0xE4, 0xF4, 0x05, 0x15, 0xF5, 0x16, 0x26,
+ 0xD6, 0xE6, 0xF6, 0x17, 0x27, 0xD7, 0xE7, 0xF7, 0x19, 0x29, 0x39, 0xE9,
+ 0xF9, 0x1A, 0x2A, 0xEA, 0xFA, 0x0B, 0x1B, 0xFB, 0x1C, 0x2C, 0xEC, 0xFC,
+ 0x3D, 0x7D, 0x9D, 0xDD, 0xED, 0x4E, 0x6E, 0x7E, 0x9E, 0xAE, 0xCE, 0xDE,
+ 0x4F, 0x5F, 0x6F, 0x7F, 0x9F, 0xAF, 0xBF, 0xCF, 0x52, 0xB2, 0x43, 0x53,
+ 0x63, 0x73, 0xB3, 0xC3, 0x34, 0x44, 0x64, 0x74, 0x94, 0xA4, 0xB4, 0xC4,
+ 0xD4, 0x25, 0x35, 0x65, 0x75, 0x95, 0xA5, 0xD5, 0xE5, 0x36, 0x46, 0x56,
+ 0x66, 0xA6, 0xB6, 0xC6, 0x37, 0x47, 0x57, 0xB7, 0xC7, 0x49, 0x59, 0x69,
+ 0xB9, 0xC9, 0xD9, 0x3A, 0x4A, 0x5A, 0x6A, 0xAA, 0xBA, 0xCA, 0xDA, 0x2B,
+ 0x3B, 0x6B, 0x7B, 0x9B, 0xAB, 0xDB, 0xEB, 0x3C, 0x4C, 0x6C, 0x7C, 0x9C,
+ 0xAC, 0xCC, 0xDC, 0x4D, 0x5D, 0x6D, 0xAD, 0xBD, 0xCD, 0x5E, 0xBE, 0x54,
+ 0x45, 0x55, 0xB5, 0xC5, 0x76, 0x96, 0x67, 0x77, 0x97, 0xA7, 0x79, 0x99,
+ 0xA9, 0x7A, 0x9A, 0x4B, 0x5B, 0xBB, 0xCB, 0x5C, 0xBC
+};
+
+static const uint8_t huff_b07_cb[9] = { 3, 9, 3, 2, 4, 8, 23, 13, 10 };
+
+static const uint8_t huff_b07_xlat[63] = {
+ 0, 1, 63, 2, 62, 3, 4, 60, 61, 5, 6, 7, 8, 56, 57, 58,
+ 59, 9, 10, 11, 12, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36,
+ 37, 38, 39, 51, 52, 53, 54, 55, 13, 14, 15, 16, 17, 18, 19, 45,
+ 46, 47, 48, 49, 50, 20, 21, 22, 23, 24, 40, 41, 42, 43, 44
+};
+
+static const uint8_t huff_b12_cb[10] = { 3, 10, 1, 3, 12, 0, 30, 9, 18, 8 };
+
+static const uint8_t huff_b12_xlat[81] = {
+ 0x00, 0x40, 0x04, 0x01, 0x10, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x80, 0x90, 0x20, 0x60, 0x84, 0x94, 0x24, 0x64,
+ 0x08, 0x48, 0x18, 0x81, 0x91, 0x61, 0x85, 0x95, 0x25, 0x65, 0x09, 0x49,
+ 0x19, 0x59, 0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56, 0xA4, 0x58,
+ 0x68, 0x21, 0xA5, 0x29, 0x69, 0x1A, 0x5A, 0xA0, 0x88, 0x98, 0x28, 0xA1,
+ 0x89, 0x99, 0xA9, 0x92, 0x22, 0x62, 0x86, 0x96, 0x26, 0x66, 0x0A, 0x4A,
+ 0x6A, 0xA8, 0x82, 0xA2, 0xA6, 0x8A, 0x9A, 0x2A, 0xAA
+};
+
+static const uint8_t huff_b14_cb[14] = {
+ 1, 12, 1, 0, 0, 4, 0, 3, 5, 16, 28, 34, 26, 4
+};
+
+static const uint8_t huff_b14_xlat[121] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0xF1, 0x1F, 0xFF, 0x20, 0xE0, 0x11, 0x02,
+ 0x0E, 0x30, 0x50, 0xB0, 0xD0, 0x21, 0xE1, 0x12, 0xF2, 0x03, 0x05, 0x0B,
+ 0x0D, 0x1E, 0xFE, 0x2F, 0xEF, 0x40, 0xC0, 0x31, 0x51, 0xB1, 0xC1, 0xD1,
+ 0x22, 0x52, 0xE2, 0x13, 0xF3, 0x04, 0x15, 0xF5, 0x1B, 0xEB, 0xFB, 0x0C,
+ 0x1D, 0xFD, 0x2E, 0x5E, 0xEE, 0x3F, 0x5F, 0xBF, 0xDF, 0x41, 0x32, 0x42,
+ 0xB2, 0xD2, 0x23, 0x53, 0xB3, 0xE3, 0x14, 0x24, 0xE4, 0xF4, 0x25, 0x35,
+ 0xD5, 0xE5, 0x2B, 0x3B, 0xDB, 0x1C, 0x2C, 0xBC, 0xEC, 0xFC, 0x2D, 0xBD,
+ 0xED, 0x3E, 0x4E, 0xBE, 0xDE, 0x4F, 0xCF, 0xC2, 0x33, 0x43, 0xC3, 0xD3,
+ 0x34, 0x44, 0x54, 0xB4, 0xD4, 0x45, 0x55, 0xC5, 0x4B, 0xCB, 0x3C, 0x4C,
+ 0x5C, 0xCC, 0xDC, 0x3D, 0x4D, 0x5D, 0xCD, 0xDD, 0xCE, 0xC4, 0xB5, 0x5B,
+ 0xBB
+};
+
+static const uint8_t huff_b16_cb[11] = {
+ 4, 12, 4, 4, 9, 13, 37, 76, 72, 39, 2
+};
+
+static const uint8_t huff_b16_xlat[256] = {
+ 0x00, 0x10, 0x01, 0x11, 0x20, 0x21, 0x02, 0x12, 0x30, 0x31, 0x41, 0x22,
+ 0x32, 0x03, 0x13, 0x23, 0x14, 0x40, 0x51, 0x61, 0x42, 0x52, 0x33, 0x43,
+ 0x04, 0x24, 0x34, 0x15, 0x25, 0x16, 0x50, 0x60, 0x70, 0x71, 0x81, 0xD1,
+ 0xE1, 0x62, 0x72, 0x82, 0xD2, 0x53, 0x63, 0x73, 0xD3, 0x44, 0x54, 0x05,
+ 0x35, 0x45, 0x55, 0x06, 0x26, 0x36, 0x07, 0x17, 0x27, 0x37, 0x18, 0x28,
+ 0x19, 0x1D, 0x2D, 0x3D, 0x1E, 0x2E, 0x1F, 0x80, 0x90, 0xD0, 0xE0, 0xF0,
+ 0x91, 0xA1, 0xB1, 0xC1, 0xF1, 0x92, 0xA2, 0xB2, 0xC2, 0xE2, 0xF2, 0x83,
+ 0x93, 0xA3, 0xC3, 0xE3, 0xF3, 0x64, 0x74, 0x84, 0x94, 0xD4, 0xE4, 0xF4,
+ 0x65, 0x75, 0x85, 0xD5, 0xE5, 0x46, 0x56, 0x66, 0x76, 0xD6, 0xE6, 0x47,
+ 0x57, 0x67, 0xD7, 0x08, 0x38, 0x48, 0x58, 0x09, 0x29, 0x39, 0x49, 0x0A,
+ 0x1A, 0x2A, 0x3A, 0x1B, 0x2B, 0x0C, 0x1C, 0x2C, 0x3C, 0x0D, 0x4D, 0x5D,
+ 0x6D, 0x7D, 0x0E, 0x3E, 0x4E, 0x5E, 0x6E, 0x0F, 0x2F, 0x3F, 0x4F, 0xA0,
+ 0xB0, 0xC0, 0xB3, 0xA4, 0xB4, 0xC4, 0x95, 0xA5, 0xB5, 0xC5, 0xF5, 0x86,
+ 0x96, 0xA6, 0xB6, 0xC6, 0xF6, 0x77, 0x87, 0x97, 0xA7, 0xC7, 0xE7, 0xF7,
+ 0x68, 0x78, 0x88, 0x98, 0xD8, 0xE8, 0xF8, 0x59, 0x69, 0x79, 0x89, 0xD9,
+ 0xE9, 0xF9, 0x4A, 0x5A, 0x6A, 0x7A, 0xDA, 0xEA, 0x0B, 0x3B, 0x4B, 0x5B,
+ 0xDB, 0xEB, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0xDC, 0x8D, 0x9D, 0xAD, 0xBD,
+ 0xCD, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xB7,
+ 0xA8, 0xB8, 0xC8, 0x99, 0xA9, 0xB9, 0xC9, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA,
+ 0xFA, 0x6B, 0x7B, 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xFB, 0x9C, 0xAC, 0xBC,
+ 0xCC, 0xEC, 0xFC, 0xDD, 0xED, 0xFD, 0xCE, 0xDE, 0xEE, 0xFE, 0xAF, 0xBF,
+ 0xCF, 0xDF, 0xEF, 0xFF
+};
+
+static const uint8_t huff_b26_cb[12] = {
+ 3, 12, 2, 2, 4, 5, 11, 26, 67, 78, 51, 10
+};
+
+static const uint8_t huff_b26_xlat[256] = {
+ 0x00, 0x01, 0x10, 0x11, 0x20, 0x21, 0x02, 0x12, 0x30, 0x31, 0x22, 0x03,
+ 0x13, 0x40, 0x41, 0x51, 0x32, 0x42, 0x23, 0x33, 0x04, 0x14, 0x24, 0x15,
+ 0x50, 0x61, 0x71, 0xD1, 0xE1, 0x52, 0x62, 0xD2, 0x43, 0x53, 0xD3, 0x34,
+ 0x44, 0x05, 0x25, 0x35, 0x06, 0x16, 0x26, 0x17, 0x18, 0x1D, 0x2D, 0x3D,
+ 0x1E, 0x2E, 0x60, 0x70, 0x80, 0xD0, 0xE0, 0xF0, 0x81, 0x91, 0xA1, 0xC1,
+ 0xF1, 0x72, 0x82, 0x92, 0xC2, 0xE2, 0xF2, 0x63, 0x73, 0xE3, 0xF3, 0x54,
+ 0x64, 0x74, 0xD4, 0xE4, 0xF4, 0x45, 0x55, 0x65, 0xD5, 0xE5, 0xF5, 0x36,
+ 0x46, 0x56, 0xD6, 0xE6, 0x07, 0x27, 0x37, 0x47, 0xD7, 0x08, 0x28, 0x38,
+ 0x19, 0x29, 0x1A, 0x1B, 0x1C, 0x2C, 0x0D, 0x4D, 0x5D, 0x6D, 0x7D, 0x0E,
+ 0x3E, 0x4E, 0x5E, 0x6E, 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x90, 0xA0, 0xC0,
+ 0xB1, 0xA2, 0xB2, 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0x84, 0x94, 0xA4, 0xC4,
+ 0x75, 0x85, 0x95, 0xC5, 0x66, 0x76, 0x86, 0x96, 0xC6, 0xF6, 0x57, 0x67,
+ 0x77, 0xE7, 0xF7, 0x48, 0x58, 0x68, 0x78, 0xD8, 0xE8, 0xF8, 0x09, 0x39,
+ 0x49, 0x59, 0xD9, 0xE9, 0xF9, 0x0A, 0x2A, 0x3A, 0x4A, 0xDA, 0xEA, 0x0B,
+ 0x2B, 0x3B, 0xDB, 0xEB, 0x0C, 0x3C, 0x4C, 0x5C, 0x6C, 0xDC, 0x8D, 0x9D,
+ 0xAD, 0xBD, 0xCD, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0x5F, 0x6F, 0x7F,
+ 0x8F, 0x9F, 0xAF, 0xB0, 0xB4, 0xA5, 0xB5, 0xA6, 0xB6, 0x87, 0x97, 0xA7,
+ 0xB7, 0xC7, 0x88, 0x98, 0xA8, 0xC8, 0x69, 0x79, 0x89, 0x99, 0xA9, 0xC9,
+ 0x5A, 0x6A, 0x7A, 0x9A, 0xCA, 0xFA, 0x4B, 0x5B, 0x6B, 0x7B, 0xCB, 0xFB,
+ 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xEC, 0xFC, 0xDD, 0xED, 0xFD, 0xDE,
+ 0xEE, 0xFE, 0xBF, 0xCF, 0xDF, 0xEF, 0xB8, 0xB9, 0x8A, 0xAA, 0xBA, 0x8B,
+ 0x9B, 0xAB, 0xBB, 0xFF
+};
+
+static const uint8_t huff_b32_cb[12] = {
+ 2, 11, 1, 0, 4, 6, 7, 10, 22, 11, 16, 4
+};
+
+static const uint8_t huff_b32_xlat[81] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x41, 0x11, 0x05, 0x80,
+ 0x54, 0x51, 0x45, 0x15, 0x55, 0x02, 0x90, 0x20, 0x60, 0x84, 0x24, 0x08,
+ 0x18, 0x09, 0x12, 0x06, 0xA0, 0x94, 0x64, 0x48, 0x58, 0x81, 0x91, 0x21,
+ 0x61, 0x85, 0x95, 0x25, 0x65, 0x49, 0x19, 0x59, 0x42, 0x52, 0x46, 0x16,
+ 0x56, 0x0A, 0xA4, 0x28, 0x68, 0xA1, 0xA5, 0x29, 0x69, 0x26, 0x4A, 0x1A,
+ 0x5A, 0x88, 0x98, 0xA8, 0x89, 0x99, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x86,
+ 0x96, 0x66, 0x9A, 0x2A, 0x6A, 0xA2, 0xA6, 0x8A, 0xAA
+};
+
+static const uint8_t huff_b33_cb[13] = {
+ 2, 12, 1, 0, 0, 4, 11, 8, 28, 92, 97, 13, 2
+};
+
+static const uint8_t huff_b33_xlat[256] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51,
+ 0x05, 0x45, 0x15, 0x55, 0x20, 0x95, 0x65, 0x49, 0x59, 0x52, 0x46, 0x16,
+ 0x80, 0x90, 0x60, 0x84, 0x94, 0x24, 0x64, 0xA4, 0x08, 0x48, 0x18, 0x58,
+ 0x81, 0x91, 0x21, 0x61, 0x85, 0x25, 0x09, 0x19, 0x69, 0x02, 0x42, 0x12,
+ 0x06, 0x56, 0x5A, 0x57, 0xD0, 0x74, 0x68, 0x5C, 0xC1, 0xD5, 0xA5, 0xE5,
+ 0x75, 0xB5, 0xF5, 0x99, 0xD9, 0xA9, 0xE9, 0x79, 0xB9, 0xF9, 0x1D, 0x5D,
+ 0x9D, 0xDD, 0x6D, 0xAD, 0xED, 0x7D, 0xBD, 0xFD, 0x82, 0x92, 0xD2, 0x62,
+ 0x96, 0xD6, 0x26, 0x66, 0xA6, 0xE6, 0x76, 0xB6, 0xF6, 0x0A, 0x4A, 0x1A,
+ 0x9A, 0xDA, 0x2A, 0x6A, 0xAA, 0xEA, 0x7A, 0xBA, 0xFA, 0x5E, 0x9E, 0xDE,
+ 0x6E, 0xAE, 0xEE, 0x7E, 0xBE, 0xFE, 0x03, 0x13, 0x53, 0x17, 0x97, 0xD7,
+ 0x67, 0xA7, 0xE7, 0x77, 0xB7, 0xF7, 0x5B, 0x9B, 0xDB, 0x6B, 0xAB, 0xEB,
+ 0x7B, 0xBB, 0xFB, 0x5F, 0x9F, 0xDF, 0x6F, 0xAF, 0xEF, 0x7F, 0xBF, 0xFF,
+ 0xC0, 0xA0, 0xE0, 0x30, 0xC4, 0xD4, 0xE4, 0x34, 0xB4, 0xF4, 0x88, 0xC8,
+ 0x98, 0xD8, 0x28, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, 0x0C, 0x4C, 0x1C,
+ 0x9C, 0xDC, 0x6C, 0xAC, 0xEC, 0x7C, 0xBC, 0xFC, 0xD1, 0xA1, 0xE1, 0x31,
+ 0x71, 0xB1, 0xF1, 0xC5, 0x35, 0x89, 0xC9, 0x29, 0x39, 0x0D, 0x4D, 0x8D,
+ 0xCD, 0x2D, 0x3D, 0x22, 0xA2, 0xE2, 0x72, 0xB2, 0xF2, 0x86, 0xC6, 0x36,
+ 0x8A, 0xCA, 0x3A, 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x2E, 0x3E, 0x43, 0x83,
+ 0x93, 0xD3, 0x23, 0x63, 0xA3, 0xE3, 0x73, 0xB3, 0xF3, 0x07, 0x47, 0x87,
+ 0xC7, 0x27, 0x37, 0x4B, 0x8B, 0xCB, 0x1B, 0x2B, 0x3B, 0x4F, 0x8F, 0xCF,
+ 0x1F, 0x70, 0xB0, 0xF0, 0x8C, 0xCC, 0x2C, 0x3C, 0xC2, 0x32, 0xC3, 0x0F,
+ 0x2F, 0x3F, 0x33, 0x0B
+};
+
+static const uint8_t huff_b35_cb[14] = {
+ 1, 12, 1, 0, 0, 0, 4, 6, 6, 14, 42, 63, 59, 30
+};
+
+static const uint8_t huff_b35_xlat[225] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x11, 0xF1, 0x02, 0x0E, 0x1F, 0xFF, 0x20,
+ 0xE0, 0x21, 0xF2, 0xFE, 0xEF, 0x30, 0xD0, 0xE1, 0x12, 0x22, 0xE2, 0x03,
+ 0x0D, 0x1D, 0x1E, 0x2E, 0xEE, 0x2F, 0xDF, 0x40, 0x60, 0x70, 0x90, 0xA0,
+ 0xB0, 0xC0, 0x31, 0x71, 0x91, 0xC1, 0xD1, 0x32, 0xD2, 0x13, 0xE3, 0xF3,
+ 0x04, 0x05, 0x06, 0x07, 0x17, 0xF7, 0x09, 0x19, 0x0A, 0x1A, 0xFA, 0x0C,
+ 0x1C, 0x2D, 0xED, 0xFD, 0x3E, 0x7E, 0xDE, 0x3F, 0x6F, 0x7F, 0x9F, 0xAF,
+ 0xCF, 0x50, 0x41, 0x51, 0x61, 0xA1, 0xB1, 0x62, 0x72, 0x92, 0xA2, 0xC2,
+ 0x23, 0x33, 0x63, 0x73, 0x93, 0xA3, 0xD3, 0x14, 0x24, 0x34, 0xD4, 0xE4,
+ 0xF4, 0x15, 0xF5, 0x16, 0x26, 0xD6, 0xE6, 0xF6, 0x27, 0x37, 0x47, 0xE7,
+ 0x29, 0x39, 0xC9, 0xD9, 0xE9, 0xF9, 0x2A, 0xEA, 0x0B, 0x1B, 0xFB, 0x2C,
+ 0x7C, 0xEC, 0xFC, 0x3D, 0x4D, 0x6D, 0x7D, 0xDD, 0x4E, 0x5E, 0x6E, 0x9E,
+ 0xAE, 0xCE, 0x4F, 0x5F, 0x42, 0x52, 0xB2, 0x43, 0xB3, 0xC3, 0x44, 0x64,
+ 0x74, 0x94, 0xA4, 0x25, 0x35, 0x65, 0x75, 0x95, 0xA5, 0xE5, 0x36, 0x46,
+ 0x66, 0x76, 0x96, 0xA6, 0xB6, 0xC6, 0x57, 0xA7, 0xB7, 0xC7, 0xD7, 0x59,
+ 0xA9, 0xB9, 0x3A, 0x4A, 0x6A, 0xCA, 0xDA, 0x2B, 0x3B, 0x6B, 0x9B, 0xAB,
+ 0xDB, 0xEB, 0x3C, 0x6C, 0x9C, 0xAC, 0xCC, 0xDC, 0x5D, 0x9D, 0xAD, 0xBD,
+ 0xCD, 0xBE, 0xBF, 0x53, 0x54, 0xB4, 0xC4, 0x45, 0x55, 0xB5, 0xC5, 0xD5,
+ 0x56, 0x67, 0x77, 0x97, 0x49, 0x69, 0x79, 0x99, 0x5A, 0x7A, 0x9A, 0xAA,
+ 0xBA, 0x4B, 0x5B, 0x7B, 0xBB, 0xCB, 0x4C, 0x5C, 0xBC
+};
+
+static const uint8_t huff_b37_cb[13] = {
+ 1, 11, 1, 0, 2, 0, 2, 2, 6, 17, 14, 13, 6
+};
+
+static const uint8_t huff_b37_xlat[63] = {
+ 0, 1, 63, 2, 62, 3, 61, 4, 5, 6, 58, 59, 60, 7, 8, 9,
+ 10, 25, 26, 27, 28, 29, 34, 35, 37, 38, 39, 55, 56, 57, 11, 13,
+ 14, 15, 30, 31, 33, 36, 49, 50, 51, 52, 53, 54, 12, 16, 17, 18,
+ 19, 21, 41, 43, 44, 45, 46, 47, 48, 20, 22, 23, 24, 40, 42
+};
+
+static const uint8_t huff_b41_cb[14] = {
+ 1, 12, 1, 0, 0, 1, 7, 0, 20, 4, 10, 24, 2, 12
+};
+
+static const uint8_t huff_b41_xlat[81] = {
+ 0x00, 0x01, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x03, 0x50, 0xD0, 0x70,
+ 0xF0, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0xC1, 0x11, 0x31, 0x05, 0x0D,
+ 0xC3, 0x13, 0x33, 0x07, 0x0F, 0x44, 0xCC, 0x41, 0x43, 0x54, 0x74, 0xDC,
+ 0xFC, 0x71, 0x15, 0x4D, 0x1D, 0x37, 0x3F, 0xD4, 0xF4, 0x5C, 0x7C, 0x51,
+ 0xD1, 0xF1, 0x45, 0xC5, 0x35, 0xCD, 0xDD, 0x3D, 0x53, 0xD3, 0x73, 0xF3,
+ 0x47, 0xC7, 0x17, 0x77, 0x4F, 0xCF, 0x1F, 0x55, 0xFF, 0xD5, 0x75, 0xF5,
+ 0x5D, 0x7D, 0xFD, 0x57, 0xD7, 0xF7, 0x5F, 0xDF, 0x7F
+};
+
+static const uint8_t huff_b42_cb[11] = { 1, 9, 1, 0, 1, 3, 2, 3, 7, 4, 4 };
+
+static const uint8_t huff_b42_xlat[25] = {
+ 0x00, 0x07, 0x08, 0x38, 0x01, 0x39, 0x0F, 0x10, 0x09, 0x3F, 0x30, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x17, 0x11, 0x0A, 0x3E, 0x37, 0x12, 0x32, 0x16,
+ 0x36
+};
+
+static const uint8_t huff_b43_cb[10] = { 2, 9, 1, 1, 3, 4, 9, 15, 12, 4 };
+
+static const uint8_t huff_b43_xlat[49] = {
+ 0x00, 0x07, 0x08, 0x38, 0x01, 0x09, 0x39, 0x0F, 0x3F, 0x10, 0x30, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x17, 0x37, 0x18, 0x28, 0x11, 0x19, 0x29, 0x0A,
+ 0x03, 0x0B, 0x3B, 0x05, 0x0D, 0x3D, 0x3E, 0x1F, 0x2F, 0x12, 0x1A, 0x2A,
+ 0x32, 0x13, 0x33, 0x15, 0x35, 0x16, 0x1E, 0x2E, 0x36, 0x1B, 0x2B, 0x1D,
+ 0x2D
+};
+
+static const uint8_t huff_b47_cb[10] = { 2, 9, 1, 1, 3, 4, 6, 14, 22, 12 };
+
+static const uint8_t huff_b47_xlat[63] = {
+ 0, 1, 2, 62, 63, 3, 4, 60, 61, 5, 6, 7, 57, 58, 59, 8,
+ 9, 10, 11, 12, 26, 27, 37, 38, 52, 53, 54, 55, 56, 13, 14, 15,
+ 16, 17, 18, 25, 28, 29, 30, 31, 33, 34, 35, 36, 39, 46, 47, 48,
+ 49, 50, 51, 19, 20, 21, 22, 23, 24, 40, 41, 42, 43, 44, 45
+};
+
+static const uint8_t huff_b52_cb[11] = { 1, 9, 1, 0, 1, 3, 2, 3, 7, 4, 4 };
+
+static const uint8_t huff_b52_xlat[25] = {
+ 0x00, 0x01, 0x08, 0x38, 0x07, 0x39, 0x0F, 0x30, 0x09, 0x3F, 0x10, 0x31,
+ 0x02, 0x3A, 0x06, 0x0E, 0x17, 0x11, 0x0A, 0x3E, 0x37, 0x12, 0x32, 0x16,
+ 0x36
+};
+
+static const uint8_t huff_b53_cb[7] = { 1, 5, 1, 1, 1, 0, 4 }; // same as b63!!!
+
+static const uint8_t huff_b53_xlat[7] = { 0, 7, 1, 2, 3, 5, 6 };
+
+static const uint8_t huff_b56_cb[11] = { 1, 9, 1, 0, 2, 0, 2, 4, 11, 9, 2 };
+
+static const uint8_t huff_b56_xlat[31] = {
+ 0, 1, 31, 2, 30, 3, 4, 13, 29, 5, 6, 7, 14, 15, 17, 18,
+ 19, 26, 27, 28, 8, 9, 12, 20, 21, 22, 23, 24, 25, 10, 11
+};
+
+static const uint8_t huff_b62_cb[14] = {
+ 1, 12, 1, 0, 0, 2, 3, 5, 12, 14, 18, 15, 9, 2
+};
+
+static const uint8_t huff_b62_xlat[81] = {
+ 0x00, 0x40, 0x01, 0x10, 0x04, 0x02, 0x80, 0x50, 0x90, 0x05, 0x06, 0x20,
+ 0x60, 0x44, 0x14, 0x54, 0x24, 0x08, 0x18, 0x41, 0x11, 0x15, 0x09, 0xA0,
+ 0x84, 0x94, 0x64, 0xA4, 0x28, 0x51, 0x45, 0x55, 0x19, 0x12, 0x16, 0x0A,
+ 0x1A, 0x48, 0x58, 0x68, 0x81, 0x91, 0x21, 0x61, 0x85, 0x95, 0x25, 0x65,
+ 0x49, 0x59, 0x29, 0x69, 0x42, 0x46, 0x56, 0x88, 0x98, 0xA8, 0xA1, 0xA5,
+ 0x99, 0xA9, 0x52, 0x22, 0x26, 0x66, 0x4A, 0x5A, 0x2A, 0x6A, 0x89, 0x82,
+ 0x92, 0x62, 0x86, 0x96, 0xA6, 0x8A, 0xAA, 0xA2, 0x9A
+};
+
+static const uint8_t huff_b63_cb[7] = { 1, 5, 1, 1, 1, 0, 4 };
+
+static const uint8_t huff_b63_xlat[7] = { 0, 1, 7, 2, 3, 5, 6 };
+
+static const uint8_t huff_b64_cb[7] = { 1, 5, 1, 1, 1, 1, 2 };
+
+static const uint8_t huff_b64_xlat[6] = { 1, 0, 2, 5, 3, 4 };
+
+static const uint8_t huff_b65_cb[14] = {
+ 1, 12, 1, 0, 0, 2, 2, 2, 6, 12, 34, 92, 54, 20
+};
+
+static const uint8_t huff_b65_xlat[225] = {
+ 0x00, 0xF0, 0x01, 0x10, 0x0F, 0x11, 0xF1, 0x20, 0xE0, 0x02, 0x0E, 0x1F,
+ 0xFF, 0xD0, 0x21, 0xE1, 0x12, 0xF2, 0x07, 0x0A, 0x0D, 0x1E, 0xFE, 0x2F,
+ 0xEF, 0x30, 0x70, 0x90, 0xA0, 0xC0, 0x71, 0x91, 0xC1, 0xD1, 0x32, 0x92,
+ 0xE2, 0x03, 0x13, 0x63, 0x04, 0x06, 0xE6, 0xE7, 0xF7, 0x09, 0x19, 0x39,
+ 0xFA, 0x0C, 0x1C, 0xDD, 0xED, 0xFD, 0x2E, 0x7E, 0x9E, 0x3F, 0x9F, 0x40,
+ 0x50, 0x60, 0xB0, 0x31, 0x41, 0x61, 0xA1, 0xB1, 0x22, 0x42, 0x72, 0xA2,
+ 0xB2, 0xC2, 0xD2, 0x23, 0x33, 0x73, 0xA3, 0xC3, 0xD3, 0xE3, 0xF3, 0x14,
+ 0x24, 0x34, 0x44, 0x74, 0xD4, 0xE4, 0x05, 0x25, 0x45, 0x65, 0x95, 0xA5,
+ 0x16, 0x26, 0x46, 0x76, 0xA6, 0xB6, 0xC6, 0xD6, 0xF6, 0x17, 0x27, 0x37,
+ 0x47, 0x67, 0xA7, 0xD7, 0x29, 0x69, 0xB9, 0xD9, 0xE9, 0xF9, 0x1A, 0x2A,
+ 0x3A, 0x9A, 0xCA, 0xDA, 0xEA, 0x0B, 0x1B, 0x3B, 0x6B, 0xEB, 0xFB, 0x2C,
+ 0x6C, 0xEC, 0xFC, 0x1D, 0x2D, 0x4D, 0x6D, 0x9D, 0xAD, 0x3E, 0x4E, 0x6E,
+ 0xAE, 0xCE, 0xEE, 0x4F, 0x5F, 0x6F, 0xDF, 0x51, 0x52, 0x62, 0x43, 0x93,
+ 0xB3, 0x54, 0x94, 0xA4, 0xF4, 0x15, 0x75, 0xB5, 0xE5, 0xF5, 0x36, 0x56,
+ 0x66, 0x96, 0x57, 0x77, 0x49, 0x59, 0xA9, 0xC9, 0x4A, 0x5A, 0x6A, 0x7A,
+ 0xAA, 0xBA, 0x2B, 0x4B, 0x7B, 0x9B, 0xAB, 0xDB, 0x3C, 0x4C, 0x7C, 0x9C,
+ 0xAC, 0xBC, 0xCC, 0x3D, 0x5D, 0x7D, 0xBD, 0xCD, 0x5E, 0xBE, 0xDE, 0xBF,
+ 0xCF, 0x53, 0x64, 0xB4, 0xC4, 0x35, 0x55, 0xC5, 0xD5, 0x97, 0xB7, 0xC7,
+ 0x79, 0x99, 0x5B, 0xBB, 0xCB, 0x5C, 0xDC, 0x7F, 0xAF
+};
+
+static const uint8_t huff_b66_cb[14] = {
+ 1, 12, 1, 0, 0, 3, 0, 3, 3, 10, 40, 85, 61, 50
+};
+
+static const uint8_t huff_b66_xlat[256] = {
+ 0x00, 0x10, 0x01, 0x11, 0x21, 0x02, 0x12, 0x20, 0x22, 0x13, 0x30, 0x31,
+ 0x41, 0xD1, 0xE1, 0x32, 0x52, 0x03, 0x23, 0x2D, 0x40, 0x50, 0x60, 0x80,
+ 0xD0, 0xE0, 0x51, 0x61, 0xF1, 0x42, 0x62, 0xD2, 0xE2, 0xF2, 0x33, 0x43,
+ 0xC3, 0xD3, 0xE3, 0x04, 0x14, 0xD4, 0xF4, 0x25, 0x35, 0x16, 0x17, 0xF7,
+ 0xD8, 0x1C, 0x3C, 0x0D, 0x1D, 0x3D, 0x5D, 0x0E, 0x1E, 0x2E, 0x7E, 0x2F,
+ 0xC0, 0xF0, 0x71, 0x81, 0x91, 0xC1, 0x72, 0x82, 0x92, 0xB2, 0xC2, 0x53,
+ 0x63, 0x73, 0x93, 0xA3, 0xF3, 0x24, 0x44, 0x64, 0x84, 0xA4, 0xB4, 0x05,
+ 0x15, 0x95, 0xD5, 0x06, 0x26, 0x36, 0x46, 0x96, 0xD6, 0xE6, 0xF6, 0x07,
+ 0x27, 0x37, 0xD7, 0xE7, 0x08, 0x18, 0x28, 0x38, 0xE8, 0xF8, 0x09, 0x19,
+ 0x29, 0xE9, 0xF9, 0x0A, 0x1A, 0xCA, 0xDA, 0xEA, 0x0B, 0x1B, 0xDB, 0xEB,
+ 0xFB, 0x2C, 0x4C, 0x5C, 0x7C, 0x8C, 0x4D, 0x6D, 0x8D, 0x9D, 0xFD, 0x3E,
+ 0x5E, 0x6E, 0x8E, 0x9E, 0xEE, 0x0F, 0x1F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,
+ 0xCF, 0x70, 0xA1, 0xA2, 0x83, 0xB3, 0x34, 0x74, 0xC4, 0xE4, 0x55, 0x65,
+ 0x85, 0xA5, 0xC5, 0xE5, 0xF5, 0x56, 0x66, 0x76, 0x86, 0xA6, 0xC6, 0x57,
+ 0x67, 0x77, 0x97, 0xA7, 0x48, 0x88, 0x98, 0x49, 0x59, 0x79, 0x99, 0x3A,
+ 0x4A, 0x8A, 0xBA, 0xFA, 0x2B, 0x7B, 0x0C, 0xAC, 0xBC, 0xCC, 0xEC, 0x7D,
+ 0xAD, 0xBD, 0xDD, 0x4E, 0xBE, 0xCE, 0xFE, 0x8F, 0x9F, 0xAF, 0xBF, 0xDF,
+ 0xEF, 0xFF, 0x90, 0xA0, 0xB0, 0xB1, 0x54, 0x94, 0x45, 0x75, 0xB5, 0xB6,
+ 0x47, 0x87, 0xB7, 0xC7, 0x58, 0x68, 0x78, 0xA8, 0xB8, 0xC8, 0x39, 0x69,
+ 0x89, 0xA9, 0xB9, 0xC9, 0xD9, 0x2A, 0x5A, 0x6A, 0x7A, 0x9A, 0xAA, 0x3B,
+ 0x4B, 0x5B, 0x6B, 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0x6C, 0x9C, 0xDC, 0xFC,
+ 0xCD, 0xED, 0xAE, 0xDE
+};
+
+static const uint8_t huff_b67_cb[10] = { 2, 9, 1, 2, 1, 4, 7, 10, 26, 12 };
+
+static const uint8_t huff_b67_xlat[63] = {
+ 0, 1, 63, 62, 2, 3, 60, 61, 4, 5, 6, 7, 57, 58, 59, 8,
+ 9, 10, 11, 12, 52, 53, 54, 55, 56, 13, 14, 15, 16, 17, 18, 25,
+ 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 46, 47, 48,
+ 49, 50, 51, 19, 20, 21, 22, 23, 24, 40, 41, 42, 43, 44, 45
+};
+
+static const uint8_t huff_b71_cb[14] = {
+ 1, 12, 1, 0, 0, 1, 7, 0, 19, 5, 13, 23, 0, 12
+};
+
+static const uint8_t huff_b71_xlat[81] = {
+ 0x00, 0x03, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x50, 0xD0, 0x70,
+ 0xF0, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0xC1, 0x11, 0x31, 0x05, 0x0D,
+ 0x13, 0x33, 0x07, 0x0F, 0x44, 0xCC, 0x41, 0x43, 0xC3, 0x54, 0x74, 0xDC,
+ 0xFC, 0xF1, 0xC5, 0x15, 0x1D, 0x53, 0xC7, 0x37, 0x4F, 0x3F, 0xD4, 0xF4,
+ 0x5C, 0x7C, 0x51, 0xD1, 0x71, 0x45, 0x55, 0x35, 0x4D, 0xCD, 0xDD, 0x3D,
+ 0xD3, 0x73, 0xF3, 0x47, 0x17, 0x77, 0xCF, 0x1F, 0xFF, 0xD5, 0x75, 0xF5,
+ 0x5D, 0x7D, 0xFD, 0x57, 0xD7, 0xF7, 0x5F, 0xDF, 0x7F
+};
+
+static const uint8_t huff_b73_cb[13] = {
+ 1, 11, 1, 0, 0, 0, 1, 4, 9, 4, 103, 110, 24
+};
+
+static const uint8_t huff_b73_xlat[256] = {
+ 0x00, 0x40, 0x10, 0x04, 0x01, 0x05, 0x50, 0x14, 0x54, 0x41, 0x11, 0x51,
+ 0x45, 0x15, 0x55, 0x44, 0x95, 0x6A, 0x03, 0x80, 0xC0, 0x90, 0xD0, 0x94,
+ 0xD4, 0x24, 0x64, 0x58, 0x91, 0xA1, 0x85, 0xD5, 0x25, 0x65, 0xA5, 0xE5,
+ 0x75, 0xB5, 0xF5, 0x19, 0x59, 0x99, 0xD9, 0x69, 0xA9, 0xE9, 0x79, 0xB9,
+ 0xF9, 0x4D, 0x5D, 0x9D, 0xDD, 0x6D, 0xAD, 0xED, 0x7D, 0xBD, 0xFD, 0x02,
+ 0x42, 0x52, 0x06, 0x46, 0x16, 0x56, 0x96, 0xD6, 0x26, 0x66, 0xA6, 0xE6,
+ 0x76, 0xB6, 0xF6, 0x1A, 0x5A, 0x9A, 0xDA, 0xAA, 0xEA, 0x7A, 0xBA, 0xFA,
+ 0x5E, 0x9E, 0xDE, 0x6E, 0xAE, 0xEE, 0x7E, 0xBE, 0xFE, 0x07, 0x47, 0x57,
+ 0x97, 0xD7, 0x67, 0xA7, 0xE7, 0x77, 0xB7, 0xF7, 0x5B, 0x9B, 0xDB, 0x6B,
+ 0xAB, 0xEB, 0x7B, 0xBB, 0xFB, 0x5F, 0x9F, 0xDF, 0x6F, 0xAF, 0xEF, 0x7F,
+ 0xBF, 0xFF, 0x20, 0x60, 0x70, 0xB0, 0xF0, 0x84, 0xC4, 0xA4, 0xE4, 0x74,
+ 0xB4, 0xF4, 0x08, 0x88, 0x18, 0x98, 0xD8, 0x68, 0xA8, 0xE8, 0x78, 0xB8,
+ 0xF8, 0x1C, 0x5C, 0x9C, 0xDC, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,
+ 0x81, 0xD1, 0x21, 0x61, 0xE1, 0x71, 0xB1, 0xF1, 0xC5, 0x35, 0x09, 0x49,
+ 0x89, 0xC9, 0x29, 0x39, 0x0D, 0x8D, 0xCD, 0x1D, 0x2D, 0x3D, 0x92, 0xD2,
+ 0x22, 0x62, 0xA2, 0xE2, 0x72, 0xB2, 0xF2, 0x86, 0xC6, 0x36, 0x0A, 0x4A,
+ 0x8A, 0xCA, 0x2A, 0x3A, 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x2E, 0x3E, 0x13,
+ 0x53, 0x93, 0xD3, 0x63, 0xA3, 0xE3, 0x73, 0xB3, 0xF3, 0x87, 0xC7, 0x17,
+ 0x27, 0x37, 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x2B, 0x3B, 0x0F, 0x4F, 0x8F,
+ 0xCF, 0x1F, 0x2F, 0x3F, 0xA0, 0xE0, 0x30, 0x34, 0x48, 0xC8, 0x28, 0x38,
+ 0x0C, 0x4C, 0x8C, 0xCC, 0x2C, 0xC1, 0x31, 0x82, 0xC2, 0x12, 0x32, 0x43,
+ 0x83, 0xC3, 0x23, 0x33
+};
+
+static const uint8_t huff_b74_cb[8] = { 1, 6, 1, 0, 2, 2, 2, 4 };
+
+static const uint8_t huff_b74_xlat[11] = {
+ 0, 1, 15, 2, 14, 5, 13, 3, 4, 11, 12
+};
+
+static const uint8_t huff_b75_cb[13] = {
+ 2, 12, 1, 4, 0, 0, 0, 8, 11, 24, 53, 64, 60
+};
+
+static const uint8_t huff_b75_xlat[225] = {
+ 0x00, 0x10, 0xF0, 0x01, 0x0F, 0x20, 0xE0, 0x11, 0xF1, 0x02, 0x0E, 0x1F,
+ 0xFF, 0xD0, 0x21, 0xE1, 0x12, 0xF2, 0x03, 0x0D, 0x1E, 0xFE, 0x2F, 0xEF,
+ 0x30, 0x40, 0x60, 0x70, 0x90, 0xA0, 0xC0, 0x31, 0xD1, 0x22, 0xE2, 0x13,
+ 0xF3, 0x04, 0x06, 0x07, 0x09, 0x0C, 0x1D, 0xFD, 0x2E, 0xEE, 0x3F, 0xDF,
+ 0x50, 0xB0, 0x41, 0x61, 0x71, 0x91, 0xA1, 0xC1, 0x32, 0x62, 0x72, 0x92,
+ 0xA2, 0xD2, 0x23, 0xD3, 0xE3, 0x14, 0xF4, 0x05, 0x16, 0x26, 0xE6, 0xF6,
+ 0x17, 0x27, 0xE7, 0xF7, 0x19, 0x29, 0xF9, 0x0A, 0x1A, 0x2A, 0xFA, 0x0B,
+ 0x1C, 0x2C, 0xFC, 0x2D, 0x3D, 0xED, 0x3E, 0x4E, 0x7E, 0x9E, 0xDE, 0x4F,
+ 0x6F, 0x7F, 0x9F, 0xAF, 0xCF, 0x51, 0xB1, 0x42, 0x52, 0xB2, 0xC2, 0x33,
+ 0x63, 0x73, 0x93, 0xA3, 0xB3, 0xC3, 0x24, 0x34, 0x74, 0xA4, 0xD4, 0xE4,
+ 0x15, 0x25, 0x65, 0x95, 0xE5, 0xF5, 0x36, 0xD6, 0x37, 0x47, 0xC7, 0xD7,
+ 0x39, 0x59, 0xB9, 0xC9, 0xD9, 0xE9, 0x3A, 0x6A, 0xDA, 0xEA, 0x1B, 0x2B,
+ 0x9B, 0xAB, 0xEB, 0xFB, 0x6C, 0x7C, 0x9C, 0xAC, 0xEC, 0x4D, 0x6D, 0x7D,
+ 0x9D, 0xAD, 0xBD, 0xDD, 0x5E, 0x6E, 0xAE, 0xCE, 0x5F, 0x43, 0x53, 0x44,
+ 0x54, 0x64, 0x94, 0xB4, 0xC4, 0x35, 0x45, 0x55, 0x75, 0xA5, 0xB5, 0xC5,
+ 0xD5, 0x46, 0x56, 0x66, 0x76, 0x96, 0xA6, 0xB6, 0xC6, 0x57, 0x67, 0x77,
+ 0x97, 0xA7, 0xB7, 0x49, 0x69, 0x79, 0x99, 0xA9, 0x4A, 0x5A, 0x7A, 0x9A,
+ 0xAA, 0xBA, 0xCA, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0xBB, 0xCB, 0xDB, 0x3C,
+ 0x4C, 0x5C, 0xBC, 0xCC, 0xDC, 0x5D, 0xCD, 0xBE, 0xBF
+};
+
+static const uint8_t huff_b77_cb[12] = {
+ 2, 11, 1, 0, 4, 6, 10, 12, 7, 15, 4, 4
+};
+
+static const uint8_t huff_b77_xlat[63] = {
+ 0, 1, 2, 62, 63, 3, 4, 5, 59, 60, 61, 6, 7, 8, 9, 10,
+ 54, 55, 56, 57, 58, 11, 12, 13, 14, 15, 16, 47, 49, 50, 51, 52,
+ 53, 17, 18, 19, 20, 45, 46, 48, 21, 22, 23, 24, 25, 26, 27, 37,
+ 38, 39, 40, 41, 42, 43, 44, 28, 29, 30, 35, 31, 33, 34, 36
+};
+
+/** Tables for spectrum coding. */
+typedef struct Atrac3pSpecCodeTab {
+ uint8_t group_size; ///< number of coefficients grouped together
+ uint8_t num_coeffs; ///< 1 - map index to a single value, > 1 - map index to a vector of values
+ uint8_t bits; ///< number of bits a single coefficient occupy
+ uint8_t is_signed; ///< 1 - values in that table are signed ones, otherwise - absolute ones
+
+ int redirect; ///< if >= 0: tells which huffman table must be reused
+ const uint8_t *cb; ///< pointer to the codebook descriptor
+ const uint8_t *xlat; ///< pointer to the translation table or NULL if none
+} Atrac3pSpecCodeTab;
+
+static const Atrac3pSpecCodeTab atrac3p_spectra_tabs[112] = {
+ /* table set = A */
+ /* code table = 0 */
+ { 1, 4, 2, 1, -1, huff_a01_cb, huff_a01_xlat }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_a02_cb, huff_a02_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, -1, huff_a03_cb, huff_a03_xlat }, // wordlen = 3
+ { 1, 1, 3, 0, -1, huff_a04_cb, huff_a04_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_a05_cb, huff_a05_xlat }, // wordlen = 5
+ { 1, 1, 4, 0, -1, huff_a06_cb, huff_a06_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a07_cb, huff_a07_xlat }, // wordlen = 7
+
+ /* code table = 1 */
+ { 4, 4, 2, 1, -1, huff_a11_cb, huff_a11_xlat }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_a12_cb, huff_a12_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, -1, huff_a13_cb, huff_a13_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_a14_cb, huff_a14_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_a15_cb, huff_a15_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_a16_cb, huff_a16_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a17_cb, huff_a17_xlat }, // wordlen = 7
+
+ /* code table = 2 */
+ { 1, 4, 2, 1, -1, huff_a21_cb, huff_a21_xlat }, // wordlen = 1
+ { 1, 2, 3, 1, -1, huff_a22_cb, huff_a22_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, -1, huff_a23_cb, huff_a23_xlat }, // wordlen = 3
+ { 1, 1, 3, 0, -1, huff_a24_cb, NULL }, // wordlen = 4
+ { 1, 1, 3, 0, -1, huff_a25_cb, huff_a25_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_a26_cb, huff_a26_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a27_cb, huff_a27_xlat }, // wordlen = 7
+
+ /* code table = 3 */
+ { 1, 2, 2, 1, -1, huff_a31_cb, huff_a31_xlat }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_a32_cb, huff_a32_xlat }, // wordlen = 2
+ { 1, 4, 2, 0, -1, huff_a33_cb, huff_a33_xlat }, // wordlen = 3
+ { 1, 1, 3, 0, -1, huff_a34_cb, huff_a34_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_a35_cb, huff_a35_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_a36_cb, huff_a36_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a37_cb, huff_a37_xlat }, // wordlen = 7
+
+ /* code table = 4 */
+ { 1, 4, 2, 1, -1, huff_a41_cb, huff_a41_xlat }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_a42_cb, huff_a42_xlat }, // wordlen = 2
+ { 1, 1, 3, 1, -1, huff_a43_cb, huff_a43_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_a44_cb, huff_a44_xlat }, // wordlen = 4
+ { 1, 1, 3, 0, -1, huff_a45_cb, huff_a45_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_a46_cb, huff_a46_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a47_cb, huff_a47_xlat }, // wordlen = 7
+
+ /* code table = 5 */
+ { 1, 4, 2, 1, -1, huff_a51_cb, huff_a51_xlat }, // wordlen = 1
+ { 1, 2, 3, 1, -1, huff_a52_cb, huff_a52_xlat }, // wordlen = 2
+ { 1, 1, 3, 1, -1, huff_a43_cb, huff_a53_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_a54_cb, huff_a54_xlat }, // wordlen = 4
+ { 1, 1, 3, 0, -1, huff_a55_cb, huff_a55_xlat }, // wordlen = 5
+ { 1, 1, 5, 1, -1, huff_a56_cb, huff_a56_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a57_cb, huff_a57_xlat }, // wordlen = 7
+
+ /* code table = 6 */
+ { 2, 4, 2, 1, -1, huff_a61_cb, huff_a61_xlat }, // wordlen = 1
+ { 1, 2, 3, 1, -1, huff_a62_cb, huff_a62_xlat }, // wordlen = 2
+ { 1, 4, 2, 0, -1, huff_a63_cb, huff_a63_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_a64_cb, huff_a64_xlat }, // wordlen = 4
+ { 1, 1, 4, 1, -1, huff_a65_cb, huff_a65_xlat }, // wordlen = 5
+ { 1, 1, 5, 1, -1, huff_a66_cb, huff_a66_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_a67_cb, huff_a67_xlat }, // wordlen = 7
+
+ /* code table = 7 */
+ { 1, 2, 1, 0, -1, huff_a71_cb, NULL }, // wordlen = 1
+ { 2, 4, 2, 0, -1, huff_a72_cb, huff_a72_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, -1, huff_a73_cb, huff_a73_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_a74_cb, huff_a74_xlat }, // wordlen = 4
+ { 1, 1, 4, 1, -1, huff_a75_cb, huff_a75_xlat }, // wordlen = 5
+ { 2, 2, 4, 0, -1, huff_a76_cb, huff_a76_xlat }, // wordlen = 6
+ { 4, 1, 6, 1, 6, NULL, NULL }, // wordlen = 7
+
+ /* table set = B */
+ /* code table = 0 */
+ { 4, 4, 2, 1, -1, huff_b01_cb, huff_b01_xlat }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_b02_cb, huff_b02_xlat }, // wordlen = 2
+ { 4, 2, 3, 1, -1, huff_b03_cb, huff_b03_xlat }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_b04_cb, huff_b04_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_b05_cb, huff_b05_xlat }, // wordlen = 5
+ { 1, 1, 4, 0, 5, NULL, NULL }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_b07_cb, huff_b07_xlat }, // wordlen = 7
+
+ /* code table = 1 */
+ { 1, 4, 2, 1, 14, NULL, NULL }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_b12_cb, huff_b12_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, 9, NULL, NULL }, // wordlen = 3
+ { 1, 2, 4, 1, -1, huff_b14_cb, huff_b14_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, 11, NULL, NULL }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_b16_cb, huff_b16_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, 6, NULL, NULL }, // wordlen = 7
+
+ /* code table = 2 */
+ { 4, 4, 2, 1, 28, NULL, NULL }, // wordlen = 1
+ { 4, 4, 2, 0, 22, NULL, NULL }, // wordlen = 2
+ { 1, 2, 3, 1, 2, NULL, NULL }, // wordlen = 3
+ { 1, 2, 4, 1, 31, NULL, NULL }, // wordlen = 4
+ { 2, 2, 4, 1, 60, NULL, NULL }, // wordlen = 5
+ { 2, 2, 4, 0, -1, huff_b26_cb, huff_b26_xlat }, // wordlen = 6
+ { 4, 1, 6, 1, 6, NULL, NULL }, // wordlen = 7
+
+ /* code table = 3 */
+ { 1, 4, 2, 1, 35, NULL, NULL }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_b32_cb, huff_b32_xlat }, // wordlen = 2
+ { 1, 4, 2, 0, -1, huff_b33_cb, huff_b33_xlat }, // wordlen = 3
+ { 2, 2, 4, 1, 59, NULL, NULL }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_b35_cb, huff_b35_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, 75, NULL, NULL }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_b37_cb, huff_b37_xlat }, // wordlen = 7
+
+ /* code table = 4 */
+ { 1, 4, 2, 1, -1, huff_b41_cb, huff_b41_xlat }, // wordlen = 1
+ { 4, 2, 3, 1, -1, huff_b42_cb, huff_b42_xlat }, // wordlen = 2
+ { 1, 2, 3, 1, -1, huff_b43_cb, huff_b43_xlat }, // wordlen = 3
+ { 4, 2, 4, 1, 66, NULL, NULL }, // wordlen = 4
+ { 1, 1, 3, 0, 32, NULL, NULL }, // wordlen = 5
+ { 1, 2, 4, 0, 12, NULL, NULL }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_b47_cb, huff_b47_xlat }, // wordlen = 7
+
+ /* code table = 5 */
+ { 2, 4, 2, 1, 42, NULL, NULL }, // wordlen = 1
+ { 1, 2, 3, 1, -1, huff_b52_cb, huff_b52_xlat }, // wordlen = 2
+ { 4, 1, 3, 1, -1, huff_b53_cb, huff_b53_xlat }, // wordlen = 3
+ { 1, 1, 3, 0, 17, NULL, NULL }, // wordlen = 4
+ { 1, 1, 3, 0, 39, NULL, NULL }, // wordlen = 5
+ { 1, 1, 5, 1, -1, huff_b56_cb, huff_b56_xlat }, // wordlen = 6
+ { 2, 1, 6, 1, 62, NULL, NULL }, // wordlen = 7
+
+ /* code table = 6 */
+ { 1, 4, 2, 1, 28, NULL, NULL }, // wordlen = 1
+ { 1, 4, 2, 0, -1, huff_b62_cb, huff_b62_xlat }, // wordlen = 2
+ { 1, 1, 3, 1, -1, huff_b63_cb, huff_b63_xlat }, // wordlen = 3
+ { 1, 1, 3, 0, -1, huff_b64_cb, huff_b64_xlat }, // wordlen = 4
+ { 4, 2, 4, 1, -1, huff_b65_cb, huff_b65_xlat }, // wordlen = 5
+ { 1, 2, 4, 0, -1, huff_b66_cb, huff_b66_xlat }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_b67_cb, huff_b67_xlat }, // wordlen = 7
+
+ /* code table = 7 */
+ { 1, 4, 2, 1, -1, huff_b71_cb, huff_b71_xlat }, // wordlen = 1
+ { 4, 4, 2, 0, 78, NULL, NULL }, // wordlen = 2
+ { 4, 4, 2, 0, -1, huff_b73_cb, huff_b73_xlat }, // wordlen = 3
+ { 1, 1, 4, 1, -1, huff_b74_cb, huff_b74_xlat }, // wordlen = 4
+ { 1, 2, 4, 1, -1, huff_b75_cb, huff_b75_xlat }, // wordlen = 5
+ { 1, 1, 5, 1, 47, NULL, NULL }, // wordlen = 6
+ { 1, 1, 6, 1, -1, huff_b77_cb, huff_b77_xlat }, // wordlen = 7
+};
+
+/* Huffman tables for gain control data. */
+static const uint8_t atrac3p_huff_gain_npoints1_cb[9] = {
+ 1, 7, 1, 1, 1, 1, 1, 1, 2
+};
+
+static const uint8_t atrac3p_huff_gain_npoints2_xlat[8] = {
+ 0, 1, 7, 2, 6, 3, 4, 5
+};
+
+static const uint8_t atrac3p_huff_gain_lev1_cb[9] = { 1, 7, 1, 0, 2, 2, 1, 2, 8 };
+static const uint8_t atrac3p_huff_gain_lev1_xlat[16] = {
+ 7, 5, 8, 6, 9, 4, 10, 11, 0, 1, 2, 3, 12, 13, 14, 15
+};
+
+static const uint8_t atrac3p_huff_gain_lev2_cb[11] = {
+ 1, 9, 1, 1, 1, 1, 1, 0, 2, 0, 8
+};
+
+static const uint8_t atrac3p_huff_gain_lev2_xlat[15] = {
+ 15, 14, 1, 13, 2, 3, 12, 4, 5, 6, 7, 8, 9, 10, 11
+};
+
+static const uint8_t atrac3p_huff_gain_lev3_cb[11] = {
+ 1, 9, 1, 0, 3, 1, 1, 0, 2, 0, 8
+};
+
+static const uint8_t atrac3p_huff_gain_lev3_xlat[16] = {
+ 0, 1, 14, 15, 2, 13, 3, 12, 4, 5, 6, 7, 8, 9, 10, 11
+};
+
+static const uint8_t atrac3p_huff_gain_lev4_cb[11] = {
+ 1, 9, 1, 1, 1, 1, 1, 0, 1, 2, 8
+};
+
+static const uint8_t atrac3p_huff_gain_lev4_xlat[16] = {
+ 0, 1, 15, 14, 2, 13, 3, 12, 4, 5, 6, 7, 8, 9, 10, 11
+};
+
+static const uint8_t atrac3p_huff_gain_loc1_cb[9] = { 2, 8, 1, 2, 4, 4, 4, 0, 16 };
+static const uint8_t atrac3p_huff_gain_loc1_xlat[31] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
+};
+
+static const uint8_t atrac3p_huff_gain_loc2_cb[8] = { 3, 8, 5, 3, 2, 3, 2, 16 };
+static const uint8_t atrac3p_huff_gain_loc2_xlat[31] = {
+ 2, 3, 4, 5, 6, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
+};
+
+static const uint8_t atrac3p_huff_gain_loc3_cb[7] = { 2, 6, 1, 0, 2, 11, 18 };
+static const uint8_t atrac3p_huff_gain_loc3_xlat[32] = {
+ 0, 1, 31, 2, 3, 4, 5, 6, 7, 26, 27, 28, 29, 30, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
+};
+
+static const uint8_t atrac3p_huff_gain_loc4_cb[5] = { 4, 6, 3, 23, 6 };
+static const uint8_t atrac3p_huff_gain_loc4_xlat[32] = {
+ 0, 28, 29, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 5, 6, 7, 8, 9, 10
+};
+
+static const uint8_t atrac3p_huff_gain_loc5_cb[9] = { 1, 7, 1, 0, 0, 3, 2, 6, 20 };
+static const uint8_t atrac3p_huff_gain_loc5_xlat[32] = {
+ 0, 1, 2, 31, 3, 4, 5, 6, 7, 8, 29, 30, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
+};
+
+/* Huffman tables for GHA waves data. */
+static const uint8_t atrac3p_huff_tonebands_cb[8] = { 1, 6, 1, 0, 1, 2, 4, 8 };
+static const uint8_t atrac3p_huff_numwavs1_cb[9] = { 1, 7, 1, 1, 1, 1, 1, 1, 2 };
+static const uint8_t atrac3p_huff_numwavs2_cb[8] = { 1, 6, 1, 1, 1, 1, 0, 4 };
+static const uint8_t atrac3p_huff_numwavs2_xlat[8] = { 0, 1, 7, 2, 3, 4, 5, 6 };
+static const uint8_t atrac3p_huff_wav_ampsf1_cb[7] = { 4, 8, 10, 8, 6, 0, 8 };
+static const uint8_t atrac3p_huff_wav_ampsf1_xlat[32] = {
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 18, 19, 20,
+ 21, 22, 4, 23, 24, 25, 26, 27, 0, 1, 2, 3, 28, 29, 30, 31
+};
+
+static const uint8_t atrac3p_huff_wav_ampsf2_cb[7] = { 4, 8, 11, 5, 6, 6, 4 };
+static const uint8_t atrac3p_huff_wav_ampsf2_xlat[32] = {
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 14, 15, 16, 17, 29,
+ 9, 10, 11, 12, 13, 30, 4, 5, 6, 7, 8, 31, 0, 1, 2, 3
+};
+
+static const uint8_t atrac3p_huff_wav_ampsf3_cb[9] = { 2, 8, 1, 3, 3, 1, 4, 4, 16 };
+static const uint8_t atrac3p_huff_wav_ampsf3_xlat[32] = {
+ 0, 1, 2, 31, 3, 29, 30, 4, 5, 6, 27, 28, 7, 24, 25, 26,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
+};
+
+static const uint8_t atrac3p_huff_freq_cb[13] = {
+ 1, 11, 1, 0, 0, 2, 2, 0, 9, 9, 29, 104, 100
+};
+
+static const uint8_t atrac3p_huff_freq_xlat[256] = {
+ 0, 1, 255, 2, 254, 3, 4, 5, 6, 7, 8, 251, 252, 253, 9, 10,
+ 11, 12, 246, 247, 248, 249, 250, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+ 38, 243, 244, 245, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
+ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 194, 195, 196, 197, 198,
+ 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
+ 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
+ 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 94, 95, 96, 97,
+ 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+ 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
+ 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
+ 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
+ 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+ 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193
+};
+
+#endif /* AVCODEC_ATRAC3PLUS_DATA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac3plusdec.c b/chromium/third_party/ffmpeg/libavcodec/atrac3plusdec.c
new file mode 100644
index 00000000000..652bd7890da
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac3plusdec.c
@@ -0,0 +1,396 @@
+/*
+ * ATRAC3+ compatible decoder
+ *
+ * Copyright (c) 2010-2013 Maxim Poliakovski
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Sony ATRAC3+ compatible decoder.
+ *
+ * Container formats used to store its data:
+ * RIFF WAV (.at3) and Sony OpenMG (.oma, .aa3).
+ *
+ * Technical description of this codec can be found here:
+ * http://wiki.multimedia.cx/index.php?title=ATRAC3plus
+ *
+ * Kudos to Benjamin Larsson and Michael Karcher
+ * for their precious technical help!
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/float_dsp.h"
+#include "avcodec.h"
+#include "get_bits.h"
+#include "internal.h"
+#include "atrac.h"
+#include "atrac3plus.h"
+
+typedef struct ATRAC3PContext {
+ GetBitContext gb;
+ AVFloatDSPContext fdsp;
+
+ DECLARE_ALIGNED(32, float, samples)[2][ATRAC3P_FRAME_SAMPLES]; ///< quantized MDCT spectrum
+ DECLARE_ALIGNED(32, float, mdct_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< output of the IMDCT
+ DECLARE_ALIGNED(32, float, time_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< output of the gain compensation
+ DECLARE_ALIGNED(32, float, outp_buf)[2][ATRAC3P_FRAME_SAMPLES];
+
+ AtracGCContext gainc_ctx; ///< gain compensation context
+ FFTContext mdct_ctx;
+ FFTContext ipqf_dct_ctx; ///< IDCT context used by IPQF
+
+ Atrac3pChanUnitCtx *ch_units; ///< global channel units
+
+ int num_channel_blocks; ///< number of channel blocks
+ uint8_t channel_blocks[5]; ///< channel configuration descriptor
+ uint64_t my_channel_layout; ///< current channel layout
+} ATRAC3PContext;
+
+static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
+{
+ av_free(((ATRAC3PContext *)(avctx->priv_data))->ch_units);
+
+ return 0;
+}
+
+static av_cold int set_channel_params(ATRAC3PContext *ctx,
+ AVCodecContext *avctx)
+{
+ memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks));
+
+ switch (avctx->channels) {
+ case 1:
+ if (avctx->channel_layout != AV_CH_FRONT_LEFT)
+ avctx->channel_layout = AV_CH_LAYOUT_MONO;
+
+ ctx->num_channel_blocks = 1;
+ ctx->channel_blocks[0] = CH_UNIT_MONO;
+ break;
+ case 2:
+ avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+ ctx->num_channel_blocks = 1;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ break;
+ case 3:
+ avctx->channel_layout = AV_CH_LAYOUT_SURROUND;
+ ctx->num_channel_blocks = 2;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ ctx->channel_blocks[1] = CH_UNIT_MONO;
+ break;
+ case 4:
+ avctx->channel_layout = AV_CH_LAYOUT_4POINT0;
+ ctx->num_channel_blocks = 3;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ ctx->channel_blocks[1] = CH_UNIT_MONO;
+ ctx->channel_blocks[2] = CH_UNIT_MONO;
+ break;
+ case 6:
+ avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
+ ctx->num_channel_blocks = 4;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ ctx->channel_blocks[1] = CH_UNIT_MONO;
+ ctx->channel_blocks[2] = CH_UNIT_STEREO;
+ ctx->channel_blocks[3] = CH_UNIT_MONO;
+ break;
+ case 7:
+ avctx->channel_layout = AV_CH_LAYOUT_6POINT1_BACK;
+ ctx->num_channel_blocks = 5;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ ctx->channel_blocks[1] = CH_UNIT_MONO;
+ ctx->channel_blocks[2] = CH_UNIT_STEREO;
+ ctx->channel_blocks[3] = CH_UNIT_MONO;
+ ctx->channel_blocks[4] = CH_UNIT_MONO;
+ break;
+ case 8:
+ avctx->channel_layout = AV_CH_LAYOUT_7POINT1;
+ ctx->num_channel_blocks = 5;
+ ctx->channel_blocks[0] = CH_UNIT_STEREO;
+ ctx->channel_blocks[1] = CH_UNIT_MONO;
+ ctx->channel_blocks[2] = CH_UNIT_STEREO;
+ ctx->channel_blocks[3] = CH_UNIT_STEREO;
+ ctx->channel_blocks[4] = CH_UNIT_MONO;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported channel count: %d!\n", avctx->channels);
+ return AVERROR_INVALIDDATA;
+ }
+
+ return 0;
+}
+
+static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
+{
+ ATRAC3PContext *ctx = avctx->priv_data;
+ int i, ch, ret;
+
+ if (!avctx->block_align) {
+ av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
+ return AVERROR(EINVAL);
+ }
+
+ ff_atrac3p_init_vlcs();
+
+ avpriv_float_dsp_init(&ctx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
+
+ /* initialize IPQF */
+ ff_mdct_init(&ctx->ipqf_dct_ctx, 5, 1, 32.0 / 32768.0);
+
+ ff_atrac3p_init_imdct(avctx, &ctx->mdct_ctx);
+
+ ff_atrac_init_gain_compensation(&ctx->gainc_ctx, 6, 2);
+
+ ff_atrac3p_init_wave_synth();
+
+ if ((ret = set_channel_params(ctx, avctx)) < 0)
+ return ret;
+
+ ctx->my_channel_layout = avctx->channel_layout;
+
+ ctx->ch_units = av_mallocz(sizeof(*ctx->ch_units) *
+ ctx->num_channel_blocks);
+ if (!ctx->ch_units) {
+ atrac3p_decode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
+ for (i = 0; i < ctx->num_channel_blocks; i++) {
+ for (ch = 0; ch < 2; ch++) {
+ ctx->ch_units[i].channels[ch].ch_num = ch;
+ ctx->ch_units[i].channels[ch].wnd_shape = &ctx->ch_units[i].channels[ch].wnd_shape_hist[0][0];
+ ctx->ch_units[i].channels[ch].wnd_shape_prev = &ctx->ch_units[i].channels[ch].wnd_shape_hist[1][0];
+ ctx->ch_units[i].channels[ch].gain_data = &ctx->ch_units[i].channels[ch].gain_data_hist[0][0];
+ ctx->ch_units[i].channels[ch].gain_data_prev = &ctx->ch_units[i].channels[ch].gain_data_hist[1][0];
+ ctx->ch_units[i].channels[ch].tones_info = &ctx->ch_units[i].channels[ch].tones_info_hist[0][0];
+ ctx->ch_units[i].channels[ch].tones_info_prev = &ctx->ch_units[i].channels[ch].tones_info_hist[1][0];
+ }
+
+ ctx->ch_units[i].waves_info = &ctx->ch_units[i].wave_synth_hist[0];
+ ctx->ch_units[i].waves_info_prev = &ctx->ch_units[i].wave_synth_hist[1];
+ }
+
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
+ return 0;
+}
+
+static void decode_residual_spectrum(Atrac3pChanUnitCtx *ctx,
+ float out[2][ATRAC3P_FRAME_SAMPLES],
+ int num_channels,
+ AVCodecContext *avctx)
+{
+ int i, sb, ch, qu, nspeclines, RNG_index;
+ float *dst, q;
+ int16_t *src;
+ /* calculate RNG table index for each subband */
+ int sb_RNG_index[ATRAC3P_SUBBANDS] = { 0 };
+
+ if (ctx->mute_flag) {
+ for (ch = 0; ch < num_channels; ch++)
+ memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch]));
+ return;
+ }
+
+ for (qu = 0, RNG_index = 0; qu < ctx->used_quant_units; qu++)
+ RNG_index += ctx->channels[0].qu_sf_idx[qu] +
+ ctx->channels[1].qu_sf_idx[qu];
+
+ for (sb = 0; sb < ctx->num_coded_subbands; sb++, RNG_index += 128)
+ sb_RNG_index[sb] = RNG_index & 0x3FC;
+
+ /* inverse quant and power compensation */
+ for (ch = 0; ch < num_channels; ch++) {
+ /* clear channel's residual spectrum */
+ memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch]));
+
+ for (qu = 0; qu < ctx->used_quant_units; qu++) {
+ src = &ctx->channels[ch].spectrum[ff_atrac3p_qu_to_spec_pos[qu]];
+ dst = &out[ch][ff_atrac3p_qu_to_spec_pos[qu]];
+ nspeclines = ff_atrac3p_qu_to_spec_pos[qu + 1] -
+ ff_atrac3p_qu_to_spec_pos[qu];
+
+ if (ctx->channels[ch].qu_wordlen[qu] > 0) {
+ q = ff_atrac3p_sf_tab[ctx->channels[ch].qu_sf_idx[qu]] *
+ ff_atrac3p_mant_tab[ctx->channels[ch].qu_wordlen[qu]];
+ for (i = 0; i < nspeclines; i++)
+ dst[i] = src[i] * q;
+ }
+ }
+
+ for (sb = 0; sb < ctx->num_coded_subbands; sb++)
+ ff_atrac3p_power_compensation(ctx, ch, &out[ch][0],
+ sb_RNG_index[sb], sb);
+ }
+
+ if (ctx->unit_type == CH_UNIT_STEREO) {
+ for (sb = 0; sb < ctx->num_coded_subbands; sb++) {
+ if (ctx->swap_channels[sb]) {
+ for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++)
+ FFSWAP(float, out[0][sb * ATRAC3P_SUBBAND_SAMPLES + i],
+ out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]);
+ }
+
+ /* flip coefficients' sign if requested */
+ if (ctx->negate_coeffs[sb])
+ for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++)
+ out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i] = -(out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]);
+ }
+ }
+}
+
+static void reconstruct_frame(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
+ int num_channels, AVCodecContext *avctx)
+{
+ int ch, sb;
+
+ for (ch = 0; ch < num_channels; ch++) {
+ for (sb = 0; sb < ch_unit->num_subbands; sb++) {
+ /* inverse transform and windowing */
+ ff_atrac3p_imdct(&ctx->fdsp, &ctx->mdct_ctx,
+ &ctx->samples[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
+ &ctx->mdct_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
+ (ch_unit->channels[ch].wnd_shape_prev[sb] << 1) +
+ ch_unit->channels[ch].wnd_shape[sb], sb);
+
+ /* gain compensation and overlapping */
+ ff_atrac_gain_compensation(&ctx->gainc_ctx,
+ &ctx->mdct_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
+ &ch_unit->prev_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
+ &ch_unit->channels[ch].gain_data_prev[sb],
+ &ch_unit->channels[ch].gain_data[sb],
+ ATRAC3P_SUBBAND_SAMPLES,
+ &ctx->time_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES]);
+ }
+
+ /* zero unused subbands in both output and overlapping buffers */
+ memset(&ch_unit->prev_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES],
+ 0,
+ (ATRAC3P_SUBBANDS - ch_unit->num_subbands) *
+ ATRAC3P_SUBBAND_SAMPLES *
+ sizeof(ch_unit->prev_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES]));
+ memset(&ctx->time_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES],
+ 0,
+ (ATRAC3P_SUBBANDS - ch_unit->num_subbands) *
+ ATRAC3P_SUBBAND_SAMPLES *
+ sizeof(ctx->time_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES]));
+
+ /* resynthesize and add tonal signal */
+ if (ch_unit->waves_info->tones_present ||
+ ch_unit->waves_info_prev->tones_present) {
+ for (sb = 0; sb < ch_unit->num_subbands; sb++)
+ if (ch_unit->channels[ch].tones_info[sb].num_wavs ||
+ ch_unit->channels[ch].tones_info_prev[sb].num_wavs) {
+ ff_atrac3p_generate_tones(ch_unit, &ctx->fdsp, ch, sb,
+ &ctx->time_buf[ch][sb * 128]);
+ }
+ }
+
+ /* subband synthesis and acoustic signal output */
+ ff_atrac3p_ipqf(&ctx->ipqf_dct_ctx, &ch_unit->ipqf_ctx[ch],
+ &ctx->time_buf[ch][0], &ctx->outp_buf[ch][0]);
+ }
+
+ /* swap window shape and gain control buffers. */
+ for (ch = 0; ch < num_channels; ch++) {
+ FFSWAP(uint8_t *, ch_unit->channels[ch].wnd_shape,
+ ch_unit->channels[ch].wnd_shape_prev);
+ FFSWAP(AtracGainInfo *, ch_unit->channels[ch].gain_data,
+ ch_unit->channels[ch].gain_data_prev);
+ FFSWAP(Atrac3pWavesData *, ch_unit->channels[ch].tones_info,
+ ch_unit->channels[ch].tones_info_prev);
+ }
+
+ FFSWAP(Atrac3pWaveSynthParams *, ch_unit->waves_info, ch_unit->waves_info_prev);
+}
+
+static int atrac3p_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
+{
+ ATRAC3PContext *ctx = avctx->priv_data;
+ AVFrame *frame = data;
+ int i, ret, ch_unit_id, ch_block = 0, out_ch_index = 0, channels_to_process;
+ float **samples_p = (float **)frame->extended_data;
+
+ frame->nb_samples = ATRAC3P_FRAME_SAMPLES;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+
+ if ((ret = init_get_bits8(&ctx->gb, avpkt->data, avpkt->size)) < 0)
+ return ret;
+
+ if (get_bits1(&ctx->gb)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid start bit!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ while (get_bits_left(&ctx->gb) >= 2 &&
+ (ch_unit_id = get_bits(&ctx->gb, 2)) != CH_UNIT_TERMINATOR) {
+ if (ch_unit_id == CH_UNIT_EXTENSION) {
+ avpriv_report_missing_feature(avctx, "Channel unit extension");
+ return AVERROR_PATCHWELCOME;
+ }
+ if (ch_block >= ctx->num_channel_blocks ||
+ ctx->channel_blocks[ch_block] != ch_unit_id) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Frame data doesn't match channel configuration!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ ctx->ch_units[ch_block].unit_type = ch_unit_id;
+ channels_to_process = ch_unit_id + 1;
+
+ if ((ret = ff_atrac3p_decode_channel_unit(&ctx->gb,
+ &ctx->ch_units[ch_block],
+ channels_to_process,
+ avctx)) < 0)
+ return ret;
+
+ decode_residual_spectrum(&ctx->ch_units[ch_block], ctx->samples,
+ channels_to_process, avctx);
+ reconstruct_frame(ctx, &ctx->ch_units[ch_block],
+ channels_to_process, avctx);
+
+ for (i = 0; i < channels_to_process; i++)
+ memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i],
+ ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p));
+
+ ch_block++;
+ out_ch_index += channels_to_process;
+ }
+
+ *got_frame_ptr = 1;
+
+ return avctx->block_align;
+}
+
+AVCodec ff_atrac3p_decoder = {
+ .name = "atrac3plus",
+ .long_name = NULL_IF_CONFIG_SMALL("ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_ATRAC3P,
+ .priv_data_size = sizeof(ATRAC3PContext),
+ .init = atrac3p_decode_init,
+ .close = atrac3p_decode_close,
+ .decode = atrac3p_decode_frame,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/atrac3plusdsp.c b/chromium/third_party/ffmpeg/libavcodec/atrac3plusdsp.c
new file mode 100644
index 00000000000..3522af1e5ac
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/atrac3plusdsp.c
@@ -0,0 +1,638 @@
+/*
+ * ATRAC3+ compatible decoder
+ *
+ * Copyright (c) 2010-2013 Maxim Poliakovski
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * DSP functions for ATRAC3+ decoder.
+ */
+
+#include <math.h>
+
+#include "libavutil/float_dsp.h"
+#include "avcodec.h"
+#include "sinewin.h"
+#include "fft.h"
+#include "atrac3plus.h"
+
+/**
+ * Map quant unit number to its position in the spectrum.
+ * To get the number of spectral lines in each quant unit do the following:
+ * num_specs = qu_to_spec_pos[i+1] - qu_to_spec_pos[i]
+ */
+const uint16_t ff_atrac3p_qu_to_spec_pos[33] = {
+ 0, 16, 32, 48, 64, 80, 96, 112,
+ 128, 160, 192, 224, 256, 288, 320, 352,
+ 384, 448, 512, 576, 640, 704, 768, 896,
+ 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920,
+ 2048
+};
+
+/* Scalefactors table. */
+/* Approx. Equ: pow(2.0, (i - 16.0 + 0.501783948) / 3.0) */
+const float ff_atrac3p_sf_tab[64] = {
+ 0.027852058, 0.0350914, 0.044212341, 0.055704117, 0.0701828,
+ 0.088424683, 0.11140823, 0.1403656, 0.17684937, 0.22281647, 0.2807312, 0.35369873,
+ 0.44563293, 0.5614624, 0.70739746, 0.89126587, 1.1229248, 1.4147949, 1.7825317,
+ 2.2458496, 2.8295898, 3.5650635, 4.4916992, 5.6591797, 7.130127, 8.9833984,
+ 11.318359, 14.260254, 17.966797, 22.636719, 28.520508, 35.933594, 45.273438,
+ 57.041016, 71.867188, 90.546875, 114.08203, 143.73438, 181.09375, 228.16406,
+ 287.46875, 362.1875, 456.32812, 574.9375, 724.375, 912.65625, 1149.875,
+ 1448.75, 1825.3125, 2299.75, 2897.5, 3650.625, 4599.5, 5795.0,
+ 7301.25, 9199.0, 11590.0, 14602.5, 18398.0, 23180.0, 29205.0,
+ 36796.0, 46360.0, 58410.0
+};
+
+/* Mantissa table. */
+/* pow(10, x * log10(2) + 0.05) / 2 / ([1,2,3,5,7,15,31] + 0.5) */
+const float ff_atrac3p_mant_tab[8] = {
+ 0.0,
+ 0.74801636,
+ 0.44882202,
+ 0.32058716,
+ 0.20400238,
+ 0.1496048,
+ 0.07239151,
+ 0.035619736
+};
+
+#define ATRAC3P_MDCT_SIZE (ATRAC3P_SUBBAND_SAMPLES * 2)
+
+av_cold void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx)
+{
+ ff_init_ff_sine_windows(7);
+ ff_init_ff_sine_windows(6);
+
+ /* Initialize the MDCT transform. */
+ ff_mdct_init(mdct_ctx, 8, 1, -1.0);
+}
+
+#define TWOPI (2 * M_PI)
+
+#define DEQUANT_PHASE(ph) (((ph) & 0x1F) << 6)
+
+static DECLARE_ALIGNED(32, float, sine_table)[2048]; ///< wave table
+static DECLARE_ALIGNED(32, float, hann_window)[256]; ///< Hann windowing function
+static float amp_sf_tab[64]; ///< scalefactors for quantized amplitudes
+
+av_cold void ff_atrac3p_init_wave_synth(void)
+{
+ int i;
+
+ /* generate sine wave table */
+ for (i = 0; i < 2048; i++)
+ sine_table[i] = sin(TWOPI * i / 2048);
+
+ /* generate Hann window */
+ for (i = 0; i < 256; i++)
+ hann_window[i] = (1.0f - cos(TWOPI * i / 256.0f)) * 0.5f;
+
+ /* generate amplitude scalefactors table */
+ for (i = 0; i < 64; i++)
+ amp_sf_tab[i] = pow(2.0f, ((double)i - 3) / 4.0f);
+}
+
+/**
+ * Synthesize sine waves according to given parameters.
+ *
+ * @param[in] synth_param ptr to common synthesis parameters
+ * @param[in] waves_info parameters for each sine wave
+ * @param[in] envelope envelope data for all waves in a group
+ * @param[in] phase_shift flag indicates 180° phase shift
+ * @param[in] reg_offset region offset for trimming envelope data
+ * @param[out] out receives sythesized data
+ */
+static void waves_synth(Atrac3pWaveSynthParams *synth_param,
+ Atrac3pWavesData *waves_info,
+ Atrac3pWaveEnvelope *envelope,
+ int phase_shift, int reg_offset, float *out)
+{
+ int i, wn, inc, pos;
+ double amp;
+ Atrac3pWaveParam *wave_param = &synth_param->waves[waves_info->start_index];
+
+ for (wn = 0; wn < waves_info->num_wavs; wn++, wave_param++) {
+ /* amplitude dequantization */
+ amp = amp_sf_tab[wave_param->amp_sf] *
+ (!synth_param->amplitude_mode
+ ? (wave_param->amp_index + 1) / 15.13f
+ : 1.0f);
+
+ inc = wave_param->freq_index;
+ pos = DEQUANT_PHASE(wave_param->phase_index) - (reg_offset ^ 128) * inc & 2047;
+
+ /* waveform generation */
+ for (i = 0; i < 128; i++) {
+ out[i] += sine_table[pos] * amp;
+ pos = (pos + inc) & 2047;
+ }
+ }
+
+ /* fade in with steep Hann window if requested */
+ if (envelope->has_start_point) {
+ pos = (envelope->start_pos << 2) - reg_offset;
+ if (pos > 0 && pos <= 128) {
+ memset(out, 0, pos * sizeof(*out));
+ if (!envelope->has_stop_point ||
+ envelope->start_pos != envelope->stop_pos) {
+ out[pos + 0] *= hann_window[0];
+ out[pos + 1] *= hann_window[32];
+ out[pos + 2] *= hann_window[64];
+ out[pos + 3] *= hann_window[96];
+ }
+ }
+ }
+
+ /* fade out with steep Hann window if requested */
+ if (envelope->has_stop_point) {
+ pos = (envelope->stop_pos + 1 << 2) - reg_offset;
+ if (pos > 0 && pos <= 128) {
+ out[pos - 4] *= hann_window[96];
+ out[pos - 3] *= hann_window[64];
+ out[pos - 2] *= hann_window[32];
+ out[pos - 1] *= hann_window[0];
+ memset(&out[pos], 0, (128 - pos) * sizeof(out[pos]));
+ }
+ }
+}
+
+void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *fdsp,
+ int ch_num, int sb, float *out)
+{
+ DECLARE_ALIGNED(32, float, wavreg1)[128] = { 0 };
+ DECLARE_ALIGNED(32, float, wavreg2)[128] = { 0 };
+ int i, reg1_env_nonzero, reg2_env_nonzero;
+ Atrac3pWavesData *tones_now = &ch_unit->channels[ch_num].tones_info_prev[sb];
+ Atrac3pWavesData *tones_next = &ch_unit->channels[ch_num].tones_info[sb];
+
+ /* reconstruct full envelopes for both overlapping regions
+ * from truncated bitstream data */
+ if (tones_next->pend_env.has_start_point &&
+ tones_next->pend_env.start_pos < tones_next->pend_env.stop_pos) {
+ tones_next->curr_env.has_start_point = 1;
+ tones_next->curr_env.start_pos = tones_next->pend_env.start_pos + 32;
+ } else if (tones_now->pend_env.has_start_point) {
+ tones_next->curr_env.has_start_point = 1;
+ tones_next->curr_env.start_pos = tones_now->pend_env.start_pos;
+ } else {
+ tones_next->curr_env.has_start_point = 0;
+ tones_next->curr_env.start_pos = 0;
+ }
+
+ if (tones_now->pend_env.has_stop_point &&
+ tones_now->pend_env.stop_pos >= tones_next->curr_env.start_pos) {
+ tones_next->curr_env.has_stop_point = 1;
+ tones_next->curr_env.stop_pos = tones_now->pend_env.stop_pos;
+ } else if (tones_next->pend_env.has_stop_point) {
+ tones_next->curr_env.has_stop_point = 1;
+ tones_next->curr_env.stop_pos = tones_next->pend_env.stop_pos + 32;
+ } else {
+ tones_next->curr_env.has_stop_point = 0;
+ tones_next->curr_env.stop_pos = 64;
+ }
+
+ /* is the visible part of the envelope non-zero? */
+ reg1_env_nonzero = (tones_now->curr_env.stop_pos < 32) ? 0 : 1;
+ reg2_env_nonzero = (tones_next->curr_env.start_pos >= 32) ? 0 : 1;
+
+ /* synthesize waves for both overlapping regions */
+ if (tones_now->num_wavs && reg1_env_nonzero)
+ waves_synth(ch_unit->waves_info_prev, tones_now, &tones_now->curr_env,
+ ch_unit->waves_info_prev->phase_shift[sb] & ch_num,
+ 128, wavreg1);
+
+ if (tones_next->num_wavs && reg2_env_nonzero)
+ waves_synth(ch_unit->waves_info, tones_next, &tones_next->curr_env,
+ ch_unit->waves_info->phase_shift[sb] & ch_num, 0, wavreg2);
+
+ /* Hann windowing for non-faded wave signals */
+ if (tones_now->num_wavs && tones_next->num_wavs &&
+ reg1_env_nonzero && reg2_env_nonzero) {
+ fdsp->vector_fmul(wavreg1, wavreg1, &hann_window[128], 128);
+ fdsp->vector_fmul(wavreg2, wavreg2, hann_window, 128);
+ } else {
+ if (tones_now->num_wavs && !tones_now->curr_env.has_stop_point)
+ fdsp->vector_fmul(wavreg1, wavreg1, &hann_window[128], 128);
+
+ if (tones_next->num_wavs && !tones_next->curr_env.has_start_point)
+ fdsp->vector_fmul(wavreg2, wavreg2, hann_window, 128);
+ }
+
+ /* Overlap and add to residual */
+ for (i = 0; i < 128; i++)
+ out[i] += wavreg1[i] + wavreg2[i];
+}
+
+static const int subband_to_powgrp[ATRAC3P_SUBBANDS] = {
+ 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4
+};
+
+/* noise table for power compensation */
+static const float noise_tab[1024] = {
+ -0.01358032, -0.05593872, 0.01696777, -0.14871216, -0.26412964, -0.09893799, 0.25723267,
+ 0.02008057, -0.72235107, -0.44351196, -0.22985840, 0.16833496, 0.46902466, 0.05917358,
+ -0.15179443, 0.41299438, -0.01287842, 0.13360596, 0.43557739, -0.09530640, -0.58422852,
+ 0.39266968, -0.08343506, -0.25604248, 0.22848511, 0.26013184, -0.65588379, 0.17288208,
+ -0.08673096, -0.05203247, 0.07299805, -0.28665161, -0.35806274, 0.06552124, -0.09387207,
+ 0.21099854, -0.28347778, -0.72402954, 0.05050659, -0.10635376, -0.18853760, 0.29724121,
+ 0.20703125, -0.29791260, -0.37634277, 0.47970581, -0.09976196, 0.32641602, -0.29248047,
+ -0.28237915, 0.26028442, -0.36157227, 0.22042847, -0.03222656, -0.37268066, -0.03759766,
+ 0.09909058, 0.23284912, 0.19320679, 0.14453125, -0.02139282, -0.19702148, 0.31533813,
+ -0.16741943, 0.35031128, -0.35656738, -0.66128540, -0.00701904, 0.20898438, 0.26837158,
+ -0.33706665, -0.04568481, 0.12600708, 0.10284424, 0.07321167, -0.18280029, 0.38101196,
+ 0.21301270, 0.04541016, 0.01156616, -0.26391602, -0.02346802, -0.22125244, 0.29760742,
+ -0.36233521, -0.31314087, -0.13967896, -0.11276245, -0.19433594, 0.34490967, 0.02343750,
+ 0.21963501, -0.02777100, -0.67678833, -0.08999634, 0.14233398, -0.27697754, 0.51422119,
+ -0.05047607, 0.48327637, 0.37167358, -0.60806274, 0.18728638, -0.15191650, 0.00637817,
+ 0.02832031, -0.15618896, 0.60644531, 0.21826172, 0.06384277, -0.31863403, 0.08816528,
+ 0.15447998, -0.07015991, -0.08154297, -0.40966797, -0.39785767, -0.11709595, 0.22052002,
+ 0.18466187, -0.17257690, 0.03759766, -0.06195068, 0.00433350, 0.12176514, 0.34011841,
+ 0.25610352, -0.05294800, 0.41033936, 0.16854858, -0.76187134, 0.13845825, -0.19418335,
+ -0.21524048, -0.44412231, -0.08160400, -0.28195190, -0.01873779, 0.15524292, -0.37438965,
+ -0.44860840, 0.43096924, -0.24746704, 0.49856567, 0.14859009, 0.38159180, 0.20541382,
+ -0.39175415, -0.65850830, -0.43716431, 0.13037109, -0.05111694, 0.39956665, 0.21447754,
+ -0.04861450, 0.33654785, 0.10589600, -0.88085938, -0.30822754, 0.38577271, 0.30047607,
+ 0.38836670, 0.09118652, -0.36477661, -0.01641846, -0.23031616, 0.26058960, 0.18859863,
+ -0.21868896, -0.17861938, -0.29754639, 0.09777832, 0.10806274, -0.51605225, 0.00076294,
+ 0.13259888, 0.11090088, -0.24084473, 0.24957275, 0.01379395, -0.04141235, -0.04937744,
+ 0.57394409, 0.27410889, 0.27587891, 0.45013428, -0.32592773, 0.11160278, -0.00970459,
+ 0.29092407, 0.03356934, -0.70925903, 0.04882812, 0.43499756, 0.07720947, -0.27554321,
+ -0.01742554, -0.08413696, -0.04028320, -0.52850342, -0.07330322, 0.05181885, 0.21362305,
+ -0.18765259, 0.07058716, -0.03009033, 0.32662964, 0.27023315, -0.28002930, 0.17568970,
+ 0.03338623, 0.30242920, -0.03921509, 0.32174683, -0.23733521, 0.08575439, -0.38269043,
+ 0.09194946, -0.07238770, 0.17941284, -0.51278687, -0.25146484, 0.19790649, -0.19195557,
+ 0.16549683, 0.42456055, 0.39129639, -0.02868652, 0.17980957, 0.24902344, -0.76583862,
+ -0.20959473, 0.61013794, 0.37011719, 0.36859131, -0.04486084, 0.10678101, -0.15994263,
+ -0.05328369, 0.28463745, -0.06420898, -0.36987305, -0.28009033, -0.11764526, 0.04312134,
+ -0.08038330, 0.04885864, -0.03067017, -0.00042725, 0.34289551, -0.00988770, 0.34838867,
+ 0.32516479, -0.16271973, 0.38269043, 0.03240967, 0.12417603, -0.14331055, -0.34902954,
+ -0.18325806, 0.29421997, 0.44284058, 0.75170898, -0.67245483, -0.12176514, 0.27914429,
+ -0.29806519, 0.19863892, 0.30087280, 0.22680664, -0.36633301, -0.32534790, -0.57553101,
+ -0.16641235, 0.43811035, 0.08331299, 0.15942383, 0.26516724, -0.24240112, -0.11761475,
+ -0.16827393, -0.14260864, 0.46343994, 0.11804199, -0.55514526, -0.02520752, -0.14309692,
+ 0.00448608, 0.02749634, -0.30545044, 0.70965576, 0.45108032, 0.66439819, -0.68255615,
+ -0.12496948, 0.09146118, -0.21109009, -0.23791504, 0.79943848, -0.35205078, -0.24963379,
+ 0.18719482, -0.19079590, 0.07458496, 0.07623291, -0.28781128, -0.37121582, -0.19580078,
+ -0.01773071, -0.16717529, 0.13040161, 0.14672852, 0.42379761, 0.03582764, 0.11431885,
+ 0.05145264, 0.44702148, 0.08963013, 0.01367188, -0.54519653, -0.12692261, 0.21176147,
+ 0.04925537, 0.30670166, -0.11029053, 0.19555664, -0.27740479, 0.23043823, 0.15554810,
+ -0.19299316, -0.25729370, 0.17800903, -0.03579712, -0.05065918, -0.06933594, -0.09500122,
+ -0.07821655, 0.23889160, -0.31900024, 0.03073120, -0.00415039, 0.61315918, 0.37176514,
+ -0.13442993, -0.15536499, -0.19216919, -0.37899780, 0.19992065, 0.02630615, -0.12573242,
+ 0.25927734, -0.02447510, 0.29629517, -0.40731812, -0.17333984, 0.24310303, -0.10607910,
+ 0.14828491, 0.08792114, -0.18743896, -0.05572510, -0.04833984, 0.10473633, -0.29028320,
+ -0.67687988, -0.28170776, -0.41687012, 0.05413818, -0.23284912, 0.09555054, -0.08969116,
+ -0.15112305, 0.12738037, 0.35986328, 0.28948975, 0.30691528, 0.23956299, 0.06973267,
+ -0.31198120, -0.18450928, 0.22280884, -0.21600342, 0.23522949, -0.61840820, -0.13012695,
+ 0.26412964, 0.47320557, -0.26440430, 0.38757324, 0.17352295, -0.26104736, -0.25866699,
+ -0.12274170, -0.29733276, 0.07687378, 0.18588257, -0.08880615, 0.31185913, 0.05313110,
+ -0.10885620, -0.14901733, -0.22323608, -0.08538818, 0.19812012, 0.19732666, -0.18927002,
+ 0.29058838, 0.25555420, -0.48599243, 0.18768311, 0.01345825, 0.34887695, 0.21530151,
+ 0.19857788, 0.18661499, -0.01394653, -0.09063721, -0.38781738, 0.27160645, -0.20379639,
+ -0.32119751, -0.23889160, 0.27096558, 0.24951172, 0.07922363, 0.07479858, -0.50946045,
+ 0.10220337, 0.58364868, -0.19503784, -0.18560791, -0.01165771, 0.47195435, 0.22430420,
+ -0.38635254, -0.03732300, -0.09179688, 0.06991577, 0.15106201, 0.20605469, -0.05969238,
+ -0.41821289, 0.12231445, -0.04672241, -0.05117798, -0.11523438, -0.51849365, -0.04077148,
+ 0.44284058, -0.64086914, 0.17019653, 0.02236938, 0.22848511, -0.23214722, -0.32354736,
+ -0.14068604, -0.29690552, -0.19891357, 0.02774048, -0.20965576, -0.52191162, -0.19299316,
+ -0.07290649, 0.49053955, -0.22302246, 0.05642700, 0.13122559, -0.20819092, -0.83590698,
+ -0.08181763, 0.26797485, -0.00091553, -0.09457397, 0.17089844, -0.27020264, 0.30270386,
+ 0.05496216, 0.09564209, -0.08590698, 0.02130127, 0.35931396, 0.21728516, -0.15396118,
+ -0.05053711, 0.02719116, 0.16302490, 0.43212891, 0.10229492, -0.40820312, 0.21646118,
+ 0.08435059, -0.11145020, -0.39962769, -0.05618286, -0.10223389, -0.60839844, 0.33724976,
+ -0.06341553, -0.47369385, -0.32852173, 0.05242920, 0.19635010, -0.19137573, -0.67901611,
+ 0.16180420, 0.05133057, -0.22283936, 0.09646606, 0.24288940, -0.45007324, 0.08804321,
+ 0.14053345, 0.22619629, -0.01000977, 0.36355591, -0.19863892, -0.30364990, -0.24118042,
+ -0.57461548, 0.26498413, 0.04345703, -0.09796143, -0.47714233, -0.23739624, 0.18737793,
+ 0.08926392, -0.02795410, 0.00305176, -0.08700562, -0.38711548, 0.03222656, 0.10940552,
+ -0.41906738, -0.01620483, -0.47061157, 0.37985229, -0.21624756, 0.47976685, -0.20046997,
+ -0.62533569, -0.26907349, -0.02877808, 0.00671387, -0.29071045, -0.24685669, -0.15722656,
+ -0.26055908, 0.29968262, 0.28225708, -0.08990479, -0.16748047, -0.46759033, -0.25067139,
+ -0.25183105, -0.45932007, 0.05828857, 0.29006958, 0.23840332, -0.17974854, 0.26931763,
+ 0.10696411, -0.06848145, -0.17126465, -0.10522461, -0.55386353, -0.42306519, -0.07608032,
+ 0.24380493, 0.38586426, 0.16882324, 0.26751709, 0.17303467, 0.35809326, -0.22094727,
+ -0.30703735, -0.28497314, -0.04321289, 0.15219116, -0.17071533, -0.39334106, 0.03439331,
+ -0.10809326, -0.30590820, 0.26449585, -0.07412720, 0.13638306, -0.01062012, 0.27996826,
+ 0.04397583, -0.05557251, -0.56933594, 0.03363037, -0.00949097, 0.52642822, -0.44329834,
+ 0.28308105, -0.05499268, -0.23312378, -0.29870605, -0.05123901, 0.26831055, -0.35238647,
+ -0.30993652, 0.34646606, -0.19775391, 0.44595337, 0.13769531, 0.45358276, 0.19961548,
+ 0.42681885, 0.15722656, 0.00128174, 0.23757935, 0.40988159, 0.25164795, -0.00732422,
+ -0.12405396, -0.43420410, -0.00402832, 0.34243774, 0.36264038, 0.18807983, -0.09301758,
+ -0.10296631, 0.05532837, -0.31652832, 0.14337158, 0.35040283, 0.32540894, 0.05728149,
+ -0.12030029, -0.25942993, -0.20312500, -0.16491699, -0.46051025, -0.08004761, 0.50772095,
+ 0.16168213, 0.28439331, 0.08105469, -0.19104004, 0.38589478, -0.16400146, -0.25454712,
+ 0.20281982, -0.20730591, -0.06311035, 0.32937622, 0.15032959, -0.05340576, 0.30487061,
+ -0.11648560, 0.38009644, -0.20062256, 0.43466187, 0.01150513, 0.35754395, -0.13146973,
+ 0.67489624, 0.05212402, 0.27914429, -0.39431763, 0.75308228, -0.13366699, 0.24453735,
+ 0.42248535, -0.65905762, -0.00546265, -0.03491211, -0.13659668, -0.08294678, -0.45666504,
+ 0.27188110, 0.12731934, 0.61148071, 0.10449219, -0.28836060, 0.00091553, 0.24618530,
+ 0.13119507, 0.05685425, 0.17355347, 0.42034912, 0.08514404, 0.24536133, 0.18951416,
+ -0.19107056, -0.15036011, 0.02334595, 0.54986572, 0.32321167, -0.16104126, -0.03054810,
+ 0.43594360, 0.17309570, 0.61053467, 0.24731445, 0.33334351, 0.15240479, 0.15588379,
+ 0.36425781, -0.30407715, -0.13302612, 0.00427246, 0.04171753, -0.33178711, 0.34216309,
+ -0.12463379, -0.02764893, 0.05905151, -0.31436157, 0.16531372, 0.34542847, -0.03292847,
+ 0.12527466, -0.12313843, -0.13171387, 0.04757690, -0.45095825, -0.19085693, 0.35342407,
+ -0.23239136, -0.34387207, 0.11264038, -0.15740967, 0.05273438, 0.74942017, 0.21505737,
+ 0.08514404, -0.42391968, -0.19531250, 0.35293579, 0.25305176, 0.15731812, -0.70324707,
+ -0.21591187, 0.35604858, 0.14132690, 0.11724854, 0.15853882, -0.24597168, 0.07019043,
+ 0.02127075, 0.12658691, 0.06390381, -0.12292480, 0.15441895, -0.47640991, 0.06195068,
+ 0.58981323, -0.15151978, -0.03604126, -0.45059204, -0.01672363, -0.46997070, 0.25750732,
+ 0.18084717, 0.06661987, 0.13253784, 0.67828369, 0.11370850, 0.11325073, -0.04611206,
+ -0.07791138, -0.36544800, -0.06747437, -0.31594849, 0.16131592, 0.41983032, 0.11071777,
+ -0.36889648, 0.30963135, -0.37875366, 0.58508301, 0.00393677, 0.12338257, 0.03424072,
+ -0.21728516, -0.12838745, -0.46981812, 0.05868530, -0.25015259, 0.27407837, 0.65240479,
+ -0.34429932, -0.15179443, 0.14056396, 0.33505249, 0.28826904, 0.09921265, 0.34390259,
+ 0.13656616, -0.23608398, 0.00863647, 0.02627563, -0.19119263, 0.19775391, -0.07214355,
+ 0.07809448, 0.03454590, -0.03417969, 0.00033569, -0.23095703, 0.18673706, 0.05798340,
+ 0.03814697, -0.04318237, 0.05487061, 0.08633423, 0.55950928, -0.06347656, 0.10333252,
+ 0.25305176, 0.05853271, 0.12246704, -0.25543213, -0.34262085, -0.36437988, -0.21304321,
+ -0.05093384, 0.02777100, 0.07620239, -0.21215820, -0.09326172, 0.19021606, -0.40579224,
+ -0.01193237, 0.19845581, -0.35336304, -0.07397461, 0.20104980, 0.08615112, -0.44375610,
+ 0.11419678, 0.24453735, -0.16555786, -0.05081177, -0.01406860, 0.27893066, -0.18692017,
+ 0.07473755, 0.03451538, -0.39733887, 0.21548462, -0.22534180, -0.39651489, -0.04989624,
+ -0.57662964, 0.06390381, 0.62020874, -0.13470459, 0.04345703, -0.21862793, -0.02789307,
+ 0.51696777, -0.27587891, 0.39004517, 0.09857178, -0.00738525, 0.31317139, 0.00048828,
+ -0.46572876, 0.29531860, -0.10009766, -0.27856445, 0.03594971, 0.25048828, -0.74584961,
+ -0.25350952, -0.03302002, 0.31188965, 0.01571655, 0.46710205, 0.21591187, 0.07260132,
+ -0.42132568, -0.53900146, -0.13674927, -0.16571045, -0.34454346, 0.12359619, -0.11184692,
+ 0.00967407, 0.34576416, -0.05761719, 0.34848022, 0.17645264, -0.39395142, 0.10339355,
+ 0.18215942, 0.20697021, 0.59109497, -0.11560059, -0.07385254, 0.10397339, 0.35437012,
+ -0.22863770, 0.01794434, 0.17559814, -0.17495728, 0.12142944, 0.10928345, -1.00000000,
+ -0.01379395, 0.21237183, -0.27035522, 0.27319336, -0.37066650, 0.41354370, -0.40054321,
+ 0.00689697, 0.26321411, 0.39266968, 0.65298462, 0.41625977, -0.13909912, 0.78375244,
+ -0.30941772, 0.20169067, -0.39367676, 0.94021606, -0.24066162, 0.05557251, -0.24533081,
+ -0.05444336, -0.76754761, -0.19375610, -0.11041260, -0.17532349, 0.16006470, 0.02188110,
+ 0.17465210, -0.04342651, -0.56777954, -0.40988159, 0.26687622, 0.11700439, -0.00344849,
+ -0.05395508, 0.37426758, -0.40719604, -0.15032959, -0.01660156, 0.04196167, -0.04559326,
+ -0.12969971, 0.12011719, 0.08419800, -0.11199951, 0.35174561, 0.10275269, -0.25686646,
+ 0.48446655, 0.03225708, 0.28408813, -0.18701172, 0.36282349, -0.03280640, 0.32302856,
+ 0.17233276, 0.48269653, 0.31112671, -0.04946899, 0.12774658, 0.52685547, 0.10211182,
+ 0.05953979, 0.05999756, 0.20144653, 0.00744629, 0.27316284, 0.24377441, 0.39672852,
+ 0.01702881, -0.35513306, 0.11364746, -0.13555908, 0.48880005, -0.15417480, -0.09149170,
+ -0.02615356, 0.46246338, -0.72250366, 0.22332764, 0.23849487, -0.25686646, -0.08514404,
+ -0.02062988, -0.34494019, -0.02297974, -0.80386353, -0.08074951, -0.12689209, -0.06896973,
+ 0.24099731, -0.35650635, -0.09558105, 0.29254150, 0.23132324, -0.16726685, 0.00000000,
+ -0.24237061, 0.30899048, 0.29504395, -0.20898438, 0.17059326, -0.07672119, -0.14395142,
+ 0.05572510, 0.20602417, -0.51550293, -0.03167725, -0.48840332, -0.20425415, 0.14144897,
+ 0.07275391, -0.76669312, -0.22488403, 0.20651245, 0.03259277, 0.00085449, 0.03039551,
+ 0.47555542, 0.38351440
+};
+
+/** Noise level table for power compensation.
+ * Equ: pow(2.0f, (double)(6 - i) / 3.0f) where i = 0...15 */
+static const float pwc_levs[16] = {
+ 3.96875, 3.15625, 2.5, 2.0, 1.59375, 1.25, 1.0, 0.78125,
+ 0.625, 0.5, 0.40625, 0.3125, 0.25, 0.1875, 0.15625, 0.0
+};
+
+/** Map subband number to quant unit number. */
+static const int subband_to_qu[17] = {
+ 0, 8, 12, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
+};
+
+void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, int ch_index,
+ float *sp, int rng_index, int sb)
+{
+ AtracGainInfo *g1, *g2;
+ float pwcsp[ATRAC3P_SUBBAND_SAMPLES], *dst, grp_lev, qu_lev;
+ int i, gain_lev, gcv = 0, qu, nsp;
+ int swap_ch = (ctx->unit_type == CH_UNIT_STEREO && ctx->swap_channels[sb]) ? 1 : 0;
+
+ if (ctx->channels[ch_index ^ swap_ch].power_levs[subband_to_powgrp[sb]] == ATRAC3P_POWER_COMP_OFF)
+ return;
+
+ /* generate initial noise spectrum */
+ for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++, rng_index++)
+ pwcsp[i] = noise_tab[rng_index & 0x3FF];
+
+ /* check gain control information */
+ g1 = &ctx->channels[ch_index ^ swap_ch].gain_data[sb];
+ g2 = &ctx->channels[ch_index ^ swap_ch].gain_data_prev[sb];
+
+ gain_lev = (g1->num_points > 0) ? (6 - g1->lev_code[0]) : 0;
+
+ for (i = 0; i < g2->num_points; i++)
+ gcv = FFMAX(gcv, gain_lev - (g2->lev_code[i] - 6));
+
+ for (i = 0; i < g1->num_points; i++)
+ gcv = FFMAX(gcv, 6 - g1->lev_code[i]);
+
+ grp_lev = pwc_levs[ctx->channels[ch_index ^ swap_ch].power_levs[subband_to_powgrp[sb]]] / (1 << gcv);
+
+ /* skip the lowest two quant units (frequencies 0...351 Hz) for subband 0 */
+ for (qu = subband_to_qu[sb] + (!sb ? 2 : 0); qu < subband_to_qu[sb + 1]; qu++) {
+ if (ctx->channels[ch_index].qu_wordlen[qu] <= 0)
+ continue;
+
+ qu_lev = ff_atrac3p_sf_tab[ctx->channels[ch_index].qu_sf_idx[qu]] *
+ ff_atrac3p_mant_tab[ctx->channels[ch_index].qu_wordlen[qu]] /
+ (1 << ctx->channels[ch_index].qu_wordlen[qu]) * grp_lev;
+
+ dst = &sp[ff_atrac3p_qu_to_spec_pos[qu]];
+ nsp = ff_atrac3p_qu_to_spec_pos[qu + 1] - ff_atrac3p_qu_to_spec_pos[qu];
+
+ for (i = 0; i < nsp; i++)
+ dst[i] += pwcsp[i] * qu_lev;
+ }
+}
+
+void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
+ float *pOut, int wind_id, int sb)
+{
+ int i;
+
+ if (sb & 1)
+ for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES / 2; i++)
+ FFSWAP(float, pIn[i], pIn[ATRAC3P_SUBBAND_SAMPLES - 1 - i]);
+
+ mdct_ctx->imdct_calc(mdct_ctx, pOut, pIn);
+
+ /* Perform windowing on the output.
+ * ATRAC3+ uses two different MDCT windows:
+ * - The first one is just the plain sine window of size 256
+ * - The 2nd one is the plain sine window of size 128
+ * wrapped into zero (at the start) and one (at the end) regions.
+ * Both regions are 32 samples long. */
+ if (wind_id & 2) { /* 1st half: steep window */
+ memset(pOut, 0, sizeof(float) * 32);
+ fdsp->vector_fmul(&pOut[32], &pOut[32], ff_sine_64, 64);
+ } else /* 1st half: simple sine window */
+ fdsp->vector_fmul(pOut, pOut, ff_sine_128, ATRAC3P_MDCT_SIZE / 2);
+
+ if (wind_id & 1) { /* 2nd half: steep window */
+ fdsp->vector_fmul_reverse(&pOut[160], &pOut[160], ff_sine_64, 64);
+ memset(&pOut[224], 0, sizeof(float) * 32);
+ } else /* 2nd half: simple sine window */
+ fdsp->vector_fmul_reverse(&pOut[128], &pOut[128], ff_sine_128,
+ ATRAC3P_MDCT_SIZE / 2);
+}
+
+/* lookup table for fast modulo 23 op required for cyclic buffers of the IPQF */
+static const int mod23_lut[26] = {
+ 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0
+};
+
+/* First half of the 384-tap IPQF filtering coefficients. */
+static const float ipqf_coeffs1[ATRAC3P_PQF_FIR_LEN][16] = {
+ { -5.8336207e-7, -8.0604229e-7, -4.2005411e-7, -4.4400572e-8,
+ 3.226247e-8, 3.530856e-8, 1.2660377e-8, 0.000010516783,
+ -0.000011838618, 6.005389e-7, 0.0000014333754, 0.0000023108685,
+ 0.0000032569742, 0.0000046192422, 0.0000063894258, 0.0000070302972 },
+ { -0.0000091622824, -0.000010502935, -0.0000079212787, -0.0000041712024,
+ -0.0000026336629, -0.0000015432918, -5.7168614e-7, 0.0000018111954,
+ 0.000023530851, 0.00002780562, 0.000032302323, 0.000036968919,
+ 0.000041575615, 0.000045337845, 0.000046043948, 0.000048585582 },
+ { -0.000064464548, -0.000068306952, -0.000073081472, -0.00007612785,
+ -0.000074850752, -0.000070208509, -0.000062285151, -0.000058270442,
+ -0.000056296329, -0.000049888811, -0.000035615325, -0.000018532943,
+ 0.0000016657353, 0.00002610587, 0.000053397067, 0.00008079566 },
+ { -0.00054488552, -0.00052537228, -0.00049731287, -0.00045778,
+ -0.00040612387, -0.00034301577, -0.00026866337, -0.00018248901,
+ -0.000084307925, 0.000025081157, 0.00014135583, 0.00026649953,
+ 0.00039945057, 0.00053928449, 0.00068422867, 0.00083093712 },
+ { -0.0014771431, -0.001283227, -0.0010566821, -0.00079780724,
+ -0.00050782406, -0.00018855913, 0.00015771533, 0.00052769453,
+ 0.00091862219, 0.001326357, 0.0017469483, 0.0021754825,
+ 0.0026067684, 0.0030352892, 0.0034549395, 0.0038591374 },
+ { -0.0022995141, -0.001443546, -0.00049266568, 0.00055068987,
+ 0.001682895, 0.0028992873, 0.0041943151, 0.0055614738,
+ 0.0069935122, 0.0084823566, 0.010018963, 0.011593862,
+ 0.013196872, 0.014817309, 0.016444042, 0.018065533 },
+ { -0.034426283, -0.034281436, -0.033992987, -0.033563249,
+ -0.032995768, -0.032295227, -0.031467363, -0.030518902,
+ -0.02945766, -0.028291954, -0.027031265, -0.025685543,
+ -0.024265358, -0.022781773, -0.021246184, -0.019670162 },
+ { -0.0030586775, -0.0037203205, -0.0042847847, -0.0047529764,
+ -0.0051268316, -0.0054091476, -0.0056034233, -0.005714261,
+ -0.0057445862, -0.0057025906, -0.0055920109, -0.0054194843,
+ -0.0051914565, -0.0049146507, -0.0045959447, -0.0042418269 },
+ { -0.0016376863, -0.0017651899, -0.0018608454, -0.0019252141,
+ -0.0019593791, -0.0019653172, -0.0019450618, -0.0018990048,
+ -0.00183808, -0.0017501717, -0.0016481078, -0.0015320742,
+ -0.0014046903, -0.0012685474, -0.001125814, -0.00097943726 },
+ { -0.00055432378, -0.00055472925, -0.00054783461, -0.00053276919,
+ -0.00051135791, -0.00048466062, -0.00045358928, -0.00042499689,
+ -0.00036942671, -0.0003392619, -0.00030001783, -0.00025986304,
+ -0.0002197204, -0.00018116167, -0.00014691355, -0.00011279432 },
+ { -0.000064147389, -0.00006174868, -0.000054267788, -0.000047133824,
+ -0.000042927582, -0.000039477309, -0.000036340745, -0.000029687517,
+ -0.000049787737, -0.000041577889, -0.000033864744, -0.000026534748,
+ -0.000019841305, -0.000014789486, -0.000013131184, -0.0000099198869 },
+ { -0.0000062990207, -0.0000072701259, -0.000011984052, -0.000017348082,
+ -0.000019907106, -0.000021348773, -0.000021961965, -0.000012203576,
+ -0.000010840992, 4.6299544e-7, 5.2588763e-7, 2.7792686e-7,
+ -2.3649704e-7, -0.0000010897784, -9.171448e-7, -5.22682e-7 }
+};
+
+/* Second half of the 384-tap IPQF filtering coefficients. */
+static const float ipqf_coeffs2[ATRAC3P_PQF_FIR_LEN][16] = {
+ { 5.22682e-7, 9.171448e-7, 0.0000010897784, 2.3649704e-7,
+ -2.7792686e-7, -5.2588763e-7, -4.6299544e-7, 0.000010840992,
+ -0.000012203576, -0.000021961965, -0.000021348773, -0.000019907106,
+ -0.000017348082, -0.000011984052, -0.0000072701259, -0.0000062990207 },
+ { 0.0000099198869, 0.000013131184, 0.000014789486, 0.000019841305,
+ 0.000026534748, 0.000033864744, 0.000041577889, 0.000049787737,
+ -0.000029687517, -0.000036340745, -0.000039477309, -0.000042927582,
+ -0.000047133824, -0.000054267788, -0.00006174868, -0.000064147389 },
+ { 0.00011279432, 0.00014691355, 0.00018116167, 0.0002197204,
+ 0.00025986304, 0.00030001783, 0.0003392619, 0.00036942671,
+ -0.00042499689, -0.00045358928, -0.00048466062, -0.00051135791,
+ -0.00053276919, -0.00054783461, -0.00055472925, -0.00055432378 },
+ { 0.00097943726, 0.001125814, 0.0012685474, 0.0014046903,
+ 0.0015320742, 0.0016481078, 0.0017501717, 0.00183808,
+ -0.0018990048, -0.0019450618, -0.0019653172, -0.0019593791,
+ -0.0019252141, -0.0018608454, -0.0017651899, -0.0016376863 },
+ { 0.0042418269, 0.0045959447, 0.0049146507, 0.0051914565,
+ 0.0054194843, 0.0055920109, 0.0057025906, 0.0057445862,
+ -0.005714261, -0.0056034233, -0.0054091476, -0.0051268316,
+ -0.0047529764, -0.0042847847, -0.0037203205, -0.0030586775 },
+ { 0.019670162, 0.021246184, 0.022781773, 0.024265358,
+ 0.025685543, 0.027031265, 0.028291954, 0.02945766,
+ -0.030518902, -0.031467363, -0.032295227, -0.032995768,
+ -0.033563249, -0.033992987, -0.034281436, -0.034426283 },
+ { -0.018065533, -0.016444042, -0.014817309, -0.013196872,
+ -0.011593862, -0.010018963, -0.0084823566, -0.0069935122,
+ 0.0055614738, 0.0041943151, 0.0028992873, 0.001682895,
+ 0.00055068987, -0.00049266568, -0.001443546, -0.0022995141 },
+ { -0.0038591374, -0.0034549395, -0.0030352892, -0.0026067684,
+ -0.0021754825, -0.0017469483, -0.001326357, -0.00091862219,
+ 0.00052769453, 0.00015771533, -0.00018855913, -0.00050782406,
+ -0.00079780724, -0.0010566821, -0.001283227, -0.0014771431 },
+ { -0.00083093712, -0.00068422867, -0.00053928449, -0.00039945057,
+ -0.00026649953, -0.00014135583, -0.000025081157, 0.000084307925,
+ -0.00018248901, -0.00026866337, -0.00034301577, -0.00040612387,
+ -0.00045778, -0.00049731287, -0.00052537228, -0.00054488552 },
+ { -0.00008079566, -0.000053397067, -0.00002610587, -0.0000016657353,
+ 0.000018532943, 0.000035615325, 0.000049888811, 0.000056296329,
+ -0.000058270442, -0.000062285151, -0.000070208509, -0.000074850752,
+ -0.00007612785, -0.000073081472, -0.000068306952, -0.000064464548 },
+ { -0.000048585582, -0.000046043948, -0.000045337845, -0.000041575615,
+ -0.000036968919, -0.000032302323, -0.00002780562, -0.000023530851,
+ 0.0000018111954, -5.7168614e-7, -0.0000015432918, -0.0000026336629,
+ -0.0000041712024, -0.0000079212787, -0.000010502935, -0.0000091622824 },
+ { -0.0000070302972, -0.0000063894258, -0.0000046192422, -0.0000032569742,
+ -0.0000023108685, -0.0000014333754, -6.005389e-7, 0.000011838618,
+ 0.000010516783, 1.2660377e-8, 3.530856e-8, 3.226247e-8,
+ -4.4400572e-8, -4.2005411e-7, -8.0604229e-7, -5.8336207e-7 }
+};
+
+void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
+ const float *in, float *out)
+{
+ int i, s, sb, t, pos_now, pos_next;
+ DECLARE_ALIGNED(32, float, idct_in)[ATRAC3P_SUBBANDS];
+ DECLARE_ALIGNED(32, float, idct_out)[ATRAC3P_SUBBANDS];
+
+ memset(out, 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out));
+
+ for (s = 0; s < ATRAC3P_SUBBAND_SAMPLES; s++) {
+ /* pick up one sample from each subband */
+ for (sb = 0; sb < ATRAC3P_SUBBANDS; sb++)
+ idct_in[sb] = in[sb * ATRAC3P_SUBBAND_SAMPLES + s];
+
+ /* Calculate the sine and cosine part of the PQF using IDCT-IV */
+ dct_ctx->imdct_half(dct_ctx, idct_out, idct_in);
+
+ /* append the result to the history */
+ for (i = 0; i < 8; i++) {
+ hist->buf1[hist->pos][i] = idct_out[i + 8];
+ hist->buf2[hist->pos][i] = idct_out[7 - i];
+ }
+
+ pos_now = hist->pos;
+ pos_next = mod23_lut[pos_now + 2]; // pos_next = (pos_now + 1) % 23;
+
+ for (t = 0; t < ATRAC3P_PQF_FIR_LEN; t++) {
+ for (i = 0; i < 8; i++) {
+ out[s * 16 + i + 0] += hist->buf1[pos_now][i] * ipqf_coeffs1[t][i] +
+ hist->buf2[pos_next][i] * ipqf_coeffs2[t][i];
+ out[s * 16 + i + 8] += hist->buf1[pos_now][7 - i] * ipqf_coeffs1[t][i + 8] +
+ hist->buf2[pos_next][7 - i] * ipqf_coeffs2[t][i + 8];
+ }
+
+ pos_now = mod23_lut[pos_next + 2]; // pos_now = (pos_now + 2) % 23;
+ pos_next = mod23_lut[pos_now + 2]; // pos_next = (pos_next + 2) % 23;
+ }
+
+ hist->pos = mod23_lut[hist->pos]; // hist->pos = (hist->pos - 1) % 23;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/avcodec.h b/chromium/third_party/ffmpeg/libavcodec/avcodec.h
index 132c4ceaf68..9c182954940 100644
--- a/chromium/third_party/ffmpeg/libavcodec/avcodec.h
+++ b/chromium/third_party/ffmpeg/libavcodec/avcodec.h
@@ -286,6 +286,16 @@ enum AVCodecID {
AV_CODEC_ID_WEBP_DEPRECATED,
AV_CODEC_ID_HNM4_VIDEO,
AV_CODEC_ID_HEVC_DEPRECATED,
+ AV_CODEC_ID_FIC,
+ AV_CODEC_ID_ALIAS_PIX,
+ AV_CODEC_ID_BRENDER_PIX_DEPRECATED,
+ AV_CODEC_ID_PAF_VIDEO_DEPRECATED,
+ AV_CODEC_ID_EXR_DEPRECATED,
+ AV_CODEC_ID_VP7_DEPRECATED,
+ AV_CODEC_ID_SANM_DEPRECATED,
+ AV_CODEC_ID_SGIRLE_DEPRECATED,
+ AV_CODEC_ID_MVC1_DEPRECATED,
+ AV_CODEC_ID_MVC2_DEPRECATED,
AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
@@ -314,6 +324,7 @@ enum AVCodecID {
AV_CODEC_ID_SMVJPEG = MKBETAG('S','M','V','J'),
AV_CODEC_ID_HEVC = MKBETAG('H','2','6','5'),
#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC
+ AV_CODEC_ID_VP7 = MKBETAG('V','P','7','0'),
/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
@@ -382,6 +393,8 @@ enum AVCodecID {
AV_CODEC_ID_ADPCM_IMA_ISS,
AV_CODEC_ID_ADPCM_G722,
AV_CODEC_ID_ADPCM_IMA_APC,
+ AV_CODEC_ID_ADPCM_VIMA_DEPRECATED,
+ AV_CODEC_ID_ADPCM_VIMA = MKBETAG('V','I','M','A'),
AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
AV_CODEC_ID_ADPCM_AFC = MKBETAG('A','F','C',' '),
AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
@@ -471,6 +484,8 @@ enum AVCodecID {
AV_CODEC_ID_COMFORT_NOISE,
AV_CODEC_ID_TAK_DEPRECATED,
AV_CODEC_ID_METASOUND,
+ AV_CODEC_ID_PAF_AUDIO_DEPRECATED,
+ AV_CODEC_ID_ON2AVC,
AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
@@ -479,6 +494,10 @@ enum AVCodecID {
AV_CODEC_ID_TAK = MKBETAG('t','B','a','K'),
AV_CODEC_ID_EVRC = MKBETAG('s','e','v','c'),
AV_CODEC_ID_SMV = MKBETAG('s','s','m','v'),
+ AV_CODEC_ID_DSD_LSBF = MKBETAG('D','S','D','L'),
+ AV_CODEC_ID_DSD_MSBF = MKBETAG('D','S','D','M'),
+ AV_CODEC_ID_DSD_LSBF_PLANAR = MKBETAG('D','S','D','1'),
+ AV_CODEC_ID_DSD_MSBF_PLANAR = MKBETAG('D','S','D','8'),
/* subtitle codecs */
AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
@@ -514,6 +533,8 @@ enum AVCodecID {
AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
AV_CODEC_ID_DVD_NAV = MKBETAG('D','N','A','V'),
+ AV_CODEC_ID_TIMED_ID3 = MKBETAG('T','I','D','3'),
+ AV_CODEC_ID_BIN_DATA = MKBETAG('D','A','T','A'),
AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
@@ -551,6 +572,13 @@ typedef struct AVCodecDescriptor {
* Codec properties, a combination of AV_CODEC_PROP_* flags.
*/
int props;
+
+ /**
+ * MIME type(s) associated with the codec.
+ * May be NULL; if not, a NULL-terminated array of MIME types.
+ * The first item is always non-NULL and is the prefered MIME type.
+ */
+ const char *const *mime_types;
} AVCodecDescriptor;
/**
@@ -718,22 +746,46 @@ typedef struct RcOverride{
#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
#define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted
#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
+#if FF_API_GMC
+/**
+ * @deprecated use the "gmc" private option of the libxvid encoder
+ */
#define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
-#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
+#endif
+#if FF_API_MV0
/**
- * The parent program guarantees that the input for B-frames containing
- * streams is not written to for at least s->max_b_frames+1 frames, if
- * this is not set the input will be copied.
+ * @deprecated use the flag "mv0" in the "mpv_flags" private option of the
+ * mpegvideo encoders
+ */
+#define CODEC_FLAG_MV0 0x0040
+#endif
+#if FF_API_INPUT_PRESERVED
+/**
+ * @deprecated passing reference-counted frames to the encoders replaces this
+ * flag
*/
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
+#endif
#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
-#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
+#if FF_API_EMU_EDGE
+/**
+ * @deprecated edges are not used/required anymore. I.e. this flag is now always
+ * set.
+ */
+#define CODEC_FLAG_EMU_EDGE 0x4000
+#endif
#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
location instead of only at frame boundaries. */
-#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
+#if FF_API_NORMALIZE_AQP
+/**
+ * @deprecated use the flag "naq" in the "mpv_flags" private option of the
+ * mpegvideo encoders
+ */
+#define CODEC_FLAG_NORMALIZE_AQP 0x00020000
+#endif
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
@@ -768,7 +820,13 @@ typedef struct RcOverride{
#define CODEC_CAP_DR1 0x0002
#define CODEC_CAP_TRUNCATED 0x0008
#if FF_API_XVMC
-/* Codec can export data for HW decoding (XvMC). */
+/* Codec can export data for HW decoding. This flag indicates that
+ * the codec would call get_format() with list that might contain HW accelerated
+ * pixel formats (XvMC, VDPAU, VAAPI, etc). The application can pick any of them
+ * including raw image format.
+ * The application can use the passed context to determine bitstream version,
+ * chroma format, resolution etc.
+ */
#define CODEC_CAP_HWACCEL 0x0010
#endif /* FF_API_XVMC */
/**
@@ -990,6 +1048,12 @@ enum AVPacketSideDataType {
AV_PKT_DATA_H263_MB_INFO,
/**
+ * This side data should be associated with an audio stream and contains
+ * ReplayGain information in form of the AVReplayGain struct.
+ */
+ AV_PKT_DATA_REPLAYGAIN,
+
+ /**
* Recommmends skipping the specified number of samples
* @code
* u32le number of samples to skip from start of this packet
@@ -1054,6 +1118,12 @@ enum AVPacketSideDataType {
AV_PKT_DATA_METADATA_UPDATE,
};
+typedef struct AVPacketSideData {
+ uint8_t *data;
+ int size;
+ enum AVPacketSideDataType type;
+} AVPacketSideData;
+
/**
* This structure stores compressed data. It is typically exported by demuxers
* and then passed as input to decoders, or received as output from encoders and
@@ -1110,11 +1180,7 @@ typedef struct AVPacket {
* Additional packet data that can be provided by the container.
* Packet can contain several types of side information.
*/
- struct {
- uint8_t *data;
- int size;
- enum AVPacketSideDataType type;
- } *side_data;
+ AVPacketSideData *side_data;
int side_data_elems;
/**
@@ -1123,11 +1189,9 @@ typedef struct AVPacket {
*/
int duration;
#if FF_API_DESTRUCT_PACKET
- // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611
- // attribute_deprecated
+ attribute_deprecated
void (*destruct)(struct AVPacket *);
- // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611
- // attribute_deprecated
+ attribute_deprecated
void *priv;
#endif
int64_t pos; ///< byte position in stream, -1 if unknown
@@ -1194,7 +1258,13 @@ typedef struct AVCodecContext {
enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
const struct AVCodec *codec;
+#if FF_API_CODEC_NAME
+ /**
+ * @deprecated this field is not used for anything in libavcodec
+ */
+ attribute_deprecated
char codec_name[32];
+#endif
enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
/**
@@ -1327,12 +1397,17 @@ typedef struct AVCodecContext {
* encoded input.
*
* Audio:
- * For encoding, this is the number of "priming" samples added to the
- * beginning of the stream. The decoded output will be delayed by this
- * many samples relative to the input to the encoder. Note that this
- * field is purely informational and does not directly affect the pts
- * output by the encoder, which should always be based on the actual
- * presentation time, including any delay.
+ * For encoding, this is the number of "priming" samples added by the
+ * encoder to the beginning of the stream. The decoded output will be
+ * delayed by this many samples relative to the input to the encoder (or
+ * more, if the decoder adds its own padding).
+ * The timestamps on the output packets are adjusted by the encoder so
+ * that they always refer to the first sample of the data actually
+ * contained in the packet, including any added padding.
+ * E.g. if the timebase is 1/samplerate and the timestamp of the first
+ * input sample is 0, the timestamp of the first output packet will be
+ * -delay.
+ *
* For decoding, this is the number of samples the decoder needs to
* output before the decoder's output is valid. When seeking, you should
* start decoding this many samples prior to your desired seek point.
@@ -1698,7 +1773,7 @@ typedef struct AVCodecContext {
* XVideo Motion Acceleration
* - encoding: forbidden
* - decoding: set by decoder
- * @deprecated XvMC support is slated for removal.
+ * @deprecated XvMC doesn't need it anymore.
*/
attribute_deprecated int xvmc_acceleration;
#endif /* FF_API_XVMC */
@@ -2064,8 +2139,7 @@ typedef struct AVCodecContext {
*
* @deprecated use get_buffer2()
*/
- // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611
- // attribute_deprecated
+ attribute_deprecated
int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
/**
@@ -2079,8 +2153,7 @@ typedef struct AVCodecContext {
*
* @deprecated custom freeing callbacks should be set from get_buffer2()
*/
- // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611
- // attribute_deprecated
+ attribute_deprecated
void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
/**
@@ -2150,12 +2223,11 @@ typedef struct AVCodecContext {
* If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
* (read and/or written to if it is writable) later by libavcodec.
*
- * If CODEC_FLAG_EMU_EDGE is not set in s->flags, the buffer must contain an
- * edge of the size returned by avcodec_get_edge_width() on all sides.
- *
* avcodec_align_dimensions2() should be used to find the required width and
* height, as they normally need to be rounded up to the next multiple of 16.
*
+ * Some decoders do not support linesizes changing between frames.
+ *
* If frame multithreading is used and thread_safe_callbacks is set,
* this callback may be called from a different thread, but not from more
* than one at once. Does not need to be reentrant.
@@ -2222,7 +2294,7 @@ typedef struct AVCodecContext {
/**
* ratecontrol qmin qmax limiting method
- * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
+ * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax.
* - encoding: Set by user.
* - decoding: unused
*/
@@ -2317,14 +2389,14 @@ typedef struct AVCodecContext {
int context_model;
/**
- * minimum Lagrange multipler
+ * minimum Lagrange multiplier
* - encoding: Set by user.
* - decoding: unused
*/
int lmin;
/**
- * maximum Lagrange multipler
+ * maximum Lagrange multiplier
* - encoding: Set by user.
* - decoding: unused
*/
@@ -2485,6 +2557,7 @@ typedef struct AVCodecContext {
int error_concealment;
#define FF_EC_GUESS_MVS 1
#define FF_EC_DEBLOCK 2
+#define FF_EC_FAVOR_INTER 256
/**
* debug
@@ -2516,6 +2589,7 @@ typedef struct AVCodecContext {
#endif
#define FF_DEBUG_BUFFERS 0x00008000
#define FF_DEBUG_THREADS 0x00010000
+#define FF_DEBUG_NOMC 0x01000000
#if FF_API_DEBUG_MV
/**
@@ -2548,8 +2622,9 @@ typedef struct AVCodecContext {
#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
+#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
-#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliancies as errors
+#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error
@@ -2613,13 +2688,17 @@ typedef struct AVCodecContext {
#define FF_IDCT_SIMPLEMMX 3
#define FF_IDCT_ARM 7
#define FF_IDCT_ALTIVEC 8
+#if FF_API_ARCH_SH4
#define FF_IDCT_SH4 9
+#endif
#define FF_IDCT_SIMPLEARM 10
#define FF_IDCT_IPP 13
#define FF_IDCT_XVIDMMX 14
#define FF_IDCT_SIMPLEARMV5TE 16
#define FF_IDCT_SIMPLEARMV6 17
+#if FF_API_ARCH_SPARC
#define FF_IDCT_SIMPLEVIS 18
+#endif
#define FF_IDCT_FAAN 20
#define FF_IDCT_SIMPLENEON 22
#if FF_API_ARCH_ALPHA
@@ -2735,7 +2814,7 @@ typedef struct AVCodecContext {
#endif
/**
- * noise vs. sse weight for the nsse comparsion function
+ * noise vs. sse weight for the nsse comparison function
* - encoding: Set by user.
* - decoding: unused
*/
@@ -2980,6 +3059,14 @@ typedef struct AVCodecContext {
#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
#endif
+
+ /**
+ * custom intra quantization matrix
+ * Code outside libavcodec should access this field using av_codec_g/set_chroma_intra_matrix()
+ * - encoding: Set by user, can be NULL.
+ * - decoding: unused.
+ */
+ uint16_t *chroma_intra_matrix;
} AVCodecContext;
AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
@@ -2994,6 +3081,9 @@ void av_codec_set_lowres(AVCodecContext *avctx, int val);
int av_codec_get_seek_preroll(const AVCodecContext *avctx);
void av_codec_set_seek_preroll(AVCodecContext *avctx, int val);
+uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx);
+void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val);
+
/**
* AVProfile.
*/
@@ -3105,6 +3195,8 @@ typedef struct AVCodec {
int av_codec_get_max_lowres(const AVCodec *codec);
+struct MpegEncContext;
+
/**
* AVHWAccel.
*/
@@ -3143,9 +3235,21 @@ typedef struct AVHWAccel {
*/
int capabilities;
+ /*****************************************************************
+ * No fields below this line are part of the public API. They
+ * may not be used outside of libavcodec and can be changed and
+ * removed at will.
+ * New public fields should be added right above.
+ *****************************************************************
+ */
struct AVHWAccel *next;
/**
+ * Allocate a custom buffer
+ */
+ int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
+
+ /**
* Called at the beginning of each frame or field picture.
*
* Meaningful frame information (codec specific) is guaranteed to
@@ -3166,6 +3270,7 @@ typedef struct AVHWAccel {
*
* Meaningful slice information (codec specific) is guaranteed to
* be parsed at this point. This function is mandatory.
+ * The only exception is XvMC, that works on MB level.
*
* @param avctx the codec context
* @param buf the slice data buffer base
@@ -3186,12 +3291,46 @@ typedef struct AVHWAccel {
int (*end_frame)(AVCodecContext *avctx);
/**
- * Size of HW accelerator private data.
+ * Size of per-frame hardware accelerator private data.
*
* Private data is allocated with av_mallocz() before
* AVCodecContext.get_buffer() and deallocated after
* AVCodecContext.release_buffer().
*/
+ int frame_priv_data_size;
+
+ /**
+ * Called for every Macroblock in a slice.
+ *
+ * XvMC uses it to replace the ff_MPV_decode_mb().
+ * Instead of decoding to raw picture, MB parameters are
+ * stored in an array provided by the video driver.
+ *
+ * @param s the mpeg context
+ */
+ void (*decode_mb)(struct MpegEncContext *s);
+
+ /**
+ * Initialize the hwaccel private data.
+ *
+ * This will be called from ff_get_format(), after hwaccel and
+ * hwaccel_context are set and the hwaccel private data in AVCodecInternal
+ * is allocated.
+ */
+ int (*init)(AVCodecContext *avctx);
+
+ /**
+ * Uninitialize the hwaccel private data.
+ *
+ * This will be called from get_format() or avcodec_close(), after hwaccel
+ * and hwaccel_context are already uninitialized.
+ */
+ int (*uninit)(AVCodecContext *avctx);
+
+ /**
+ * Size of the private data to allocate in
+ * AVCodecInternal.hwaccel_priv_data.
+ */
int priv_data_size;
} AVHWAccel;
@@ -3387,13 +3526,15 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
*/
attribute_deprecated
AVFrame *avcodec_alloc_frame(void);
-#endif
/**
* Set the fields of the given AVFrame to default values.
*
* @param frame The AVFrame of which the fields should be set to default values.
+ *
+ * @deprecated use av_frame_unref()
*/
+attribute_deprecated
void avcodec_get_frame_defaults(AVFrame *frame);
/**
@@ -3405,8 +3546,12 @@ void avcodec_get_frame_defaults(AVFrame *frame);
* @warning this function does NOT free the data buffers themselves
* (it does not know how, since they might have been allocated with
* a custom get_buffer()).
+ *
+ * @deprecated use av_frame_free()
*/
+attribute_deprecated
void avcodec_free_frame(AVFrame **frame);
+#endif
/**
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
@@ -3478,8 +3623,7 @@ void avsubtitle_free(AVSubtitle *sub);
* Default packet destructor.
* @deprecated use the AVBuffer API instead
*/
-// TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611
-// attribute_deprecated
+attribute_deprecated
void av_destruct_packet(AVPacket *pkt);
#endif
@@ -3545,14 +3689,14 @@ int av_dup_packet(AVPacket *pkt);
*
* @return 0 on success, negative AVERROR on fail
*/
-int av_copy_packet(AVPacket *dst, AVPacket *src);
+int av_copy_packet(AVPacket *dst, const AVPacket *src);
/**
* Copy packet side data
*
* @return 0 on success, negative AVERROR on fail
*/
-int av_copy_packet_side_data(AVPacket *dst, AVPacket *src);
+int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
/**
* Free a packet.
@@ -3641,7 +3785,7 @@ void av_packet_free_side_data(AVPacket *pkt);
*
* @return 0 on success, a negative AVERROR on error.
*/
-int av_packet_ref(AVPacket *dst, AVPacket *src);
+int av_packet_ref(AVPacket *dst, const AVPacket *src);
/**
* Wipe the packet.
@@ -3715,14 +3859,20 @@ attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame
*/
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
+#if FF_API_EMU_EDGE
/**
* Return the amount of padding in pixels which the get_buffer callback must
* provide around the edge of the image for codecs which do not have the
* CODEC_FLAG_EMU_EDGE flag.
*
* @return Required padding in pixels.
+ *
+ * @deprecated CODEC_FLAG_EMU_EDGE is deprecated, so this function is no longer
+ * needed
*/
+attribute_deprecated
unsigned avcodec_get_edge_width(void);
+#endif
/**
* Modify width and height values so that they will result in a memory
@@ -3730,8 +3880,6 @@ unsigned avcodec_get_edge_width(void);
* padding.
*
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
- * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
- * according to avcodec_get_edge_width() before.
*/
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
@@ -3741,8 +3889,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
* line sizes are a multiple of the respective linesize_align[i].
*
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
- * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
- * according to avcodec_get_edge_width() before.
*/
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS]);
@@ -4607,30 +4753,8 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int
*/
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
-#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
-#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
-#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
-#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
-#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
-#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
-
-/**
- * Compute what kind of losses will occur when converting from one specific
- * pixel format to another.
- * When converting from one pixel format to another, information loss may occur.
- * For example, when converting from RGB24 to GRAY, the color information will
- * be lost. Similarly, other losses occur when converting from some formats to
- * other formats. These losses can involve loss of chroma, but also loss of
- * resolution, loss of color depth, loss due to the color space conversion, loss
- * of the alpha bits or loss due to color quantization.
- * avcodec_get_fix_fmt_loss() informs you about the various types of losses
- * which will occur when converting from one pixel format to another.
- *
- * @param[in] dst_pix_fmt destination pixel format
- * @param[in] src_pix_fmt source pixel format
- * @param[in] has_alpha Whether the source pixel format alpha channel is used.
- * @return Combination of flags informing you what kind of losses will occur
- * (maximum loss for an invalid dst_pix_fmt).
+/**
+ * @deprecated see av_get_pix_fmt_loss()
*/
int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
int has_alpha);
@@ -4657,34 +4781,7 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p
int has_alpha, int *loss_ptr);
/**
- * Find the best pixel format to convert to given a certain source pixel
- * format and a selection of two destination pixel formats. When converting from
- * one pixel format to another, information loss may occur. For example, when converting
- * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
- * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
- * the given pixel formats should be used to suffer the least amount of loss.
- *
- * If one of the destination formats is AV_PIX_FMT_NONE the other pixel format (if valid) will be
- * returned.
- *
- * @code
- * src_pix_fmt = AV_PIX_FMT_YUV420P;
- * dst_pix_fmt1= AV_PIX_FMT_RGB24;
- * dst_pix_fmt2= AV_PIX_FMT_GRAY8;
- * dst_pix_fmt3= AV_PIX_FMT_RGB8;
- * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
- * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
- * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
- * @endcode
- *
- * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
- * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
- * @param[in] src_pix_fmt Source pixel format
- * @param[in] has_alpha Whether the source pixel format alpha channel is used.
- * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
- * NULL or value of zero means we care about all losses. Out: the loss
- * that occurs when converting from src to selected dst pixel format.
- * @return The best pixel format to convert to or -1 if none was found.
+ * @deprecated see av_find_best_pix_fmt_of_2()
*/
enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
@@ -4717,7 +4814,9 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
/**
* Put a string representing the codec tag codec_tag in buf.
*
+ * @param buf buffer to place codec tag in
* @param buf_size size in bytes of buf
+ * @param codec_tag codec tag to assign
* @return the length of the string that would have been generated if
* enough space had been available, excluding the trailing null
*/
diff --git a/chromium/third_party/ffmpeg/libavcodec/avfft.h b/chromium/third_party/ffmpeg/libavcodec/avfft.h
index 2d20a45f872..0c0f9b8d8da 100644
--- a/chromium/third_party/ffmpeg/libavcodec/avfft.h
+++ b/chromium/third_party/ffmpeg/libavcodec/avfft.h
@@ -99,9 +99,11 @@ enum DCTTransformType {
/**
* Set up DCT.
+ *
* @param nbits size of the input array:
* (1 << nbits) for DCT-II, DCT-III and DST-I
* (1 << nbits) + 1 for DCT-I
+ * @param type the type of transform
*
* @note the first element of the input of DST-I is ignored
*/
diff --git a/chromium/third_party/ffmpeg/libavcodec/avpacket.c b/chromium/third_party/ffmpeg/libavcodec/avpacket.c
index f966bfe8943..93efcec0615 100644
--- a/chromium/third_party/ffmpeg/libavcodec/avpacket.c
+++ b/chromium/third_party/ffmpeg/libavcodec/avpacket.c
@@ -190,7 +190,7 @@ do { \
} while (0)
/* Makes duplicates of data, side_data, but does not copy any other fields */
-static int copy_packet_data(AVPacket *pkt, AVPacket *src, int dup)
+static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
{
pkt->data = NULL;
pkt->side_data = NULL;
@@ -220,7 +220,7 @@ failed_alloc:
return AVERROR(ENOMEM);
}
-int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
+int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
{
if (src->side_data_elems) {
int i;
@@ -262,7 +262,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
-int av_copy_packet(AVPacket *dst, AVPacket *src)
+int av_copy_packet(AVPacket *dst, const AVPacket *src)
{
*dst = *src;
return copy_packet_data(dst, src, 0);
@@ -394,7 +394,7 @@ int av_packet_split_side_data(AVPacket *pkt){
p-= size+5;
}
- pkt->side_data = av_malloc(i * sizeof(*pkt->side_data));
+ pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
if (!pkt->side_data)
return AVERROR(ENOMEM);
@@ -534,7 +534,7 @@ void av_packet_unref(AVPacket *pkt)
pkt->size = 0;
}
-int av_packet_ref(AVPacket *dst, AVPacket *src)
+int av_packet_ref(AVPacket *dst, const AVPacket *src)
{
int ret;
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/Makefile b/chromium/third_party/ffmpeg/libavcodec/bfin/Makefile
index c2933602055..efdcbfc69f0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/Makefile
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/Makefile
@@ -1,10 +1,10 @@
-OBJS += bfin/dsputil_bfin.o \
- bfin/fdct_bfin.o \
- bfin/idct_bfin.o \
- bfin/pixels_bfin.o \
-
-OBJS-$(CONFIG_HPELDSP) += bfin/hpeldsp_bfin.o \
- bfin/hpel_pixels_bfin.o
-OBJS-$(CONFIG_MPEGVIDEOENC) += bfin/mpegvideo_bfin.o
-OBJS-$(CONFIG_VP3DSP) += bfin/vp3_bfin.o \
- bfin/vp3_idct_bfin.o
+OBJS-$(CONFIG_DSPUTIL) += bfin/dsputil_init.o \
+ bfin/dsputil.o \
+ bfin/fdct_bfin.o \
+ bfin/idct_bfin.o \
+ bfin/pixels.o
+OBJS-$(CONFIG_HPELDSP) += bfin/hpeldsp_init.o \
+ bfin/hpel_pixels_no_rnd.o \
+ bfin/pixels.o
+OBJS-$(CONFIG_VP3DSP) += bfin/vp3dsp_init.o \
+ bfin/vp3dsp.o
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/config_bfin.h b/chromium/third_party/ffmpeg/libavcodec/bfin/config_bfin.h
deleted file mode 100644
index 36439530e9f..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/config_bfin.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-/*
- low level assembler interface wrapper
-
-DEFUN(put_pixels_clamped,mL1,
- (int16_t *block, uint8_t *dest, int line_size)):
-
- body
-
- rts;
-*/
-
-#ifndef AVCODEC_BFIN_CONFIG_BFIN_H
-#define AVCODEC_BFIN_CONFIG_BFIN_H
-
-#include "config.h"
-
-#ifndef DEFUN
-
-#define mL3 .text
-#ifndef mL1
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define mL1 .l1.text
-#else
-#define mL1 mL3
-#endif
-#endif
-
-#define DEFUN(fname,where,interface) \
- .section where; \
- .global _ff_bfin_ ## fname ; \
- .type _ff_bfin_ ## fname, STT_FUNC; \
- .align 8; \
- _ff_bfin_ ## fname
-
-#define DEFUN_END(fname) \
- .size _ff_bfin_ ## fname, . - _ff_bfin_ ## fname
-
-#ifdef __FDPIC__
-#define RELOC(reg,got,obj) reg = [got + obj@GOT17M4]
-#else
-#define RELOC(reg,got,obj) reg.L = obj; reg.H = obj
-#endif
-
-#endif
-
-#endif /* AVCODEC_BFIN_CONFIG_BFIN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/pixels_bfin.S b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil.S
index 2c84deb83f5..25bdac2520d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/pixels_bfin.S
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil.S
@@ -18,7 +18,8 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config_bfin.h"
+
+#include "libavutil/bfin/asm.h"
DEFUN(put_pixels_clamped,mL1,
(int16_t *block, uint8_t *dest, int line_size)):
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.c b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.c
deleted file mode 100644
index a95fd6b62ca..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * BlackFin DSPUTILS
- *
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
- * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_bfin.h"
-
-int off;
-
-static void bfin_idct_add (uint8_t *dest, int line_size, int16_t *block)
-{
- ff_bfin_idct (block);
- ff_bfin_add_pixels_clamped (block, dest, line_size);
-}
-
-static void bfin_idct_put (uint8_t *dest, int line_size, int16_t *block)
-{
- ff_bfin_idct (block);
- ff_bfin_put_pixels_clamped (block, dest, line_size);
-}
-
-
-static void bfin_clear_blocks (int16_t *blocks)
-{
- // This is just a simple memset.
- //
- __asm__("P0=192; "
- "I0=%0; "
- "R0=0; "
- "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
- "clear_blocks_blkfn_lab:"
- "[I0++]=R0;"
- ::"a" (blocks):"P0","I0","R0");
-}
-
-static int bfin_pix_abs16 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- return ff_bfin_z_sad16x16 (blk1,blk2,line_size,line_size,h);
-}
-
-static int bfin_vsad_intra16 (void *c, uint8_t *blk1, uint8_t *dummy, int stride, int h) {
- return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h);
-}
-
-static int bfin_vsad (void *c, uint8_t *blk1, uint8_t *blk2, int stride, int h) {
- return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h)
- + ff_bfin_z_sad16x16 (blk2,blk2+stride,stride<<1,stride<<1,h);
-}
-
-static uint8_t vtmp_blk[256] attribute_l1_data_b;
-
-static int bfin_pix_abs16_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+1, 16, line_size, h);
- return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs16_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+line_size, 16, line_size, h);
- return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs16_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_z_put_pixels16_xy2 (vtmp_blk, blk2, 16, line_size, h);
- return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs8 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- return ff_bfin_z_sad8x8 (blk1,blk2,line_size,line_size, h);
-}
-
-static int bfin_pix_abs8_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+1, 8, line_size, h);
- return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-static int bfin_pix_abs8_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+line_size, 8, line_size, h);
- return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
- ff_bfin_z_put_pixels8_xy2 (vtmp_blk, blk2, 8, line_size, h);
- return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-
-/*
- decoder optimization
- start on 2/11 100 frames of 352x240@25 compiled with no optimization -g debugging
- 9.824s ~ 2.44x off
- 6.360s ~ 1.58x off with -O2
- 5.740s ~ 1.43x off with idcts
-
- 2.64s 2/20 same sman.mp4 decode only
-
-*/
-
-av_cold void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx)
-{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
- c->diff_pixels = ff_bfin_diff_pixels;
- c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
- c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
-
- if (!high_bit_depth)
- c->get_pixels = ff_bfin_get_pixels;
- c->clear_blocks = bfin_clear_blocks;
- c->pix_sum = ff_bfin_pix_sum;
- c->pix_norm1 = ff_bfin_pix_norm1;
-
- c->sad[0] = bfin_pix_abs16;
- c->sad[1] = bfin_pix_abs8;
-
-/* c->vsad[0] = bfin_vsad; */
-/* c->vsad[4] = bfin_vsad_intra16; */
-
- /* TODO [0] 16 [1] 8 */
- c->pix_abs[0][0] = bfin_pix_abs16;
- c->pix_abs[0][1] = bfin_pix_abs16_x2;
- c->pix_abs[0][2] = bfin_pix_abs16_y2;
- c->pix_abs[0][3] = bfin_pix_abs16_xy2;
-
- c->pix_abs[1][0] = bfin_pix_abs8;
- c->pix_abs[1][1] = bfin_pix_abs8_x2;
- c->pix_abs[1][2] = bfin_pix_abs8_y2;
- c->pix_abs[1][3] = bfin_pix_abs8_xy2;
-
-
- c->sse[0] = ff_bfin_sse16;
- c->sse[1] = ff_bfin_sse8;
- c->sse[2] = ff_bfin_sse4;
-
- if (avctx->bits_per_raw_sample <= 8) {
- if (avctx->dct_algo == FF_DCT_AUTO)
- c->fdct = ff_bfin_fdct;
-
- if (avctx->idct_algo == FF_IDCT_AUTO) {
- c->idct_permutation_type = FF_NO_IDCT_PERM;
- c->idct = ff_bfin_idct;
- c->idct_add = bfin_idct_add;
- c->idct_put = bfin_idct_put;
- }
- }
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.h b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.h
deleted file mode 100644
index 079ebdda6b6..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_bfin.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * BlackFin DSPUTILS COMMON OPTIMIZATIONS HEADER
- *
- * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef AVCODEC_BFIN_DSPUTIL_BFIN_H
-#define AVCODEC_BFIN_DSPUTIL_BFIN_H
-
-#include <stdint.h>
-
-#include "config.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define attribute_l1_text __attribute__ ((l1_text))
-#define attribute_l1_data_b __attribute__((l1_data_B))
-#else
-#define attribute_l1_text
-#define attribute_l1_data_b
-#endif
-
-void ff_bfin_idct (int16_t *block) attribute_l1_text;
-void ff_bfin_fdct (int16_t *block) attribute_l1_text;
-void ff_bfin_add_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text;
-void ff_bfin_put_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text;
-void ff_bfin_diff_pixels (int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride) attribute_l1_text;
-void ff_bfin_get_pixels (int16_t *restrict block, const uint8_t *pixels, int line_size) attribute_l1_text;
-int ff_bfin_pix_norm1 (uint8_t * pix, int line_size) attribute_l1_text;
-int ff_bfin_z_sad8x8 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) attribute_l1_text;
-int ff_bfin_z_sad16x16 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) attribute_l1_text;
-
-int ff_bfin_pix_sum (uint8_t *p, int stride) attribute_l1_text;
-
-int ff_bfin_sse4 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-int ff_bfin_sse8 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-int ff_bfin_sse16 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-
-
-#ifdef BFIN_PROFILE
-
-static double Telem[16];
-static char *TelemNames[16];
-static int TelemCnt;
-
-#define PROF(lab,e) { int xx_e = e; char*xx_lab = lab; uint64_t xx_t0 = read_time();
-#define EPROF() xx_t0 = read_time()-xx_t0; Telem[xx_e] = Telem[xx_e] + xx_t0; TelemNames[xx_e] = xx_lab; }
-
-static void prof_report (void)
-{
- int i;
- double s = 0;
- for (i=0;i<16;i++) {
- double v;
- if (TelemNames[i]) {
- v = Telem[i]/TelemCnt;
- av_log (NULL,AV_LOG_DEBUG,"%-20s: %12.4f\t%12.4f\n", TelemNames[i],v,v/64);
- s = s + Telem[i];
- }
- }
- av_log (NULL,AV_LOG_DEBUG,"%-20s: %12.4f\t%12.4f\n%20.4f\t%d\n",
- "total",s/TelemCnt,s/TelemCnt/64,s,TelemCnt);
-}
-
-static void bfprof (void)
-{
- static int init;
- if (!init) atexit (prof_report);
- init=1;
- TelemCnt++;
-}
-
-#else
-#define PROF(a,b)
-#define EPROF()
-#define bfprof()
-#endif
-
-#endif /* AVCODEC_BFIN_DSPUTIL_BFIN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_init.c b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_init.c
new file mode 100644
index 00000000000..92bd354ff3f
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/dsputil_init.c
@@ -0,0 +1,195 @@
+/*
+ * BlackFin DSPUTILS
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
+ * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
+#include "libavcodec/mpegvideo.h"
+
+void ff_bfin_idct(int16_t *block) attribute_l1_text;
+void ff_bfin_fdct(int16_t *block) attribute_l1_text;
+
+void ff_bfin_add_pixels_clamped(const int16_t *block, uint8_t *dest,
+ int line_size) attribute_l1_text;
+void ff_bfin_put_pixels_clamped(const int16_t *block, uint8_t *dest,
+ int line_size) attribute_l1_text;
+
+void ff_bfin_diff_pixels(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+ int stride) attribute_l1_text;
+void ff_bfin_get_pixels(int16_t *restrict block, const uint8_t *pixels,
+ int line_size) attribute_l1_text;
+
+int ff_bfin_pix_norm1(uint8_t *pix, int line_size) attribute_l1_text;
+int ff_bfin_pix_sum(uint8_t *p, int stride) attribute_l1_text;
+
+int ff_bfin_z_sad8x8(uint8_t *blk1, uint8_t *blk2, int dsz,
+ int line_size, int h) attribute_l1_text;
+int ff_bfin_z_sad16x16(uint8_t *blk1, uint8_t *blk2, int dsz,
+ int line_size, int h) attribute_l1_text;
+
+int ff_bfin_sse4(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h) attribute_l1_text;
+int ff_bfin_sse8(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h) attribute_l1_text;
+int ff_bfin_sse16(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h) attribute_l1_text;
+
+static void bfin_idct_add(uint8_t *dest, int line_size, int16_t *block)
+{
+ ff_bfin_idct(block);
+ ff_bfin_add_pixels_clamped(block, dest, line_size);
+}
+
+static void bfin_idct_put(uint8_t *dest, int line_size, int16_t *block)
+{
+ ff_bfin_idct(block);
+ ff_bfin_put_pixels_clamped(block, dest, line_size);
+}
+
+static void bfin_clear_blocks(int16_t *blocks)
+{
+ // This is just a simple memset.
+ __asm__ ("P0=192; "
+ "I0=%0; "
+ "R0=0; "
+ "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
+ "clear_blocks_blkfn_lab:"
+ "[I0++]=R0;"
+ ::"a" (blocks) : "P0", "I0", "R0");
+}
+
+static int bfin_pix_abs16(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ return ff_bfin_z_sad16x16(blk1, blk2, line_size, line_size, h);
+}
+
+static uint8_t vtmp_blk[256] attribute_l1_data_b;
+
+static int bfin_pix_abs16_x2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + 1, 16, line_size, h);
+ return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_y2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + line_size, 16, line_size, h);
+ return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_xy2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_z_put_pixels16_xy2(vtmp_blk, blk2, 16, line_size, h);
+ return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs8(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ return ff_bfin_z_sad8x8(blk1, blk2, line_size, line_size, h);
+}
+
+static int bfin_pix_abs8_x2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + 1, 8, line_size, h);
+ return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_y2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + line_size, 8, line_size, h);
+ return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_xy2(MpegEncContext *c, uint8_t *blk1, uint8_t *blk2,
+ int line_size, int h)
+{
+ ff_bfin_z_put_pixels8_xy2(vtmp_blk, blk2, 8, line_size, h);
+ return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+/*
+ * decoder optimization
+ * start on 2/11 100 frames of 352x240@25 compiled with no optimization -g debugging
+ * 9.824s ~ 2.44x off
+ * 6.360s ~ 1.58x off with -O2
+ * 5.740s ~ 1.43x off with idcts
+ *
+ * 2.64s 2/20 same sman.mp4 decode only
+ */
+
+av_cold void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
+{
+ c->diff_pixels = ff_bfin_diff_pixels;
+
+ c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
+ c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
+
+ c->clear_blocks = bfin_clear_blocks;
+
+ c->pix_sum = ff_bfin_pix_sum;
+ c->pix_norm1 = ff_bfin_pix_norm1;
+
+ c->sad[0] = bfin_pix_abs16;
+ c->sad[1] = bfin_pix_abs8;
+
+ /* TODO [0] 16 [1] 8 */
+ c->pix_abs[0][0] = bfin_pix_abs16;
+ c->pix_abs[0][1] = bfin_pix_abs16_x2;
+ c->pix_abs[0][2] = bfin_pix_abs16_y2;
+ c->pix_abs[0][3] = bfin_pix_abs16_xy2;
+
+ c->pix_abs[1][0] = bfin_pix_abs8;
+ c->pix_abs[1][1] = bfin_pix_abs8_x2;
+ c->pix_abs[1][2] = bfin_pix_abs8_y2;
+ c->pix_abs[1][3] = bfin_pix_abs8_xy2;
+
+ c->sse[0] = ff_bfin_sse16;
+ c->sse[1] = ff_bfin_sse8;
+ c->sse[2] = ff_bfin_sse4;
+
+ if (!high_bit_depth) {
+ c->get_pixels = ff_bfin_get_pixels;
+
+ if (avctx->dct_algo == FF_DCT_AUTO)
+ c->fdct = ff_bfin_fdct;
+
+ if (avctx->idct_algo == FF_IDCT_AUTO) {
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ c->idct = ff_bfin_idct;
+ c->idct_add = bfin_idct_add;
+ c->idct_put = bfin_idct_put;
+ }
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/fdct_bfin.S b/chromium/third_party/ffmpeg/libavcodec/bfin/fdct_bfin.S
index 916957467c6..1b839aafb2b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/fdct_bfin.S
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/fdct_bfin.S
@@ -127,21 +127,16 @@ root:/u/ffmpeg/bhead/libavcodec>
*/
-#include "config.h"
-#include "config_bfin.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw",@progbits
-#else
-.data
-#endif
+#include "libavutil/bfin/asm.h"
+
+SECTION_L1_DATA_B
+
.align 4;
dct_coeff:
.short 0x5a82, 0x2d41, 0x187e, 0x3b21, 0x0c7c, 0x3ec5, 0x238e, 0x3537;
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A,"aw",@progbits
-#endif
+SECTION_L1_DATA_A
+
.align 4
vtmp: .space 128
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_no_rnd.S b/chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_no_rnd.S
new file mode 100644
index 00000000000..aeb56edadb1
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_no_rnd.S
@@ -0,0 +1,81 @@
+/*
+ * Blackfin Pixel Operations
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/bfin/asm.h"
+
+DEFUN(put_pixels8uc_no_rnd,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int line_size, int h)):
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r2=[sp+12]; // line_size
+ p0=[sp+16]; // h
+ [--sp] = (r7:6);
+ r2+=-4;
+ m3=r2;
+ r2+=-4;
+ m0=r2;
+ LSETUP(pp8$2,pp8$3) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp8$2: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0]|| R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R6 ;
+pp8$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+ RTS;
+DEFUN_END(put_pixels8uc_no_rnd)
+
+DEFUN(put_pixels16uc_no_rnd,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int line_size, int h)):
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r2=[sp+12]; // line_size
+ p0=[sp+16]; // h
+
+ [--sp] = (r7:6);
+ r2+=-12;
+ m3=r2; // line_size
+ r2+=-4;
+ m0=r2;
+
+ LSETUP(pp16$2,pp16$3) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp16$2:
+ DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++] || R2 =[I1++];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++] || R3 =[I1++];
+ [I3++] = R6;
+
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0] || R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R7 ;
+ [I3++] = R6;
+pp16$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+
+ RTS;
+DEFUN_END(put_pixels16uc_no_rnd)
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.c b/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.c
deleted file mode 100644
index 2df551b89a7..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * BlackFin DSPUTILS
- *
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
- * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavcodec/hpeldsp.h"
-#include "hpeldsp_bfin.h"
-
-static void bfin_put_pixels8 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc (block, pixels, pixels, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc (block, pixels, pixels+1, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_y2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc (block, pixels, pixels+line_size, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, ptrdiff_t line_size, int h)
-{
- ff_bfin_z_put_pixels8_xy2 (block,s0,line_size, line_size, h);
-}
-
-static void bfin_put_pixels16 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc (block, pixels, pixels, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_x2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc (block, pixels, pixels+1, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_y2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc (block, pixels, pixels+line_size, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, ptrdiff_t line_size, int h)
-{
- ff_bfin_z_put_pixels16_xy2 (block,s0,line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc_nornd (block, pixels, pixels, line_size, h);
-}
-
-static void bfin_put_pixels8_x2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+1, line_size, h);
-}
-
-static void bfin_put_pixels8_y2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+line_size, line_size, h);
-}
-
-
-static void bfin_put_pixels16_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc_nornd (block, pixels, pixels, line_size, h);
-}
-
-static void bfin_put_pixels16_x2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+1, line_size, h);
-}
-
-static void bfin_put_pixels16_y2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+line_size, line_size, h);
-}
-
-av_cold void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags)
-{
- c->put_pixels_tab[0][0] = bfin_put_pixels16;
- c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
- c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
- c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
-
- c->put_pixels_tab[1][0] = bfin_put_pixels8;
- c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
- c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
- c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
-
- c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_nornd;
- c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_nornd;
- c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_nornd;
-/* c->put_no_rnd_pixels_tab[1][3] = ff_bfin_put_pixels8_xy2_nornd; */
-
- c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_nornd;
- c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_nornd;
- c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_nornd;
-/* c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd; */
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.h b/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.h
deleted file mode 100644
index 36f38722d25..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_bfin.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * BlackFin DSPUTILS COMMON OPTIMIZATIONS HEADER
- *
- * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef AVCODEC_BFIN_HPELDSP_BFIN_H
-#define AVCODEC_BFIN_HPELDSP_BFIN_H
-
-#include <stdint.h>
-
-#include "config.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define attribute_l1_text __attribute__ ((l1_text))
-#define attribute_l1_data_b __attribute__((l1_data_B))
-#else
-#define attribute_l1_text
-#define attribute_l1_data_b
-#endif
-
-void ff_bfin_z_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_z_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16_xy2_nornd (uint8_t *block, const uint8_t *s0, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels8_xy2_nornd (uint8_t *block, const uint8_t *s0, int line_size, int h) attribute_l1_text;
-
-
-void ff_bfin_put_pixels8uc (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16uc (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels8uc_nornd (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16uc_nornd (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) attribute_l1_text;
-
-#endif /* AVCODEC_BFIN_HPELDSP_BFIN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_init.c b/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_init.c
new file mode 100644
index 00000000000..d671e53425e
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/hpeldsp_init.c
@@ -0,0 +1,146 @@
+/*
+ * BlackFin halfpel functions
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
+ * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
+#include "libavcodec/hpeldsp.h"
+#include "pixels.h"
+
+void ff_bfin_put_pixels8uc_no_rnd(uint8_t *block, const uint8_t *s0,
+ const uint8_t *s1, int line_size,
+ int h) attribute_l1_text;
+void ff_bfin_put_pixels16uc_no_rnd(uint8_t *block, const uint8_t *s0,
+ const uint8_t *s1, int line_size,
+ int h) attribute_l1_text;
+
+static void bfin_put_pixels8(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc(block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc(block, pixels, pixels + 1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_y2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc(block, pixels, pixels + line_size,
+ line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_xy2(uint8_t *block, const uint8_t *s0,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_z_put_pixels8_xy2(block, s0, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc(block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_x2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc(block, pixels, pixels + 1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_y2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc(block, pixels, pixels + line_size,
+ line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_xy2(uint8_t *block, const uint8_t *s0,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_z_put_pixels16_xy2(block, s0, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels8_x2_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels + 1, line_size, h);
+}
+
+static void bfin_put_pixels8_y2_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels + line_size,
+ line_size, h);
+}
+
+static void bfin_put_pixels16_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels16_x2_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels + 1, line_size, h);
+}
+
+static void bfin_put_pixels16_y2_no_rnd(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels + line_size,
+ line_size, h);
+}
+
+av_cold void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags)
+{
+ c->put_pixels_tab[0][0] = bfin_put_pixels16;
+ c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
+ c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
+ c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
+
+ c->put_pixels_tab[1][0] = bfin_put_pixels8;
+ c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
+ c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
+ c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
+
+ c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_no_rnd;
+ c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_no_rnd;
+ c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_no_rnd;
+
+ c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_no_rnd;
+ c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_no_rnd;
+ c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_no_rnd;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/idct_bfin.S b/chromium/third_party/ffmpeg/libavcodec/bfin/idct_bfin.S
index bd80447bde8..0ae3f5ac374 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/idct_bfin.S
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/idct_bfin.S
@@ -55,14 +55,9 @@ IDCT BFINidct: 88.3 kdct/s
*/
-#include "config.h"
-#include "config_bfin.h"
+#include "libavutil/bfin/asm.h"
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw",@progbits
-#else
-.data
-#endif
+SECTION_L1_DATA_B
.align 4;
coefs:
@@ -77,9 +72,7 @@ coefs:
.short 0x18F9; //cos(7pi/16)
.short 0x7D8A; //cos(pi/16)
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A,"aw",@progbits
-#endif
+SECTION_L1_DATA_A
vtmp: .space 256
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/mpegvideo_bfin.c b/chromium/third_party/ffmpeg/libavcodec/bfin/mpegvideo_bfin.c
deleted file mode 100644
index 458e7dcdbae..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/mpegvideo_bfin.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * BlackFin MPEGVIDEO OPTIMIZATIONS
- *
- * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/mpegvideo.h"
-#include "dsputil_bfin.h"
-
-static int dct_quantize_bfin (MpegEncContext *s,
- int16_t *block, int n,
- int qscale, int *overflow)
-{
- int last_non_zero, q, start_i;
- const short *qmat;
- short *bias;
- const uint8_t *scantable= s->intra_scantable.scantable;
- short dc;
- int max=0;
-
- PROF("fdct",0);
- s->dsp.fdct(block);
- EPROF();
-
- PROF("denoise",1);
- if(s->dct_error_sum)
- s->denoise_dct(s, block);
- EPROF();
-
- PROF("quant-init",2);
- if (s->mb_intra) {
- if (!s->h263_aic) {
- if (n < 4)
- q = s->y_dc_scale;
- else
- q = s->c_dc_scale;
- q = q << 3;
- } else
- /* For AIC we skip quant/dequant of INTRADC */
- q = 1 << 3;
-
- /* note: block[0] is assumed to be positive */
- dc = block[0] = (block[0] + (q >> 1)) / q;
- start_i = 1;
- last_non_zero = 0;
- if(n<4){
- bias = s->q_intra_matrix16[qscale][1];
- qmat = s->q_intra_matrix16[qscale][0];
- }else{
- bias = s->q_chroma_intra_matrix16[qscale][1];
- qmat = s->q_chroma_intra_matrix16[qscale][0];
- }
-
- } else {
- start_i = 0;
- last_non_zero = -1;
- bias = s->q_inter_matrix16[qscale][1];
- qmat = s->q_inter_matrix16[qscale][0];
-
- }
- EPROF();
-
- PROF("quantize",4);
-
- /* for(i=start_i; i<64; i++) { */
- /* sign = (block[i]>>15)|1; */
- /* level = ((abs(block[i])+bias[0])*qmat[i])>>16; */
- /* if (level < 0) level = 0; */
- /* max |= level; */
- /* level = level * sign; */
- /* block[i] = level; */
- /* } */
-
- __asm__ volatile
- ("i2=%1;\n\t"
- "r1=[%1++]; \n\t"
- "r0=r1>>>15 (v); \n\t"
- "lsetup (0f,1f) lc0=%3; \n\t"
- "0: r0=r0|%4; \n\t"
- " r1=abs r1 (v) || r2=[%2++];\n\t"
- " r1=r1+|+%5; \n\t"
- " r1=max(r1,%6) (v); \n\t"
- " r1.h=(a1 =r1.h*r2.h), r1.l=(a0 =r1.l*r2.l) (tfu); \n\t"
- " %0=%0|r1; \n\t"
- " r0.h=(a1 =r1.h*r0.h), r0.l=(a0 =r1.l*r0.l) (is) || r1=[%1++];\n\t"
- "1: r0=r1>>>15 (v) || [i2++]=r0;\n\t"
- "r1=%0>>16; \n\t"
- "%0=%0|r1; \n\t"
- "%0.h=0; \n\t"
- : "=&d" (max)
- : "b" (block), "b" (qmat), "a" (32), "d" (0x00010001), "d" (bias[0]*0x10001), "d" (0)
- : "R0","R1","R2", "I2");
- if (start_i == 1) block[0] = dc;
-
- EPROF();
-
-
- PROF("zzscan",5);
-
- __asm__ volatile
- ("r0=b[%1--] (x); \n\t"
- "lsetup (0f,1f) lc0=%3; \n\t" /* for(i=63; i>=start_i; i--) { */
- "0: p0=r0; \n\t" /* j = scantable[i]; */
- " p0=%2+(p0<<1); \n\t" /* if (block[j]) { */
- " r0=w[p0]; \n\t" /* last_non_zero = i; */
- " cc=r0==0; \n\t" /* break; */
- " if !cc jump 2f; \n\t" /* } */
- "1: r0=b[%1--] (x); \n\t" /* } */
- " %0=%4; \n\t"
- " jump 3f; \n\t"
- "2: %0=lc0; \n\t"
- "3:\n\t"
-
- : "=d" (last_non_zero)
- : "a" (scantable+63), "a" (block), "a" (63), "d" (last_non_zero)
- : "P0","R0");
-
- EPROF();
-
- *overflow= s->max_qcoeff < max; //overflow might have happened
-
- bfprof();
-
- /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
- if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
- ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
-
- return last_non_zero;
-}
-
-av_cold void ff_MPV_common_init_bfin (MpegEncContext *s)
-{
-/* s->dct_quantize= dct_quantize_bfin; */
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_bfin.S b/chromium/third_party/ffmpeg/libavcodec/bfin/pixels.S
index c0cbf1f7f90..50a3bd3aba7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/hpel_pixels_bfin.S
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/pixels.S
@@ -18,7 +18,8 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config_bfin.h"
+
+#include "libavutil/bfin/asm.h"
/*
motion compensation
@@ -96,70 +97,6 @@ pp16$1: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
RTS;
DEFUN_END(put_pixels16uc)
-
-
-
-
-
-DEFUN(put_pixels8uc_nornd,mL1,
- (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
- int line_size, int h)):
- i3=r0; // dest
- i0=r1; // src0
- i1=r2; // src1
- r2=[sp+12]; // line_size
- p0=[sp+16]; // h
- [--sp] = (r7:6);
- r2+=-4;
- m3=r2;
- r2+=-4;
- m0=r2;
- LSETUP(pp8$2,pp8$3) LC0=P0;
- DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
-
-pp8$2: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
- R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0]|| R2 =[I1++M0];
- R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R6 ;
-pp8$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
-
- (r7:6) = [sp++];
- RTS;
-DEFUN_END(put_pixels8uc_nornd)
-
-DEFUN(put_pixels16uc_nornd,mL1,
- (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
- int line_size, int h)):
- i3=r0; // dest
- i0=r1; // src0
- i1=r2; // src1
- r2=[sp+12]; // line_size
- p0=[sp+16]; // h
-
- [--sp] = (r7:6);
- r2+=-12;
- m3=r2; // line_size
- r2+=-4;
- m0=r2;
-
- LSETUP(pp16$2,pp16$3) LC0=P0;
- DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
-
-pp16$2:
- DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
- R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++] || R2 =[I1++];
- R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++] || R3 =[I1++];
- [I3++] = R6;
-
- R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0] || R2 =[I1++M0];
- R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R7 ;
- [I3++] = R6;
-pp16$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
-
- (r7:6) = [sp++];
-
- RTS;
-DEFUN_END(put_pixels16uc_nornd)
-
DEFUN(z_put_pixels16_xy2,mL1,
(uint8_t *block, const uint8_t *s0,
int dest_size, int line_size, int h)):
@@ -219,64 +156,6 @@ LE$16O: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
rts;
DEFUN_END(z_put_pixels16_xy2)
-DEFUN(put_pixels16_xy2_nornd,mL1,
- (uint8_t *block, const uint8_t *s0,
- int line_size, int h)):
- link 0;
- [--sp] = (r7:4);
- i3=r0; // dest
- i0=r1; // src0--> pixels
- i1=r1; // src1--> pixels + line_size
- m3=r2;
- r2+=-12;
- m2=r2;
- r2+=-4;
- i1+=m3; /* src1 + line_size */
- m0=r2; /* line-size - 20 */
- p0=[fp+20]; // h
-
- B0=I0;
- B1=I1;
- B3=I3;
-
- DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
-
- LSETUP(LS$16ET,LE$16ET) LC0=P0;
-LS$16ET:DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
- R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++] || R2 =[I1++];
- R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R1 = [I0++] || [I3++] = R4 ;
- DISALGNEXCPT || R3 = [I1++] || [I3++] = R5;
- R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++M0]|| R2 = [I1++M0];
- R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R0 = [I0++] || [I3++] = R4 ;
-LE$16ET:DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
-
- M1 = 1;
- I3=B3;
- I1=B1;
- I0=B0;
-
- I0 += M1;
- I1 += M1;
-
- DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
- LSETUP(LS$16OT,LE$16OT) LC0=P0;
-LS$16OT:DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
- R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++] || R2 =[I1++];
- R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R1 = [I0++] || R6 =[I3++];
- R4 = R4 +|+ R6 || R7 = [I3--];
- R5 = R5 +|+ R7 || [I3++] = R4;
- DISALGNEXCPT || R3 =[I1++] || [I3++] = R5;
- R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++M0]|| R2 = [I1++M0];
- R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R0 = [I0++] || R6 = [I3++];
- R4 = R4 +|+ R6 || R7 = [I3--];
- R5 = R5 +|+ R7 || [I3++] = R4;
-LE$16OT:DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
-
- (r7:4) = [sp++];
- unlink;
- rts;
-DEFUN_END(put_pixels16_xy2_nornd)
-
DEFUN(z_put_pixels8_xy2,mL1,
(uint8_t *block, const uint8_t *s0,
int dest_size, int line_size, int h)):
@@ -326,54 +205,3 @@ LE$8O: DISALGNEXCPT || R2 =[I1++] || [I3++M2] = R5;
unlink;
rts;
DEFUN_END(z_put_pixels8_xy2)
-
-DEFUN(put_pixels8_xy2_nornd,mL1,
- (uint8_t *block, const uint8_t *s0, int line_size, int h)):
- link 0;
- [--sp] = (r7:4);
- i3=r0; // dest
- i0=r1; // src0--> pixels
- i1=r1; // src1--> pixels + line_size
- m3=r2;
- r2+=-4;
- m2=r2;
- r2+=-4;
- i1+=m3; /* src1 + line_size */
- m0=r2; /* line-size - 20 */
- p0=[fp+20]; // h
-
-
- b0 = I0;
- b1 = I1;
- b3 = I3;
-
- LSETUP(LS$8ET,LE$8ET) LC0=P0;
- DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
-
-LS$8ET: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
- R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++M0] || R2 = [I1++M0];
- R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R0 = [I0++] || [I3++] = R4 ;
-LE$8ET: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
-
- M1 = 1;
- I3 = b3;
- I1 = b1;
- I0 = b0;
-
- I0 += M1;
- I1 += M1;
-
- LSETUP(LS$8OT,LE$8OT) LC0=P0;
- DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
-
-LS$8OT: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
- R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++M0] || R2 = [I1++M0];
- R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R0 = [I0++] || R6 = [I3++];
- R4 = R4 +|+ R6 || R7 = [I3--];
- R5 = R5 +|+ R7 || [I3++] = R4;
-LE$8OT: DISALGNEXCPT || R2 =[I1++] || [I3++M2] = R5;
-
- (r7:4) = [sp++];
- unlink;
- rts;
-DEFUN_END(put_pixels8_xy2_nornd)
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/pixels.h b/chromium/third_party/ffmpeg/libavcodec/bfin/pixels.h
new file mode 100644
index 00000000000..78a714e1a55
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/pixels.h
@@ -0,0 +1,42 @@
+/*
+ * BlackFin DSPUTILS COMMON OPTIMIZATIONS HEADER
+ *
+ * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_BFIN_PIXELS_H
+#define AVCODEC_BFIN_PIXELS_H
+
+#include <stdint.h>
+
+#include "libavutil/bfin/attributes.h"
+
+void ff_bfin_z_put_pixels16_xy2(uint8_t *block, const uint8_t *s0,
+ int dest_size, int line_size, int h) attribute_l1_text;
+void ff_bfin_z_put_pixels8_xy2(uint8_t *block, const uint8_t *s0,
+ int dest_size, int line_size, int h) attribute_l1_text;
+
+void ff_bfin_put_pixels8uc(uint8_t *block, const uint8_t *s0,
+ const uint8_t *s1, int dest_size, int line_size,
+ int h) attribute_l1_text;
+void ff_bfin_put_pixels16uc(uint8_t *block, const uint8_t *s0,
+ const uint8_t *s1, int dest_size, int line_size,
+ int h) attribute_l1_text;
+
+#endif /* AVCODEC_BFIN_PIXELS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_idct_bfin.S b/chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp.S
index 4e200459f42..216926c104c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_idct_bfin.S
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp.S
@@ -28,14 +28,9 @@ Registers Used : A0, A1, R0-R7, I0-I3, B0, B2, B3, M0-M2, L0-L3, P0-P5, LC0.
*/
-#include "config.h"
-#include "config_bfin.h"
+#include "libavutil/bfin/asm.h"
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw",@progbits
-#else
-.data
-#endif
+SECTION_L1_DATA_B
.align 4;
coefs:
@@ -50,9 +45,7 @@ coefs:
.short 0x18F9; //cos(7pi/16)
.short 0x7D8A; //cos(pi/16)
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A
-#endif
+SECTION_L1_DATA_A
vtmp: .space 256
diff --git a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.c b/chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp_init.c
index 868c4314926..739750b6e48 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bfin/vp3_bfin.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bfin/vp3dsp_init.c
@@ -18,19 +18,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
#include <string.h>
#include "libavutil/attributes.h"
#include "libavcodec/avcodec.h"
+#include "libavcodec/mathops.h"
#include "libavcodec/vp3dsp.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_bfin.h"
-#include "vp3_bfin.h"
+
+void ff_bfin_vp3_idct(int16_t *block);
/* Intra iDCT offset 128 */
static void bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + 128;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP + 128;
int i,j;
ff_bfin_vp3_idct (block);
@@ -45,7 +46,7 @@ static void bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block)
/* Inter iDCT */
static void bfin_vp3_idct_add(uint8_t *dest, int line_size, int16_t *block)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int i, j;
ff_bfin_vp3_idct (block);
diff --git a/chromium/third_party/ffmpeg/libavcodec/bink.c b/chromium/third_party/ffmpeg/libavcodec/bink.c
index 8f8a036d4f7..f23542f17e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bink.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bink.c
@@ -185,7 +185,7 @@ static av_cold int init_bundles(BinkContext *c)
blocks = bw * bh;
for (i = 0; i < BINKB_NB_SRC; i++) {
- c->bundle[i].data = av_malloc(blocks * 64);
+ c->bundle[i].data = av_mallocz(blocks * 64);
if (!c->bundle[i].data)
return AVERROR(ENOMEM);
c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
diff --git a/chromium/third_party/ffmpeg/libavcodec/binkaudio.c b/chromium/third_party/ffmpeg/libavcodec/binkaudio.c
index 8db4533221c..ffa32d12aa9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/binkaudio.c
+++ b/chromium/third_party/ffmpeg/libavcodec/binkaudio.c
@@ -306,6 +306,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf)
return AVERROR(ENOMEM);
+ memset(buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
s->packet_buffer = buf;
memcpy(s->packet_buffer, avpkt->data, avpkt->size);
if ((ret = init_get_bits8(gb, s->packet_buffer, avpkt->size)) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/binkdsp.c b/chromium/third_party/ffmpeg/libavcodec/binkdsp.c
index a23f9c73bde..5b3c26229f5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/binkdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/binkdsp.c
@@ -25,7 +25,6 @@
*/
#include "libavutil/attributes.h"
-#include "dsputil.h"
#include "binkdsp.h"
#define A1 2896 /* (1/sqrt(2))<<12 */
diff --git a/chromium/third_party/ffmpeg/libavcodec/bit_depth_template.c b/chromium/third_party/ffmpeg/libavcodec/bit_depth_template.c
index 96f5edec0f7..80184892f5a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bit_depth_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bit_depth_template.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "mathops.h"
#include "rnd_avg.h"
#include "libavutil/intreadwrite.h"
@@ -23,7 +24,7 @@
#define BIT_DEPTH 8
#endif
-#ifdef AVCODEC_H264_HIGH_DEPTH_H
+#ifdef AVCODEC_BIT_DEPTH_TEMPLATE_C
# undef pixel
# undef pixel2
# undef pixel4
@@ -43,7 +44,7 @@
# undef av_clip_pixel
# undef PIXEL_SPLAT_X4
#else
-# define AVCODEC_H264_HIGH_DEPTH_H
+# define AVCODEC_BIT_DEPTH_TEMPLATE_C
#endif
#if BIT_DEPTH > 8
diff --git a/chromium/third_party/ffmpeg/libavcodec/bitstream.c b/chromium/third_party/ffmpeg/libavcodec/bitstream.c
index 1a346266ec9..5cb86317556 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bitstream.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bitstream.c
@@ -108,7 +108,6 @@ static int alloc_table(VLC *vlc, int size, int use_static)
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
- int err;
if (use_static)
abort(); // cannot do anything, init_vlc() is used with too little memory
vlc->table_allocated += (1 << vlc->bits);
@@ -233,6 +232,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
/* note: realloc has been done, so reload tables */
table = &vlc->table[table_index];
table[j][0] = index; //code
+ av_assert0(table[j][0] == index);
i = k-1;
}
}
@@ -293,7 +293,7 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
vlc->table_allocated = 0;
vlc->table_size = 0;
- buf = av_malloc((nb_codes + 1) * sizeof(VLCcode));
+ buf = av_malloc_array((nb_codes + 1), sizeof(VLCcode));
if (!buf)
return AVERROR(ENOMEM);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bmp.c b/chromium/third_party/ffmpeg/libavcodec/bmp.c
index 404c47dece7..47ff9786325 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bmp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bmp.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "bytestream.h"
#include "bmp.h"
@@ -58,7 +60,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
fsize = bytestream_get_le32(&buf);
if (buf_size < fsize) {
- av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d), trying to decode anyway\n",
+ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %u), trying to decode anyway\n",
buf_size, fsize);
fsize = buf_size;
}
@@ -69,7 +71,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
hsize = bytestream_get_le32(&buf); /* header size */
ihsize = bytestream_get_le32(&buf); /* more header size */
if (ihsize + 14 > hsize) {
- av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
+ av_log(avctx, AV_LOG_ERROR, "invalid header size %u\n", hsize);
return AVERROR_INVALIDDATA;
}
@@ -78,7 +80,8 @@ static int bmp_decode_frame(AVCodecContext *avctx,
fsize = buf_size - 2;
if (fsize <= hsize) {
- av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n",
+ av_log(avctx, AV_LOG_ERROR,
+ "Declared file size is less than header size (%u < %u)\n",
fsize, hsize);
return AVERROR_INVALIDDATA;
}
@@ -166,7 +169,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
avctx->pix_fmt = AV_PIX_FMT_RGB444;
else {
- av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
+ av_log(avctx, AV_LOG_ERROR,
+ "Unknown bitfields %0"PRIX32" %0"PRIX32" %0"PRIX32"\n",
+ rgb[0], rgb[1], rgb[2]);
return AVERROR(EINVAL);
}
}
@@ -182,12 +187,13 @@ static int bmp_decode_frame(AVCodecContext *avctx,
if (hsize - ihsize - 14 > 0) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else {
- av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth);
+ av_log(avctx, AV_LOG_ERROR, "Unknown palette for %u-colour BMP\n",
+ 1 << depth);
return AVERROR_INVALIDDATA;
}
break;
default:
- av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
+ av_log(avctx, AV_LOG_ERROR, "depth %u not supported\n", depth);
return AVERROR_INVALIDDATA;
}
@@ -235,7 +241,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
buf = buf0 + 46;
t = bytestream_get_le32(&buf);
if (t < 0 || t > (1 << depth)) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth);
+ av_log(avctx, AV_LOG_ERROR,
+ "Incorrect number of colors - %X for bitdepth %u\n",
+ t, depth);
} else if (t) {
colors = t;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/bmp_parser.c b/chromium/third_party/ffmpeg/libavcodec/bmp_parser.c
index 06ed367b38f..eae8ae0a7f1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bmp_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/bmp_parser.c
@@ -25,6 +25,8 @@
*/
#include "libavutil/bswap.h"
+#include "libavutil/common.h"
+
#include "parser.h"
typedef struct BMPParseContext {
@@ -42,8 +44,6 @@ static int bmp_parse(AVCodecParserContext *s, AVCodecContext *avctx,
int next = END_NOT_FOUND;
int i = 0;
- s->pict_type = AV_PICTURE_TYPE_NONE;
-
*poutbuf_size = 0;
if (buf_size == 0)
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/brender_pix.c b/chromium/third_party/ffmpeg/libavcodec/brender_pix.c
deleted file mode 100644
index 23a46cc0edc..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/brender_pix.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * BRender PIX (.pix) image decoder
- * Copyright (c) 2012 Aleksi Nurmi
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Tested against samples from I-War / Independence War and Defiance.
- * If the PIX file does not contain a palette, the
- * palette_has_changed property of the AVFrame is set to 0.
- */
-
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
-#include "bytestream.h"
-#include "internal.h"
-
-typedef struct BRPixHeader {
- int format;
- unsigned int width, height;
-} BRPixHeader;
-
-static int brpix_decode_header(BRPixHeader *out, GetByteContext *pgb)
-{
- unsigned int header_len = bytestream2_get_be32(pgb);
-
- out->format = bytestream2_get_byte(pgb);
- bytestream2_skip(pgb, 2);
- out->width = bytestream2_get_be16(pgb);
- out->height = bytestream2_get_be16(pgb);
-
- // the header is at least 11 bytes long; we read the first 7
- if (header_len < 11) {
- return 0;
- }
-
- // skip the rest of the header
- bytestream2_skip(pgb, header_len-7);
-
- return 1;
-}
-
-static int brpix_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt)
-{
- AVFrame *frame = data;
-
- int ret;
- GetByteContext gb;
-
- unsigned int bytes_pp;
-
- unsigned int magic[4];
- unsigned int chunk_type;
- unsigned int data_len;
- BRPixHeader hdr;
-
- bytestream2_init(&gb, avpkt->data, avpkt->size);
-
- magic[0] = bytestream2_get_be32(&gb);
- magic[1] = bytestream2_get_be32(&gb);
- magic[2] = bytestream2_get_be32(&gb);
- magic[3] = bytestream2_get_be32(&gb);
-
- if (magic[0] != 0x12 ||
- magic[1] != 0x8 ||
- magic[2] != 0x2 ||
- magic[3] != 0x2) {
- av_log(avctx, AV_LOG_ERROR, "Not a BRender PIX file\n");
- return AVERROR_INVALIDDATA;
- }
-
- chunk_type = bytestream2_get_be32(&gb);
- if (chunk_type != 0x3 && chunk_type != 0x3d) {
- av_log(avctx, AV_LOG_ERROR, "Invalid chunk type %d\n", chunk_type);
- return AVERROR_INVALIDDATA;
- }
-
- ret = brpix_decode_header(&hdr, &gb);
- if (!ret) {
- av_log(avctx, AV_LOG_ERROR, "Invalid header length\n");
- return AVERROR_INVALIDDATA;
- }
- switch (hdr.format) {
- case 3:
- avctx->pix_fmt = AV_PIX_FMT_PAL8;
- bytes_pp = 1;
- break;
- case 4:
- avctx->pix_fmt = AV_PIX_FMT_RGB555BE;
- bytes_pp = 2;
- break;
- case 5:
- avctx->pix_fmt = AV_PIX_FMT_RGB565BE;
- bytes_pp = 2;
- break;
- case 6:
- avctx->pix_fmt = AV_PIX_FMT_RGB24;
- bytes_pp = 3;
- break;
- case 7:
- avctx->pix_fmt = AV_PIX_FMT_0RGB;
- bytes_pp = 4;
- break;
- case 18:
- avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
- bytes_pp = 2;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Format %d is not supported\n",
- hdr.format);
- return AVERROR_PATCHWELCOME;
- }
-
- if ((ret = ff_set_dimensions(avctx, hdr.width, hdr.height)) < 0)
- return ret;
-
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
- return ret;
-
- chunk_type = bytestream2_get_be32(&gb);
-
- if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
- (chunk_type == 0x3 || chunk_type == 0x3d)) {
- BRPixHeader palhdr;
- uint32_t *pal_out = (uint32_t *)frame->data[1];
- int i;
-
- ret = brpix_decode_header(&palhdr, &gb);
- if (!ret) {
- av_log(avctx, AV_LOG_ERROR, "Invalid palette header length\n");
- return AVERROR_INVALIDDATA;
- }
- if (palhdr.format != 7) {
- av_log(avctx, AV_LOG_ERROR, "Palette is not in 0RGB format\n");
- return AVERROR_INVALIDDATA;
- }
-
- chunk_type = bytestream2_get_be32(&gb);
- data_len = bytestream2_get_be32(&gb);
- bytestream2_skip(&gb, 8);
- if (chunk_type != 0x21 || data_len != 1032 ||
- bytestream2_get_bytes_left(&gb) < 1032) {
- av_log(avctx, AV_LOG_ERROR, "Invalid palette data\n");
- return AVERROR_INVALIDDATA;
- }
- // convert 0RGB to machine endian format (ARGB32)
- for (i = 0; i < 256; ++i) {
- bytestream2_skipu(&gb, 1);
- *pal_out++ = (0xFFU << 24) | bytestream2_get_be24u(&gb);
- }
- bytestream2_skip(&gb, 8);
-
- frame->palette_has_changed = 1;
-
- chunk_type = bytestream2_get_be32(&gb);
- } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
- uint32_t *pal_out = (uint32_t *)frame->data[1];
- int i;
-
- for (i = 0; i < 256; ++i) {
- *pal_out++ = (0xFFU << 24) | (i * 0x010101);
- }
- frame->palette_has_changed = 1;
- }
-
- data_len = bytestream2_get_be32(&gb);
- bytestream2_skip(&gb, 8);
-
- // read the image data to the buffer
- {
- unsigned int bytes_per_scanline = bytes_pp * hdr.width;
- unsigned int bytes_left = bytestream2_get_bytes_left(&gb);
-
- if (chunk_type != 0x21 || data_len != bytes_left ||
- bytes_left / bytes_per_scanline < hdr.height)
- {
- av_log(avctx, AV_LOG_ERROR, "Invalid image data\n");
- return AVERROR_INVALIDDATA;
- }
-
- av_image_copy_plane(frame->data[0], frame->linesize[0],
- avpkt->data + bytestream2_tell(&gb),
- bytes_per_scanline,
- bytes_per_scanline, hdr.height);
- }
-
- *got_frame = 1;
-
- return avpkt->size;
-}
-
-AVCodec ff_brender_pix_decoder = {
- .name = "brender_pix",
- .long_name = NULL_IF_CONFIG_SMALL("BRender PIX image"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_BRENDER_PIX,
- .decode = brpix_decode_frame,
- .capabilities = CODEC_CAP_DR1,
-};
diff --git a/chromium/third_party/ffmpeg/libavcodec/brenderpix.c b/chromium/third_party/ffmpeg/libavcodec/brenderpix.c
new file mode 100644
index 00000000000..e0d033fcf91
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/brenderpix.c
@@ -0,0 +1,292 @@
+/*
+ * BRender PIX (.pix) image decoder
+ * Copyright (c) 2012 Aleksi Nurmi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* Tested against samples from I-War / Independence War and Defiance. */
+
+#include "libavutil/imgutils.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define HEADER1_CHUNK 0x03
+#define HEADER2_CHUNK 0x3D
+#define IMAGE_DATA_CHUNK 0x21
+
+/* In 8-bit colour mode, 256 colours are available at any time. Which 256
+ * colours are available is determined by the contents of the hardware palette
+ * (or CLUT). In this case, the palette supplied with BRender (std.pal) has
+ * been loaded into the CLUT.
+ *
+ * The 256 colours in std.pal are divided into seven ranges, or `colour ramps'.
+ * The first 64 colours represent shades of grey ranging from very dark grey
+ * (black) to very light grey (white). The following colours are 32-element
+ * ramps for six colours as shown below.
+ */
+static const uint32_t std_pal_table[256] = {
+ // gray
+ 0xFF000000, 0xFF030303, 0xFF060606, 0xFF090909, 0xFF0C0C0C, 0xFF0F0F0F,
+ 0xFF121212, 0xFF151515, 0xFF181818, 0xFF1B1B1B, 0xFF1E1E1E, 0xFF212121,
+ 0xFF242424, 0xFF272727, 0xFF2A2A2A, 0xFF2D2D2D, 0xFF313131, 0xFF343434,
+ 0xFF373737, 0xFF3A3A3A, 0xFF3D3D3D, 0xFF404040, 0xFF434343, 0xFF464646,
+ 0xFF494949, 0xFF4C4C4C, 0xFF4F4F4F, 0xFF525252, 0xFF555555, 0xFF585858,
+ 0xFF5B5B5B, 0xFF5E5E5E, 0xFF626262, 0xFF656565, 0xFF686868, 0xFF6B6B6B,
+ 0xFF6E6E6E, 0xFF717171, 0xFF747474, 0xFF777777, 0xFF7A7A7A, 0xFF7D7D7D,
+ 0xFF808080, 0xFF838383, 0xFF868686, 0xFF898989, 0xFF8C8C8C, 0xFF8F8F8F,
+ 0xFF939393, 0xFF999999, 0xFFA0A0A0, 0xFFA7A7A7, 0xFFAEAEAE, 0xFFB4B4B4,
+ 0xFFBBBBBB, 0xFFC2C2C2, 0xFFC9C9C9, 0xFFCFCFCF, 0xFFD6D6D6, 0xFFDDDDDD,
+ 0xFFE4E4E4, 0xFFEAEAEA, 0xFFF1F1F1, 0xFFF8F8F8,
+
+ // blue
+ 0xFF000000, 0xFF020209, 0xFF050513, 0xFF07071D, 0xFF0A0A27, 0xFF0C0C31,
+ 0xFF0F0F3B, 0xFF111145, 0xFF14144F, 0xFF161659, 0xFF181863, 0xFF1B1B6D,
+ 0xFF1E1E77, 0xFF202080, 0xFF22228A, 0xFF252594, 0xFF28289E, 0xFF2A2AA8,
+ 0xFF2D2DB2, 0xFF2F2FBC, 0xFF3131C6, 0xFF3434D0, 0xFF3737DA, 0xFF3939E4,
+ 0xFF3C3CEE, 0xFF5454F0, 0xFF6C6CF2, 0xFF8585F4, 0xFF9D9DF6, 0xFFB5B5F8,
+ 0xFFCECEFA, 0xFFE6E6FC,
+
+ // green
+ 0xFF000000, 0xFF020902, 0xFF051305, 0xFF071D07, 0xFF0A270A, 0xFF0C310C,
+ 0xFF0F3B0F, 0xFF114511, 0xFF144F14, 0xFF165916, 0xFF186318, 0xFF1B6D1B,
+ 0xFF1E771E, 0xFF208020, 0xFF228A22, 0xFF259425, 0xFF289E28, 0xFF2AA82A,
+ 0xFF2DB22D, 0xFF2FBC2F, 0xFF31C631, 0xFF34D034, 0xFF37DA37, 0xFF39E439,
+ 0xFF3CEE3C, 0xFF54F054, 0xFF6CF26C, 0xFF85F485, 0xFF9DF69D, 0xFFB5F8B5,
+ 0xFFCEFACE, 0xFFE6FCE6,
+
+ // cyan
+ 0xFF000000, 0xFF020909, 0xFF051313, 0xFF071D1D, 0xFF0A2727, 0xFF0C3131,
+ 0xFF0F3B3B, 0xFF114545, 0xFF144F4F, 0xFF165959, 0xFF186363, 0xFF1B6D6D,
+ 0xFF1E7777, 0xFF208080, 0xFF228A8A, 0xFF259494, 0xFF289E9E, 0xFF2AA8A8,
+ 0xFF2DB2B2, 0xFF2FBCBC, 0xFF31C6C6, 0xFF34D0D0, 0xFF37DADA, 0xFF39E4E4,
+ 0xFF3CEEEE, 0xFF54F0F0, 0xFF6CF2F2, 0xFF85F4F4, 0xFF9DF6F6, 0xFFB5F8F8,
+ 0xFFCEFAFA, 0xFFE6FCFC,
+
+ // red
+ 0xFF000000, 0xFF090202, 0xFF130505, 0xFF1D0707, 0xFF270A0A, 0xFF310C0C,
+ 0xFF3B0F0F, 0xFF451111, 0xFF4F1414, 0xFF591616, 0xFF631818, 0xFF6D1B1B,
+ 0xFF771E1E, 0xFF802020, 0xFF8A2222, 0xFF942525, 0xFF9E2828, 0xFFA82A2A,
+ 0xFFB22D2D, 0xFFBC2F2F, 0xFFC63131, 0xFFD03434, 0xFFDA3737, 0xFFE43939,
+ 0xFFEE3C3C, 0xFFF05454, 0xFFF26C6C, 0xFFF48585, 0xFFF69D9D, 0xFFF8B5B5,
+ 0xFFFACECE, 0xFFFCE6E6,
+
+ // magenta
+ 0xFF000000, 0xFF090209, 0xFF130513, 0xFF1D071D, 0xFF270A27, 0xFF310C31,
+ 0xFF3B0F3B, 0xFF451145, 0xFF4F144F, 0xFF591659, 0xFF631863, 0xFF6D1B6D,
+ 0xFF771E77, 0xFF802080, 0xFF8A228A, 0xFF942594, 0xFF9E289E, 0xFFA82AA8,
+ 0xFFB22DB2, 0xFFBC2FBC, 0xFFC631C6, 0xFFD034D0, 0xFFDA37DA, 0xFFE439E4,
+ 0xFFEE3CEE, 0xFFF054F0, 0xFFF26CF2, 0xFFF485F4, 0xFFF69DF6, 0xFFF8B5F8,
+ 0xFFFACEFA, 0xFFFCE6FC,
+
+ // yellow
+ 0xFF000000, 0xFF090902, 0xFF131305, 0xFF1D1D07, 0xFF27270A, 0xFF31310C,
+ 0xFF3B3B0F, 0xFF454511, 0xFF4F4F14, 0xFF595916, 0xFF636318, 0xFF6D6D1B,
+ 0xFF77771E, 0xFF808020, 0xFF8A8A22, 0xFF949425, 0xFF9E9E28, 0xFFA8A82A,
+ 0xFFB2B22D, 0xFFBCBC2F, 0xFFC6C631, 0xFFD0D034, 0xFFDADA37, 0xFFE4E439,
+ 0xFFEEEE3C, 0xFFF0F054, 0xFFF2F26C, 0xFFF4F485, 0xFFF6F69D, 0xFFF8F8B5,
+ 0xFFFAFACE, 0xFFFCFCE6,
+};
+
+typedef struct PixHeader {
+ int width;
+ int height;
+ int format;
+} PixHeader;
+
+static int pix_decode_header(PixHeader *out, GetByteContext *pgb)
+{
+ unsigned int header_len = bytestream2_get_be32(pgb);
+
+ out->format = bytestream2_get_byte(pgb);
+ bytestream2_skip(pgb, 2);
+ out->width = bytestream2_get_be16(pgb);
+ out->height = bytestream2_get_be16(pgb);
+
+ // the header is at least 11 bytes long; we read the first 7
+ if (header_len < 11)
+ return AVERROR_INVALIDDATA;
+
+ // skip the rest of the header
+ bytestream2_skip(pgb, header_len - 7);
+
+ return 0;
+}
+
+static int pix_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+ AVPacket *avpkt)
+{
+ AVFrame *frame = data;
+
+ int ret, i;
+ GetByteContext gb;
+
+ unsigned int bytes_pp;
+ unsigned int magic[4];
+ unsigned int chunk_type;
+ unsigned int data_len;
+ unsigned int bytes_per_scanline;
+ unsigned int bytes_left;
+ PixHeader hdr;
+
+ bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+ magic[0] = bytestream2_get_be32(&gb);
+ magic[1] = bytestream2_get_be32(&gb);
+ magic[2] = bytestream2_get_be32(&gb);
+ magic[3] = bytestream2_get_be32(&gb);
+
+ if (magic[0] != 0x12 ||
+ magic[1] != 0x08 ||
+ magic[2] != 0x02 ||
+ magic[3] != 0x02) {
+ av_log(avctx, AV_LOG_ERROR, "Not a BRender PIX file.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ chunk_type = bytestream2_get_be32(&gb);
+ if (chunk_type != HEADER1_CHUNK && chunk_type != HEADER2_CHUNK) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid chunk type %d.\n", chunk_type);
+ return AVERROR_INVALIDDATA;
+ }
+
+ ret = pix_decode_header(&hdr, &gb);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid header length.\n");
+ return ret;
+ }
+ switch (hdr.format) {
+ case 3:
+ avctx->pix_fmt = AV_PIX_FMT_PAL8;
+ bytes_pp = 1;
+ break;
+ case 4:
+ avctx->pix_fmt = AV_PIX_FMT_RGB555BE;
+ bytes_pp = 2;
+ break;
+ case 5:
+ avctx->pix_fmt = AV_PIX_FMT_RGB565BE;
+ bytes_pp = 2;
+ break;
+ case 6:
+ avctx->pix_fmt = AV_PIX_FMT_RGB24;
+ bytes_pp = 3;
+ break;
+ case 7:
+ avctx->pix_fmt = AV_PIX_FMT_0RGB;
+ bytes_pp = 4;
+ break;
+ case 8: // ARGB
+ avctx->pix_fmt = AV_PIX_FMT_ARGB;
+ bytes_pp = 4;
+ break;
+ case 18:
+ avctx->pix_fmt = AV_PIX_FMT_Y400A;
+ bytes_pp = 2;
+ break;
+ default:
+ avpriv_request_sample(avctx, "Format %d", hdr.format);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ if ((ret = ff_set_dimensions(avctx, hdr.width, hdr.height)) < 0)
+ return ret;
+
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+ return ret;
+
+ chunk_type = bytestream2_get_be32(&gb);
+
+ if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
+ (chunk_type == HEADER1_CHUNK ||
+ chunk_type == HEADER2_CHUNK)) {
+ /* read palette data from data[1] */
+ PixHeader palhdr;
+ uint32_t *pal_out = (uint32_t *)frame->data[1];
+
+ ret = pix_decode_header(&palhdr, &gb);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid palette header length.\n");
+ return ret;
+ }
+ if (palhdr.format != 7)
+ avpriv_request_sample(avctx, "Palette not in RGB format");
+
+ chunk_type = bytestream2_get_be32(&gb);
+ data_len = bytestream2_get_be32(&gb);
+ bytestream2_skip(&gb, 8);
+ if (chunk_type != IMAGE_DATA_CHUNK || data_len != 1032 ||
+ bytestream2_get_bytes_left(&gb) < 1032) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid palette data.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ // palette data is surrounded by 8 null bytes (both top and bottom)
+ // convert 0RGB to machine endian format (ARGB32)
+ for (i = 0; i < 256; ++i)
+ *pal_out++ = (0xFFU << 24) | bytestream2_get_be32u(&gb);
+ bytestream2_skip(&gb, 8);
+
+ frame->palette_has_changed = 1;
+
+ chunk_type = bytestream2_get_be32(&gb);
+ } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+ /* no palette supplied, use the default one */
+ uint32_t *pal_out = (uint32_t *)frame->data[1];
+
+ // TODO: add an AVOption to load custom palette files
+ av_log(avctx, AV_LOG_WARNING,
+ "Using default palette, colors might be off.\n");
+ memcpy(pal_out, std_pal_table, sizeof(uint32_t) * 256);
+
+ frame->palette_has_changed = 1;
+ }
+
+ data_len = bytestream2_get_be32(&gb);
+ bytestream2_skip(&gb, 8);
+
+ // read the image data to the buffer
+ bytes_per_scanline = bytes_pp * hdr.width;
+ bytes_left = bytestream2_get_bytes_left(&gb);
+
+ if (chunk_type != IMAGE_DATA_CHUNK || data_len != bytes_left ||
+ bytes_left / bytes_per_scanline < hdr.height) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid image data.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ av_image_copy_plane(frame->data[0], frame->linesize[0],
+ avpkt->data + bytestream2_tell(&gb),
+ bytes_per_scanline,
+ bytes_per_scanline, hdr.height);
+
+ frame->pict_type = AV_PICTURE_TYPE_I;
+ frame->key_frame = 1;
+ *got_frame = 1;
+
+ return avpkt->size;
+}
+
+AVCodec ff_brender_pix_decoder = {
+ .name = "brender_pix",
+ .long_name = NULL_IF_CONFIG_SMALL("BRender PIX image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_BRENDER_PIX,
+ .decode = pix_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/bytestream.h b/chromium/third_party/ffmpeg/libavcodec/bytestream.h
index f2458591cb7..c2cb6018061 100644
--- a/chromium/third_party/ffmpeg/libavcodec/bytestream.h
+++ b/chromium/third_party/ffmpeg/libavcodec/bytestream.h
@@ -328,6 +328,32 @@ static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
return p->eof;
}
+static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p,
+ GetByteContext *g,
+ unsigned int size)
+{
+ memcpy(p->buffer, g->buffer, size);
+ p->buffer += size;
+ g->buffer += size;
+ return size;
+}
+
+static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p,
+ GetByteContext *g,
+ unsigned int size)
+{
+ int size2;
+
+ if (p->eof)
+ return 0;
+ size = FFMIN(g->buffer_end - g->buffer, size);
+ size2 = FFMIN(p->buffer_end - p->buffer, size);
+ if (size2 != size)
+ p->eof = 1;
+
+ return bytestream2_copy_bufferu(p, g, size2);
+}
+
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
uint8_t *dst,
unsigned int size)
diff --git a/chromium/third_party/ffmpeg/libavcodec/cabac.c b/chromium/third_party/ffmpeg/libavcodec/cabac.c
index dff0a91273d..65579d8d3ba 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cabac.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cabac.c
@@ -27,6 +27,7 @@
#include <string.h>
#include "libavutil/common.h"
+#include "libavutil/timer.h"
#include "get_bits.h"
#include "cabac.h"
#include "cabac_functions.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/cabac.h b/chromium/third_party/ffmpeg/libavcodec/cabac.h
index d4bafe08e06..eb6b521d3e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cabac.h
+++ b/chromium/third_party/ffmpeg/libavcodec/cabac.h
@@ -31,6 +31,7 @@
#include "put_bits.h"
+extern uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
#define H264_NORM_SHIFT_OFFSET 0
#define H264_LPS_RANGE_OFFSET 512
#define H264_MLPS_STATE_OFFSET 1024
diff --git a/chromium/third_party/ffmpeg/libavcodec/cabac_functions.h b/chromium/third_party/ffmpeg/libavcodec/cabac_functions.h
index 7e22064d067..d7d6d7dfdbb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cabac_functions.h
+++ b/chromium/third_party/ffmpeg/libavcodec/cabac_functions.h
@@ -32,11 +32,16 @@
#include "cabac.h"
#include "config.h"
+#if ARCH_AARCH64
+# include "aarch64/cabac.h"
+#endif
+#if ARCH_ARM
+# include "arm/cabac.h"
+#endif
#if ARCH_X86
# include "x86/cabac.h"
#endif
-extern uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
static uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + H264_NORM_SHIFT_OFFSET;
static uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + H264_LPS_RANGE_OFFSET;
static uint8_t * const ff_h264_mlps_state = ff_h264_cabac_tables + H264_MLPS_STATE_OFFSET;
diff --git a/chromium/third_party/ffmpeg/libavcodec/cavs.c b/chromium/third_party/ffmpeg/libavcodec/cavs.c
index cc544293d14..c5313eb19c1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cavs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cavs.c
@@ -275,7 +275,7 @@ static void intra_pred_plane(uint8_t *d, uint8_t *top, uint8_t *left, int stride
int x, y, ia;
int ih = 0;
int iv = 0;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
for (x = 0; x < 4; x++) {
ih += (x + 1) * (top[5 + x] - top[3 - x]);
diff --git a/chromium/third_party/ffmpeg/libavcodec/cavsdec.c b/chromium/third_party/ffmpeg/libavcodec/cavsdec.c
index 44d0ec0f9cc..93d1c59d5ac 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cavsdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cavsdec.c
@@ -948,8 +948,8 @@ static inline int check_for_slice(AVSContext *h)
static int decode_pic(AVSContext *h)
{
- int skip_count = -1;
int ret;
+ int skip_count = -1;
enum cavs_mb mb_type;
if (!h->top_qp) {
@@ -985,9 +985,9 @@ static int decode_pic(AVSContext *h)
skip_bits(&h->gb, 1); //marker_bit
}
- if ((ret = ff_get_buffer(h->avctx, h->cur.f,
- h->cur.f->pict_type == AV_PICTURE_TYPE_B ?
- 0 : AV_GET_BUFFER_FLAG_REF)) < 0)
+ ret = ff_get_buffer(h->avctx, h->cur.f, h->cur.f->pict_type == AV_PICTURE_TYPE_B ?
+ 0 : AV_GET_BUFFER_FLAG_REF);
+ if (ret < 0)
return ret;
if (!h->edge_emu_buffer) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/cavsdsp.c b/chromium/third_party/ffmpeg/libavcodec/cavsdsp.c
index 61283c23cee..a27915f57d1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cavsdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cavsdsp.c
@@ -23,7 +23,9 @@
*/
#include <stdio.h>
+
#include "dsputil.h"
+#include "mathops.h"
#include "cavsdsp.h"
#include "libavutil/common.h"
@@ -186,7 +188,7 @@ static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc
static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
int i;
int16_t (*src)[8] = (int16_t(*)[8])block;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
src[0][0] += 8;
@@ -261,7 +263,7 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
#define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int h=8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i=0; i<h; i++)\
{\
@@ -280,7 +282,7 @@ static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstS
\
static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w=8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i=0; i<w; i++)\
{\
@@ -334,7 +336,7 @@ static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_
int16_t *tmp = temp;\
const int h=8;\
const int w=8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
src1 -= 2*srcStride;\
for(i=0; i<h+5; i++)\
diff --git a/chromium/third_party/ffmpeg/libavcodec/cinepakenc.c b/chromium/third_party/ffmpeg/libavcodec/cinepakenc.c
new file mode 100644
index 00000000000..727734519cc
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/cinepakenc.c
@@ -0,0 +1,1335 @@
+/*
+ * Cinepak encoder (c) 2011 Tomas Härdin
+ * http://titan.codemill.se/~tomhar/cinepakenc.patch
+ *
+ * Fixes and improvements, vintage decoders compatibility
+ * (c) 2013, 2014 Rl, Aetey Global Technologies AB
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+ * TODO:
+ * - optimize: color space conversion, ...
+ * - implement options to set the min/max number of strips?
+ * MAYBE:
+ * - "optimally" split the frame into several non-regular areas
+ * using a separate codebook pair for each area and approximating
+ * the area by several rectangular strips (generally not full width ones)
+ * (use quadtree splitting? a simple fixed-granularity grid?)
+ *
+ *
+ * version 2014-01-23 Rl
+ * - added option handling for flexibility
+ *
+ * version 2014-01-21 Rl
+ * - believe it or not, now we get even smaller files, with better quality
+ * (which means I missed an optimization earlier :)
+ *
+ * version 2014-01-20 Rl
+ * - made the encoder compatible with vintage decoders
+ * and added some yet unused code for possible future
+ * incremental codebook updates
+ * - fixed a small memory leak
+ *
+ * version 2013-04-28 Rl
+ * - bugfixed codebook optimization logic
+ *
+ * version 2013-02-14 Rl
+ * "Valentine's Day" version:
+ * - made strip division more robust
+ * - minimized bruteforcing the number of strips,
+ * (costs some R/D but speeds up compession a lot), the heuristic
+ * assumption is that score as a function of the number of strips has
+ * one wide minimum which moves slowly, of course not fully true
+ * - simplified codebook generation,
+ * the old code was meant for other optimizations than we actually do
+ * - optimized the codebook generation / error estimation for MODE_MC
+ *
+ * version 2013-02-12 Rl
+ * - separated codebook training sets, avoided the transfer of wasted bytes,
+ * which yields both better quality and smaller files
+ * - now using the correct colorspace (TODO: move conversion to libswscale)
+ *
+ * version 2013-02-08 Rl
+ * - fixes/optimization in multistrip encoding and codebook size choice,
+ * quality/bitrate is now better than that of the binary proprietary encoder
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "libavutil/lfg.h"
+#include "elbg.h"
+#include "internal.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/opt.h"
+
+#define CVID_HEADER_SIZE 10
+#define STRIP_HEADER_SIZE 12
+#define CHUNK_HEADER_SIZE 4
+
+#define MB_SIZE 4 //4x4 MBs
+#define MB_AREA (MB_SIZE*MB_SIZE)
+
+#define VECTOR_MAX 6 //six or four entries per vector depending on format
+#define CODEBOOK_MAX 256 //size of a codebook
+
+#define MAX_STRIPS 32 //Note: having fewer choices regarding the number of strips speeds up encoding (obviously)
+#define MIN_STRIPS 1 //Note: having more strips speeds up encoding the frame (this is less obvious)
+// MAX_STRIPS limits the maximum quality you can reach
+// when you want hight quality on high resolutions,
+// MIN_STRIPS limits the minimum efficiently encodable bit rate
+// on low resolutions
+// the numbers are only used for brute force optimization for the first frame,
+// for the following frames they are adaptively readjusted
+// NOTE the decoder in ffmpeg has its own arbitrary limitation on the number
+// of strips, currently 32
+
+typedef enum {
+ MODE_V1_ONLY = 0,
+ MODE_V1_V4,
+ MODE_MC,
+
+ MODE_COUNT,
+} CinepakMode;
+
+typedef enum {
+ ENC_V1,
+ ENC_V4,
+ ENC_SKIP,
+
+ ENC_UNCERTAIN
+} mb_encoding;
+
+typedef struct {
+ int v1_vector; //index into v1 codebook
+ int v1_error; //error when using V1 encoding
+ int v4_vector[4]; //indices into v4 codebooks
+ int v4_error; //error when using V4 encoding
+ int skip_error; //error when block is skipped (aka copied from last frame)
+ mb_encoding best_encoding; //last result from calculate_mode_score()
+} mb_info;
+
+typedef struct {
+ int v1_codebook[CODEBOOK_MAX*VECTOR_MAX];
+ int v4_codebook[CODEBOOK_MAX*VECTOR_MAX];
+ int v1_size;
+ int v4_size;
+ CinepakMode mode;
+} strip_info;
+
+typedef struct {
+ const AVClass *class;
+ AVCodecContext *avctx;
+ unsigned char *pict_bufs[4], *strip_buf, *frame_buf;
+ AVFrame *last_frame;
+ AVFrame *best_frame;
+ AVFrame *scratch_frame;
+ AVFrame *input_frame;
+ enum AVPixelFormat pix_fmt;
+ int w, h;
+ int frame_buf_size;
+ int curframe, keyint;
+ AVLFG randctx;
+ uint64_t lambda;
+ int *codebook_input;
+ int *codebook_closest;
+ mb_info *mb; //MB RD state
+ int min_strips; //the current limit
+ int max_strips; //the current limit
+#ifdef CINEPAKENC_DEBUG
+ mb_info *best_mb; //TODO: remove. only used for printing stats
+ int num_v1_mode, num_v4_mode, num_mc_mode;
+ int num_v1_encs, num_v4_encs, num_skips;
+#endif
+// options
+ int max_extra_cb_iterations;
+ int skip_empty_cb;
+ int min_min_strips;
+ int max_max_strips;
+ int strip_number_delta_range;
+} CinepakEncContext;
+
+#define OFFSET(x) offsetof(CinepakEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "max_extra_cb_iterations", "Max extra codebook recalculation passes, more is better and slower", OFFSET(max_extra_cb_iterations), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX, VE },
+ { "skip_empty_cb", "Avoid wasting bytes, ignore vintage MacOS decoder", OFFSET(skip_empty_cb), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { "max_strips", "Limit strips/frame, vintage compatible is 1..3, otherwise the more the better", OFFSET(max_max_strips), AV_OPT_TYPE_INT, { .i64 = 3 }, MIN_STRIPS, MAX_STRIPS, VE },
+ { "min_strips", "Enforce min strips/frame, more is worse and faster, must be <= max_strips", OFFSET(min_min_strips), AV_OPT_TYPE_INT, { .i64 = MIN_STRIPS }, MIN_STRIPS, MAX_STRIPS, VE },
+ { "strip_number_adaptivity", "How fast the strip number adapts, more is slightly better, much slower", OFFSET(strip_number_delta_range), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_STRIPS-MIN_STRIPS, VE },
+ { NULL },
+};
+
+static const AVClass cinepak_class = {
+ .class_name = "cinepak",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int cinepak_encode_init(AVCodecContext *avctx)
+{
+ CinepakEncContext *s = avctx->priv_data;
+ int x, mb_count, strip_buf_size, frame_buf_size;
+
+ if (avctx->width & 3 || avctx->height & 3) {
+ av_log(avctx, AV_LOG_ERROR, "width and height must be multiples of four (got %ix%i)\n",
+ avctx->width, avctx->height);
+ return AVERROR(EINVAL);
+ }
+
+ if (s->min_min_strips > s->max_max_strips) {
+ av_log(avctx, AV_LOG_ERROR, "minimal number of strips can not exceed maximal (got %i and %i)\n",
+ s->min_min_strips, s->max_max_strips);
+ return AVERROR(EINVAL);
+ }
+
+ if (!(s->last_frame = av_frame_alloc()))
+ return AVERROR(ENOMEM);
+ if (!(s->best_frame = av_frame_alloc()))
+ goto enomem;
+ if (!(s->scratch_frame = av_frame_alloc()))
+ goto enomem;
+ if (avctx->pix_fmt == AV_PIX_FMT_RGB24)
+ if (!(s->input_frame = av_frame_alloc()))
+ goto enomem;
+
+ if (!(s->codebook_input = av_malloc(sizeof(int) * (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4) * (avctx->width * avctx->height) >> 2)))
+ goto enomem;
+
+ if (!(s->codebook_closest = av_malloc(sizeof(int) * (avctx->width * avctx->height) >> 2)))
+ goto enomem;
+
+ for(x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
+ if(!(s->pict_bufs[x] = av_malloc((avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4) * (avctx->width * avctx->height) >> 2)))
+ goto enomem;
+
+ mb_count = avctx->width * avctx->height / MB_AREA;
+
+ //the largest possible chunk is 0x31 with all MBs encoded in V4 mode
+ //and full codebooks being replaced in INTER mode,
+ // which is 34 bits per MB
+ //and 2*256 extra flag bits per strip
+ strip_buf_size = STRIP_HEADER_SIZE + 3 * CHUNK_HEADER_SIZE + 2 * VECTOR_MAX * CODEBOOK_MAX + 4 * (mb_count + (mb_count + 15) / 16) + (2 * CODEBOOK_MAX)/8;
+
+ frame_buf_size = CVID_HEADER_SIZE + s->max_max_strips * strip_buf_size;
+
+ if (!(s->strip_buf = av_malloc(strip_buf_size)))
+ goto enomem;
+
+ if (!(s->frame_buf = av_malloc(frame_buf_size)))
+ goto enomem;
+
+ if (!(s->mb = av_malloc_array(mb_count, sizeof(mb_info))))
+ goto enomem;
+
+#ifdef CINEPAKENC_DEBUG
+ if (!(s->best_mb = av_malloc_array(mb_count, sizeof(mb_info))))
+ goto enomem;
+#endif
+
+ av_lfg_init(&s->randctx, 1);
+ s->avctx = avctx;
+ s->w = avctx->width;
+ s->h = avctx->height;
+ s->frame_buf_size = frame_buf_size;
+ s->curframe = 0;
+ s->keyint = avctx->keyint_min;
+ s->pix_fmt = avctx->pix_fmt;
+
+ //set up AVFrames
+ s->last_frame->data[0] = s->pict_bufs[0];
+ s->last_frame->linesize[0] = s->w;
+ s->best_frame->data[0] = s->pict_bufs[1];
+ s->best_frame->linesize[0] = s->w;
+ s->scratch_frame->data[0] = s->pict_bufs[2];
+ s->scratch_frame->linesize[0] = s->w;
+
+ if (s->pix_fmt == AV_PIX_FMT_RGB24) {
+ s->last_frame->data[1] = s->last_frame->data[0] + s->w * s->h;
+ s->last_frame->data[2] = s->last_frame->data[1] + ((s->w * s->h) >> 2);
+ s->last_frame->linesize[1] = s->last_frame->linesize[2] = s->w >> 1;
+
+ s->best_frame->data[1] = s->best_frame->data[0] + s->w * s->h;
+ s->best_frame->data[2] = s->best_frame->data[1] + ((s->w * s->h) >> 2);
+ s->best_frame->linesize[1] = s->best_frame->linesize[2] = s->w >> 1;
+
+ s->scratch_frame->data[1] = s->scratch_frame->data[0] + s->w * s->h;
+ s->scratch_frame->data[2] = s->scratch_frame->data[1] + ((s->w * s->h) >> 2);
+ s->scratch_frame->linesize[1] = s->scratch_frame->linesize[2] = s->w >> 1;
+
+ s->input_frame->data[0] = s->pict_bufs[3];
+ s->input_frame->linesize[0] = s->w;
+ s->input_frame->data[1] = s->input_frame->data[0] + s->w * s->h;
+ s->input_frame->data[2] = s->input_frame->data[1] + ((s->w * s->h) >> 2);
+ s->input_frame->linesize[1] = s->input_frame->linesize[2] = s->w >> 1;
+ }
+
+ s->min_strips = s->min_min_strips;
+ s->max_strips = s->max_max_strips;
+
+#ifdef CINEPAKENC_DEBUG
+ s->num_v1_mode = s->num_v4_mode = s->num_mc_mode = s->num_v1_encs = s->num_v4_encs = s->num_skips = 0;
+#endif
+
+ return 0;
+
+enomem:
+ av_frame_free(&s->last_frame);
+ av_frame_free(&s->best_frame);
+ av_frame_free(&s->scratch_frame);
+ if (avctx->pix_fmt == AV_PIX_FMT_RGB24)
+ av_frame_free(&s->input_frame);
+ av_freep(&s->codebook_input);
+ av_freep(&s->codebook_closest);
+ av_freep(&s->strip_buf);
+ av_freep(&s->frame_buf);
+ av_freep(&s->mb);
+#ifdef CINEPAKENC_DEBUG
+ av_freep(&s->best_mb);
+#endif
+
+ for(x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
+ av_freep(&s->pict_bufs[x]);
+
+ return AVERROR(ENOMEM);
+}
+
+static int64_t calculate_mode_score(CinepakEncContext *s, int h, strip_info *info, int report, int *training_set_v1_shrunk, int *training_set_v4_shrunk
+#ifdef CINEPAK_REPORT_SERR
+, int64_t *serr
+#endif
+)
+{
+ //score = FF_LAMBDA_SCALE * error + lambda * bits
+ int x;
+ int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
+ int mb_count = s->w * h / MB_AREA;
+ mb_info *mb;
+ int64_t score1, score2, score3;
+ int64_t ret = s->lambda * ((info->v1_size ? CHUNK_HEADER_SIZE + info->v1_size * entry_size : 0) +
+ (info->v4_size ? CHUNK_HEADER_SIZE + info->v4_size * entry_size : 0) +
+ CHUNK_HEADER_SIZE) << 3;
+
+ //av_log(s->avctx, AV_LOG_INFO, "sizes %3i %3i -> %9lli score mb_count %i", info->v1_size, info->v4_size, (long long int)ret, mb_count);
+
+#ifdef CINEPAK_REPORT_SERR
+ *serr = 0;
+#endif
+
+ switch(info->mode) {
+ case MODE_V1_ONLY:
+ //one byte per MB
+ ret += s->lambda * 8 * mb_count;
+
+// while calculating we assume all blocks are ENC_V1
+ for(x = 0; x < mb_count; x++) {
+ mb = &s->mb[x];
+ ret += FF_LAMBDA_SCALE * mb->v1_error;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v1_error;
+#endif
+// this function is never called for report in MODE_V1_ONLY
+// if(!report)
+ mb->best_encoding = ENC_V1;
+ }
+
+ break;
+ case MODE_V1_V4:
+ //9 or 33 bits per MB
+ if(report) {
+// no moves between the corresponding training sets are allowed
+ *training_set_v1_shrunk = *training_set_v4_shrunk = 0;
+ for(x = 0; x < mb_count; x++) {
+ int mberr;
+ mb = &s->mb[x];
+ if(mb->best_encoding == ENC_V1)
+ score1 = s->lambda * 9 + FF_LAMBDA_SCALE * (mberr=mb->v1_error);
+ else
+ score1 = s->lambda * 33 + FF_LAMBDA_SCALE * (mberr=mb->v4_error);
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mberr;
+#endif
+ }
+ } else { // find best mode per block
+ for(x = 0; x < mb_count; x++) {
+ mb = &s->mb[x];
+ score1 = s->lambda * 9 + FF_LAMBDA_SCALE * mb->v1_error;
+ score2 = s->lambda * 33 + FF_LAMBDA_SCALE * mb->v4_error;
+
+ if(score1 <= score2) {
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v1_error;
+#endif
+ mb->best_encoding = ENC_V1;
+ } else {
+ ret += score2;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v4_error;
+#endif
+ mb->best_encoding = ENC_V4;
+ }
+ }
+ }
+
+ break;
+ case MODE_MC:
+ //1, 10 or 34 bits per MB
+ if(report) {
+ int v1_shrunk = 0, v4_shrunk = 0;
+ for(x = 0; x < mb_count; x++) {
+ mb = &s->mb[x];
+// it is OK to move blocks to ENC_SKIP here
+// but not to any codebook encoding!
+ score1 = s->lambda * 1 + FF_LAMBDA_SCALE * mb->skip_error;
+ if(mb->best_encoding == ENC_SKIP) {
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->skip_error;
+#endif
+ } else if(mb->best_encoding == ENC_V1) {
+ if((score2=s->lambda * 10 + FF_LAMBDA_SCALE * mb->v1_error) >= score1) {
+ mb->best_encoding = ENC_SKIP;
+ ++v1_shrunk;
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->skip_error;
+#endif
+ } else {
+ ret += score2;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v1_error;
+#endif
+ }
+ } else {
+ if((score3=s->lambda * 34 + FF_LAMBDA_SCALE * mb->v4_error) >= score1) {
+ mb->best_encoding = ENC_SKIP;
+ ++v4_shrunk;
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->skip_error;
+#endif
+ } else {
+ ret += score3;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v4_error;
+#endif
+ }
+ }
+ }
+ *training_set_v1_shrunk = v1_shrunk;
+ *training_set_v4_shrunk = v4_shrunk;
+ } else { // find best mode per block
+ for(x = 0; x < mb_count; x++) {
+ mb = &s->mb[x];
+ score1 = s->lambda * 1 + FF_LAMBDA_SCALE * mb->skip_error;
+ score2 = s->lambda * 10 + FF_LAMBDA_SCALE * mb->v1_error;
+ score3 = s->lambda * 34 + FF_LAMBDA_SCALE * mb->v4_error;
+
+ if(score1 <= score2 && score1 <= score3) {
+ ret += score1;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->skip_error;
+#endif
+ mb->best_encoding = ENC_SKIP;
+ } else if(score2 <= score3) {
+ ret += score2;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v1_error;
+#endif
+ mb->best_encoding = ENC_V1;
+ } else {
+ ret += score3;
+#ifdef CINEPAK_REPORT_SERR
+ *serr += mb->v4_error;
+#endif
+ mb->best_encoding = ENC_V4;
+ }
+ }
+ }
+
+ break;
+ }
+
+ return ret;
+}
+
+static int write_chunk_header(unsigned char *buf, int chunk_type, int chunk_size)
+{
+ buf[0] = chunk_type;
+ AV_WB24(&buf[1], chunk_size + CHUNK_HEADER_SIZE);
+ return CHUNK_HEADER_SIZE;
+}
+
+static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf)
+{
+ int x, y, ret, entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
+ int incremental_codebook_replacement_mode = 0; // hardcoded here,
+ // the compiler should notice that this is a constant -- rl
+
+ ret = write_chunk_header(buf,
+ s->pix_fmt == AV_PIX_FMT_RGB24 ?
+ chunk_type_yuv+(incremental_codebook_replacement_mode?1:0) :
+ chunk_type_gray+(incremental_codebook_replacement_mode?1:0),
+ entry_size * size
+ + (incremental_codebook_replacement_mode?(size+31)/32*4:0) );
+
+// we do codebook encoding according to the "intra" mode
+// but we keep the "dead" code for reference in case we will want
+// to use incremental codebook updates (which actually would give us
+// "kind of" motion compensation, especially in 1 strip/frame case) -- rl
+// (of course, the code will be not useful as-is)
+ if(incremental_codebook_replacement_mode) {
+ int flags = 0;
+ int flagsind;
+ for(x = 0; x < size; x++) {
+ if(flags == 0) {
+ flagsind = ret;
+ ret += 4;
+ flags = 0x80000000;
+ } else
+ flags = ((flags>>1) | 0x80000000);
+ for(y = 0; y < entry_size; y++)
+ buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
+ if((flags&0xffffffff) == 0xffffffff) {
+ AV_WB32(&buf[flagsind], flags);
+ flags = 0;
+ }
+ }
+ if(flags)
+ AV_WB32(&buf[flagsind], flags);
+ } else
+ for(x = 0; x < size; x++)
+ for(y = 0; y < entry_size; y++)
+ buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0);
+
+ return ret;
+}
+
+//sets out to the sub picture starting at (x,y) in in
+static void get_sub_picture(CinepakEncContext *s, int x, int y, AVPicture *in, AVPicture *out)
+{
+ out->data[0] = in->data[0] + x + y * in->linesize[0];
+ out->linesize[0] = in->linesize[0];
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ out->data[1] = in->data[1] + (x >> 1) + (y >> 1) * in->linesize[1];
+ out->linesize[1] = in->linesize[1];
+
+ out->data[2] = in->data[2] + (x >> 1) + (y >> 1) * in->linesize[2];
+ out->linesize[2] = in->linesize[2];
+ }
+}
+
+//decodes the V1 vector in mb into the 4x4 MB pointed to by sub_pict
+static void decode_v1_vector(CinepakEncContext *s, AVPicture *sub_pict, int v1_vector, strip_info *info)
+{
+ int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
+
+ sub_pict->data[0][0] =
+ sub_pict->data[0][1] =
+ sub_pict->data[0][ sub_pict->linesize[0]] =
+ sub_pict->data[0][1+ sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size];
+
+ sub_pict->data[0][2] =
+ sub_pict->data[0][3] =
+ sub_pict->data[0][2+ sub_pict->linesize[0]] =
+ sub_pict->data[0][3+ sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+1];
+
+ sub_pict->data[0][2*sub_pict->linesize[0]] =
+ sub_pict->data[0][1+2*sub_pict->linesize[0]] =
+ sub_pict->data[0][ 3*sub_pict->linesize[0]] =
+ sub_pict->data[0][1+3*sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+2];
+
+ sub_pict->data[0][2+2*sub_pict->linesize[0]] =
+ sub_pict->data[0][3+2*sub_pict->linesize[0]] =
+ sub_pict->data[0][2+3*sub_pict->linesize[0]] =
+ sub_pict->data[0][3+3*sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+3];
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ sub_pict->data[1][0] =
+ sub_pict->data[1][1] =
+ sub_pict->data[1][ sub_pict->linesize[1]] =
+ sub_pict->data[1][1+ sub_pict->linesize[1]] = info->v1_codebook[v1_vector*entry_size+4];
+
+ sub_pict->data[2][0] =
+ sub_pict->data[2][1] =
+ sub_pict->data[2][ sub_pict->linesize[2]] =
+ sub_pict->data[2][1+ sub_pict->linesize[2]] = info->v1_codebook[v1_vector*entry_size+5];
+ }
+}
+
+//decodes the V4 vectors in mb into the 4x4 MB pointed to by sub_pict
+static void decode_v4_vector(CinepakEncContext *s, AVPicture *sub_pict, int *v4_vector, strip_info *info)
+{
+ int i, x, y, entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
+
+ for(i = y = 0; y < 4; y += 2) {
+ for(x = 0; x < 4; x += 2, i++) {
+ sub_pict->data[0][x + y*sub_pict->linesize[0]] = info->v4_codebook[v4_vector[i]*entry_size];
+ sub_pict->data[0][x+1 + y*sub_pict->linesize[0]] = info->v4_codebook[v4_vector[i]*entry_size+1];
+ sub_pict->data[0][x + (y+1)*sub_pict->linesize[0]] = info->v4_codebook[v4_vector[i]*entry_size+2];
+ sub_pict->data[0][x+1 + (y+1)*sub_pict->linesize[0]] = info->v4_codebook[v4_vector[i]*entry_size+3];
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ sub_pict->data[1][(x>>1) + (y>>1)*sub_pict->linesize[1]] = info->v4_codebook[v4_vector[i]*entry_size+4];
+ sub_pict->data[2][(x>>1) + (y>>1)*sub_pict->linesize[2]] = info->v4_codebook[v4_vector[i]*entry_size+5];
+ }
+ }
+ }
+}
+
+static void copy_mb(CinepakEncContext *s, AVPicture *a, AVPicture *b)
+{
+ int y, p;
+
+ for(y = 0; y < MB_SIZE; y++) {
+ memcpy(a->data[0]+y*a->linesize[0], b->data[0]+y*b->linesize[0],
+ MB_SIZE);
+ }
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ for(p = 1; p <= 2; p++) {
+ for(y = 0; y < MB_SIZE/2; y++) {
+ memcpy(a->data[p] + y*a->linesize[p],
+ b->data[p] + y*b->linesize[p],
+ MB_SIZE/2);
+ }
+ }
+ }
+}
+
+static int encode_mode(CinepakEncContext *s, int h, AVPicture *scratch_pict, AVPicture *last_pict, strip_info *info, unsigned char *buf)
+{
+ int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA;
+ int needs_extra_bit, should_write_temp;
+ unsigned char temp[64]; //32/2 = 16 V4 blocks at 4 B each -> 64 B
+ mb_info *mb;
+ AVPicture sub_scratch = {{0}}, sub_last = {{0}};
+
+ //encode codebooks
+////// MacOS vintage decoder compatibility dictates the presence of
+////// the codebook chunk even when the codebook is empty - pretty dumb...
+////// and also the certain order of the codebook chunks -- rl
+ if(info->v4_size || !s->skip_empty_cb)
+ ret += encode_codebook(s, info->v4_codebook, info->v4_size, 0x20, 0x24, buf + ret);
+
+ if(info->v1_size || !s->skip_empty_cb)
+ ret += encode_codebook(s, info->v1_codebook, info->v1_size, 0x22, 0x26, buf + ret);
+
+ //update scratch picture
+ for(z = y = 0; y < h; y += MB_SIZE) {
+ for(x = 0; x < s->w; x += MB_SIZE, z++) {
+ mb = &s->mb[z];
+
+ get_sub_picture(s, x, y, scratch_pict, &sub_scratch);
+
+ if(info->mode == MODE_MC && mb->best_encoding == ENC_SKIP) {
+ get_sub_picture(s, x, y, last_pict, &sub_last);
+ copy_mb(s, &sub_scratch, &sub_last);
+ } else if(info->mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)
+ decode_v1_vector(s, &sub_scratch, mb->v1_vector, info);
+ else
+ decode_v4_vector(s, &sub_scratch, mb->v4_vector, info);
+ }
+ }
+
+ switch(info->mode) {
+ case MODE_V1_ONLY:
+ //av_log(s->avctx, AV_LOG_INFO, "mb_count = %i\n", mb_count);
+ ret += write_chunk_header(buf + ret, 0x32, mb_count);
+
+ for(x = 0; x < mb_count; x++)
+ buf[ret++] = s->mb[x].v1_vector;
+
+ break;
+ case MODE_V1_V4:
+ //remember header position
+ header_ofs = ret;
+ ret += CHUNK_HEADER_SIZE;
+
+ for(x = 0; x < mb_count; x += 32) {
+ flags = 0;
+ for(y = x; y < FFMIN(x+32, mb_count); y++)
+ if(s->mb[y].best_encoding == ENC_V4)
+ flags |= 1 << (31 - y + x);
+
+ AV_WB32(&buf[ret], flags);
+ ret += 4;
+
+ for(y = x; y < FFMIN(x+32, mb_count); y++) {
+ mb = &s->mb[y];
+
+ if(mb->best_encoding == ENC_V1)
+ buf[ret++] = mb->v1_vector;
+ else
+ for(z = 0; z < 4; z++)
+ buf[ret++] = mb->v4_vector[z];
+ }
+ }
+
+ write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE);
+
+ break;
+ case MODE_MC:
+ //remember header position
+ header_ofs = ret;
+ ret += CHUNK_HEADER_SIZE;
+ flags = bits = temp_size = 0;
+
+ for(x = 0; x < mb_count; x++) {
+ mb = &s->mb[x];
+ flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++);
+ needs_extra_bit = 0;
+ should_write_temp = 0;
+
+ if(mb->best_encoding != ENC_SKIP) {
+ if(bits < 32)
+ flags |= (mb->best_encoding == ENC_V4) << (31 - bits++);
+ else
+ needs_extra_bit = 1;
+ }
+
+ if(bits == 32) {
+ AV_WB32(&buf[ret], flags);
+ ret += 4;
+ flags = bits = 0;
+
+ if(mb->best_encoding == ENC_SKIP || needs_extra_bit) {
+ memcpy(&buf[ret], temp, temp_size);
+ ret += temp_size;
+ temp_size = 0;
+ } else
+ should_write_temp = 1;
+ }
+
+ if(needs_extra_bit) {
+ flags = (mb->best_encoding == ENC_V4) << 31;
+ bits = 1;
+ }
+
+ if(mb->best_encoding == ENC_V1)
+ temp[temp_size++] = mb->v1_vector;
+ else if(mb->best_encoding == ENC_V4)
+ for(z = 0; z < 4; z++)
+ temp[temp_size++] = mb->v4_vector[z];
+
+ if(should_write_temp) {
+ memcpy(&buf[ret], temp, temp_size);
+ ret += temp_size;
+ temp_size = 0;
+ }
+ }
+
+ if(bits > 0) {
+ AV_WB32(&buf[ret], flags);
+ ret += 4;
+ memcpy(&buf[ret], temp, temp_size);
+ ret += temp_size;
+ }
+
+ write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE);
+
+ break;
+ }
+
+ return ret;
+}
+
+//computes distortion of 4x4 MB in b compared to a
+static int compute_mb_distortion(CinepakEncContext *s, AVPicture *a, AVPicture *b)
+{
+ int x, y, p, d, ret = 0;
+
+ for(y = 0; y < MB_SIZE; y++) {
+ for(x = 0; x < MB_SIZE; x++) {
+ d = a->data[0][x + y*a->linesize[0]] - b->data[0][x + y*b->linesize[0]];
+ ret += d*d;
+ }
+ }
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ for(p = 1; p <= 2; p++) {
+ for(y = 0; y < MB_SIZE/2; y++) {
+ for(x = 0; x < MB_SIZE/2; x++) {
+ d = a->data[p][x + y*a->linesize[p]] - b->data[p][x + y*b->linesize[p]];
+ ret += d*d;
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+// return the possibly adjusted size of the codebook
+#define CERTAIN(x) ((x)!=ENC_UNCERTAIN)
+static int quantize(CinepakEncContext *s, int h, AVPicture *pict,
+ int v1mode, strip_info *info,
+ mb_encoding encoding)
+{
+ int x, y, i, j, k, x2, y2, x3, y3, plane, shift, mbn;
+ int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4;
+ int *codebook = v1mode ? info->v1_codebook : info->v4_codebook;
+ int size = v1mode ? info->v1_size : info->v4_size;
+ int64_t total_error = 0;
+ uint8_t vq_pict_buf[(MB_AREA*3)/2];
+ AVPicture sub_pict, vq_pict;
+
+ for(mbn = i = y = 0; y < h; y += MB_SIZE) {
+ for(x = 0; x < s->w; x += MB_SIZE, ++mbn) {
+ int *base;
+
+ if(CERTAIN(encoding)) {
+// use for the training only the blocks known to be to be encoded [sic:-]
+ if(s->mb[mbn].best_encoding != encoding) continue;
+ }
+
+ base = s->codebook_input + i*entry_size;
+ if(v1mode) {
+ //subsample
+ for(j = y2 = 0; y2 < entry_size; y2 += 2) {
+ for(x2 = 0; x2 < 4; x2 += 2, j++) {
+ plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
+ shift = y2 < 4 ? 0 : 1;
+ x3 = shift ? 0 : x2;
+ y3 = shift ? 0 : y2;
+ base[j] = (pict->data[plane][((x+x3) >> shift) + ((y+y3) >> shift) * pict->linesize[plane]] +
+ pict->data[plane][((x+x3) >> shift) + 1 + ((y+y3) >> shift) * pict->linesize[plane]] +
+ pict->data[plane][((x+x3) >> shift) + (((y+y3) >> shift) + 1) * pict->linesize[plane]] +
+ pict->data[plane][((x+x3) >> shift) + 1 + (((y+y3) >> shift) + 1) * pict->linesize[plane]]) >> 2;
+ }
+ }
+ } else {
+ //copy
+ for(j = y2 = 0; y2 < MB_SIZE; y2 += 2) {
+ for(x2 = 0; x2 < MB_SIZE; x2 += 2) {
+ for(k = 0; k < entry_size; k++, j++) {
+ plane = k >= 4 ? k - 3 : 0;
+
+ if(k >= 4) {
+ x3 = (x+x2) >> 1;
+ y3 = (y+y2) >> 1;
+ } else {
+ x3 = x + x2 + (k & 1);
+ y3 = y + y2 + (k >> 1);
+ }
+
+ base[j] = pict->data[plane][x3 + y3*pict->linesize[plane]];
+ }
+ }
+ }
+ }
+ i += v1mode ? 1 : 4;
+ }
+ }
+// if(i < mbn*(v1mode ? 1 : 4)) {
+// av_log(s->avctx, AV_LOG_INFO, "reducing training set for %s from %i to %i (encoding %i)\n", v1mode?"v1":"v4", mbn*(v1mode ? 1 : 4), i, encoding);
+// }
+
+ if(i == 0) // empty training set, nothing to do
+ return 0;
+ if(i < size) {
+ //av_log(s->avctx, (CERTAIN(encoding) ? AV_LOG_ERROR : AV_LOG_INFO), "WOULD WASTE: %s cbsize %i bigger than training set size %i (encoding %i)\n", v1mode?"v1":"v4", size, i, encoding);
+ size = i;
+ }
+
+ avpriv_init_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
+ avpriv_do_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
+
+ //setup vq_pict, which contains a single MB
+ vq_pict.data[0] = vq_pict_buf;
+ vq_pict.linesize[0] = MB_SIZE;
+ vq_pict.data[1] = &vq_pict_buf[MB_AREA];
+ vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);
+ vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;
+
+ //copy indices
+ for(i = j = y = 0; y < h; y += MB_SIZE) {
+ for(x = 0; x < s->w; x += MB_SIZE, j++) {
+ mb_info *mb = &s->mb[j];
+// skip uninteresting blocks if we know their preferred encoding
+ if(CERTAIN(encoding) && mb->best_encoding != encoding)
+ continue;
+
+ //point sub_pict to current MB
+ get_sub_picture(s, x, y, pict, &sub_pict);
+
+ if(v1mode) {
+ mb->v1_vector = s->codebook_closest[i];
+
+ //fill in vq_pict with V1 data
+ decode_v1_vector(s, &vq_pict, mb->v1_vector, info);
+
+ mb->v1_error = compute_mb_distortion(s, &sub_pict, &vq_pict);
+ total_error += mb->v1_error;
+ } else {
+ for(k = 0; k < 4; k++)
+ mb->v4_vector[k] = s->codebook_closest[i+k];
+
+ //fill in vq_pict with V4 data
+ decode_v4_vector(s, &vq_pict, mb->v4_vector, info);
+
+ mb->v4_error = compute_mb_distortion(s, &sub_pict, &vq_pict);
+ total_error += mb->v4_error;
+ }
+ i += v1mode ? 1 : 4;
+ }
+ }
+// check that we did it right in the beginning of the function
+ av_assert0(i >= size); // training set is no smaller than the codebook
+
+ //av_log(s->avctx, AV_LOG_INFO, "isv1 %i size= %i i= %i error %lli\n", v1mode, size, i, (long long int)total_error);
+
+ return size;
+}
+
+static void calculate_skip_errors(CinepakEncContext *s, int h, AVPicture *last_pict, AVPicture *pict, strip_info *info)
+{
+ int x, y, i;
+ AVPicture sub_last, sub_pict;
+
+ for(i = y = 0; y < h; y += MB_SIZE) {
+ for(x = 0; x < s->w; x += MB_SIZE, i++) {
+ get_sub_picture(s, x, y, last_pict, &sub_last);
+ get_sub_picture(s, x, y, pict, &sub_pict);
+
+ s->mb[i].skip_error = compute_mb_distortion(s, &sub_last, &sub_pict);
+ }
+ }
+}
+
+static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
+{
+// actually we are exclusively using intra strip coding (how much can we win
+// otherwise? how to choose which part of a codebook to update?),
+// keyframes are different only because we disallow ENC_SKIP on them -- rl
+// (besides, the logic here used to be inverted: )
+// buf[0] = keyframe ? 0x11: 0x10;
+ buf[0] = keyframe ? 0x10: 0x11;
+ AV_WB24(&buf[1], strip_size + STRIP_HEADER_SIZE);
+// AV_WB16(&buf[4], y); /* using absolute y values works -- rl */
+ AV_WB16(&buf[4], 0); /* using relative values works as well -- rl */
+ AV_WB16(&buf[6], 0);
+// AV_WB16(&buf[8], y+h); /* using absolute y values works -- rl */
+ AV_WB16(&buf[8], h); /* using relative values works as well -- rl */
+ AV_WB16(&buf[10], s->w);
+ //av_log(s->avctx, AV_LOG_INFO, "write_strip_header() %x keyframe=%d\n", buf[0], keyframe);
+}
+
+static int rd_strip(CinepakEncContext *s, int y, int h, int keyframe, AVPicture *last_pict, AVPicture *pict, AVPicture *scratch_pict, unsigned char *buf, int64_t *best_score
+#ifdef CINEPAK_REPORT_SERR
+, int64_t *best_serr
+#endif
+)
+{
+ int64_t score = 0;
+#ifdef CINEPAK_REPORT_SERR
+ int64_t serr;
+#endif
+ int best_size = 0;
+ strip_info info;
+// for codebook optimization:
+ int v1enough, v1_size, v4enough, v4_size;
+ int new_v1_size, new_v4_size;
+ int v1shrunk, v4shrunk;
+
+ if(!keyframe)
+ calculate_skip_errors(s, h, last_pict, pict, &info);
+
+ //try some powers of 4 for the size of the codebooks
+ //constraint the v4 codebook to be no bigger than v1 one,
+ //(and no less than v1_size/4)
+ //thus making v1 preferable and possibly losing small details? should be ok
+#define SMALLEST_CODEBOOK 1
+ for(v1enough = 0, v1_size = SMALLEST_CODEBOOK; v1_size <= CODEBOOK_MAX && !v1enough; v1_size <<= 2) {
+ for(v4enough = 0, v4_size = 0; v4_size <= v1_size && !v4enough; v4_size = v4_size ? v4_size << 2 : v1_size >= SMALLEST_CODEBOOK << 2 ? v1_size >> 2 : SMALLEST_CODEBOOK) {
+ //try all modes
+ for(CinepakMode mode = 0; mode < MODE_COUNT; mode++) {
+ //don't allow MODE_MC in intra frames
+ if(keyframe && mode == MODE_MC)
+ continue;
+
+ if(mode == MODE_V1_ONLY) {
+ info.v1_size = v1_size;
+// the size may shrink even before optimizations if the input is short:
+ info.v1_size = quantize(s, h, pict, 1, &info, ENC_UNCERTAIN);
+ if(info.v1_size < v1_size)
+// too few eligible blocks, no sense in trying bigger sizes
+ v1enough = 1;
+
+ info.v4_size = 0;
+ } else { // mode != MODE_V1_ONLY
+ // if v4 codebook is empty then only allow V1-only mode
+ if(!v4_size)
+ continue;
+
+ if(mode == MODE_V1_V4) {
+ info.v4_size = v4_size;
+ info.v4_size = quantize(s, h, pict, 0, &info, ENC_UNCERTAIN);
+ if(info.v4_size < v4_size)
+// too few eligible blocks, no sense in trying bigger sizes
+ v4enough = 1;
+ }
+ }
+
+ info.mode = mode;
+// choose the best encoding per block, based on current experience
+ score = calculate_mode_score(s, h, &info, 0,
+ &v1shrunk, &v4shrunk
+#ifdef CINEPAK_REPORT_SERR
+, &serr
+#endif
+);
+
+ if(mode != MODE_V1_ONLY){
+ int extra_iterations_limit = s->max_extra_cb_iterations;
+// recompute the codebooks, omitting the extra blocks
+// we assume we _may_ come here with more blocks to encode than before
+ info.v1_size = v1_size;
+ new_v1_size = quantize(s, h, pict, 1, &info, ENC_V1);
+ if(new_v1_size < info.v1_size){
+ //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: cut v1 codebook to %i entries\n", mode, v1_size, v4_size, new_v1_size);
+ info.v1_size = new_v1_size;
+ }
+// we assume we _may_ come here with more blocks to encode than before
+ info.v4_size = v4_size;
+ new_v4_size = quantize(s, h, pict, 0, &info, ENC_V4);
+ if(new_v4_size < info.v4_size) {
+ //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: cut v4 codebook to %i entries at first iteration\n", mode, v1_size, v4_size, new_v4_size);
+ info.v4_size = new_v4_size;
+ }
+// calculate the resulting score
+// (do not move blocks to codebook encodings now, as some blocks may have
+// got bigger errors despite a smaller training set - but we do not
+// ever grow the training sets back)
+ for(;;) {
+ score = calculate_mode_score(s, h, &info, 1,
+ &v1shrunk, &v4shrunk
+#ifdef CINEPAK_REPORT_SERR
+, &serr
+#endif
+);
+// do we have a reason to reiterate? if so, have we reached the limit?
+ if((!v1shrunk && !v4shrunk) || !extra_iterations_limit--) break;
+// recompute the codebooks, omitting the extra blocks
+ if(v1shrunk) {
+ info.v1_size = v1_size;
+ new_v1_size = quantize(s, h, pict, 1, &info, ENC_V1);
+ if(new_v1_size < info.v1_size){
+ //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: cut v1 codebook to %i entries\n", mode, v1_size, v4_size, new_v1_size);
+ info.v1_size = new_v1_size;
+ }
+ }
+ if(v4shrunk) {
+ info.v4_size = v4_size;
+ new_v4_size = quantize(s, h, pict, 0, &info, ENC_V4);
+ if(new_v4_size < info.v4_size) {
+ //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: cut v4 codebook to %i entries\n", mode, v1_size, v4_size, new_v4_size);
+ info.v4_size = new_v4_size;
+ }
+ }
+ }
+ }
+
+ //av_log(s->avctx, AV_LOG_INFO, "%3i %3i score = %lli\n", v1_size, v4_size, (long long int)score);
+
+ if(best_size == 0 || score < *best_score) {
+
+ *best_score = score;
+#ifdef CINEPAK_REPORT_SERR
+ *best_serr = serr;
+#endif
+ best_size = encode_mode(s, h, scratch_pict, last_pict, &info, s->strip_buf + STRIP_HEADER_SIZE);
+
+ //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18lli %i B", mode, info.v1_size, info.v4_size, (long long int)score, best_size);
+ //av_log(s->avctx, AV_LOG_INFO, "\n");
+#ifdef CINEPAK_REPORT_SERR
+ av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18lli %i B\n", mode, v1_size, v4_size, (long long int)serr, best_size);
+#endif
+
+#ifdef CINEPAKENC_DEBUG
+ //save MB encoding choices
+ memcpy(s->best_mb, s->mb, mb_count*sizeof(mb_info));
+#endif
+
+ //memcpy(strip_temp + STRIP_HEADER_SIZE, strip_temp, best_size);
+ write_strip_header(s, y, h, keyframe, s->strip_buf, best_size);
+
+ }
+ }
+ }
+ }
+
+#ifdef CINEPAKENC_DEBUG
+ //gather stats. this will only work properly of MAX_STRIPS == 1
+ if(best_info.mode == MODE_V1_ONLY) {
+ s->num_v1_mode++;
+ s->num_v1_encs += s->w*h/MB_AREA;
+ } else {
+ if(best_info.mode == MODE_V1_V4)
+ s->num_v4_mode++;
+ else
+ s->num_mc_mode++;
+
+ int x;
+ for(x = 0; x < s->w*h/MB_AREA; x++)
+ if(s->best_mb[x].best_encoding == ENC_V1)
+ s->num_v1_encs++;
+ else if(s->best_mb[x].best_encoding == ENC_V4)
+ s->num_v4_encs++;
+ else
+ s->num_skips++;
+ }
+#endif
+
+ best_size += STRIP_HEADER_SIZE;
+ memcpy(buf, s->strip_buf, best_size);
+
+ return best_size;
+}
+
+static int write_cvid_header(CinepakEncContext *s, unsigned char *buf, int num_strips, int data_size, int isakeyframe)
+{
+ buf[0] = isakeyframe ? 0 : 1;
+ AV_WB24(&buf[1], data_size + CVID_HEADER_SIZE);
+ AV_WB16(&buf[4], s->w);
+ AV_WB16(&buf[6], s->h);
+ AV_WB16(&buf[8], num_strips);
+
+ return CVID_HEADER_SIZE;
+}
+
+static int rd_frame(CinepakEncContext *s, const AVFrame *frame, int isakeyframe, unsigned char *buf, int buf_size)
+{
+ int num_strips, strip, i, y, nexty, size, temp_size;
+ AVPicture last_pict, pict, scratch_pict;
+ int64_t best_score = 0, score, score_temp;
+#ifdef CINEPAK_REPORT_SERR
+ int64_t best_serr = 0, serr, serr_temp;
+#endif
+
+ int best_nstrips = -1, best_size = -1; // mark as uninitialzed
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24) {
+ int x;
+// build a copy of the given frame in the correct colorspace
+ for(y = 0; y < s->h; y += 2) {
+ for(x = 0; x < s->w; x += 2) {
+ uint8_t *ir[2]; int32_t r, g, b, rr, gg, bb;
+ ir[0] = ((AVPicture*)frame)->data[0] + x*3 + y*((AVPicture*)frame)->linesize[0];
+ ir[1] = ir[0] + ((AVPicture*)frame)->linesize[0];
+ get_sub_picture(s, x, y, (AVPicture*)s->input_frame, &scratch_pict);
+ r = g = b = 0;
+ for(i=0; i<4; ++i) {
+ int i1, i2;
+ i1 = (i&1); i2 = (i>=2);
+ rr = ir[i2][i1*3+0];
+ gg = ir[i2][i1*3+1];
+ bb = ir[i2][i1*3+2];
+ r += rr; g += gg; b += bb;
+// using fixed point arithmetic for portable repeatability, scaling by 2^23
+// "Y"
+// rr = 0.2857*rr + 0.5714*gg + 0.1429*bb;
+ rr = (2396625*rr + 4793251*gg + 1198732*bb) >> 23;
+ if( rr < 0) rr = 0;
+ else if (rr > 255) rr = 255;
+ scratch_pict.data[0][i1 + i2*scratch_pict.linesize[0]] = rr;
+ }
+// let us scale down as late as possible
+// r /= 4; g /= 4; b /= 4;
+// "U"
+// rr = -0.1429*r - 0.2857*g + 0.4286*b;
+ rr = (-299683*r - 599156*g + 898839*b) >> 23;
+ if( rr < -128) rr = -128;
+ else if (rr > 127) rr = 127;
+ scratch_pict.data[1][0] = rr + 128; // quantize needs unsigned
+// "V"
+// rr = 0.3571*r - 0.2857*g - 0.0714*b;
+ rr = (748893*r - 599156*g - 149737*b) >> 23;
+ if( rr < -128) rr = -128;
+ else if (rr > 127) rr = 127;
+ scratch_pict.data[2][0] = rr + 128; // quantize needs unsigned
+ }
+ }
+ }
+
+ //would be nice but quite certainly incompatible with vintage players:
+ // support encoding zero strips (meaning skip the whole frame)
+ for(num_strips = s->min_strips; num_strips <= s->max_strips && num_strips <= s->h / MB_SIZE; num_strips++) {
+ score = 0;
+ size = 0;
+#ifdef CINEPAK_REPORT_SERR
+ serr = 0;
+#endif
+
+ for(y = 0, strip = 1; y < s->h; strip++, y = nexty) {
+ int strip_height;
+
+ nexty = strip * s->h / num_strips; // <= s->h
+ //make nexty the next multiple of 4 if not already there
+ if(nexty & 3)
+ nexty += 4 - (nexty & 3);
+
+ strip_height = nexty - y;
+ if(strip_height <= 0) { // can this ever happen?
+ av_log(s->avctx, AV_LOG_INFO, "skipping zero height strip %i of %i\n", strip, num_strips);
+ continue;
+ }
+
+ if(s->pix_fmt == AV_PIX_FMT_RGB24)
+ get_sub_picture(s, 0, y, (AVPicture*)s->input_frame, &pict);
+ else
+ get_sub_picture(s, 0, y, (AVPicture*)frame, &pict);
+ get_sub_picture(s, 0, y, (AVPicture*)s->last_frame, &last_pict);
+ get_sub_picture(s, 0, y, (AVPicture*)s->scratch_frame, &scratch_pict);
+
+ if((temp_size = rd_strip(s, y, strip_height, isakeyframe, &last_pict, &pict, &scratch_pict, s->frame_buf + size + CVID_HEADER_SIZE, &score_temp
+#ifdef CINEPAK_REPORT_SERR
+, &serr_temp
+#endif
+)) < 0)
+ return temp_size;
+
+ score += score_temp;
+#ifdef CINEPAK_REPORT_SERR
+ serr += serr_temp;
+#endif
+ size += temp_size;
+ //av_log(s->avctx, AV_LOG_INFO, "strip %d, isakeyframe=%d", strip, isakeyframe);
+ //av_log(s->avctx, AV_LOG_INFO, "\n");
+ }
+
+ if(best_score == 0 || score < best_score) {
+ best_score = score;
+#ifdef CINEPAK_REPORT_SERR
+ best_serr = serr;
+#endif
+ best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size, isakeyframe);
+ //av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12lli, %i B\n", num_strips, (long long int)score, best_size);
+#ifdef CINEPAK_REPORT_SERR
+ av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12lli, %i B\n", num_strips, (long long int)serr, best_size);
+#endif
+
+ FFSWAP(AVFrame *, s->best_frame, s->scratch_frame);
+ memcpy(buf, s->frame_buf, best_size);
+ best_nstrips = num_strips;
+ }
+// avoid trying too many strip numbers without a real reason
+// (this makes the processing of the very first frame faster)
+ if(num_strips - best_nstrips > 4)
+ break;
+ }
+
+ av_assert0(best_nstrips >= 0 && best_size >= 0);
+
+// let the number of strips slowly adapt to the changes in the contents,
+// compared to full bruteforcing every time this will occasionally lead
+// to some r/d performance loss but makes encoding up to several times faster
+ if(!s->strip_number_delta_range) {
+ if(best_nstrips == s->max_strips) { // let us try to step up
+ s->max_strips = best_nstrips + 1;
+ if(s->max_strips >= s->max_max_strips)
+ s->max_strips = s->max_max_strips;
+ } else { // try to step down
+ s->max_strips = best_nstrips;
+ }
+ s->min_strips = s->max_strips - 1;
+ if(s->min_strips < s->min_min_strips)
+ s->min_strips = s->min_min_strips;
+ } else {
+ s->max_strips = best_nstrips + s->strip_number_delta_range;
+ if(s->max_strips >= s->max_max_strips)
+ s->max_strips = s->max_max_strips;
+ s->min_strips = best_nstrips - s->strip_number_delta_range;
+ if(s->min_strips < s->min_min_strips)
+ s->min_strips = s->min_min_strips;
+ }
+
+ return best_size;
+}
+
+static int cinepak_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
+{
+ CinepakEncContext *s = avctx->priv_data;
+ int ret;
+
+ s->lambda = frame->quality ? frame->quality - 1 : 2 * FF_LAMBDA_SCALE;
+
+ if ((ret = ff_alloc_packet2(avctx, pkt, s->frame_buf_size)) < 0)
+ return ret;
+ ret = rd_frame(s, frame, (s->curframe == 0), pkt->data, s->frame_buf_size);
+ pkt->size = ret;
+ if (s->curframe == 0)
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ FFSWAP(AVFrame *, s->last_frame, s->best_frame);
+
+ if (++s->curframe >= s->keyint)
+ s->curframe = 0;
+
+ return 0;
+}
+
+static av_cold int cinepak_encode_end(AVCodecContext *avctx)
+{
+ CinepakEncContext *s = avctx->priv_data;
+ int x;
+
+ av_frame_free(&s->last_frame);
+ av_frame_free(&s->best_frame);
+ av_frame_free(&s->scratch_frame);
+ if (avctx->pix_fmt == AV_PIX_FMT_RGB24)
+ av_frame_free(&s->input_frame);
+ av_freep(&s->codebook_input);
+ av_freep(&s->codebook_closest);
+ av_freep(&s->strip_buf);
+ av_freep(&s->frame_buf);
+ av_freep(&s->mb);
+#ifdef CINEPAKENC_DEBUG
+ av_freep(&s->best_mb);
+#endif
+
+ for(x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
+ av_freep(&s->pict_bufs[x]);
+
+#ifdef CINEPAKENC_DEBUG
+ av_log(avctx, AV_LOG_INFO, "strip coding stats: %i V1 mode, %i V4 mode, %i MC mode (%i V1 encs, %i V4 encs, %i skips)\n",
+ s->num_v1_mode, s->num_v4_mode, s->num_mc_mode, s->num_v1_encs, s->num_v4_encs, s->num_skips);
+#endif
+
+ return 0;
+}
+
+AVCodec ff_cinepak_encoder = {
+ .name = "cinepak",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_CINEPAK,
+ .priv_data_size = sizeof(CinepakEncContext),
+ .init = cinepak_encode_init,
+ .encode2 = cinepak_encode_frame,
+ .close = cinepak_encode_end,
+ .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_RGB24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("Cinepak / CVID"),
+ .priv_class = &cinepak_class,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/cllc.c b/chromium/third_party/ffmpeg/libavcodec/cllc.c
index ee77381fd84..bc8e4b5679d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cllc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cllc.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "libavutil/intreadwrite.h"
#include "dsputil.h"
#include "get_bits.h"
@@ -367,7 +369,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, void *data,
info_offset = AV_RL32(src + 4);
if (info_offset > UINT32_MAX - 8 || info_offset + 8 > avpkt->size) {
av_log(avctx, AV_LOG_ERROR,
- "Invalid INFO header offset: 0x%08X is too large.\n",
+ "Invalid INFO header offset: 0x%08"PRIX32" is too large.\n",
info_offset);
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/cngdec.c b/chromium/third_party/ffmpeg/libavcodec/cngdec.c
index 12241c3b919..855baaaa8da 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cngdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cngdec.c
@@ -59,12 +59,12 @@ static av_cold int cng_decode_init(AVCodecContext *avctx)
p->order = 12;
avctx->frame_size = 640;
- p->refl_coef = av_mallocz(p->order * sizeof(*p->refl_coef));
- p->target_refl_coef = av_mallocz(p->order * sizeof(*p->target_refl_coef));
- p->lpc_coef = av_mallocz(p->order * sizeof(*p->lpc_coef));
- p->filter_out = av_mallocz((avctx->frame_size + p->order) *
+ p->refl_coef = av_mallocz_array(p->order, sizeof(*p->refl_coef));
+ p->target_refl_coef = av_mallocz_array(p->order, sizeof(*p->target_refl_coef));
+ p->lpc_coef = av_mallocz_array(p->order, sizeof(*p->lpc_coef));
+ p->filter_out = av_mallocz_array(avctx->frame_size + p->order,
sizeof(*p->filter_out));
- p->excitation = av_mallocz(avctx->frame_size * sizeof(*p->excitation));
+ p->excitation = av_mallocz_array(avctx->frame_size, sizeof(*p->excitation));
if (!p->refl_coef || !p->target_refl_coef || !p->lpc_coef ||
!p->filter_out || !p->excitation) {
cng_decode_close(avctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/cngenc.c b/chromium/third_party/ffmpeg/libavcodec/cngenc.c
index 5ab6e365c15..bf5f7bf54b2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cngenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cngenc.c
@@ -56,8 +56,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx)
p->order = 10;
if ((ret = ff_lpc_init(&p->lpc, avctx->frame_size, p->order, FF_LPC_TYPE_LEVINSON)) < 0)
return ret;
- p->samples32 = av_malloc(avctx->frame_size * sizeof(*p->samples32));
- p->ref_coef = av_malloc(p->order * sizeof(*p->ref_coef));
+ p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32));
+ p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef));
if (!p->samples32 || !p->ref_coef) {
cng_encode_close(avctx);
return AVERROR(ENOMEM);
diff --git a/chromium/third_party/ffmpeg/libavcodec/codec_desc.c b/chromium/third_party/ffmpeg/libavcodec/codec_desc.c
index c62734f69d0..4906a0a21d3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/codec_desc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/codec_desc.c
@@ -26,6 +26,8 @@
#include "avcodec.h"
#include "version.h"
+#define MT(...) (const char *const[]){ __VA_ARGS__, NULL }
+
static const AVCodecDescriptor codec_descriptors[] = {
/* video codecs */
{
@@ -85,6 +87,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "mjpeg",
.long_name = NULL_IF_CONFIG_SMALL("Motion JPEG"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .mime_types= MT("image/jpeg"),
},
{
.id = AV_CODEC_ID_MJPEGB,
@@ -94,28 +97,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_LJPEG,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ljpeg",
- .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SP5X,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "sp5x",
- .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_JPEGLS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "jpegls",
- .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_MPEG4,
.type = AVMEDIA_TYPE_VIDEO,
.name = "mpeg4",
@@ -466,48 +447,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_PNG,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "png",
- .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PPM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ppm",
- .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PBM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pbm",
- .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PGM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pgm",
- .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PGMYUV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pgmyuv",
- .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PAM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pam",
- .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_FFVHUFF,
.type = AVMEDIA_TYPE_VIDEO,
.name = "ffvhuff",
@@ -590,6 +529,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "bmp",
.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/x-ms-bmp"),
},
{
.id = AV_CODEC_ID_CSCD,
@@ -661,6 +601,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/jp2"),
},
{
.id = AV_CODEC_ID_VMNC,
@@ -691,13 +632,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_TARGA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "targa",
- .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_DSICINVIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "dsicinvideo",
@@ -712,20 +646,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_TIFF,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tiff",
- .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_GIF,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "gif",
- .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_DXA,
.type = AVMEDIA_TYPE_VIDEO,
.name = "dxa",
@@ -747,20 +667,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_SGI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "sgi",
- .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SGIRLE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "sgirle",
- .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_C93,
.type = AVMEDIA_TYPE_VIDEO,
.name = "c93",
@@ -775,20 +681,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_PTX,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ptx",
- .long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TXD,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "txd",
- .long_name = NULL_IF_CONFIG_SMALL("Renderware TXD (TeXture Dictionary) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
.id = AV_CODEC_ID_VP6A,
.type = AVMEDIA_TYPE_VIDEO,
.name = "vp6a",
@@ -810,20 +702,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_PCX,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pcx",
- .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SUNRAST,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "sunrast",
- .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_INDEO4,
.type = AVMEDIA_TYPE_VIDEO,
.name = "indeo4",
@@ -925,6 +803,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.id = AV_CODEC_ID_V210X,
.type = AVMEDIA_TYPE_VIDEO,
.name = "v210x",
+ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
@@ -942,13 +821,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
- .id = AV_CODEC_ID_DPX,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dpx",
- .long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_MAD,
.type = AVMEDIA_TYPE_VIDEO,
.name = "mad",
@@ -1047,13 +919,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_ANSI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ansi",
- .long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
.id = AV_CODEC_ID_A64_MULTI,
.type = AVMEDIA_TYPE_VIDEO,
.name = "a64_multi",
@@ -1124,20 +989,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_WMV3IMAGE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "wmv3image",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VC1IMAGE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vc1image",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image v2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
.id = AV_CODEC_ID_UTVIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "utvideo",
@@ -1173,13 +1024,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
- .id = AV_CODEC_ID_XWD,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "xwd",
- .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_CDXL,
.type = AVMEDIA_TYPE_VIDEO,
.name = "cdxl",
@@ -1187,13 +1031,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_XBM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "xbm",
- .long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_ZEROCODEC,
.type = AVMEDIA_TYPE_VIDEO,
.name = "zerocodec",
@@ -1264,14 +1101,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_EXR,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "exr",
- .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
- },
- {
.id = AV_CODEC_ID_AVRP,
.type = AVMEDIA_TYPE_VIDEO,
.name = "avrp",
@@ -1328,10 +1157,57 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY,
},
{
- .id = AV_CODEC_ID_SANM,
+ .id = AV_CODEC_ID_AVRN,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "sanm",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts SMUSH video"),
+ .name = "avrn",
+ .long_name = NULL_IF_CONFIG_SMALL("Avid AVI Codec"),
+ },
+ {
+ .id = AV_CODEC_ID_CPIA,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "cpia",
+ .long_name = NULL_IF_CONFIG_SMALL("CPiA video format"),
+ },
+ {
+ .id = AV_CODEC_ID_XFACE,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "xface",
+ .long_name = NULL_IF_CONFIG_SMALL("X-face image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_SMVJPEG,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "smv",
+ .long_name = NULL_IF_CONFIG_SMALL("Sigmatel Motion Video"),
+ },
+
+ {
+ .id = AV_CODEC_ID_G2M,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "g2m",
+ .long_name = NULL_IF_CONFIG_SMALL("Go2Meeting"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_HNM4_VIDEO,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "hnm4video",
+ .long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_HEVC,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "hevc",
+ .long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC (High Efficiency Video Coding)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_FIC,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "fic",
+ .long_name = NULL_IF_CONFIG_SMALL("Mirillis FIC"),
.props = AV_CODEC_PROP_LOSSY,
},
{
@@ -1342,23 +1218,41 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_AVRN,
+ .id = AV_CODEC_ID_VP7,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "avrn",
- .long_name = NULL_IF_CONFIG_SMALL("Avid AVI Codec"),
+ .name = "vp7",
+ .long_name = NULL_IF_CONFIG_SMALL("On2 VP7"),
+ .props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_CPIA,
+ .id = AV_CODEC_ID_SANM,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "cpia",
- .long_name = NULL_IF_CONFIG_SMALL("CPiA video format"),
+ .name = "sanm",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/SMUSH video"),
+ .props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_XFACE,
+ .id = AV_CODEC_ID_SGIRLE,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "xface",
- .long_name = NULL_IF_CONFIG_SMALL("X-face image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .name = "sgirle",
+ .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+
+ /* image codecs */
+ {
+ .id = AV_CODEC_ID_ALIAS_PIX,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "alias_pix",
+ .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_ANSI,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "ansi",
+ .long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
+ .props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_BRENDER_PIX,
@@ -1368,17 +1262,151 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
- .id = AV_CODEC_ID_SMVJPEG,
+ .id = AV_CODEC_ID_DPX,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "smv",
- .long_name = NULL_IF_CONFIG_SMALL("Sigmatel Motion Video"),
+ .name = "dpx",
+ .long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
-
{
- .id = AV_CODEC_ID_G2M,
+ .id = AV_CODEC_ID_EXR,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "g2m",
- .long_name = NULL_IF_CONFIG_SMALL("Go2Meeting"),
+ .name = "exr",
+ .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_GIF,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "gif",
+ .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/gif"),
+ },
+ {
+ .id = AV_CODEC_ID_JPEGLS,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "jpegls",
+ .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_LJPEG,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "ljpeg",
+ .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PAM,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "pam",
+ .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/x-portable-pixmap"),
+ },
+ {
+ .id = AV_CODEC_ID_PBM,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "pbm",
+ .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PCX,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "pcx",
+ .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/x-pcx"),
+ },
+ {
+ .id = AV_CODEC_ID_PGM,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "pgm",
+ .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PGMYUV,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "pgmyuv",
+ .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PNG,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "png",
+ .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/png"),
+ },
+ {
+ .id = AV_CODEC_ID_PPM,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "ppm",
+ .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PTX,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "ptx",
+ .long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_SGI,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "sgi",
+ .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_SP5X,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "sp5x",
+ .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_SUNRAST,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "sunrast",
+ .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_TARGA,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "targa",
+ .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/x-targa", "image/x-tga"),
+ },
+ {
+ .id = AV_CODEC_ID_TIFF,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "tiff",
+ .long_name = NULL_IF_CONFIG_SMALL("TIFF image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/tiff"),
+ },
+ {
+ .id = AV_CODEC_ID_TXD,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "txd",
+ .long_name = NULL_IF_CONFIG_SMALL("Renderware TXD (TeXture Dictionary) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_VC1IMAGE,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "vc1image",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image v2"),
.props = AV_CODEC_PROP_LOSSY,
},
{
@@ -1388,20 +1416,29 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("WebP"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/webp"),
},
{
- .id = AV_CODEC_ID_HNM4_VIDEO,
+ .id = AV_CODEC_ID_WMV3IMAGE,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "hnm4video",
- .long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"),
+ .name = "wmv3image",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image"),
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_HEVC,
+ .id = AV_CODEC_ID_XBM,
.type = AVMEDIA_TYPE_VIDEO,
- .name = "hevc",
- .long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC (High Efficiency Video Coding)"),
- .props = AV_CODEC_PROP_LOSSY,
+ .name = "xbm",
+ .long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_XWD,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "xwd",
+ .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .mime_types= MT("image/x-xwindowdump"),
},
/* various PCM "codecs" */
@@ -1869,6 +1906,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"),
.props = AV_CODEC_PROP_LOSSY,
},
+ {
+ .id = AV_CODEC_ID_ADPCM_VIMA,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "adpcm_vima",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
/* AMR */
{
@@ -1965,20 +2009,21 @@ static const AVCodecDescriptor codec_descriptors[] = {
.id = AV_CODEC_ID_DTS,
.type = AVMEDIA_TYPE_AUDIO,
.name = "dts",
- .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
+ .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_VORBIS,
.type = AVMEDIA_TYPE_AUDIO,
.name = "vorbis",
- .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
+ .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
.props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_DVAUDIO,
.type = AVMEDIA_TYPE_AUDIO,
.name = "dvaudio",
+ .long_name = NULL_IF_CONFIG_SMALL("DV audio"),
.props = AV_CODEC_PROP_LOSSY,
},
{
@@ -2362,13 +2407,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
- .id = AV_CODEC_ID_VIMA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "vima",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
.id = AV_CODEC_ID_FFWAVESYNTH,
.type = AVMEDIA_TYPE_AUDIO,
.name = "wavesynth",
@@ -2387,13 +2425,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
},
{
- .id = AV_CODEC_ID_PAF_AUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "paf_audio",
- .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
.id = AV_CODEC_ID_OPUS,
.type = AVMEDIA_TYPE_AUDIO,
.name = "opus",
@@ -2422,6 +2453,20 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSY,
},
{
+ .id = AV_CODEC_ID_PAF_AUDIO,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "paf_audio",
+ .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_ON2AVC,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "avc",
+ .long_name = NULL_IF_CONFIG_SMALL("On2 Audio for Video Codec"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
.id = AV_CODEC_ID_EVRC,
.type = AVMEDIA_TYPE_AUDIO,
.name = "evrc",
@@ -2435,6 +2480,34 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("SMV (Selectable Mode Vocoder)"),
.props = AV_CODEC_PROP_LOSSY,
},
+ {
+ .id = AV_CODEC_ID_DSD_LSBF,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "dsd_lsbf",
+ .long_name = NULL_IF_CONFIG_SMALL("DSD (Direct Stream Digital), least significant bit first"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_DSD_MSBF,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "dsd_msbf",
+ .long_name = NULL_IF_CONFIG_SMALL("DSD (Direct Stream Digital), most significant bit first"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_DSD_LSBF_PLANAR,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "dsd_lsbf_planar",
+ .long_name = NULL_IF_CONFIG_SMALL("DSD (Direct Stream Digital), least significant bit first, planar"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_DSD_MSBF_PLANAR,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "dsd_msbf_planar",
+ .long_name = NULL_IF_CONFIG_SMALL("DSD (Direct Stream Digital), most significant bit first, planar"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
/* subtitle codecs */
{
@@ -2589,6 +2662,15 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
.props = AV_CODEC_PROP_TEXT_SUB,
},
+
+ /* other kind of codecs and pseudo-codecs */
+ {
+ .id = AV_CODEC_ID_TTF,
+ .type = AVMEDIA_TYPE_DATA,
+ .name = "ttf",
+ .long_name = NULL_IF_CONFIG_SMALL("TrueType font"),
+ .mime_types= MT("application/x-truetype-font", "application/x-font"),
+ },
{
.id = AV_CODEC_ID_BINTEXT,
.type = AVMEDIA_TYPE_VIDEO,
@@ -2611,6 +2693,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_INTRA_ONLY,
},
{
+ .id = AV_CODEC_ID_OTF,
+ .type = AVMEDIA_TYPE_DATA,
+ .name = "otf",
+ .long_name = NULL_IF_CONFIG_SMALL("OpenType font"),
+ .mime_types= MT("application/vnd.ms-opentype"),
+ },
+ {
.id = AV_CODEC_ID_SMPTE_KLV,
.type = AVMEDIA_TYPE_DATA,
.name = "klv",
@@ -2622,7 +2711,136 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "dvd_nav_packet",
.long_name = NULL_IF_CONFIG_SMALL("DVD Nav packet"),
},
+ {
+ .id = AV_CODEC_ID_TIMED_ID3,
+ .type = AVMEDIA_TYPE_DATA,
+ .name = "timed_id3",
+ .long_name = NULL_IF_CONFIG_SMALL("timed ID3 metadata"),
+ },
+ {
+ .id = AV_CODEC_ID_BIN_DATA,
+ .type = AVMEDIA_TYPE_DATA,
+ .name = "bin_data",
+ .long_name = NULL_IF_CONFIG_SMALL("binary data"),
+ .mime_types= MT("application/octet-stream"),
+ },
+ /* deprecated codec ids */
+ {
+ .id = AV_CODEC_ID_BRENDER_PIX_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "brender_pix_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("BRender PIX image (deprecated id)"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_ESCAPE130_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "escape130_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("Escape 130 (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_EXR_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "exr_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image (deprecated id)"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_G2M_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "g2m_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("Go2Meeting (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_HEVC_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "hevc_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC (High Efficiency Video Coding) (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_PAF_VIDEO_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "paf_video_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Video (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_SANM_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "sanm_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/SMUSH video (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_VP7_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "vp7_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("On2 VP7 (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_WEBP_DEPRECATED,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "webp_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("WebP (deprecated id)"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+ },
+
+ {
+ .id = AV_CODEC_ID_VIMA,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "vima",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_ADPCM_VIMA_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "adpcm_vima_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_OPUS_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "opus_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("Opus (Opus Interactive Audio Codec) (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_PAF_AUDIO_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "paf_audio_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
+ {
+ .id = AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "pcm_s24le_planar_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("PCM signed 24-bit little-endian planar (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "pcm_s32le_planar_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("PCM signed 32-bit little-endian planar (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ },
+ {
+ .id = AV_CODEC_ID_TAK_DEPRECATED,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "tak_deprecated",
+ .long_name = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor) (deprecated id)"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ },
};
const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id)
@@ -2648,9 +2866,8 @@ const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name)
{
const AVCodecDescriptor *desc = NULL;
- while ((desc = avcodec_descriptor_next(desc))) {
+ while ((desc = avcodec_descriptor_next(desc)))
if (!strcmp(desc->name, name))
return desc;
- }
return NULL;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/cook.c b/chromium/third_party/ffmpeg/libavcodec/cook.c
index 402093c425d..d84d755dea9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cook.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cook.c
@@ -219,7 +219,7 @@ static av_cold int init_cook_mlt(COOKContext *q)
int j, ret;
int mlt_size = q->samples_per_channel;
- if ((q->mlt_window = av_malloc(mlt_size * sizeof(*q->mlt_window))) == 0)
+ if ((q->mlt_window = av_malloc_array(mlt_size, sizeof(*q->mlt_window))) == 0)
return AVERROR(ENOMEM);
/* Initialize the MLT window: simple sine window. */
diff --git a/chromium/third_party/ffmpeg/libavcodec/copy_block.h b/chromium/third_party/ffmpeg/libavcodec/copy_block.h
index a73910d80f4..9ed451f2940 100644
--- a/chromium/third_party/ffmpeg/libavcodec/copy_block.h
+++ b/chromium/third_party/ffmpeg/libavcodec/copy_block.h
@@ -37,57 +37,52 @@ static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride,
static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
- for(i=0; i<h; i++)
- {
+ for (i = 0; i < h; i++) {
AV_COPY32U(dst, src);
- dst+=dstStride;
- src+=srcStride;
+ dst += dstStride;
+ src += srcStride;
}
}
static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
- for(i=0; i<h; i++)
- {
+ for (i = 0; i < h; i++) {
AV_COPY64U(dst, src);
- dst+=dstStride;
- src+=srcStride;
+ dst += dstStride;
+ src += srcStride;
}
}
-static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
+static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
- for(i=0; i<h; i++)
- {
- AV_COPY128U(dst, src);
- dst+=dstStride;
- src+=srcStride;
+ for (i = 0; i < h; i++) {
+ AV_COPY64U(dst, src);
+ dst[8] = src[8];
+ dst += dstStride;
+ src += srcStride;
}
}
-static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
+static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
- for(i=0; i<h; i++)
- {
- AV_COPY64U(dst, src);
- dst[8]= src[8];
- dst+=dstStride;
- src+=srcStride;
+ for (i = 0; i < h; i++) {
+ AV_COPY128U(dst, src);
+ dst += dstStride;
+ src += srcStride;
}
}
static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
int i;
- for(i=0; i<h; i++)
- {
+ for (i = 0; i < h; i++) {
AV_COPY128U(dst, src);
- dst[16]= src[16];
- dst+=dstStride;
- src+=srcStride;
+ dst[16] = src[16];
+ dst += dstStride;
+ src += srcStride;
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/cos_tablegen.c b/chromium/third_party/ffmpeg/libavcodec/cos_tablegen.c
index 48b7b900103..9af83f4d7d0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cos_tablegen.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cos_tablegen.c
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
double (*func)(double) = do_sin ? sin : cos;
printf("/* This file was automatically generated. */\n");
- printf("#define CONFIG_FFT_FLOAT %d\n", !fixed);
+ printf("#define FFT_FLOAT %d\n", !fixed);
printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h");
for (i = 4; i <= BITS; i++) {
int m = 1 << i;
diff --git a/chromium/third_party/ffmpeg/libavcodec/cpia.c b/chromium/third_party/ffmpeg/libavcodec/cpia.c
index 44226fb46bb..9036cb37fca 100644
--- a/chromium/third_party/ffmpeg/libavcodec/cpia.c
+++ b/chromium/third_party/ffmpeg/libavcodec/cpia.c
@@ -76,15 +76,15 @@ static int cpia_decode_frame(AVCodecContext *avctx,
// currently unsupported properties
if (header[17] == SUBSAMPLE_422) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported subsample!\n");
+ avpriv_report_missing_feature(avctx, "4:2:2 subsampling");
return AVERROR_PATCHWELCOME;
}
if (header[18] == YUVORDER_UYVY) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported YUV byte order!\n");
+ avpriv_report_missing_feature(avctx, "YUV byte order UYVY");
return AVERROR_PATCHWELCOME;
}
if (header[29] == DECIMATION_ENAB) {
- av_log(avctx, AV_LOG_ERROR, "Decimation unsupported!\n");
+ avpriv_report_missing_feature(avctx, "Decimation");
return AVERROR_PATCHWELCOME;
}
@@ -114,7 +114,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
if (src_size < linelength) {
av_frame_set_decode_error_flags(frame, FF_DECODE_ERROR_INVALID_BITSTREAM);
- av_log(avctx, AV_LOG_WARNING, "Frame ended enexpectedly!\n");
+ av_log(avctx, AV_LOG_WARNING, "Frame ended unexpectedly!\n");
break;
}
if (src[linelength - 1] != EOL) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/dca.c b/chromium/third_party/ffmpeg/libavcodec/dca.c
index 1c1c0803506..fcdfef21475 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dca.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dca.c
@@ -25,8 +25,10 @@
#include <stdint.h>
#include <string.h>
-#include "put_bits.h"
+#include "libavutil/error.h"
+
#include "dca.h"
+#include "put_bits.h"
const uint32_t avpriv_dca_sample_rates[16] =
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/dcadata.h b/chromium/third_party/ffmpeg/libavcodec/dcadata.h
index 5154fbca0ca..0ae125c2f44 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dcadata.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dcadata.h
@@ -7305,205 +7305,208 @@ DECLARE_ALIGNED(16, static const float, fir_32bands_nonperfect)[] =
+1.390191784E-007
};
+/* pre-scale lfe fir coefficients */
+#define SCALE(c) ((c) / (256.0f * 32768.0f))
DECLARE_ALIGNED(16, static const float, lfe_fir_64)[] =
{
- 2.658434386830777e-4, 9.029330685734748e-3,
- 7.939263433218002e-2, 2.425158768892288e-1,
- 3.430179357528686e-1, 2.398228943347931e-1,
- 7.746443897485733e-2, 8.622321300208569e-3,
- 8.179365249816328e-5, 9.450953453779220e-3,
- 8.134882897138596e-2, 2.451938837766648e-1,
- 3.429597318172455e-1, 2.371159791946411e-1,
- 7.556436210870743e-2, 8.229630999267101e-3,
- 9.439323912374676e-5, 9.887560270726680e-3,
- 8.333285897970200e-2, 2.478559017181396e-1,
- 3.428434133529663e-1, 2.343961596488952e-1,
- 7.369252294301987e-2, 7.850865833461285e-3,
- 1.082170274457894e-4, 1.033949479460716e-2,
- 8.534456789493561e-2, 2.505008876323700e-1,
- 3.426689505577088e-1, 2.316644787788391e-1,
- 7.184901088476181e-2, 7.485736627131701e-3,
- 1.233371440321207e-4, 1.080708485096693e-2,
- 8.738376945257187e-2, 2.531278133392334e-1,
- 3.424364924430847e-1, 2.289219647645950e-1,
- 7.003392279148102e-2, 7.133882027119398e-3,
- 1.397485757479444e-4, 1.129068247973919e-2,
- 8.945026248693466e-2, 2.557355761528015e-1,
- 3.421461284160614e-1, 2.261696159839630e-1,
- 6.824731826782227e-2, 6.794991903007030e-3,
- 1.575958012836054e-4, 1.179065089672804e-2,
- 9.154383838176728e-2, 2.583232223987580e-1,
- 3.417979776859284e-1, 2.234084606170654e-1,
- 6.648923456668854e-2, 6.468691397458315e-3,
- 1.769922382663936e-4, 1.230732165277004e-2,
- 9.366425126791000e-2, 2.608896791934967e-1,
- 3.413922190666198e-1, 2.206395119428635e-1,
- 6.475970894098282e-2, 6.154712289571762e-3,
- 1.981738605536520e-4, 1.284105982631445e-2,
- 9.581124037504196e-2, 2.634339034557342e-1,
- 3.409290313720703e-1, 2.178637981414795e-1,
- 6.305878609418869e-2, 5.852684378623962e-3,
- 2.211847313446924e-4, 1.339218579232693e-2,
- 9.798453748226166e-2, 2.659549415111542e-1,
- 3.404086530208588e-1, 2.150822728872299e-1,
- 6.138643622398376e-2, 5.562345497310162e-3,
- 2.460231189616024e-4, 1.396108977496624e-2,
- 1.001838669180870e-1, 2.684516608715058e-1,
- 3.398312926292420e-1, 2.122959494590759e-1,
- 5.974265560507774e-2, 5.283284001052380e-3,
- 2.726115926634520e-4, 1.454808749258518e-2,
- 1.024089083075523e-1, 2.709231376647949e-1,
- 3.391972482204438e-1, 2.095058411359787e-1,
- 5.812742188572884e-2, 5.015311297029257e-3,
- 3.013863170053810e-4, 1.515355054289102e-2,
- 1.046593263745308e-1, 2.733682692050934e-1,
- 3.385068178176880e-1, 2.067128717899322e-1,
- 5.654069408774376e-2, 4.758012015372515e-3,
- 3.328395541757345e-4, 1.577781140804291e-2,
- 1.069347932934761e-1, 2.757860720157624e-1,
- 3.377602994441986e-1, 2.039180546998978e-1,
- 5.498242005705833e-2, 4.511159844696522e-3,
- 3.658991190604866e-4, 1.642123050987720e-2,
- 1.092349365353584e-1, 2.781755328178406e-1,
- 3.369580209255218e-1, 2.011223286390304e-1,
- 5.345252528786659e-2, 4.274417180567980e-3,
- 4.018281470052898e-4, 1.708412915468216e-2,
- 1.115593686699867e-1, 2.805356979370117e-1,
- 3.361004292964936e-1, 1.983266174793244e-1,
- 5.195093154907227e-2, 4.047499038279056e-3,
- 4.401875485200435e-4, 1.776690222322941e-2,
- 1.139076948165894e-1, 2.828655838966370e-1,
- 3.351879119873047e-1, 1.955319195985794e-1,
- 5.047753453254700e-2, 3.830091329291463e-3,
- 4.812776169274002e-4, 1.846982724964619e-2,
- 1.162794977426529e-1, 2.851640880107880e-1,
- 3.342207968235016e-1, 1.927391141653061e-1,
- 4.903224110603333e-2, 3.621967276558280e-3,
- 5.252459668554366e-4, 1.919330470263958e-2,
- 1.186743453145027e-1, 2.874303460121155e-1,
- 3.331996202468872e-1, 1.899491697549820e-1,
- 4.761491715908051e-2, 3.422776935622096e-3,
- 5.721592460758984e-4, 1.993762329220772e-2,
- 1.210917681455612e-1, 2.896633744239807e-1,
- 3.321248590946198e-1, 1.871629506349564e-1,
- 4.622544348239899e-2, 3.232272574678064e-3,
- 6.222130032256246e-4, 2.070316113531590e-2,
- 1.235313042998314e-1, 2.918621897697448e-1,
- 3.309969604015350e-1, 1.843813359737396e-1,
- 4.486365616321564e-2, 3.050152910873294e-3,
- 6.755515350960195e-4, 2.149021252989769e-2,
- 1.259924471378326e-1, 2.940258979797364e-1,
- 3.298164308071136e-1, 1.816052496433258e-1,
- 4.352942481637001e-2, 2.876190468668938e-3,
- 7.324148900806904e-4, 2.229913882911205e-2,
- 1.284746825695038e-1, 2.961534857749939e-1,
- 3.285838961601258e-1, 1.788355410099030e-1,
- 4.222255200147629e-2, 2.710093278437853e-3,
- 7.928516715764999e-4, 2.313023805618286e-2,
- 1.309774816036224e-1, 2.982441186904907e-1,
- 3.272998929023742e-1, 1.760730892419815e-1,
- 4.094288870692253e-2, 2.551567042246461e-3,
- 8.570110658183694e-4, 2.398385666310787e-2,
- 1.335003077983856e-1, 3.002967536449432e-1,
- 3.259649574756622e-1, 1.733186990022659e-1,
- 3.969023004174232e-2, 2.400433411821723e-3,
- 9.251192095689476e-4, 2.486028522253036e-2,
- 1.360425949096680e-1, 3.023106753826142e-1,
- 3.245797157287598e-1, 1.705732345581055e-1,
- 3.846437484025955e-2, 2.256359672173858e-3,
- 9.974770946428180e-4, 2.575986087322235e-2,
- 1.386037617921829e-1, 3.042849004268646e-1,
- 3.231448531150818e-1, 1.678375005722046e-1,
- 3.726511076092720e-2, 2.119151875376701e-3,
- 1.073930296115577e-3, 2.668286114931106e-2,
- 1.411831974983215e-1, 3.062185347080230e-1,
- 3.216609656810760e-1, 1.651122719049454e-1,
- 3.609224036335945e-2, 1.988604199141264e-3,
- 1.155023579485714e-3, 2.762960828840732e-2,
- 1.437802612781525e-1, 3.081108033657074e-1,
- 3.201287388801574e-1, 1.623983532190323e-1,
- 3.494550660252571e-2, 1.864377525635064e-3,
- 1.240676851011813e-3, 2.860039286315441e-2,
- 1.463943719863892e-1, 3.099608123302460e-1,
- 3.185488879680634e-1, 1.596965193748474e-1,
- 3.382468968629837e-2, 1.746327499859035e-3,
- 1.331258914433420e-3, 2.959549613296986e-2,
- 1.490248143672943e-1, 3.117676973342896e-1,
- 3.169221282005310e-1, 1.570075154304504e-1,
- 3.272953629493714e-2, 1.634211512282491e-3,
- 1.426893868483603e-3, 3.061520494520664e-2,
- 1.516709625720978e-1, 3.135308027267456e-1,
- 3.152491748332978e-1, 1.543320864439010e-1,
- 3.165979683399200e-2, 1.527829794213176e-3,
+ SCALE(2.658434386830777e-4), SCALE(9.029330685734748e-3),
+ SCALE(7.939263433218002e-2), SCALE(2.425158768892288e-1),
+ SCALE(3.430179357528686e-1), SCALE(2.398228943347931e-1),
+ SCALE(7.746443897485733e-2), SCALE(8.622321300208569e-3),
+ SCALE(8.179365249816328e-5), SCALE(9.450953453779220e-3),
+ SCALE(8.134882897138596e-2), SCALE(2.451938837766648e-1),
+ SCALE(3.429597318172455e-1), SCALE(2.371159791946411e-1),
+ SCALE(7.556436210870743e-2), SCALE(8.229630999267101e-3),
+ SCALE(9.439323912374676e-5), SCALE(9.887560270726680e-3),
+ SCALE(8.333285897970200e-2), SCALE(2.478559017181396e-1),
+ SCALE(3.428434133529663e-1), SCALE(2.343961596488952e-1),
+ SCALE(7.369252294301987e-2), SCALE(7.850865833461285e-3),
+ SCALE(1.082170274457894e-4), SCALE(1.033949479460716e-2),
+ SCALE(8.534456789493561e-2), SCALE(2.505008876323700e-1),
+ SCALE(3.426689505577088e-1), SCALE(2.316644787788391e-1),
+ SCALE(7.184901088476181e-2), SCALE(7.485736627131701e-3),
+ SCALE(1.233371440321207e-4), SCALE(1.080708485096693e-2),
+ SCALE(8.738376945257187e-2), SCALE(2.531278133392334e-1),
+ SCALE(3.424364924430847e-1), SCALE(2.289219647645950e-1),
+ SCALE(7.003392279148102e-2), SCALE(7.133882027119398e-3),
+ SCALE(1.397485757479444e-4), SCALE(1.129068247973919e-2),
+ SCALE(8.945026248693466e-2), SCALE(2.557355761528015e-1),
+ SCALE(3.421461284160614e-1), SCALE(2.261696159839630e-1),
+ SCALE(6.824731826782227e-2), SCALE(6.794991903007030e-3),
+ SCALE(1.575958012836054e-4), SCALE(1.179065089672804e-2),
+ SCALE(9.154383838176728e-2), SCALE(2.583232223987580e-1),
+ SCALE(3.417979776859284e-1), SCALE(2.234084606170654e-1),
+ SCALE(6.648923456668854e-2), SCALE(6.468691397458315e-3),
+ SCALE(1.769922382663936e-4), SCALE(1.230732165277004e-2),
+ SCALE(9.366425126791000e-2), SCALE(2.608896791934967e-1),
+ SCALE(3.413922190666198e-1), SCALE(2.206395119428635e-1),
+ SCALE(6.475970894098282e-2), SCALE(6.154712289571762e-3),
+ SCALE(1.981738605536520e-4), SCALE(1.284105982631445e-2),
+ SCALE(9.581124037504196e-2), SCALE(2.634339034557342e-1),
+ SCALE(3.409290313720703e-1), SCALE(2.178637981414795e-1),
+ SCALE(6.305878609418869e-2), SCALE(5.852684378623962e-3),
+ SCALE(2.211847313446924e-4), SCALE(1.339218579232693e-2),
+ SCALE(9.798453748226166e-2), SCALE(2.659549415111542e-1),
+ SCALE(3.404086530208588e-1), SCALE(2.150822728872299e-1),
+ SCALE(6.138643622398376e-2), SCALE(5.562345497310162e-3),
+ SCALE(2.460231189616024e-4), SCALE(1.396108977496624e-2),
+ SCALE(1.001838669180870e-1), SCALE(2.684516608715058e-1),
+ SCALE(3.398312926292420e-1), SCALE(2.122959494590759e-1),
+ SCALE(5.974265560507774e-2), SCALE(5.283284001052380e-3),
+ SCALE(2.726115926634520e-4), SCALE(1.454808749258518e-2),
+ SCALE(1.024089083075523e-1), SCALE(2.709231376647949e-1),
+ SCALE(3.391972482204438e-1), SCALE(2.095058411359787e-1),
+ SCALE(5.812742188572884e-2), SCALE(5.015311297029257e-3),
+ SCALE(3.013863170053810e-4), SCALE(1.515355054289102e-2),
+ SCALE(1.046593263745308e-1), SCALE(2.733682692050934e-1),
+ SCALE(3.385068178176880e-1), SCALE(2.067128717899322e-1),
+ SCALE(5.654069408774376e-2), SCALE(4.758012015372515e-3),
+ SCALE(3.328395541757345e-4), SCALE(1.577781140804291e-2),
+ SCALE(1.069347932934761e-1), SCALE(2.757860720157624e-1),
+ SCALE(3.377602994441986e-1), SCALE(2.039180546998978e-1),
+ SCALE(5.498242005705833e-2), SCALE(4.511159844696522e-3),
+ SCALE(3.658991190604866e-4), SCALE(1.642123050987720e-2),
+ SCALE(1.092349365353584e-1), SCALE(2.781755328178406e-1),
+ SCALE(3.369580209255218e-1), SCALE(2.011223286390304e-1),
+ SCALE(5.345252528786659e-2), SCALE(4.274417180567980e-3),
+ SCALE(4.018281470052898e-4), SCALE(1.708412915468216e-2),
+ SCALE(1.115593686699867e-1), SCALE(2.805356979370117e-1),
+ SCALE(3.361004292964936e-1), SCALE(1.983266174793244e-1),
+ SCALE(5.195093154907227e-2), SCALE(4.047499038279056e-3),
+ SCALE(4.401875485200435e-4), SCALE(1.776690222322941e-2),
+ SCALE(1.139076948165894e-1), SCALE(2.828655838966370e-1),
+ SCALE(3.351879119873047e-1), SCALE(1.955319195985794e-1),
+ SCALE(5.047753453254700e-2), SCALE(3.830091329291463e-3),
+ SCALE(4.812776169274002e-4), SCALE(1.846982724964619e-2),
+ SCALE(1.162794977426529e-1), SCALE(2.851640880107880e-1),
+ SCALE(3.342207968235016e-1), SCALE(1.927391141653061e-1),
+ SCALE(4.903224110603333e-2), SCALE(3.621967276558280e-3),
+ SCALE(5.252459668554366e-4), SCALE(1.919330470263958e-2),
+ SCALE(1.186743453145027e-1), SCALE(2.874303460121155e-1),
+ SCALE(3.331996202468872e-1), SCALE(1.899491697549820e-1),
+ SCALE(4.761491715908051e-2), SCALE(3.422776935622096e-3),
+ SCALE(5.721592460758984e-4), SCALE(1.993762329220772e-2),
+ SCALE(1.210917681455612e-1), SCALE(2.896633744239807e-1),
+ SCALE(3.321248590946198e-1), SCALE(1.871629506349564e-1),
+ SCALE(4.622544348239899e-2), SCALE(3.232272574678064e-3),
+ SCALE(6.222130032256246e-4), SCALE(2.070316113531590e-2),
+ SCALE(1.235313042998314e-1), SCALE(2.918621897697448e-1),
+ SCALE(3.309969604015350e-1), SCALE(1.843813359737396e-1),
+ SCALE(4.486365616321564e-2), SCALE(3.050152910873294e-3),
+ SCALE(6.755515350960195e-4), SCALE(2.149021252989769e-2),
+ SCALE(1.259924471378326e-1), SCALE(2.940258979797364e-1),
+ SCALE(3.298164308071136e-1), SCALE(1.816052496433258e-1),
+ SCALE(4.352942481637001e-2), SCALE(2.876190468668938e-3),
+ SCALE(7.324148900806904e-4), SCALE(2.229913882911205e-2),
+ SCALE(1.284746825695038e-1), SCALE(2.961534857749939e-1),
+ SCALE(3.285838961601258e-1), SCALE(1.788355410099030e-1),
+ SCALE(4.222255200147629e-2), SCALE(2.710093278437853e-3),
+ SCALE(7.928516715764999e-4), SCALE(2.313023805618286e-2),
+ SCALE(1.309774816036224e-1), SCALE(2.982441186904907e-1),
+ SCALE(3.272998929023742e-1), SCALE(1.760730892419815e-1),
+ SCALE(4.094288870692253e-2), SCALE(2.551567042246461e-3),
+ SCALE(8.570110658183694e-4), SCALE(2.398385666310787e-2),
+ SCALE(1.335003077983856e-1), SCALE(3.002967536449432e-1),
+ SCALE(3.259649574756622e-1), SCALE(1.733186990022659e-1),
+ SCALE(3.969023004174232e-2), SCALE(2.400433411821723e-3),
+ SCALE(9.251192095689476e-4), SCALE(2.486028522253036e-2),
+ SCALE(1.360425949096680e-1), SCALE(3.023106753826142e-1),
+ SCALE(3.245797157287598e-1), SCALE(1.705732345581055e-1),
+ SCALE(3.846437484025955e-2), SCALE(2.256359672173858e-3),
+ SCALE(9.974770946428180e-4), SCALE(2.575986087322235e-2),
+ SCALE(1.386037617921829e-1), SCALE(3.042849004268646e-1),
+ SCALE(3.231448531150818e-1), SCALE(1.678375005722046e-1),
+ SCALE(3.726511076092720e-2), SCALE(2.119151875376701e-3),
+ SCALE(1.073930296115577e-3), SCALE(2.668286114931106e-2),
+ SCALE(1.411831974983215e-1), SCALE(3.062185347080230e-1),
+ SCALE(3.216609656810760e-1), SCALE(1.651122719049454e-1),
+ SCALE(3.609224036335945e-2), SCALE(1.988604199141264e-3),
+ SCALE(1.155023579485714e-3), SCALE(2.762960828840732e-2),
+ SCALE(1.437802612781525e-1), SCALE(3.081108033657074e-1),
+ SCALE(3.201287388801574e-1), SCALE(1.623983532190323e-1),
+ SCALE(3.494550660252571e-2), SCALE(1.864377525635064e-3),
+ SCALE(1.240676851011813e-3), SCALE(2.860039286315441e-2),
+ SCALE(1.463943719863892e-1), SCALE(3.099608123302460e-1),
+ SCALE(3.185488879680634e-1), SCALE(1.596965193748474e-1),
+ SCALE(3.382468968629837e-2), SCALE(1.746327499859035e-3),
+ SCALE(1.331258914433420e-3), SCALE(2.959549613296986e-2),
+ SCALE(1.490248143672943e-1), SCALE(3.117676973342896e-1),
+ SCALE(3.169221282005310e-1), SCALE(1.570075154304504e-1),
+ SCALE(3.272953629493714e-2), SCALE(1.634211512282491e-3),
+ SCALE(1.426893868483603e-3), SCALE(3.061520494520664e-2),
+ SCALE(1.516709625720978e-1), SCALE(3.135308027267456e-1),
+ SCALE(3.152491748332978e-1), SCALE(1.543320864439010e-1),
+ SCALE(3.165979683399200e-2), SCALE(1.527829794213176e-3),
};
DECLARE_ALIGNED(16, static const float, lfe_fir_128)[] =
{
- 0.00053168571, 0.15878495574, 0.68603444099, 0.15492856503,
- 0.00016358691, 0.16269733012, 0.68591803312, 0.15112841129,
- 0.00018878609, 0.16666537523, 0.68568539619, 0.14738474786,
- 0.00021643363, 0.17068879306, 0.68533653021, 0.14369773865,
- 0.00024667382, 0.17476719618, 0.68487155437, 0.14006754756,
- 0.00027949660, 0.17890018225, 0.68429082632, 0.13649433851,
- 0.00031519096, 0.18308731914, 0.68359452486, 0.13297818601,
- 0.00035398375, 0.18732811511, 0.68278300762, 0.12951917946,
- 0.00039634691, 0.19162209332, 0.68185669184, 0.12611730397,
- 0.00044236859, 0.19596865773, 0.68081587553, 0.12277261168,
- 0.00049204525, 0.20036731660, 0.67966115475, 0.11948505789,
- 0.00054522208, 0.20481738448, 0.67839306593, 0.11625462025,
- 0.00060277141, 0.20931822062, 0.67701220512, 0.11308115721,
- 0.00066567765, 0.21386915445, 0.67551922798, 0.10996460915,
- 0.00073179678, 0.21846942604, 0.67391467094, 0.10690483451,
- 0.00080365466, 0.22311829031, 0.67219948769, 0.10390164703,
- 0.00088037323, 0.22781492770, 0.67037439346, 0.10095486045,
- 0.00096255314, 0.23255851865, 0.66844022274, 0.09806428105,
- 0.00105048984, 0.23734821379, 0.66639786959, 0.09522963315,
- 0.00114431616, 0.24218304455, 0.66424828768, 0.09245070815,
- 0.00124442333, 0.24706205726, 0.66199249029, 0.08972713351,
- 0.00135110028, 0.25198432803, 0.65963155031, 0.08705867827,
- 0.00146482687, 0.25694879889, 0.65716648102, 0.08444493264,
- 0.00158570008, 0.26195442677, 0.65459835529, 0.08188561350,
- 0.00171401864, 0.26700007915, 0.65192854404, 0.07938029617,
- 0.00185023469, 0.27208462358, 0.64915806055, 0.07692859322,
- 0.00199495023, 0.27720692754, 0.64628833532, 0.07453006506,
- 0.00214785640, 0.28236576915, 0.64332056046, 0.07218432426,
- 0.00231004250, 0.28755992651, 0.64025616646, 0.06989086419,
- 0.00248134881, 0.29278811812, 0.63709646463, 0.06764923781,
- 0.00266251224, 0.29804900289, 0.63384294510, 0.06545893103,
- 0.00285378192, 0.30334126949, 0.63049703836, 0.06331945211,
- 0.00305565330, 0.30866351724, 0.62706029415, 0.06123027951,
- 0.00326841651, 0.31401440501, 0.62353414297, 0.05919086933,
- 0.00349264755, 0.31939238310, 0.61992025375, 0.05720067024,
- 0.00372874714, 0.32479602098, 0.61622029543, 0.05525910854,
- 0.00397720048, 0.33022382855, 0.61243581772, 0.05336561054,
- 0.00423829490, 0.33567428589, 0.60856848955, 0.05151961371,
- 0.00451271003, 0.34114575386, 0.60462015867, 0.04972046614,
- 0.00480085658, 0.34663668275, 0.60059231520, 0.04796761274,
- 0.00510312291, 0.35214546323, 0.59648692608, 0.04626038298,
- 0.00542017492, 0.35767036676, 0.59230577946, 0.04459818453,
- 0.00575236930, 0.36320972443, 0.58805054426, 0.04298033938,
- 0.00610029325, 0.36876192689, 0.58372318745, 0.04140623659,
- 0.00646453211, 0.37432509661, 0.57932555676, 0.03987516090,
- 0.00684553990, 0.37989753485, 0.57485944033, 0.03838652745,
- 0.00724391919, 0.38547745347, 0.57032698393, 0.03693958372,
- 0.00766016589, 0.39106300473, 0.56572991610, 0.03553372994,
- 0.00809498038, 0.39665243030, 0.56107026339, 0.03416819125,
- 0.00854881573, 0.40224379301, 0.55634999275, 0.03284239396,
- 0.00902230106, 0.40783521533, 0.55157101154, 0.03155555204,
- 0.00951600447, 0.41342487931, 0.54673534632, 0.03030703776,
- 0.01003060210, 0.41901078820, 0.54184508324, 0.02909611352,
- 0.01056654565, 0.42459106445, 0.53690224886, 0.02792212367,
- 0.01112466771, 0.43016362190, 0.53190881014, 0.02678431384,
- 0.01170534454, 0.43572667241, 0.52686679363, 0.02568206564,
- 0.01230939943, 0.44127810001, 0.52177828550, 0.02461459488,
- 0.01293735672, 0.44681602716, 0.51664537191, 0.02358125709,
- 0.01358995494, 0.45233830810, 0.51147013903, 0.02258131653,
- 0.01426773332, 0.45784294605, 0.50625455379, 0.02161412500,
- 0.01497144438, 0.46332800388, 0.50100076199, 0.02067894675,
- 0.01570170000, 0.46879136562, 0.49571081996, 0.01977507770,
- 0.01645922661, 0.47423094511, 0.49038675427, 0.01890186779,
- 0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412,
+ SCALE(0.00053168571), SCALE(0.15878495574), SCALE(0.68603444099), SCALE(0.15492856503),
+ SCALE(0.00016358691), SCALE(0.16269733012), SCALE(0.68591803312), SCALE(0.15112841129),
+ SCALE(0.00018878609), SCALE(0.16666537523), SCALE(0.68568539619), SCALE(0.14738474786),
+ SCALE(0.00021643363), SCALE(0.17068879306), SCALE(0.68533653021), SCALE(0.14369773865),
+ SCALE(0.00024667382), SCALE(0.17476719618), SCALE(0.68487155437), SCALE(0.14006754756),
+ SCALE(0.00027949660), SCALE(0.17890018225), SCALE(0.68429082632), SCALE(0.13649433851),
+ SCALE(0.00031519096), SCALE(0.18308731914), SCALE(0.68359452486), SCALE(0.13297818601),
+ SCALE(0.00035398375), SCALE(0.18732811511), SCALE(0.68278300762), SCALE(0.12951917946),
+ SCALE(0.00039634691), SCALE(0.19162209332), SCALE(0.68185669184), SCALE(0.12611730397),
+ SCALE(0.00044236859), SCALE(0.19596865773), SCALE(0.68081587553), SCALE(0.12277261168),
+ SCALE(0.00049204525), SCALE(0.20036731660), SCALE(0.67966115475), SCALE(0.11948505789),
+ SCALE(0.00054522208), SCALE(0.20481738448), SCALE(0.67839306593), SCALE(0.11625462025),
+ SCALE(0.00060277141), SCALE(0.20931822062), SCALE(0.67701220512), SCALE(0.11308115721),
+ SCALE(0.00066567765), SCALE(0.21386915445), SCALE(0.67551922798), SCALE(0.10996460915),
+ SCALE(0.00073179678), SCALE(0.21846942604), SCALE(0.67391467094), SCALE(0.10690483451),
+ SCALE(0.00080365466), SCALE(0.22311829031), SCALE(0.67219948769), SCALE(0.10390164703),
+ SCALE(0.00088037323), SCALE(0.22781492770), SCALE(0.67037439346), SCALE(0.10095486045),
+ SCALE(0.00096255314), SCALE(0.23255851865), SCALE(0.66844022274), SCALE(0.09806428105),
+ SCALE(0.00105048984), SCALE(0.23734821379), SCALE(0.66639786959), SCALE(0.09522963315),
+ SCALE(0.00114431616), SCALE(0.24218304455), SCALE(0.66424828768), SCALE(0.09245070815),
+ SCALE(0.00124442333), SCALE(0.24706205726), SCALE(0.66199249029), SCALE(0.08972713351),
+ SCALE(0.00135110028), SCALE(0.25198432803), SCALE(0.65963155031), SCALE(0.08705867827),
+ SCALE(0.00146482687), SCALE(0.25694879889), SCALE(0.65716648102), SCALE(0.08444493264),
+ SCALE(0.00158570008), SCALE(0.26195442677), SCALE(0.65459835529), SCALE(0.08188561350),
+ SCALE(0.00171401864), SCALE(0.26700007915), SCALE(0.65192854404), SCALE(0.07938029617),
+ SCALE(0.00185023469), SCALE(0.27208462358), SCALE(0.64915806055), SCALE(0.07692859322),
+ SCALE(0.00199495023), SCALE(0.27720692754), SCALE(0.64628833532), SCALE(0.07453006506),
+ SCALE(0.00214785640), SCALE(0.28236576915), SCALE(0.64332056046), SCALE(0.07218432426),
+ SCALE(0.00231004250), SCALE(0.28755992651), SCALE(0.64025616646), SCALE(0.06989086419),
+ SCALE(0.00248134881), SCALE(0.29278811812), SCALE(0.63709646463), SCALE(0.06764923781),
+ SCALE(0.00266251224), SCALE(0.29804900289), SCALE(0.63384294510), SCALE(0.06545893103),
+ SCALE(0.00285378192), SCALE(0.30334126949), SCALE(0.63049703836), SCALE(0.06331945211),
+ SCALE(0.00305565330), SCALE(0.30866351724), SCALE(0.62706029415), SCALE(0.06123027951),
+ SCALE(0.00326841651), SCALE(0.31401440501), SCALE(0.62353414297), SCALE(0.05919086933),
+ SCALE(0.00349264755), SCALE(0.31939238310), SCALE(0.61992025375), SCALE(0.05720067024),
+ SCALE(0.00372874714), SCALE(0.32479602098), SCALE(0.61622029543), SCALE(0.05525910854),
+ SCALE(0.00397720048), SCALE(0.33022382855), SCALE(0.61243581772), SCALE(0.05336561054),
+ SCALE(0.00423829490), SCALE(0.33567428589), SCALE(0.60856848955), SCALE(0.05151961371),
+ SCALE(0.00451271003), SCALE(0.34114575386), SCALE(0.60462015867), SCALE(0.04972046614),
+ SCALE(0.00480085658), SCALE(0.34663668275), SCALE(0.60059231520), SCALE(0.04796761274),
+ SCALE(0.00510312291), SCALE(0.35214546323), SCALE(0.59648692608), SCALE(0.04626038298),
+ SCALE(0.00542017492), SCALE(0.35767036676), SCALE(0.59230577946), SCALE(0.04459818453),
+ SCALE(0.00575236930), SCALE(0.36320972443), SCALE(0.58805054426), SCALE(0.04298033938),
+ SCALE(0.00610029325), SCALE(0.36876192689), SCALE(0.58372318745), SCALE(0.04140623659),
+ SCALE(0.00646453211), SCALE(0.37432509661), SCALE(0.57932555676), SCALE(0.03987516090),
+ SCALE(0.00684553990), SCALE(0.37989753485), SCALE(0.57485944033), SCALE(0.03838652745),
+ SCALE(0.00724391919), SCALE(0.38547745347), SCALE(0.57032698393), SCALE(0.03693958372),
+ SCALE(0.00766016589), SCALE(0.39106300473), SCALE(0.56572991610), SCALE(0.03553372994),
+ SCALE(0.00809498038), SCALE(0.39665243030), SCALE(0.56107026339), SCALE(0.03416819125),
+ SCALE(0.00854881573), SCALE(0.40224379301), SCALE(0.55634999275), SCALE(0.03284239396),
+ SCALE(0.00902230106), SCALE(0.40783521533), SCALE(0.55157101154), SCALE(0.03155555204),
+ SCALE(0.00951600447), SCALE(0.41342487931), SCALE(0.54673534632), SCALE(0.03030703776),
+ SCALE(0.01003060210), SCALE(0.41901078820), SCALE(0.54184508324), SCALE(0.02909611352),
+ SCALE(0.01056654565), SCALE(0.42459106445), SCALE(0.53690224886), SCALE(0.02792212367),
+ SCALE(0.01112466771), SCALE(0.43016362190), SCALE(0.53190881014), SCALE(0.02678431384),
+ SCALE(0.01170534454), SCALE(0.43572667241), SCALE(0.52686679363), SCALE(0.02568206564),
+ SCALE(0.01230939943), SCALE(0.44127810001), SCALE(0.52177828550), SCALE(0.02461459488),
+ SCALE(0.01293735672), SCALE(0.44681602716), SCALE(0.51664537191), SCALE(0.02358125709),
+ SCALE(0.01358995494), SCALE(0.45233830810), SCALE(0.51147013903), SCALE(0.02258131653),
+ SCALE(0.01426773332), SCALE(0.45784294605), SCALE(0.50625455379), SCALE(0.02161412500),
+ SCALE(0.01497144438), SCALE(0.46332800388), SCALE(0.50100076199), SCALE(0.02067894675),
+ SCALE(0.01570170000), SCALE(0.46879136562), SCALE(0.49571081996), SCALE(0.01977507770),
+ SCALE(0.01645922661), SCALE(0.47423094511), SCALE(0.49038675427), SCALE(0.01890186779),
+ SCALE(0.01724460535), SCALE(0.47964480519), SCALE(0.48503074050), SCALE(0.01805862412),
};
+#undef SCALE
/*
* D.11 Look-up Table for Downmix Scale Factors
diff --git a/chromium/third_party/ffmpeg/libavcodec/dcadec.c b/chromium/third_party/ffmpeg/libavcodec/dcadec.c
index cc2fa0af12e..6a9dfa34d43 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dcadec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dcadec.c
@@ -53,7 +53,6 @@
//#define TRACE
#define DCA_PRIM_CHANNELS_MAX (7)
-#define DCA_SUBBANDS (64)
#define DCA_ABITS_MAX (32) /* Should be 28 */
#define DCA_SUBSUBFRAMES_MAX (4)
#define DCA_SUBFRAMES_MAX (16)
@@ -400,7 +399,7 @@ typedef struct {
int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs
int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index
int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< transition mode (transients)
- int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]; ///< scale factors (2 if transient)
+ int32_t scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2];///< scale factors (2 if transient)
int joint_huff[DCA_PRIM_CHANNELS_MAX]; ///< joint subband scale factors codebook
int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors
float downmix_coef[DCA_PRIM_CHANNELS_MAX + 1][2]; ///< stereo downmix coefficients
@@ -413,7 +412,7 @@ typedef struct {
uint8_t core_downmix_amode; ///< audio channel arrangement of embedded downmix
uint16_t core_downmix_codes[DCA_PRIM_CHANNELS_MAX + 1][4]; ///< embedded downmix coefficients (9-bit codes)
- int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands
+ int32_t high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands
float lfe_data[2 * DCA_LFE_MAX * (DCA_BLOCKS_MAX + 4)]; ///< Low frequency effect data
int lfe_scale_factor;
@@ -1105,7 +1104,7 @@ static void qmf_32_subbands(DCAContext *s, int chans,
static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
int num_deci_sample, float *samples_in,
- float *samples_out, float scale)
+ float *samples_out)
{
/* samples_in: An array holding decimated samples.
* Samples in current subframe starts from samples_in[0],
@@ -1115,23 +1114,23 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
* samples_out: An array holding interpolated samples
*/
- int decifactor;
+ int idx;
const float *prCoeff;
int deciindex;
/* Select decimation filter */
if (decimation_select == 1) {
- decifactor = 64;
+ idx = 1;
prCoeff = lfe_fir_128;
} else {
- decifactor = 32;
+ idx = 0;
prCoeff = lfe_fir_64;
}
/* Interpolation */
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
- s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale);
+ s->dcadsp.lfe_fir[idx](samples_out, samples_in, prCoeff);
samples_in++;
- samples_out += 2 * decifactor;
+ samples_out += 2 * 32 * (1 + idx);
}
}
@@ -1246,16 +1245,6 @@ static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 };
static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 };
-#ifndef int8x8_fmul_int32
-static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
-{
- float fscale = scale / 16.0;
- int i;
- for (i = 0; i < 8; i++)
- dst[i] = src[i] * fscale;
-}
-#endif
-
static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
{
int k, l;
@@ -1352,16 +1341,27 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
*/
if (s->prediction_mode[k][l]) {
int n;
- for (m = 0; m < 8; m++) {
- for (n = 1; n <= 4; n++)
+ if (s->predictor_history)
+ subband_samples[k][l][0] += (adpcm_vb[s->prediction_vq[k][l]][0] *
+ s->subband_samples_hist[k][l][3] +
+ adpcm_vb[s->prediction_vq[k][l]][1] *
+ s->subband_samples_hist[k][l][2] +
+ adpcm_vb[s->prediction_vq[k][l]][2] *
+ s->subband_samples_hist[k][l][1] +
+ adpcm_vb[s->prediction_vq[k][l]][3] *
+ s->subband_samples_hist[k][l][0]) *
+ (1.0f / 8192);
+ for (m = 1; m < 8; m++) {
+ float sum = adpcm_vb[s->prediction_vq[k][l]][0] *
+ subband_samples[k][l][m - 1];
+ for (n = 2; n <= 4; n++)
if (m >= n)
- subband_samples[k][l][m] +=
- (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
- subband_samples[k][l][m - n] / 8192);
+ sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ subband_samples[k][l][m - n];
else if (s->predictor_history)
- subband_samples[k][l][m] +=
- (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
- s->subband_samples_hist[k][l][m - n + 4] / 8192);
+ sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ s->subband_samples_hist[k][l][m - n + 4];
+ subband_samples[k][l][m] += sum * (1.0f / 8192);
}
}
}
@@ -1369,20 +1369,16 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
/*
* Decode VQ encoded high frequencies
*/
- for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) {
- /* 1 vector -> 32 samples but we only need the 8 samples
- * for this subsubframe. */
- int hfvq = s->high_freq_vq[k][l];
-
- if (!s->debug_flag & 0x01) {
+ if (s->subband_activity[k] > s->vq_start_subband[k]) {
+ if (!(s->debug_flag & 0x01)) {
av_log(s->avctx, AV_LOG_DEBUG,
"Stream with high frequencies VQ coding\n");
s->debug_flag |= 0x01;
}
-
- int8x8_fmul_int32(subband_samples[k][l],
- &high_freq_vq[hfvq][subsubframe * 8],
- s->scale_factor[k][l][0]);
+ s->dcadsp.decode_hf(subband_samples[k], s->high_freq_vq[k],
+ high_freq_vq, subsubframe * 8,
+ s->scale_factor[k], s->vq_start_subband[k],
+ s->subband_activity[k]);
}
}
@@ -1401,9 +1397,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
/* Backup predictor history for adpcm */
for (k = base_channel; k < s->prim_channels; k++)
for (l = 0; l < s->vq_start_subband[k]; l++)
- memcpy(s->subband_samples_hist[k][l],
- &subband_samples[k][l][4],
- 4 * sizeof(subband_samples[0][0][0]));
+ AV_COPY128(s->subband_samples_hist[k][l], &subband_samples[k][l][4]);
return 0;
}
@@ -1427,8 +1421,7 @@ static int dca_filter_channels(DCAContext *s, int block_index)
if (s->lfe) {
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
s->lfe_data + 2 * s->lfe * (block_index + 4),
- s->samples_chanptr[s->lfe_index],
- 1.0 / (256.0 * 32768.0));
+ s->samples_chanptr[s->lfe_index]);
/* Outputs 20bits pcm samples */
}
@@ -2071,6 +2064,8 @@ static void dca_exss_parse_header(DCAContext *s)
}
}
+ av_assert0(num_assets > 0); // silence a warning
+
for (i = 0; i < num_assets; i++)
asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup);
@@ -2082,7 +2077,6 @@ static void dca_exss_parse_header(DCAContext *s)
/* not parsed further, we were only interested in the extensions mask
* from the asset header */
- if (num_assets > 0) {
j = get_bits_count(&s->gb);
if (start_posn + hdrsize * 8 > j)
skip_bits_long(&s->gb, start_posn + hdrsize * 8 - j);
@@ -2107,7 +2101,6 @@ static void dca_exss_parse_header(DCAContext *s)
if (start_posn + asset_size[i] * 8 > j)
skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j);
}
- }
}
/**
@@ -2149,7 +2142,6 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
- init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
if ((ret = dca_parse_frame_header(s)) < 0) {
//seems like the frame is corrupt, try with the next one
return ret;
@@ -2180,7 +2172,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
if (s->core_downmix && (s->core_downmix_amode == DCA_STEREO ||
s->core_downmix_amode == DCA_STEREO_TOTAL)) {
int sign, code;
- for (i = 0; i < s->prim_channels + !!s->lfe; i++) {
+ for (i = 0; i < num_core_channels + !!s->lfe; i++) {
sign = s->core_downmix_codes[i][0] & 0x100 ? 1 : -1;
code = s->core_downmix_codes[i][0] & 0x0FF;
s->downmix_coef[i][0] = (!code ? 0.0f :
@@ -2190,6 +2182,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
s->downmix_coef[i][1] = (!code ? 0.0f :
sign * dca_dmixtable[code - 1]);
}
+ s->output = s->core_downmix_amode;
} else {
int am = s->amode & DCA_CHANNEL_MASK;
if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {
@@ -2197,19 +2190,19 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
"Invalid channel mode %d\n", am);
return AVERROR_INVALIDDATA;
}
- if (s->prim_channels + !!s->lfe >
+ if (num_core_channels + !!s->lfe >
FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
avpriv_request_sample(s->avctx, "Downmixing %d channels",
s->prim_channels + !!s->lfe);
return AVERROR_PATCHWELCOME;
}
- for (i = 0; i < s->prim_channels + !!s->lfe; i++) {
+ for (i = 0; i < num_core_channels + !!s->lfe; i++) {
s->downmix_coef[i][0] = dca_default_coeffs[am][i][0];
s->downmix_coef[i][1] = dca_default_coeffs[am][i][1];
}
}
av_dlog(s->avctx, "Stereo downmix coeffs:\n");
- for (i = 0; i < s->prim_channels + !!s->lfe; i++) {
+ for (i = 0; i < num_core_channels + !!s->lfe; i++) {
av_dlog(s->avctx, "L, input channel %d = %f\n", i,
s->downmix_coef[i][0]);
av_dlog(s->avctx, "R, input channel %d = %f\n", i,
@@ -2335,6 +2328,17 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
{ /* xxx should also do MA extensions */
if (s->amode < 16) {
avctx->channel_layout = dca_core_channel_layout[s->amode];
+
+ if (s->prim_channels + !!s->lfe > 2 &&
+ avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
+ /*
+ * Neither the core's auxiliary data nor our default tables contain
+ * downmix coefficients for the additional channel coded in the XCh
+ * extension, so when we're doing a Stereo downmix, don't decode it.
+ */
+ s->xch_disable = 1;
+ }
+
#if FF_API_REQUEST_CHANNELS
FF_DISABLE_DEPRECATION_WARNINGS
if (s->xch_present && !s->xch_disable &&
@@ -2372,10 +2376,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
return AVERROR_INVALIDDATA;
}
- if (s->prim_channels + !!s->lfe > 2 &&
+ if (num_core_channels + !!s->lfe > 2 &&
avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
channels = 2;
- s->output = DCA_STEREO;
+ s->output = s->prim_channels == 2 ? s->amode : DCA_STEREO;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
}
else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) {
@@ -2421,7 +2425,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
* masks in some sense -- unfortunately some channels could overlap */
if (av_popcount(channel_mask) != av_popcount(channel_layout)) {
av_log(avctx, AV_LOG_DEBUG,
- "DTS-XXCH: Inconsistant avcodec/dts channel layouts\n");
+ "DTS-XXCH: Inconsistent avcodec/dts channel layouts\n");
return AVERROR_INVALIDDATA;
}
@@ -2439,6 +2443,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->xxch_order_tab[j++] = posn;
}
}
+
}
s->lfe_index = av_popcount(channel_layout & (AV_CH_LOW_FREQUENCY-1));
@@ -2559,6 +2564,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
for (i = 0; i < 2 * s->lfe * 4; i++)
s->lfe_data[i] = s->lfe_data[i + lfe_samples];
+ /* AVMatrixEncoding
+ *
+ * DCA_STEREO_TOTAL (Lt/Rt) is equivalent to Dolby Surround */
+ ret = ff_side_data_update_matrix_encoding(frame,
+ (s->output & ~DCA_LFE) == DCA_STEREO_TOTAL ?
+ AV_MATRIX_ENCODING_DOLBY : AV_MATRIX_ENCODING_NONE);
+ if (ret < 0)
+ return ret;
+
*got_frame_ptr = 1;
return buf_size;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dcadsp.c b/chromium/third_party/ffmpeg/libavcodec/dcadsp.c
index abeba2492bf..7d5044298a0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dcadsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dcadsp.c
@@ -24,25 +24,42 @@
#include "libavutil/intreadwrite.h"
#include "dcadsp.h"
-static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
- int decifactor, float scale)
+static void decode_hf_c(float dst[DCA_SUBBANDS][8],
+ const int32_t vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int32_t scale[DCA_SUBBANDS][2],
+ intptr_t start, intptr_t end)
{
- float *out2 = out + decifactor;
- const float *cf0 = coefs;
- const float *cf1 = coefs + 256;
+ int i, l;
+
+ for (l = start; l < end; l++) {
+ /* 1 vector -> 32 samples but we only need the 8 samples
+ * for this subsubframe. */
+ const int8_t *ptr = &hf_vq[vq_num[l]][vq_offset];
+ float fscale = scale[l][0] * (1 / 16.0);
+ for (i = 0; i < 8; i++)
+ dst[l][i] = ptr[i] * fscale;
+ }
+}
+
+static inline void
+dca_lfe_fir(float *out, const float *in, const float *coefs,
+ int decifactor)
+{
+ float *out2 = out + 2 * decifactor - 1;
+ int num_coeffs = 256 / decifactor;
int j, k;
/* One decimated sample generates 2*decifactor interpolated ones */
for (k = 0; k < decifactor; k++) {
float v0 = 0.0;
float v1 = 0.0;
- for (j = 0; j < 256 / decifactor; j++) {
- float s = in[-j];
- v0 += s * *cf0++;
- v1 += s * *--cf1;
+ for (j = 0; j < num_coeffs; j++, coefs++) {
+ v0 += in[-j] * *coefs;
+ v1 += in[j + 1 - num_coeffs] * *coefs;
}
- *out++ = v0 * scale;
- *out2++ = v1 * scale;
+ *out++ = v0;
+ *out2-- = v1;
}
}
@@ -74,9 +91,22 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
}
}
+static void dca_lfe_fir0_c(float *out, const float *in, const float *coefs)
+{
+ dca_lfe_fir(out, in, coefs, 32);
+}
+
+static void dca_lfe_fir1_c(float *out, const float *in, const float *coefs)
+{
+ dca_lfe_fir(out, in, coefs, 64);
+}
+
av_cold void ff_dcadsp_init(DCADSPContext *s)
{
- s->lfe_fir = dca_lfe_fir_c;
+ s->lfe_fir[0] = dca_lfe_fir0_c;
+ s->lfe_fir[1] = dca_lfe_fir1_c;
s->qmf_32_subbands = dca_qmf_32_subbands;
+ s->decode_hf = decode_hf_c;
if (ARCH_ARM) ff_dcadsp_init_arm(s);
+ if (ARCH_X86) ff_dcadsp_init_x86(s);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dcadsp.h b/chromium/third_party/ffmpeg/libavcodec/dcadsp.h
index d86c1f32a6d..abf577b61fa 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dcadsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dcadsp.h
@@ -22,18 +22,25 @@
#include "avfft.h"
#include "synth_filter.h"
+#define DCA_SUBBANDS 64
+
typedef struct DCADSPContext {
- void (*lfe_fir)(float *out, const float *in, const float *coefs,
- int decifactor, float scale);
+ void (*lfe_fir[2])(float *out, const float *in, const float *coefs);
void (*qmf_32_subbands)(float samples_in[32][8], int sb_act,
SynthFilterContext *synth, FFTContext *imdct,
float synth_buf_ptr[512],
int *synth_buf_offset, float synth_buf2[32],
const float window[512], float *samples_out,
float raXin[32], float scale);
+ void (*decode_hf)(float dst[DCA_SUBBANDS][8],
+ const int32_t vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int32_t scale[DCA_SUBBANDS][2],
+ intptr_t start, intptr_t end);
} DCADSPContext;
void ff_dcadsp_init(DCADSPContext *s);
void ff_dcadsp_init_arm(DCADSPContext *s);
+void ff_dcadsp_init_x86(DCADSPContext *s);
#endif /* AVCODEC_DCADSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/dcaenc.c b/chromium/third_party/ffmpeg/libavcodec/dcaenc.c
index cb73f42a078..8d0655ddcfe 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dcaenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dcaenc.c
@@ -29,6 +29,7 @@
#include "dcadata.h"
#include "dcaenc.h"
#include "internal.h"
+#include "mathops.h"
#include "put_bits.h"
#define MAX_CHANNELS 6
diff --git a/chromium/third_party/ffmpeg/libavcodec/dct-test.c b/chromium/third_party/ffmpeg/libavcodec/dct-test.c
index 547ea02a219..63083483617 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dct-test.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dct-test.c
@@ -99,6 +99,18 @@ static const struct algo fdct_tab[] = {
{ 0 }
};
+static void ff_prores_idct_wrap(int16_t *dst){
+ DECLARE_ALIGNED(16, static int16_t, qmat)[64];
+ int i;
+
+ for(i=0; i<64; i++){
+ qmat[i]=4;
+ }
+ ff_prores_idct(dst, qmat);
+ for(i=0; i<64; i++) {
+ dst[i] -= 512;
+ }
+}
#if ARCH_X86_64 && HAVE_MMX && HAVE_YASM
void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
int16_t *block, int16_t *qmat);
@@ -113,6 +125,10 @@ static void ff_prores_idct_put_10_sse2_wrap(int16_t *dst){
tmp[i]= dst[i];
}
ff_prores_idct_put_10_sse2(dst, 16, tmp, qmat);
+
+ for(i=0; i<64; i++) {
+ dst[i] -= 512;
+ }
}
#endif
@@ -121,6 +137,7 @@ static const struct algo idct_tab[] = {
{ "REF-DBL", ff_ref_idct, NO_PERM },
{ "INT", ff_j_rev_dct, MMX_PERM },
{ "SIMPLE-C", ff_simple_idct_8, NO_PERM },
+ { "PR-C", ff_prores_idct_wrap, NO_PERM, 0, 1 },
#if HAVE_MMX_INLINE
{ "SIMPLE-MMX", ff_simple_idct_mmx, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX },
@@ -150,7 +167,7 @@ static const struct algo idct_tab[] = {
#if HAVE_ARMV6
{ "SIMPLE-ARMV6", ff_simple_idct_armv6, MMX_PERM, AV_CPU_FLAG_ARMV6 },
#endif
-#if HAVE_NEON
+#if HAVE_NEON && ARCH_ARM
{ "SIMPLE-NEON", ff_simple_idct_neon, PARTTRANS_PERM, AV_CPU_FLAG_NEON },
#endif
@@ -280,6 +297,9 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
}
ref(block1);
+ if (!strcmp(dct->name, "PR-SSE2"))
+ for (i = 0; i < 64; i++)
+ block1[i] = av_clip(block1[i], 4-512, 1019-512);
blockSumErr = 0;
for (i = 0; i < 64; i++) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/dct.c b/chromium/third_party/ffmpeg/libavcodec/dct.c
index b1ee06a8178..26b485106d2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dct.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dct.c
@@ -190,7 +190,7 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
ff_init_ff_cos_tabs(nbits + 2);
s->costab = ff_cos_tabs[nbits + 2];
- s->csc2 = av_malloc(n / 2 * sizeof(FFTSample));
+ s->csc2 = av_malloc_array(n / 2, sizeof(FFTSample));
if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
av_free(s->csc2);
diff --git a/chromium/third_party/ffmpeg/libavcodec/dfa.c b/chromium/third_party/ffmpeg/libavcodec/dfa.c
index b1be475ef21..f13291ef28a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dfa.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dfa.c
@@ -20,11 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavutil/avassert.h"
+#include <inttypes.h>
+
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
+#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
@@ -369,7 +371,8 @@ static int dfa_decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
} else {
- av_log(avctx, AV_LOG_WARNING, "Ignoring unknown chunk type %d\n",
+ av_log(avctx, AV_LOG_WARNING,
+ "Ignoring unknown chunk type %"PRIu32"\n",
chunk_type);
}
buf += chunk_size;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dirac_arith.h b/chromium/third_party/ffmpeg/libavcodec/dirac_arith.h
index f9a8bba5fd7..089c71a6983 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dirac_arith.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dirac_arith.h
@@ -28,6 +28,7 @@
#ifndef AVCODEC_DIRAC_ARITH_H
#define AVCODEC_DIRAC_ARITH_H
+#include "libavutil/x86/asm.h"
#include "bytestream.h"
#include "get_bits.h"
@@ -134,7 +135,7 @@ static inline int dirac_get_arith_bit(DiracArith *c, int ctx)
range_times_prob = (c->range * prob_zero) >> 16;
-#if HAVE_FAST_CMOV && HAVE_INLINE_ASM
+#if HAVE_FAST_CMOV && HAVE_INLINE_ASM && HAVE_6REGS
low -= range_times_prob << 16;
range -= range_times_prob;
bit = 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.c b/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.c
index bbd8ec74a6b..51a924be958 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.c
@@ -535,6 +535,7 @@ int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height
d->vertical_compose_l0 = (void*)vertical_compose_fidelityiL0;
d->vertical_compose_h0 = (void*)vertical_compose_fidelityiH0;
d->horizontal_compose = horizontal_compose_fidelityi;
+ d->support = 0; // not really used
break;
case DWT_DIRAC_DAUB9_7:
d->spatial_compose = spatial_compose_daub97i_dy;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.h b/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.h
index 25c13d1a656..e5e447b0ac6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dirac_dwt.h
@@ -82,7 +82,7 @@ int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height
void ff_spatial_idwt_slice2(DWTContext *d, int y);
-// shared stuff for simd optimiztions
+// shared stuff for simd optimizations
#define COMPOSE_53iL0(b0, b1, b2)\
(b1 - ((b0 + b2 + 2) >> 2))
diff --git a/chromium/third_party/ffmpeg/libavcodec/diracdec.c b/chromium/third_party/ffmpeg/libavcodec/diracdec.c
index dbc2aab3348..1be4115c59c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/diracdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/diracdec.c
@@ -80,7 +80,7 @@
#define DIVRNDUP(a, b) (((a) + (b) - 1) / (b))
typedef struct {
- AVFrame avframe;
+ AVFrame *avframe;
int interpolated[3]; /* 1 if hpel[] is valid */
uint8_t *hpel[3][4];
uint8_t *hpel_base[3][4];
@@ -291,7 +291,7 @@ static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum)
int i, remove_idx = -1;
for (i = 0; framelist[i]; i++)
- if (framelist[i]->avframe.display_picture_number == picnum) {
+ if (framelist[i]->avframe->display_picture_number == picnum) {
remove_pic = framelist[i];
remove_idx = i;
}
@@ -336,8 +336,8 @@ static int alloc_sequence_buffers(DiracContext *s)
w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
- s->plane[i].idwt_buf_base = av_mallocz((w+max_xblen)*h * sizeof(IDWTELEM));
- s->plane[i].idwt_tmp = av_malloc((w+16) * sizeof(IDWTELEM));
+ s->plane[i].idwt_buf_base = av_mallocz_array((w+max_xblen), h * sizeof(IDWTELEM));
+ s->plane[i].idwt_tmp = av_malloc_array((w+16), sizeof(IDWTELEM));
s->plane[i].idwt_buf = s->plane[i].idwt_buf_base + top_padding*w;
if (!s->plane[i].idwt_buf_base || !s->plane[i].idwt_tmp)
return AVERROR(ENOMEM);
@@ -347,12 +347,12 @@ static int alloc_sequence_buffers(DiracContext *s)
h = s->source.height;
/* fixme: allocate using real stride here */
- s->sbsplit = av_malloc(sbwidth * sbheight);
- s->blmotion = av_malloc(sbwidth * sbheight * 16 * sizeof(*s->blmotion));
- s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
+ s->sbsplit = av_malloc_array(sbwidth, sbheight);
+ s->blmotion = av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
+ s->edge_emu_buffer_base = av_malloc_array((w+64), MAX_BLOCKSIZE);
- s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
- s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
+ s->mctmp = av_malloc_array((w+64+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
+ s->mcscratch = av_malloc_array((w+64), MAX_BLOCKSIZE);
if (!s->sbsplit || !s->blmotion || !s->mctmp || !s->mcscratch)
return AVERROR(ENOMEM);
@@ -364,8 +364,8 @@ static void free_sequence_buffers(DiracContext *s)
int i, j, k;
for (i = 0; i < MAX_FRAMES; i++) {
- if (s->all_frames[i].avframe.data[0]) {
- av_frame_unref(&s->all_frames[i].avframe);
+ if (s->all_frames[i].avframe->data[0]) {
+ av_frame_unref(s->all_frames[i].avframe);
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
}
@@ -393,17 +393,23 @@ static void free_sequence_buffers(DiracContext *s)
static av_cold int dirac_decode_init(AVCodecContext *avctx)
{
DiracContext *s = avctx->priv_data;
+ int i;
+
s->avctx = avctx;
s->frame_number = -1;
- if (avctx->flags&CODEC_FLAG_EMU_EDGE) {
- av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported!\n");
- return AVERROR_PATCHWELCOME;
- }
-
ff_dsputil_init(&s->dsp, avctx);
ff_diracdsp_init(&s->diracdsp);
+ for (i = 0; i < MAX_FRAMES; i++) {
+ s->all_frames[i].avframe = av_frame_alloc();
+ if (!s->all_frames[i].avframe) {
+ while (i > 0)
+ av_frame_free(&s->all_frames[--i].avframe);
+ return AVERROR(ENOMEM);
+ }
+ }
+
return 0;
}
@@ -417,7 +423,13 @@ static void dirac_decode_flush(AVCodecContext *avctx)
static av_cold int dirac_decode_end(AVCodecContext *avctx)
{
+ DiracContext *s = avctx->priv_data;
+ int i;
+
dirac_decode_flush(avctx);
+ for (i = 0; i < MAX_FRAMES; i++)
+ av_frame_free(&s->all_frames[i].avframe);
+
return 0;
}
@@ -742,7 +754,7 @@ static void decode_lowdelay(DiracContext *s)
struct lowdelay_slice *slices;
int slice_num = 0;
- slices = av_mallocz(s->lowdelay.num_x * s->lowdelay.num_y * sizeof(struct lowdelay_slice));
+ slices = av_mallocz_array(s->lowdelay.num_x, s->lowdelay.num_y * sizeof(struct lowdelay_slice));
align_get_bits(&s->gb);
/*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
@@ -1343,8 +1355,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
motion_y >>= s->chroma_y_shift;
}
- mx = motion_x & ~(-1 << s->mv_precision);
- my = motion_y & ~(-1 << s->mv_precision);
+ mx = motion_x & ~(-1U << s->mv_precision);
+ my = motion_y & ~(-1U << s->mv_precision);
motion_x >>= s->mv_precision;
motion_y >>= s->mv_precision;
/* normalize subpel coordinates to epel */
@@ -1519,8 +1531,8 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
just use 8 for everything for the moment */
int i, edge = EDGE_WIDTH/2;
- ref->hpel[plane][0] = ref->avframe.data[plane];
- s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
+ ref->hpel[plane][0] = ref->avframe->data[plane];
+ s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
/* no need for hpel if we only have fpel vectors */
if (!s->mv_precision)
@@ -1528,18 +1540,18 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
for (i = 1; i < 4; i++) {
if (!ref->hpel_base[plane][i])
- ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe.linesize[plane] + 32);
+ ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32);
/* we need to be 16-byte aligned even for chroma */
- ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe.linesize[plane] + 16;
+ ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16;
}
if (!ref->interpolated[plane]) {
s->diracdsp.dirac_hpel_filter(ref->hpel[plane][1], ref->hpel[plane][2],
ref->hpel[plane][3], ref->hpel[plane][0],
- ref->avframe.linesize[plane], width, height);
- s->dsp.draw_edges(ref->hpel[plane][1], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(ref->hpel[plane][2], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(ref->hpel[plane][3], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ ref->avframe->linesize[plane], width, height);
+ s->dsp.draw_edges(ref->hpel[plane][1], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ s->dsp.draw_edges(ref->hpel[plane][2], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ s->dsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
}
ref->interpolated[plane] = 1;
}
@@ -1565,7 +1577,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
for (comp = 0; comp < 3; comp++) {
Plane *p = &s->plane[comp];
- uint8_t *frame = s->current_picture->avframe.data[comp];
+ uint8_t *frame = s->current_picture->avframe->data[comp];
/* FIXME: small resolutions */
for (i = 0; i < 4; i++)
@@ -1629,6 +1641,29 @@ static int dirac_decode_frame_internal(DiracContext *s)
return 0;
}
+static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
+{
+ int ret, i;
+ int chroma_x_shift, chroma_y_shift;
+ avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, &chroma_y_shift);
+
+ f->width = avctx->width + 2 * EDGE_WIDTH;
+ f->height = avctx->height + 2 * EDGE_WIDTH + 2;
+ ret = ff_get_buffer(avctx, f, flags);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; f->data[i]; i++) {
+ int offset = (EDGE_WIDTH >> (i && i<3 ? chroma_y_shift : 0)) *
+ f->linesize[i] + 32;
+ f->data[i] += offset;
+ }
+ f->width = avctx->width;
+ f->height = avctx->height;
+
+ return 0;
+}
+
/**
* Dirac Specification ->
* 11.1.1 Picture Header. picture_header()
@@ -1640,7 +1675,7 @@ static int dirac_decode_picture_header(DiracContext *s)
GetBitContext *gb = &s->gb;
/* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
- picnum = s->current_picture->avframe.display_picture_number = get_bits_long(gb, 32);
+ picnum = s->current_picture->avframe->display_picture_number = get_bits_long(gb, 32);
av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
@@ -1659,9 +1694,9 @@ static int dirac_decode_picture_header(DiracContext *s)
/* Jordi: this is needed if the referenced picture hasn't yet arrived */
for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
if (s->ref_frames[j]
- && FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum) < refdist) {
+ && FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum) < refdist) {
s->ref_pics[i] = s->ref_frames[j];
- refdist = FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum);
+ refdist = FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum);
}
if (!s->ref_pics[i] || refdist)
@@ -1670,21 +1705,21 @@ static int dirac_decode_picture_header(DiracContext *s)
/* if there were no references at all, allocate one */
if (!s->ref_pics[i])
for (j = 0; j < MAX_FRAMES; j++)
- if (!s->all_frames[j].avframe.data[0]) {
+ if (!s->all_frames[j].avframe->data[0]) {
s->ref_pics[i] = &s->all_frames[j];
- ff_get_buffer(s->avctx, &s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
+ get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
break;
}
}
/* retire the reference frames that are not used anymore */
- if (s->current_picture->avframe.reference) {
+ if (s->current_picture->avframe->reference) {
retire = picnum + dirac_get_se_golomb(gb);
if (retire != picnum) {
DiracFrame *retire_pic = remove_frame(s->ref_frames, retire);
if (retire_pic)
- retire_pic->avframe.reference &= DELAYED_PIC_REF;
+ retire_pic->avframe->reference &= DELAYED_PIC_REF;
else
av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n");
}
@@ -1692,7 +1727,7 @@ static int dirac_decode_picture_header(DiracContext *s)
/* if reference array is full, remove the oldest as per the spec */
while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
- remove_frame(s->ref_frames, s->ref_frames[0]->avframe.display_picture_number)->avframe.reference &= DELAYED_PIC_REF;
+ remove_frame(s->ref_frames, s->ref_frames[0]->avframe->display_picture_number)->avframe->reference &= DELAYED_PIC_REF;
}
}
@@ -1717,7 +1752,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
/* find frame with lowest picture number */
for (i = 1; s->delay_frames[i]; i++)
- if (s->delay_frames[i]->avframe.display_picture_number < out->avframe.display_picture_number) {
+ if (s->delay_frames[i]->avframe->display_picture_number < out->avframe->display_picture_number) {
out = s->delay_frames[i];
out_idx = i;
}
@@ -1726,9 +1761,9 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
s->delay_frames[i] = s->delay_frames[i+1];
if (out) {
- out->avframe.reference ^= DELAYED_PIC_REF;
+ out->avframe->reference ^= DELAYED_PIC_REF;
*got_frame = 1;
- if((ret = av_frame_ref(picture, &out->avframe)) < 0)
+ if((ret = av_frame_ref(picture, out->avframe)) < 0)
return ret;
}
@@ -1790,14 +1825,14 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
/* find an unused frame */
for (i = 0; i < MAX_FRAMES; i++)
- if (s->all_frames[i].avframe.data[0] == NULL)
+ if (s->all_frames[i].avframe->data[0] == NULL)
pic = &s->all_frames[i];
if (!pic) {
av_log(avctx, AV_LOG_ERROR, "framelist full\n");
return -1;
}
- avcodec_get_frame_defaults(&pic->avframe);
+ av_frame_unref(pic->avframe);
/* [DIRAC_STD] Defined in 9.6.1 ... */
tmp = parse_code & 0x03; /* [DIRAC_STD] num_refs() */
@@ -1808,16 +1843,16 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
s->num_refs = tmp;
s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */
s->low_delay = (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */
- pic->avframe.reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
- pic->avframe.key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */
- pic->avframe.pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
+ pic->avframe->reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
+ pic->avframe->key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */
+ pic->avframe->pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
- if ((ret = ff_get_buffer(avctx, &pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
+ if ((ret = get_buffer_with_edge(avctx, pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
return ret;
s->current_picture = pic;
- s->plane[0].stride = pic->avframe.linesize[0];
- s->plane[1].stride = pic->avframe.linesize[1];
- s->plane[2].stride = pic->avframe.linesize[2];
+ s->plane[0].stride = pic->avframe->linesize[0];
+ s->plane[1].stride = pic->avframe->linesize[1];
+ s->plane[2].stride = pic->avframe->linesize[2];
/* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
if (dirac_decode_picture_header(s))
@@ -1833,7 +1868,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
{
DiracContext *s = avctx->priv_data;
- DiracFrame *picture = data;
+ AVFrame *picture = data;
uint8_t *buf = pkt->data;
int buf_size = pkt->size;
int i, data_unit_size, buf_idx = 0;
@@ -1841,8 +1876,8 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
/* release unused frames */
for (i = 0; i < MAX_FRAMES; i++)
- if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
- av_frame_unref(&s->all_frames[i].avframe);
+ if (s->all_frames[i].avframe->data[0] && !s->all_frames[i].avframe->reference) {
+ av_frame_unref(s->all_frames[i].avframe);
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
}
@@ -1887,40 +1922,40 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (!s->current_picture)
return buf_size;
- if (s->current_picture->avframe.display_picture_number > s->frame_number) {
+ if (s->current_picture->avframe->display_picture_number > s->frame_number) {
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
- s->current_picture->avframe.reference |= DELAYED_PIC_REF;
+ s->current_picture->avframe->reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
- int min_num = s->delay_frames[0]->avframe.display_picture_number;
+ int min_num = s->delay_frames[0]->avframe->display_picture_number;
/* Too many delayed frames, so we display the frame with the lowest pts */
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
delayed_frame = s->delay_frames[0];
for (i = 1; s->delay_frames[i]; i++)
- if (s->delay_frames[i]->avframe.display_picture_number < min_num)
- min_num = s->delay_frames[i]->avframe.display_picture_number;
+ if (s->delay_frames[i]->avframe->display_picture_number < min_num)
+ min_num = s->delay_frames[i]->avframe->display_picture_number;
delayed_frame = remove_frame(s->delay_frames, min_num);
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
}
if (delayed_frame) {
- delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
- if((ret=av_frame_ref(data, &delayed_frame->avframe)) < 0)
+ delayed_frame->avframe->reference ^= DELAYED_PIC_REF;
+ if((ret=av_frame_ref(data, delayed_frame->avframe)) < 0)
return ret;
*got_frame = 1;
}
- } else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
+ } else if (s->current_picture->avframe->display_picture_number == s->frame_number) {
/* The right frame at the right time :-) */
- if((ret=av_frame_ref(data, &s->current_picture->avframe)) < 0)
+ if((ret=av_frame_ref(data, s->current_picture->avframe)) < 0)
return ret;
*got_frame = 1;
}
if (*got_frame)
- s->frame_number = picture->avframe.display_picture_number + 1;
+ s->frame_number = picture->display_picture_number + 1;
return buf_idx;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhd_parser.c b/chromium/third_party/ffmpeg/libavcodec/dnxhd_parser.c
index 6e030e4212a..fffb98fa48c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhd_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhd_parser.c
@@ -46,7 +46,7 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
if (!pic_found) {
for (i = 0; i < buf_size; i++) {
- state = (state<<8) | buf[i];
+ state = (state << 8) | buf[i];
if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
i++;
pic_found = 1;
@@ -61,14 +61,14 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
if (!buf_size) /* EOF considered as end of frame */
return 0;
for (; i < buf_size; i++) {
- state = (state<<8) | buf[i];
+ state = (state << 8) | buf[i];
if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
if (!interlaced || dctx->cur_field) {
pc->frame_start_found = 0;
pc->state64 = -1;
dctx->interlaced = interlaced;
dctx->cur_field = 0;
- return i-5;
+ return i - 5;
} else {
/* continue, to get the second field */
dctx->interlaced = interlaced = (state&2)>>1;
@@ -98,12 +98,12 @@ static int dnxhd_parse(AVCodecParserContext *s,
} else {
next = dnxhd_find_frame_end(dctx, buf, buf_size);
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
+ *poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
- *poutbuf = buf;
+ *poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhddata.c b/chromium/third_party/ffmpeg/libavcodec/dnxhddata.c
index 669b8067e99..7ea91915e2d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhddata.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhddata.c
@@ -222,6 +222,17 @@ static const uint8_t dnxhd_1252_chroma_weight[] = {
114, 128, 125, 129, 134, 125, 116, 116,
};
+static const uint8_t dnxhd_1256_chroma_weight[] = {
+ 0, 32, 32, 32, 32, 32, 32, 33,
+ 32, 32, 32, 32, 32, 32, 32, 34,
+ 32, 32, 32, 32, 32, 32, 33, 37,
+ 32, 32, 32, 32, 32, 32, 36, 39,
+ 32, 32, 32, 32, 32, 34, 39, 44,
+ 32, 37, 32, 32, 35, 40, 43, 49,
+ 32, 33, 36, 36, 40, 43, 50, 60,
+ 34, 37, 39, 44, 51, 56, 61, 70,
+};
+
static const uint8_t dnxhd_1237_dc_codes[12] = {
0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
};
@@ -1026,6 +1037,14 @@ const CIDEntry ff_dnxhd_cid_table[] = {
dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
{ 36, 36, 45, 75, 90 },
{ { 24000, 1001 }, { 25, 1 }, { 30000, 1001 }, { 50, 1 }, { 60000, 1001 } } },
+ { 1256, 1920, 1080, 0, 1835008, 1835008, 6, 10, 4,
+ dnxhd_1235_luma_weight, dnxhd_1256_chroma_weight,
+ dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits,
+ dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level,
+ dnxhd_1235_1241_ac_flags,
+ dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run,
+ { 350, 390, 440, 730, 880 },
+ { { 24000, 1001 }, { 25, 1 }, { 30000, 1001 }, { 50, 1 }, { 60000, 1001 } } },
};
int ff_dnxhd_get_cid_table(int cid)
@@ -1048,7 +1067,7 @@ int avpriv_dnxhd_get_frame_size(int cid)
int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth)
{
int i, j;
- int mbs = avctx->bit_rate/1000000;
+ int mbs = avctx->bit_rate / 1000000;
if (!mbs)
return 0;
for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhddata.h b/chromium/third_party/ffmpeg/libavcodec/dnxhddata.h
index b8bcb21d8ea..8166ee848f4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhddata.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhddata.h
@@ -42,7 +42,7 @@ typedef struct CIDEntry {
const uint8_t *ac_flags;
const uint16_t *run_codes;
const uint8_t *run_bits, *run;
- int bit_rates[5]; ///< Helpher to choose variants, rounded to nearest 5Mb/s
+ int bit_rates[5]; ///< Helper to choose variants, rounded to nearest 5Mb/s
AVRational frame_rates[5];
} CIDEntry;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhddec.c b/chromium/third_party/ffmpeg/libavcodec/dnxhddec.c
index 42775dfd2b7..e33593c1149 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhddec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhddec.c
@@ -23,6 +23,7 @@
*/
#include "libavutil/imgutils.h"
+#include "libavutil/timer.h"
#include "avcodec.h"
#include "get_bits.h"
#include "dnxhddata.h"
@@ -41,10 +42,11 @@ typedef struct DNXHDContext {
VLC ac_vlc, dc_vlc, run_vlc;
int last_dc[3];
DSPContext dsp;
- DECLARE_ALIGNED(16, int16_t, blocks)[8][64];
+ DECLARE_ALIGNED(16, int16_t, blocks)[12][64];
ScanTable scantable;
const CIDEntry *cid_table;
int bit_depth; // 8, 10 or 0 if not initialized at all.
+ int is_444;
void (*decode_dct_block)(struct DNXHDContext *ctx, int16_t *block,
int n, int qscale);
int last_qscale;
@@ -55,8 +57,12 @@ typedef struct DNXHDContext {
#define DNXHD_VLC_BITS 9
#define DNXHD_DC_VLC_BITS 7
-static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, int16_t *block, int n, int qscale);
-static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block, int n, int qscale);
+static void dnxhd_decode_dct_block_8(DNXHDContext *ctx, int16_t *block,
+ int n, int qscale);
+static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block,
+ int n, int qscale);
+static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block,
+ int n, int qscale);
static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
{
@@ -74,7 +80,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
- return -1;
+ return AVERROR(ENOSYS);
}
if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth) {
av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, ctx->bit_depth);
@@ -96,30 +102,34 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
ctx->cid_table->run_bits, 1, 1,
ctx->cid_table->run_codes, 2, 2, 0);
- ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);
+ ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable,
+ ff_zigzag_direct);
ctx->cid = cid;
}
return 0;
}
static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
- const uint8_t *buf, int buf_size, int first_field)
+ const uint8_t *buf, int buf_size,
+ int first_field)
{
- static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
- int i, cid;
+ static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
+ static const uint8_t header_prefix444[] = { 0x00, 0x00, 0x02, 0x80, 0x02 };
+ int i, cid, ret;
if (buf_size < 0x280)
- return -1;
+ return AVERROR_INVALIDDATA;
- if (memcmp(buf, header_prefix, 5)) {
+ if (memcmp(buf, header_prefix, 5) && memcmp(buf, header_prefix444, 5)) {
av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (buf[5] & 2) { /* interlaced */
ctx->cur_field = buf[5] & 1;
frame->interlaced_frame = 1;
frame->top_field_first = first_field ^ ctx->cur_field;
- av_log(ctx->avctx, AV_LOG_DEBUG, "interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
+ av_log(ctx->avctx, AV_LOG_DEBUG,
+ "interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
}
ctx->height = AV_RB16(buf + 0x18);
@@ -127,7 +137,17 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
av_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height);
- if (buf[0x21] & 0x40) {
+ ctx->is_444 = 0;
+ if (buf[0x4] == 0x2) {
+ ctx->avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+ ctx->avctx->bits_per_raw_sample = 10;
+ if (ctx->bit_depth != 10) {
+ ff_dsputil_init(&ctx->dsp, ctx->avctx);
+ ctx->bit_depth = 10;
+ ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
+ }
+ ctx->is_444 = 1;
+ } else if (buf[0x21] & 0x40) {
ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
ctx->avctx->bits_per_raw_sample = 10;
if (ctx->bit_depth != 10) {
@@ -148,34 +168,36 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
cid = AV_RB32(buf + 0x28);
av_dlog(ctx->avctx, "compression id %d\n", cid);
- if (dnxhd_init_vlc(ctx, cid) < 0)
- return -1;
+ if ((ret = dnxhd_init_vlc(ctx, cid)) < 0)
+ return ret;
if (buf_size < ctx->cid_table->coding_unit_size) {
av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
- ctx->mb_width = ctx->width>>4;
+ ctx->mb_width = ctx->width >> 4;
ctx->mb_height = buf[0x16d];
- av_dlog(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
+ av_dlog(ctx->avctx,
+ "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
- if ((ctx->height+15)>>4 == ctx->mb_height && frame->interlaced_frame)
+ if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
ctx->height <<= 1;
if (ctx->mb_height > 68 ||
- (ctx->mb_height << frame->interlaced_frame) > (ctx->height+15)>>4) {
- av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big: %d\n", ctx->mb_height);
- return -1;
+ (ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
+ av_log(ctx->avctx, AV_LOG_ERROR,
+ "mb height too big: %d\n", ctx->mb_height);
+ return AVERROR_INVALIDDATA;
}
for (i = 0; i < ctx->mb_height; i++) {
- ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2));
+ ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i << 2));
av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
if (buf_size < ctx->mb_scan_index[i] + 0x280LL) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
@@ -198,14 +220,25 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
const int eob_index = ctx->cid_table->eob_index;
OPEN_READER(bs, &ctx->gb);
- if (n&2) {
- component = 1 + (n&1);
- scale = ctx->chroma_scale;
- weight_matrix = ctx->cid_table->chroma_weight;
+ if (!ctx->is_444) {
+ if (n & 2) {
+ component = 1 + (n & 1);
+ scale = ctx->chroma_scale;
+ weight_matrix = ctx->cid_table->chroma_weight;
+ } else {
+ component = 0;
+ scale = ctx->luma_scale;
+ weight_matrix = ctx->cid_table->luma_weight;
+ }
} else {
- component = 0;
- scale = ctx->luma_scale;
- weight_matrix = ctx->cid_table->luma_weight;
+ component = (n >> 1) % 3;
+ if (component) {
+ scale = ctx->chroma_scale;
+ weight_matrix = ctx->cid_table->chroma_weight;
+ } else {
+ scale = ctx->luma_scale;
+ weight_matrix = ctx->cid_table->luma_weight;
+ }
}
UPDATE_CACHE(bs, &ctx->gb);
@@ -249,13 +282,13 @@ static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx,
break;
}
- j = ctx->scantable.permutated[i];
+ j = ctx->scantable.permutated[i];
level *= scale[i];
if (level_bias < 32 || weight_matrix[i] != level_bias)
level += level_bias;
level >>= level_shift;
- block[j] = (level^sign) - sign;
+ block[j] = (level ^ sign) - sign;
UPDATE_CACHE(bs, &ctx->gb);
GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table,
@@ -277,7 +310,14 @@ static void dnxhd_decode_dct_block_10(DNXHDContext *ctx, int16_t *block,
dnxhd_decode_dct_block(ctx, block, n, qscale, 6, 8, 4);
}
-static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int y)
+static void dnxhd_decode_dct_block_10_444(DNXHDContext *ctx, int16_t *block,
+ int n, int qscale)
+{
+ dnxhd_decode_dct_block(ctx, block, n, qscale, 6, 32, 6);
+}
+
+static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,
+ int x, int y)
{
int shift1 = ctx->bit_depth == 10;
int dct_linesize_luma = frame->linesize[0];
@@ -301,6 +341,12 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int
ctx->dsp.clear_block(ctx->blocks[i]);
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
}
+ if (ctx->is_444) {
+ for (; i < 12; i++) {
+ ctx->dsp.clear_block(ctx->blocks[i]);
+ ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
+ }
+ }
if (frame->interlaced_frame) {
dct_linesize_luma <<= 1;
@@ -308,8 +354,8 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int
}
dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1));
- dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
- dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
+ dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
+ dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
if (ctx->cur_field) {
dest_y += frame->linesize[0];
@@ -319,17 +365,36 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int
dct_y_offset = dct_linesize_luma << 3;
dct_x_offset = 8 << shift1;
- ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
- ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
- ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);
- ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
-
- if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
- dct_y_offset = dct_linesize_chroma << 3;
- ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
- ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
- ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
- ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);
+ if (!ctx->is_444) {
+ ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
+ ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
+ ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);
+ ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
+
+ if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
+ dct_y_offset = dct_linesize_chroma << 3;
+ ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
+ ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
+ ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
+ ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);
+ }
+ } else {
+ ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
+ ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
+ ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]);
+ ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);
+
+ if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
+ dct_y_offset = dct_linesize_chroma << 3;
+ ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
+ ctx->dsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]);
+ ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]);
+ ctx->dsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]);
+ ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]);
+ ctx->dsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]);
+ ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]);
+ ctx->dsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]);
+ }
}
return 0;
@@ -353,8 +418,8 @@ static int dnxhd_decode_macroblocks(DNXHDContext *ctx, AVFrame *frame,
return 0;
}
-static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
+static int dnxhd_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
@@ -366,9 +431,9 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
av_dlog(avctx, "frame size %d\n", buf_size);
- decode_coding_unit:
- if (dnxhd_decode_header(ctx, picture, buf, buf_size, first_field) < 0)
- return -1;
+decode_coding_unit:
+ if ((ret = dnxhd_decode_header(ctx, picture, buf, buf_size, first_field)) < 0)
+ return ret;
if ((avctx->width || avctx->height) &&
(ctx->width != avctx->width || ctx->height != avctx->height)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.c b/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.c
index c2fbd5c9993..b5edb726436 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.c
@@ -23,23 +23,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define RC_VARIANCE 1 // use variance or ssd for fast rc
-
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
+#include "libavutil/timer.h"
+
#include "avcodec.h"
#include "dsputil.h"
#include "internal.h"
#include "mpegvideo.h"
#include "dnxhdenc.h"
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-#define DNX10BIT_QMAT_SHIFT 18 // The largest value that will not lead to overflow for 10bit samples.
-static const AVOption options[]={
- {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VE},
-{NULL}
+// The largest value that will not lead to overflow for 10bit samples.
+#define DNX10BIT_QMAT_SHIFT 18
+#define RC_VARIANCE 1 // use variance or ssd for fast rc
+#define LAMBDA_FRAC_BITS 10
+
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "nitris_compat", "encode with Avid Nitris compatibility",
+ offsetof(DNXHDEncContext, nitris_compat), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { NULL }
};
static const AVClass dnxhd_class = {
@@ -49,18 +54,22 @@ static const AVClass dnxhd_class = {
.version = LIBAVUTIL_VERSION_INT,
};
-#define LAMBDA_FRAC_BITS 10
-
-static void dnxhd_8bit_get_pixels_8x4_sym(int16_t *av_restrict block, const uint8_t *pixels, int line_size)
+static void dnxhd_8bit_get_pixels_8x4_sym(int16_t *av_restrict block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size)
{
int i;
for (i = 0; i < 4; i++) {
- block[0] = pixels[0]; block[1] = pixels[1];
- block[2] = pixels[2]; block[3] = pixels[3];
- block[4] = pixels[4]; block[5] = pixels[5];
- block[6] = pixels[6]; block[7] = pixels[7];
- pixels += line_size;
- block += 8;
+ block[0] = pixels[0];
+ block[1] = pixels[1];
+ block[2] = pixels[2];
+ block[3] = pixels[3];
+ block[4] = pixels[4];
+ block[5] = pixels[5];
+ block[6] = pixels[6];
+ block[7] = pixels[7];
+ pixels += line_size;
+ block += 8;
}
memcpy(block, block - 8, sizeof(*block) * 8);
memcpy(block + 8, block - 16, sizeof(*block) * 8);
@@ -68,7 +77,10 @@ static void dnxhd_8bit_get_pixels_8x4_sym(int16_t *av_restrict block, const uint
memcpy(block + 24, block - 32, sizeof(*block) * 8);
}
-static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym(int16_t *av_restrict block, const uint8_t *pixels, int line_size)
+static av_always_inline
+void dnxhd_10bit_get_pixels_8x4_sym(int16_t *av_restrict block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size)
{
int i;
const uint16_t* pixels16 = (const uint16_t*)pixels;
@@ -117,24 +129,28 @@ static int dnxhd_10bit_dct_quantize(MpegEncContext *ctx, int16_t *block,
static av_cold int dnxhd_init_vlc(DNXHDEncContext *ctx)
{
int i, j, level, run;
- int max_level = 1<<(ctx->cid_table->bit_depth+2);
-
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_codes, max_level*4*sizeof(*ctx->vlc_codes), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits, max_level*4*sizeof(*ctx->vlc_bits) , fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2, fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits, 63, fail);
-
- ctx->vlc_codes += max_level*2;
- ctx->vlc_bits += max_level*2;
+ int max_level = 1 << (ctx->cid_table->bit_depth + 2);
+
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_codes,
+ max_level * 4 * sizeof(*ctx->vlc_codes), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits,
+ max_level * 4 * sizeof(*ctx->vlc_bits), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes,
+ 63 * 2, fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits,
+ 63, fail);
+
+ ctx->vlc_codes += max_level * 2;
+ ctx->vlc_bits += max_level * 2;
for (level = -max_level; level < max_level; level++) {
for (run = 0; run < 2; run++) {
- int index = (level<<1)|run;
+ int index = (level << 1) | run;
int sign, offset = 0, alevel = level;
MASK_ABS(sign, alevel);
if (alevel > 64) {
- offset = (alevel-1)>>6;
- alevel -= offset<<6;
+ offset = (alevel - 1) >> 6;
+ alevel -= offset << 6;
}
for (j = 0; j < 257; j++) {
if (ctx->cid_table->ac_level[j] >> 1 == alevel &&
@@ -142,19 +158,21 @@ static av_cold int dnxhd_init_vlc(DNXHDEncContext *ctx)
(!run || (ctx->cid_table->ac_flags[j] & 2) && run)) {
av_assert1(!ctx->vlc_codes[index]);
if (alevel) {
- ctx->vlc_codes[index] = (ctx->cid_table->ac_codes[j]<<1)|(sign&1);
- ctx->vlc_bits [index] = ctx->cid_table->ac_bits[j]+1;
+ ctx->vlc_codes[index] =
+ (ctx->cid_table->ac_codes[j] << 1) | (sign & 1);
+ ctx->vlc_bits[index] = ctx->cid_table->ac_bits[j] + 1;
} else {
ctx->vlc_codes[index] = ctx->cid_table->ac_codes[j];
- ctx->vlc_bits [index] = ctx->cid_table->ac_bits [j];
+ ctx->vlc_bits[index] = ctx->cid_table->ac_bits[j];
}
break;
}
}
av_assert0(!alevel || j < 257);
if (offset) {
- ctx->vlc_codes[index] = (ctx->vlc_codes[index]<<ctx->cid_table->index_bits)|offset;
- ctx->vlc_bits [index]+= ctx->cid_table->index_bits;
+ ctx->vlc_codes[index] =
+ (ctx->vlc_codes[index] << ctx->cid_table->index_bits) | offset;
+ ctx->vlc_bits[index] += ctx->cid_table->index_bits;
}
}
}
@@ -162,45 +180,56 @@ static av_cold int dnxhd_init_vlc(DNXHDEncContext *ctx)
int run = ctx->cid_table->run[i];
av_assert0(run < 63);
ctx->run_codes[run] = ctx->cid_table->run_codes[i];
- ctx->run_bits [run] = ctx->cid_table->run_bits[i];
+ ctx->run_bits[run] = ctx->cid_table->run_bits[i];
}
return 0;
- fail:
- return -1;
+fail:
+ return AVERROR(ENOMEM);
}
static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
{
// init first elem to 1 to avoid div by 0 in convert_matrix
- uint16_t weight_matrix[64] = {1,}; // convert_matrix needs uint16_t*
+ uint16_t weight_matrix[64] = { 1, }; // convert_matrix needs uint16_t*
int qscale, i;
const uint8_t *luma_weight_table = ctx->cid_table->luma_weight;
const uint8_t *chroma_weight_table = ctx->cid_table->chroma_weight;
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c, (ctx->m.avctx->qmax+1) * 64 * sizeof(int), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l,
+ (ctx->m.avctx->qmax + 1) * 64 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c,
+ (ctx->m.avctx->qmax + 1) * 64 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16,
+ (ctx->m.avctx->qmax + 1) * 64 * 2 * sizeof(uint16_t),
+ fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16,
+ (ctx->m.avctx->qmax + 1) * 64 * 2 * sizeof(uint16_t),
+ fail);
if (ctx->cid_table->bit_depth == 8) {
for (i = 1; i < 64; i++) {
int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];
weight_matrix[j] = ctx->cid_table->luma_weight[i];
}
- ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_l, ctx->qmatrix_l16, weight_matrix,
- ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1);
+ ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_l, ctx->qmatrix_l16,
+ weight_matrix, ctx->m.intra_quant_bias, 1,
+ ctx->m.avctx->qmax, 1);
for (i = 1; i < 64; i++) {
int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];
weight_matrix[j] = ctx->cid_table->chroma_weight[i];
}
- ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_c, ctx->qmatrix_c16, weight_matrix,
- ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1);
+ ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_c, ctx->qmatrix_c16,
+ weight_matrix, ctx->m.intra_quant_bias, 1,
+ ctx->m.avctx->qmax, 1);
for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {
for (i = 0; i < 64; i++) {
- ctx->qmatrix_l [qscale] [i] <<= 2; ctx->qmatrix_c [qscale] [i] <<= 2;
- ctx->qmatrix_l16[qscale][0][i] <<= 2; ctx->qmatrix_l16[qscale][1][i] <<= 2;
- ctx->qmatrix_c16[qscale][0][i] <<= 2; ctx->qmatrix_c16[qscale][1][i] <<= 2;
+ ctx->qmatrix_l[qscale][i] <<= 2;
+ ctx->qmatrix_c[qscale][i] <<= 2;
+ ctx->qmatrix_l16[qscale][0][i] <<= 2;
+ ctx->qmatrix_l16[qscale][1][i] <<= 2;
+ ctx->qmatrix_c16[qscale][0][i] <<= 2;
+ ctx->qmatrix_c16[qscale][1][i] <<= 2;
}
}
} else {
@@ -209,16 +238,21 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
for (i = 1; i < 64; i++) {
int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];
- // The quantization formula from the VC-3 standard is:
- // quantized = sign(block[i]) * floor(abs(block[i]/s) * p / (qscale * weight_table[i]))
- // Where p is 32 for 8-bit samples and 8 for 10-bit ones.
- // The s factor compensates scaling of DCT coefficients done by the DCT routines,
- // and therefore is not present in standard. It's 8 for 8-bit samples and 4 for 10-bit ones.
- // We want values of ctx->qtmatrix_l and ctx->qtmatrix_r to be:
- // ((1 << DNX10BIT_QMAT_SHIFT) * (p / s)) / (qscale * weight_table[i])
- // For 10-bit samples, p / s == 2
- ctx->qmatrix_l[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) / (qscale * luma_weight_table[i]);
- ctx->qmatrix_c[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) / (qscale * chroma_weight_table[i]);
+ /* The quantization formula from the VC-3 standard is:
+ * quantized = sign(block[i]) * floor(abs(block[i]/s) * p /
+ * (qscale * weight_table[i]))
+ * Where p is 32 for 8-bit samples and 8 for 10-bit ones.
+ * The s factor compensates scaling of DCT coefficients done by
+ * the DCT routines, and therefore is not present in standard.
+ * It's 8 for 8-bit samples and 4 for 10-bit ones.
+ * We want values of ctx->qtmatrix_l and ctx->qtmatrix_r to be:
+ * ((1 << DNX10BIT_QMAT_SHIFT) * (p / s)) /
+ * (qscale * weight_table[i])
+ * For 10-bit samples, p / s == 2 */
+ ctx->qmatrix_l[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) /
+ (qscale * luma_weight_table[i]);
+ ctx->qmatrix_c[qscale][j] = (1 << (DNX10BIT_QMAT_SHIFT + 1)) /
+ (qscale * chroma_weight_table[i]);
}
}
}
@@ -229,28 +263,30 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
ctx->m.q_intra_matrix = ctx->qmatrix_l;
return 0;
- fail:
- return -1;
+fail:
+ return AVERROR(ENOMEM);
}
static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
{
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160 * (ctx->m.avctx->qmax + 1) * sizeof(RCEntry), fail);
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp,
+ ctx->m.mb_num * sizeof(RCCMPEntry), fail);
- ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;
+ ctx->frame_bits = (ctx->cid_table->coding_unit_size -
+ 640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
- ctx->lambda = 2<<LAMBDA_FRAC_BITS; // qscale 2
+ ctx->lambda = 2 << LAMBDA_FRAC_BITS; // qscale 2
return 0;
- fail:
- return -1;
+fail:
+ return AVERROR(ENOMEM);
}
static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
{
DNXHDEncContext *ctx = avctx->priv_data;
- int i, index, bit_depth;
+ int i, index, bit_depth, ret;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV422P:
@@ -260,15 +296,17 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
bit_depth = 10;
break;
default:
- av_log(avctx, AV_LOG_ERROR, "pixel format is incompatible with DNxHD\n");
- return -1;
+ av_log(avctx, AV_LOG_ERROR,
+ "pixel format is incompatible with DNxHD\n");
+ return AVERROR(EINVAL);
}
ctx->cid = ff_dnxhd_find_cid(avctx, bit_depth);
if (!ctx->cid) {
- av_log(avctx, AV_LOG_ERROR, "video parameters incompatible with DNxHD. Valid DNxHD profiles:\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "video parameters incompatible with DNxHD. Valid DNxHD profiles:\n");
ff_dnxhd_print_profiles(avctx, AV_LOG_ERROR);
- return -1;
+ return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_DEBUG, "cid %d\n", ctx->cid);
@@ -276,7 +314,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
av_assert0(index >= 0);
ctx->cid_table = &ff_dnxhd_cid_table[index];
- ctx->m.avctx = avctx;
+ ctx->m.avctx = avctx;
ctx->m.mb_intra = 1;
ctx->m.h263_aic = 1;
@@ -289,12 +327,12 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
ctx->m.dct_quantize = ff_dct_quantize_c;
if (ctx->cid_table->bit_depth == 10) {
- ctx->m.dct_quantize = dnxhd_10bit_dct_quantize;
- ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym;
- ctx->block_width_l2 = 4;
+ ctx->m.dct_quantize = dnxhd_10bit_dct_quantize;
+ ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym;
+ ctx->block_width_l2 = 4;
} else {
- ctx->get_pixels_8x4_sym = dnxhd_8bit_get_pixels_8x4_sym;
- ctx->block_width_l2 = 3;
+ ctx->get_pixels_8x4_sym = dnxhd_8bit_get_pixels_8x4_sym;
+ ctx->block_width_l2 = 3;
}
if (ARCH_X86)
@@ -304,7 +342,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
ctx->m.mb_width = (avctx->width + 15) / 16;
if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {
- ctx->interlaced = 1;
+ ctx->interlaced = 1;
ctx->m.mb_height /= 2;
}
@@ -312,22 +350,28 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
ctx->m.intra_quant_bias = avctx->intra_quant_bias;
- if (dnxhd_init_qmat(ctx, ctx->m.intra_quant_bias, 0) < 0) // XXX tune lbias/cbias
- return -1;
+ // XXX tune lbias/cbias
+ if ((ret = dnxhd_init_qmat(ctx, ctx->m.intra_quant_bias, 0)) < 0)
+ return ret;
- // Avid Nitris hardware decoder requires a minimum amount of padding in the coding unit payload
+ /* Avid Nitris hardware decoder requires a minimum amount of padding
+ * in the coding unit payload */
if (ctx->nitris_compat)
ctx->min_padding = 1600;
- if (dnxhd_init_vlc(ctx) < 0)
- return -1;
- if (dnxhd_init_rc(ctx) < 0)
- return -1;
+ if ((ret = dnxhd_init_vlc(ctx)) < 0)
+ return ret;
+ if ((ret = dnxhd_init_rc(ctx)) < 0)
+ return ret;
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_size, ctx->m.mb_height*sizeof(uint32_t), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_offs, ctx->m.mb_height*sizeof(uint32_t), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits, ctx->m.mb_num *sizeof(uint16_t), fail);
- FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_size,
+ ctx->m.mb_height * sizeof(uint32_t), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_offs,
+ ctx->m.mb_height * sizeof(uint32_t), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits,
+ ctx->m.mb_num * sizeof(uint16_t), fail);
+ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,
+ ctx->m.mb_num * sizeof(uint8_t), fail);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
@@ -338,37 +382,42 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
if (avctx->thread_count > MAX_THREADS) {
av_log(avctx, AV_LOG_ERROR, "too many threads\n");
- return -1;
+ return AVERROR(EINVAL);
+ }
+
+ if (avctx->qmax <= 1) {
+ av_log(avctx, AV_LOG_ERROR, "qmax must be at least 2\n");
+ return AVERROR(EINVAL);
}
ctx->thread[0] = ctx;
for (i = 1; i < avctx->thread_count; i++) {
- ctx->thread[i] = av_malloc(sizeof(DNXHDEncContext));
+ ctx->thread[i] = av_malloc(sizeof(DNXHDEncContext));
memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext));
}
return 0;
- fail: //for FF_ALLOCZ_OR_GOTO
- return -1;
+fail: // for FF_ALLOCZ_OR_GOTO
+ return AVERROR(ENOMEM);
}
static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
{
DNXHDEncContext *ctx = avctx->priv_data;
- static const uint8_t header_prefix[5] = { 0x00,0x00,0x02,0x80,0x01 };
+ static const uint8_t header_prefix[5] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
memset(buf, 0, 640);
memcpy(buf, header_prefix, 5);
- buf[5] = ctx->interlaced ? ctx->cur_field+2 : 0x01;
+ buf[5] = ctx->interlaced ? ctx->cur_field + 2 : 0x01;
buf[6] = 0x80; // crc flag off
buf[7] = 0xa0; // reserved
- AV_WB16(buf + 0x18, avctx->height>>ctx->interlaced); // ALPF
+ AV_WB16(buf + 0x18, avctx->height >> ctx->interlaced); // ALPF
AV_WB16(buf + 0x1a, avctx->width); // SPL
- AV_WB16(buf + 0x1d, avctx->height>>ctx->interlaced); // NAL
+ AV_WB16(buf + 0x1d, avctx->height >> ctx->interlaced); // NAL
buf[0x21] = ctx->cid_table->bit_depth == 10 ? 0x58 : 0x38;
- buf[0x22] = 0x88 + (ctx->interlaced<<2);
+ buf[0x22] = 0x88 + (ctx->interlaced << 2);
AV_WB32(buf + 0x28, ctx->cid); // CID
buf[0x2c] = ctx->interlaced ? 0 : 0x80;
@@ -387,16 +436,19 @@ static av_always_inline void dnxhd_encode_dc(DNXHDEncContext *ctx, int diff)
{
int nbits;
if (diff < 0) {
- nbits = av_log2_16bit(-2*diff);
+ nbits = av_log2_16bit(-2 * diff);
diff--;
} else {
- nbits = av_log2_16bit(2*diff);
+ nbits = av_log2_16bit(2 * diff);
}
put_bits(&ctx->m.pb, ctx->cid_table->dc_bits[nbits] + nbits,
- (ctx->cid_table->dc_codes[nbits]<<nbits) + (diff & ((1 << nbits) - 1)));
+ (ctx->cid_table->dc_codes[nbits] << nbits) +
+ (diff & ((1 << nbits) - 1)));
}
-static av_always_inline void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block, int last_index, int n)
+static av_always_inline
+void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *block,
+ int last_index, int n)
{
int last_non_zero = 0;
int slevel, i, j;
@@ -409,30 +461,34 @@ static av_always_inline void dnxhd_encode_block(DNXHDEncContext *ctx, int16_t *b
slevel = block[j];
if (slevel) {
int run_level = i - last_non_zero - 1;
- int rlevel = (slevel<<1)|!!run_level;
+ int rlevel = (slevel << 1) | !!run_level;
put_bits(&ctx->m.pb, ctx->vlc_bits[rlevel], ctx->vlc_codes[rlevel]);
if (run_level)
- put_bits(&ctx->m.pb, ctx->run_bits[run_level], ctx->run_codes[run_level]);
+ put_bits(&ctx->m.pb, ctx->run_bits[run_level],
+ ctx->run_codes[run_level]);
last_non_zero = i;
}
}
put_bits(&ctx->m.pb, ctx->vlc_bits[0], ctx->vlc_codes[0]); // EOB
}
-static av_always_inline void dnxhd_unquantize_c(DNXHDEncContext *ctx, int16_t *block, int n, int qscale, int last_index)
+static av_always_inline
+void dnxhd_unquantize_c(DNXHDEncContext *ctx, int16_t *block, int n,
+ int qscale, int last_index)
{
const uint8_t *weight_matrix;
int level;
int i;
- weight_matrix = (n&2) ? ctx->cid_table->chroma_weight : ctx->cid_table->luma_weight;
+ weight_matrix = (n & 2) ? ctx->cid_table->chroma_weight
+ : ctx->cid_table->luma_weight;
for (i = 1; i <= last_index; i++) {
int j = ctx->m.intra_scantable.permutated[i];
level = block[j];
if (level) {
if (level < 0) {
- level = (1-2*level) * qscale * weight_matrix[i];
+ level = (1 - 2 * level) * qscale * weight_matrix[i];
if (ctx->cid_table->bit_depth == 10) {
if (weight_matrix[i] != 8)
level += 8;
@@ -444,7 +500,7 @@ static av_always_inline void dnxhd_unquantize_c(DNXHDEncContext *ctx, int16_t *b
}
level = -level;
} else {
- level = (2*level+1) * qscale * weight_matrix[i];
+ level = (2 * level + 1) * qscale * weight_matrix[i];
if (ctx->cid_table->bit_depth == 10) {
if (weight_matrix[i] != 8)
level += 8;
@@ -469,7 +525,8 @@ static av_always_inline int dnxhd_ssd_block(int16_t *qblock, int16_t *block)
return score;
}
-static av_always_inline int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index)
+static av_always_inline
+int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *block, int last_index)
{
int last_non_zero = 0;
int bits = 0;
@@ -479,20 +536,25 @@ static av_always_inline int dnxhd_calc_ac_bits(DNXHDEncContext *ctx, int16_t *bl
level = block[j];
if (level) {
int run_level = i - last_non_zero - 1;
- bits += ctx->vlc_bits[(level<<1)|!!run_level]+ctx->run_bits[run_level];
+ bits += ctx->vlc_bits[(level << 1) |
+ !!run_level] + ctx->run_bits[run_level];
last_non_zero = i;
}
}
return bits;
}
-static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y)
+static av_always_inline
+void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y)
{
const int bs = ctx->block_width_l2;
const int bw = 1 << bs;
- const uint8_t *ptr_y = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs+1);
- const uint8_t *ptr_u = ctx->thread[0]->src[1] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs);
- const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs);
+ const uint8_t *ptr_y = ctx->thread[0]->src[0] +
+ ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs + 1);
+ const uint8_t *ptr_u = ctx->thread[0]->src[1] +
+ ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs);
+ const uint8_t *ptr_v = ctx->thread[0]->src[2] +
+ ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs);
DSPContext *dsp = &ctx->m.dsp;
dsp->get_pixels(ctx->blocks[0], ptr_y, ctx->m.linesize);
@@ -500,12 +562,20 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in
dsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize);
dsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize);
- if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
+ if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
if (ctx->interlaced) {
- ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize);
- ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize);
- ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize);
- ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[4],
+ ptr_y + ctx->dct_y_offset,
+ ctx->m.linesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[5],
+ ptr_y + ctx->dct_y_offset + bw,
+ ctx->m.linesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[6],
+ ptr_u + ctx->dct_uv_offset,
+ ctx->m.uvlinesize);
+ ctx->get_pixels_8x4_sym(ctx->blocks[7],
+ ptr_v + ctx->dct_uv_offset,
+ ctx->m.uvlinesize);
} else {
dsp->clear_block(ctx->blocks[4]);
dsp->clear_block(ctx->blocks[5]);
@@ -513,20 +583,26 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in
dsp->clear_block(ctx->blocks[7]);
}
} else {
- dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset, ctx->m.linesize);
- dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize);
- dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize);
- dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[4],
+ ptr_y + ctx->dct_y_offset, ctx->m.linesize);
+ dsp->get_pixels(ctx->blocks[5],
+ ptr_y + ctx->dct_y_offset + bw, ctx->m.linesize);
+ dsp->get_pixels(ctx->blocks[6],
+ ptr_u + ctx->dct_uv_offset, ctx->m.uvlinesize);
+ dsp->get_pixels(ctx->blocks[7],
+ ptr_v + ctx->dct_uv_offset, ctx->m.uvlinesize);
}
}
-static av_always_inline int dnxhd_switch_matrix(DNXHDEncContext *ctx, int i)
+static av_always_inline
+int dnxhd_switch_matrix(DNXHDEncContext *ctx, int i)
{
const static uint8_t component[8]={0,0,1,2,0,0,1,2};
return component[i];
}
-static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
+static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg,
+ int jobnr, int threadnr)
{
DNXHDEncContext *ctx = avctx->priv_data;
int mb_y = jobnr, mb_x;
@@ -552,13 +628,16 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, i
int overflow, nbits, diff, last_index;
int n = dnxhd_switch_matrix(ctx, i);
- memcpy(block, src_block, 64*sizeof(*block));
- last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow);
- ac_bits += dnxhd_calc_ac_bits(ctx, block, last_index);
+ memcpy(block, src_block, 64 * sizeof(*block));
+ last_index = ctx->m.dct_quantize(&ctx->m, block, 4 & (2*i),
+ qscale, &overflow);
+ ac_bits += dnxhd_calc_ac_bits(ctx, block, last_index);
diff = block[0] - ctx->m.last_dc[n];
- if (diff < 0) nbits = av_log2_16bit(-2*diff);
- else nbits = av_log2_16bit( 2*diff);
+ if (diff < 0)
+ nbits = av_log2_16bit(-2 * diff);
+ else
+ nbits = av_log2_16bit(2 * diff);
av_assert1(nbits < ctx->cid_table->bit_depth + 4);
dc_bits += ctx->cid_table->dc_bits[nbits] + nbits;
@@ -571,18 +650,21 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, i
ssd += dnxhd_ssd_block(block, src_block);
}
}
- ctx->mb_rc[qscale][mb].ssd = ssd;
- ctx->mb_rc[qscale][mb].bits = ac_bits+dc_bits+12+8*ctx->vlc_bits[0];
+ ctx->mb_rc[qscale][mb].ssd = ssd;
+ ctx->mb_rc[qscale][mb].bits = ac_bits + dc_bits + 12 +
+ 8 * ctx->vlc_bits[0];
}
return 0;
}
-static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
+static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg,
+ int jobnr, int threadnr)
{
DNXHDEncContext *ctx = avctx->priv_data;
int mb_y = jobnr, mb_x;
ctx = ctx->thread[threadnr];
- init_put_bits(&ctx->m.pb, (uint8_t *)arg + 640 + ctx->slice_offs[jobnr], ctx->slice_size[jobnr]);
+ init_put_bits(&ctx->m.pb, (uint8_t *)arg + 640 + ctx->slice_offs[jobnr],
+ ctx->slice_size[jobnr]);
ctx->m.last_dc[0] =
ctx->m.last_dc[1] =
@@ -592,21 +674,22 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int
int qscale = ctx->mb_qscale[mb];
int i;
- put_bits(&ctx->m.pb, 12, qscale<<1);
+ put_bits(&ctx->m.pb, 12, qscale << 1);
dnxhd_get_blocks(ctx, mb_x, mb_y);
for (i = 0; i < 8; i++) {
int16_t *block = ctx->blocks[i];
int overflow, n = dnxhd_switch_matrix(ctx, i);
- int last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow);
- //START_TIMER;
+ int last_index = ctx->m.dct_quantize(&ctx->m, block, 4 & (2*i),
+ qscale, &overflow);
+ // START_TIMER;
dnxhd_encode_block(ctx, block, last_index, n);
- //STOP_TIMER("encode_block");
+ // STOP_TIMER("encode_block");
}
}
- if (put_bits_count(&ctx->m.pb)&31)
- put_bits(&ctx->m.pb, 32-(put_bits_count(&ctx->m.pb)&31), 0);
+ if (put_bits_count(&ctx->m.pb) & 31)
+ put_bits(&ctx->m.pb, 32 - (put_bits_count(&ctx->m.pb) & 31), 0);
flush_put_bits(&ctx->m.pb);
return 0;
}
@@ -623,14 +706,15 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx)
unsigned mb = mb_y * ctx->m.mb_width + mb_x;
ctx->slice_size[mb_y] += ctx->mb_bits[mb];
}
- ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31;
+ ctx->slice_size[mb_y] = (ctx->slice_size[mb_y] + 31) & ~31;
ctx->slice_size[mb_y] >>= 3;
thread_size = ctx->slice_size[mb_y];
offset += thread_size;
}
}
-static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
+static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
+ int jobnr, int threadnr)
{
DNXHDEncContext *ctx = avctx->priv_data;
int mb_y = jobnr, mb_x, x, y;
@@ -639,9 +723,9 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int
ctx = ctx->thread[threadnr];
if (ctx->cid_table->bit_depth == 8) {
- uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y<<4) * ctx->m.linesize);
+ uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize);
for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) {
- unsigned mb = mb_y * ctx->m.mb_width + mb_x;
+ unsigned mb = mb_y * ctx->m.mb_width + mb_x;
int sum;
int varc;
@@ -660,15 +744,16 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int
}
}
}
- varc = (varc - (((unsigned)sum * sum) >> 8) + 128) >> 8;
+ varc = (varc - (((unsigned) sum * sum) >> 8) + 128) >> 8;
ctx->mb_cmp[mb].value = varc;
- ctx->mb_cmp[mb].mb = mb;
+ ctx->mb_cmp[mb].mb = mb;
}
} else { // 10-bit
int const linesize = ctx->m.linesize >> 1;
for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) {
- uint16_t *pix = (uint16_t*)ctx->thread[0]->src[0] + ((mb_y << 4) * linesize) + (mb_x << 4);
+ uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] +
+ ((mb_y << 4) * linesize) + (mb_x << 4);
unsigned mb = mb_y * ctx->m.mb_width + mb_x;
int sum = 0;
int sqsum = 0;
@@ -678,8 +763,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int
for (i = 0; i < 16; ++i) {
for (j = 0; j < 16; ++j) {
// Turn 16-bit pixels into 10-bit ones.
- int const sample = (unsigned)pix[j] >> 6;
- sum += sample;
+ int const sample = (unsigned) pix[j] >> 6;
+ sum += sample;
sqsum += sample * sample;
// 2^10 * 2^10 * 16 * 16 = 2^28, which is less than INT_MAX
}
@@ -688,7 +773,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int
mean = sum >> 8; // 16*16 == 2^8
sqmean = sqsum >> 8;
ctx->mb_cmp[mb].value = sqmean - mean * mean;
- ctx->mb_cmp[mb].mb = mb;
+ ctx->mb_cmp[mb].mb = mb;
}
}
return 0;
@@ -702,14 +787,15 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
for (q = 1; q < avctx->qmax; q++) {
ctx->qscale = q;
- avctx->execute2(avctx, dnxhd_calc_bits_thread, NULL, NULL, ctx->m.mb_height);
+ avctx->execute2(avctx, dnxhd_calc_bits_thread,
+ NULL, NULL, ctx->m.mb_height);
}
- up_step = down_step = 2<<LAMBDA_FRAC_BITS;
- lambda = ctx->lambda;
+ up_step = down_step = 2 << LAMBDA_FRAC_BITS;
+ lambda = ctx->lambda;
for (;;) {
int bits = 0;
- int end = 0;
+ int end = 0;
if (lambda == last_higher) {
lambda++;
end = 1; // need to set final qscales/bits
@@ -718,28 +804,29 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
for (x = 0; x < ctx->m.mb_width; x++) {
unsigned min = UINT_MAX;
int qscale = 1;
- int mb = y*ctx->m.mb_width+x;
+ int mb = y * ctx->m.mb_width + x;
for (q = 1; q < avctx->qmax; q++) {
- unsigned score = ctx->mb_rc[q][mb].bits*lambda+
- ((unsigned)ctx->mb_rc[q][mb].ssd<<LAMBDA_FRAC_BITS);
+ unsigned score = ctx->mb_rc[q][mb].bits * lambda +
+ ((unsigned) ctx->mb_rc[q][mb].ssd << LAMBDA_FRAC_BITS);
if (score < min) {
- min = score;
+ min = score;
qscale = q;
}
}
bits += ctx->mb_rc[qscale][mb].bits;
ctx->mb_qscale[mb] = qscale;
- ctx->mb_bits[mb] = ctx->mb_rc[qscale][mb].bits;
+ ctx->mb_bits[mb] = ctx->mb_rc[qscale][mb].bits;
}
- bits = (bits+31)&~31; // padding
+ bits = (bits + 31) & ~31; // padding
if (bits > ctx->frame_bits)
break;
}
- //av_dlog(ctx->m.avctx, "lambda %d, up %u, down %u, bits %d, frame %d\n",
- // lambda, last_higher, last_lower, bits, ctx->frame_bits);
+ // av_dlog(ctx->m.avctx,
+ // "lambda %d, up %u, down %u, bits %d, frame %d\n",
+ // lambda, last_higher, last_lower, bits, ctx->frame_bits);
if (end) {
if (bits > ctx->frame_bits)
- return -1;
+ return AVERROR(EINVAL);
break;
}
if (bits < ctx->frame_bits) {
@@ -758,7 +845,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
if (last_lower != INT_MAX)
lambda = (lambda+last_lower)>>1;
else if ((int64_t)lambda + up_step > INT_MAX)
- return -1;
+ return AVERROR(EINVAL);
else
lambda += up_step;
up_step = FFMIN((int64_t)up_step*5, INT_MAX);
@@ -785,7 +872,8 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
bits = 0;
ctx->qscale = qscale;
// XXX avoid recalculating bits
- ctx->m.avctx->execute2(ctx->m.avctx, dnxhd_calc_bits_thread, NULL, NULL, ctx->m.mb_height);
+ ctx->m.avctx->execute2(ctx->m.avctx, dnxhd_calc_bits_thread,
+ NULL, NULL, ctx->m.mb_height);
for (y = 0; y < ctx->m.mb_height; y++) {
for (x = 0; x < ctx->m.mb_width; x++)
bits += ctx->mb_rc[qscale][y*ctx->m.mb_width+x].bits;
@@ -793,8 +881,10 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
if (bits > ctx->frame_bits)
break;
}
- //av_dlog(ctx->m.avctx, "%d, qscale %d, bits %d, frame %d, higher %d, lower %d\n",
- // ctx->m.avctx->frame_number, qscale, bits, ctx->frame_bits, last_higher, last_lower);
+ // av_dlog(ctx->m.avctx,
+ // "%d, qscale %d, bits %d, frame %d, higher %d, lower %d\n",
+ // ctx->m.avctx->frame_number, qscale, bits, ctx->frame_bits,
+ // last_higher, last_lower);
if (bits < ctx->frame_bits) {
if (qscale == 1)
return 1;
@@ -804,7 +894,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
}
last_lower = FFMIN(qscale, last_lower);
if (last_higher != 0)
- qscale = (qscale+last_higher)>>1;
+ qscale = (qscale + last_higher) >> 1;
else
qscale -= down_step++;
if (qscale < 1)
@@ -815,12 +905,12 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
break;
last_higher = FFMAX(qscale, last_higher);
if (last_lower != INT_MAX)
- qscale = (qscale+last_lower)>>1;
+ qscale = (qscale + last_lower) >> 1;
else
qscale += up_step++;
down_step = 1;
if (qscale >= ctx->m.avctx->qmax)
- return -1;
+ return AVERROR(EINVAL);
}
}
//av_dlog(ctx->m.avctx, "out qscale %d\n", qscale);
@@ -835,11 +925,12 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
static inline int get_bucket(int value, int shift)
{
value >>= shift;
- value &= NBUCKETS - 1;
+ value &= NBUCKETS - 1;
return NBUCKETS - 1 - value;
}
-static void radix_count(const RCCMPEntry *data, int size, int buckets[RADIX_PASSES][NBUCKETS])
+static void radix_count(const RCCMPEntry *data, int size,
+ int buckets[RADIX_PASSES][NBUCKETS])
{
int i, j;
memset(buckets, 0, sizeof(buckets[0][0]) * RADIX_PASSES * NBUCKETS);
@@ -859,12 +950,13 @@ static void radix_count(const RCCMPEntry *data, int size, int buckets[RADIX_PASS
}
}
-static void radix_sort_pass(RCCMPEntry *dst, const RCCMPEntry *data, int size, int buckets[NBUCKETS], int pass)
+static void radix_sort_pass(RCCMPEntry *dst, const RCCMPEntry *data,
+ int size, int buckets[NBUCKETS], int pass)
{
int shift = pass * BUCKET_BITS;
int i;
for (i = 0; i < size; i++) {
- int v = get_bucket(data[i].value, shift);
+ int v = get_bucket(data[i].value, shift);
int pos = buckets[v]++;
dst[pos] = data[i];
}
@@ -873,7 +965,7 @@ static void radix_sort_pass(RCCMPEntry *dst, const RCCMPEntry *data, int size, i
static void radix_sort(RCCMPEntry *data, int size)
{
int buckets[RADIX_PASSES][NBUCKETS];
- RCCMPEntry *tmp = av_malloc(sizeof(*tmp) * size);
+ RCCMPEntry *tmp = av_malloc_array(size, sizeof(*tmp));
radix_count(data, size, buckets);
radix_sort_pass(tmp, data, size, buckets[0], 0);
radix_sort_pass(data, tmp, size, buckets[1], 1);
@@ -889,33 +981,38 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx)
int max_bits = 0;
int ret, x, y;
if ((ret = dnxhd_find_qscale(ctx)) < 0)
- return -1;
+ return ret;
for (y = 0; y < ctx->m.mb_height; y++) {
for (x = 0; x < ctx->m.mb_width; x++) {
- int mb = y*ctx->m.mb_width+x;
+ int mb = y * ctx->m.mb_width + x;
int delta_bits;
ctx->mb_qscale[mb] = ctx->qscale;
ctx->mb_bits[mb] = ctx->mb_rc[ctx->qscale][mb].bits;
max_bits += ctx->mb_rc[ctx->qscale][mb].bits;
if (!RC_VARIANCE) {
- delta_bits = ctx->mb_rc[ctx->qscale][mb].bits-ctx->mb_rc[ctx->qscale+1][mb].bits;
+ delta_bits = ctx->mb_rc[ctx->qscale][mb].bits -
+ ctx->mb_rc[ctx->qscale + 1][mb].bits;
ctx->mb_cmp[mb].mb = mb;
- ctx->mb_cmp[mb].value = delta_bits ?
- ((ctx->mb_rc[ctx->qscale][mb].ssd-ctx->mb_rc[ctx->qscale+1][mb].ssd)*100)/delta_bits
- : INT_MIN; //avoid increasing qscale
+ ctx->mb_cmp[mb].value =
+ delta_bits ? ((ctx->mb_rc[ctx->qscale][mb].ssd -
+ ctx->mb_rc[ctx->qscale + 1][mb].ssd) * 100) /
+ delta_bits
+ : INT_MIN; // avoid increasing qscale
}
}
- max_bits += 31; //worst padding
+ max_bits += 31; // worst padding
}
if (!ret) {
if (RC_VARIANCE)
- avctx->execute2(avctx, dnxhd_mb_var_thread, NULL, NULL, ctx->m.mb_height);
+ avctx->execute2(avctx, dnxhd_mb_var_thread,
+ NULL, NULL, ctx->m.mb_height);
radix_sort(ctx->mb_cmp, ctx->m.mb_num);
for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits; x++) {
int mb = ctx->mb_cmp[x].mb;
- max_bits -= ctx->mb_rc[ctx->qscale][mb].bits - ctx->mb_rc[ctx->qscale+1][mb].bits;
- ctx->mb_qscale[mb] = ctx->qscale+1;
- ctx->mb_bits[mb] = ctx->mb_rc[ctx->qscale+1][mb].bits;
+ max_bits -= ctx->mb_rc[ctx->qscale][mb].bits -
+ ctx->mb_rc[ctx->qscale + 1][mb].bits;
+ ctx->mb_qscale[mb] = ctx->qscale + 1;
+ ctx->mb_bits[mb] = ctx->mb_rc[ctx->qscale + 1][mb].bits;
}
}
return 0;
@@ -950,7 +1047,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
dnxhd_load_picture(ctx, frame);
- encode_coding_unit:
+encode_coding_unit:
for (i = 0; i < 3; i++) {
ctx->src[i] = frame->data[i];
if (ctx->interlaced && ctx->cur_field)
@@ -966,7 +1063,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR,
"picture could not fit ratecontrol constraints, increase qmax\n");
- return -1;
+ return ret;
}
dnxhd_setup_threads_slices(ctx);
@@ -981,14 +1078,15 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
avctx->execute2(avctx, dnxhd_encode_thread, buf, NULL, ctx->m.mb_height);
av_assert1(640 + offset + 4 <= ctx->cid_table->coding_unit_size);
- memset(buf + 640 + offset, 0, ctx->cid_table->coding_unit_size - 4 - offset - 640);
+ memset(buf + 640 + offset, 0,
+ ctx->cid_table->coding_unit_size - 4 - offset - 640);
AV_WB32(buf + ctx->cid_table->coding_unit_size - 4, 0x600DC0DE); // EOF
if (ctx->interlaced && first_field) {
first_field = 0;
ctx->cur_field ^= 1;
- buf += ctx->cid_table->coding_unit_size;
+ buf += ctx->cid_table->coding_unit_size;
goto encode_coding_unit;
}
@@ -1002,11 +1100,11 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
{
DNXHDEncContext *ctx = avctx->priv_data;
- int max_level = 1<<(ctx->cid_table->bit_depth+2);
+ int max_level = 1 << (ctx->cid_table->bit_depth + 2);
int i;
- av_free(ctx->vlc_codes-max_level*2);
- av_free(ctx->vlc_bits -max_level*2);
+ av_free(ctx->vlc_codes - max_level * 2);
+ av_free(ctx->vlc_bits - max_level * 2);
av_freep(&ctx->run_codes);
av_freep(&ctx->run_bits);
@@ -1045,9 +1143,11 @@ AVCodec ff_dnxhd_encoder = {
.encode2 = dnxhd_encode_picture,
.close = dnxhd_encode_end,
.capabilities = CODEC_CAP_SLICE_THREADS,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P,
- AV_PIX_FMT_YUV422P10,
- AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV422P,
+ AV_PIX_FMT_YUV422P10,
+ AV_PIX_FMT_NONE
+ },
.priv_class = &dnxhd_class,
.defaults = dnxhd_defaults,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.h b/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.h
index 110b0ad9e2f..4e96fa52764 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dnxhdenc.h
@@ -89,7 +89,8 @@ typedef struct DNXHDEncContext {
RCCMPEntry *mb_cmp;
RCEntry (*mb_rc)[8160];
- void (*get_pixels_8x4_sym)(int16_t * /*align 16*/, const uint8_t *, int);
+ void (*get_pixels_8x4_sym)(int16_t * /* align 16 */,
+ const uint8_t *, ptrdiff_t);
} DNXHDEncContext;
void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/dpx.c b/chromium/third_party/ffmpeg/libavcodec/dpx.c
index 5c3c3e81cb3..a21362eb113 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dpx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dpx.c
@@ -20,6 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavutil/intfloat.h"
#include "libavutil/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
@@ -146,6 +147,16 @@ static int decode_frame(AVCodecContext *avctx,
else
avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
+ if (offset >= 1724 + 4) {
+ buf = avpkt->data + 1724;
+ i = read32(&buf, endian);
+ if(i) {
+ AVRational q = av_d2q(av_int2float(i), 4096);
+ if (q.num > 0 && q.den > 0)
+ avctx->time_base = av_inv_q(q);
+ }
+ }
+
switch (descriptor) {
case 6: // Y
elements = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/rnd_mmx.c b/chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.c
index 326e2f395b6..dbeb9fe2057 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/rnd_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.c
@@ -1,4 +1,6 @@
/*
+ * Generate a header file for hardcoded DSD tables
+ *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@@ -16,20 +18,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-#include "dsputil_x86.h"
-
-#if HAVE_INLINE_ASM
+#include <stdlib.h>
+#define CONFIG_HARDCODED_TABLES 0
+#include "dsd_tablegen.h"
+#include "tableprint.h"
+#include <inttypes.h>
-#define DEF(x, y) ff_ ## x ## _ ## y ## _mmx
-#define SET_RND MOVQ_WTWO
-#define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX(a, b, c, d, e, f)
-#define PAVGB(a, b, c, e) PAVGB_MMX(a, b, c, e)
-#define STATIC
+int main(void)
+{
+ dsd_ctables_tableinit();
-#include "rnd_template.c"
+ write_fileheader();
-PIXELS16(, ff_avg, , _xy2, _mmx)
-PIXELS16(, ff_put, , _xy2, _mmx)
+ printf("static const double ctables[CTABLES][256] = {\n");
+ write_float_2d_array(ctables, CTABLES, 256);
+ printf("};\n");
-#endif /* HAVE_INLINE_ASM */
+ return 0;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.h b/chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.h
new file mode 100644
index 00000000000..6afb4167daa
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/dsd_tablegen.h
@@ -0,0 +1,95 @@
+/*
+ * Header file for hardcoded DSD tables
+ * based on BSD licensed dsd2pcm by Sebastian Gesemann
+ * Copyright (c) 2009, 2011 Sebastian Gesemann. All rights reserved.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_DSD_TABLEGEN_H
+#define AVCODEC_DSD_TABLEGEN_H
+
+#include <stdint.h>
+#include "libavutil/attributes.h"
+
+#define HTAPS 48 /** number of FIR constants */
+#define CTABLES ((HTAPS + 7) / 8) /** number of "8 MACs" lookup tables */
+
+#if CONFIG_HARDCODED_TABLES
+#define dsd_ctables_tableinit()
+#include "libavcodec/dsd_tables.h"
+#else
+#include "libavutil/common.h"
+
+/*
+ * Properties of this 96-tap lowpass filter when applied on a signal
+ * with sampling rate of 44100*64 Hz:
+ *
+ * () has a delay of 17 microseconds.
+ *
+ * () flat response up to 48 kHz
+ *
+ * () if you downsample afterwards by a factor of 8, the
+ * spectrum below 70 kHz is practically alias-free.
+ *
+ * () stopband rejection is about 160 dB
+ *
+ * The coefficient tables ("ctables") take only 6 Kibi Bytes and
+ * should fit into a modern processor's fast cache.
+ */
+
+/**
+ * The 2nd half (48 coeffs) of a 96-tap symmetric lowpass filter
+ */
+static const double htaps[HTAPS] = {
+ 0.09950731974056658, 0.09562845727714668, 0.08819647126516944,
+ 0.07782552527068175, 0.06534876523171299, 0.05172629311427257,
+ 0.0379429484910187, 0.02490921351762261, 0.0133774746265897,
+ 0.003883043418804416, -0.003284703416210726, -0.008080250212687497,
+ -0.01067241812471033, -0.01139427235000863, -0.0106813877974587,
+ -0.009007905078766049, -0.006828859761015335, -0.004535184322001496,
+ -0.002425035959059578, -0.0006922187080790708, 0.0005700762133516592,
+ 0.001353838005269448, 0.001713709169690937, 0.001742046839472948,
+ 0.001545601648013235, 0.001226696225277855, 0.0008704322683580222,
+ 0.0005381636200535649, 0.000266446345425276, 7.002968738383528e-05,
+ -5.279407053811266e-05, -0.0001140625650874684, -0.0001304796361231895,
+ -0.0001189970287491285, -9.396247155265073e-05, -6.577634378272832e-05,
+ -4.07492895872535e-05, -2.17407957554587e-05, -9.163058931391722e-06,
+ -2.017460145032201e-06, 1.249721855219005e-06, 2.166655190537392e-06,
+ 1.930520892991082e-06, 1.319400334374195e-06, 7.410039764949091e-07,
+ 3.423230509967409e-07, 1.244182214744588e-07, 3.130441005359396e-08
+};
+
+static float ctables[CTABLES][256];
+
+static av_cold void dsd_ctables_tableinit(void)
+{
+ int t, e, m, k;
+ double acc;
+ for (t = 0; t < CTABLES; ++t) {
+ k = FFMIN(HTAPS - t * 8, 8);
+ for (e = 0; e < 256; ++e) {
+ acc = 0.0;
+ for (m = 0; m < k; ++m)
+ acc += (((e >> (7 - m)) & 1) * 2 - 1) * htaps[t * 8 + m];
+ ctables[CTABLES - 1 - t][e] = (float)acc;
+ }
+ }
+}
+#endif /* CONFIG_HARDCODED_TABLES */
+
+#endif /* AVCODEC_DSD_TABLEGEN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsddec.c b/chromium/third_party/ffmpeg/libavcodec/dsddec.c
new file mode 100644
index 00000000000..f1dfd4b2313
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/dsddec.c
@@ -0,0 +1,167 @@
+/*
+ * Direct Stream Digital (DSD) decoder
+ * based on BSD licensed dsd2pcm by Sebastian Gesemann
+ * Copyright (c) 2009, 2011 Sebastian Gesemann. All rights reserved.
+ * Copyright (c) 2014 Peter Ross
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Direct Stream Digital (DSD) decoder
+ */
+
+#include "libavcodec/internal.h"
+#include "libavcodec/mathops.h"
+#include "avcodec.h"
+#include "dsd_tablegen.h"
+
+#define FIFOSIZE 16 /** must be a power of two */
+#define FIFOMASK (FIFOSIZE - 1) /** bit mask for FIFO offsets */
+
+#if FIFOSIZE * 8 < HTAPS * 2
+#error "FIFOSIZE too small"
+#endif
+
+/**
+ * Per-channel buffer
+ */
+typedef struct {
+ unsigned char buf[FIFOSIZE];
+ unsigned pos;
+} DSDContext;
+
+static void dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf,
+ const unsigned char *src, ptrdiff_t src_stride,
+ float *dst, ptrdiff_t dst_stride)
+{
+ unsigned pos, i;
+ unsigned char* p;
+ double sum;
+
+ pos = s->pos;
+
+ while (samples-- > 0) {
+ s->buf[pos] = lsbf ? ff_reverse[*src] : *src;
+ src += src_stride;
+
+ p = s->buf + ((pos - CTABLES) & FIFOMASK);
+ *p = ff_reverse[*p];
+
+ sum = 0.0;
+ for (i = 0; i < CTABLES; i++) {
+ unsigned char a = s->buf[(pos - i) & FIFOMASK];
+ unsigned char b = s->buf[(pos - (CTABLES*2 - 1) + i) & FIFOMASK];
+ sum += ctables[i][a] + ctables[i][b];
+ }
+
+ *dst = (float)sum;
+ dst += dst_stride;
+
+ pos = (pos + 1) & FIFOMASK;
+ }
+
+ s->pos = pos;
+}
+
+static av_cold void init_static_data(void)
+{
+ static int done = 0;
+ if (done)
+ return;
+ dsd_ctables_tableinit();
+ done = 1;
+}
+
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+ DSDContext * s;
+ int i;
+
+ init_static_data();
+
+ s = av_malloc_array(sizeof(DSDContext), avctx->channels);
+ if (!s)
+ return AVERROR(ENOMEM);
+
+ for (i = 0; i < avctx->channels; i++) {
+ s[i].pos = 0;
+ memset(s[i].buf, 0x69, sizeof(s[i].buf));
+
+ /* 0x69 = 01101001
+ * This pattern "on repeat" makes a low energy 352.8 kHz tone
+ * and a high energy 1.0584 MHz tone which should be filtered
+ * out completely by any playback system --> silence
+ */
+ }
+
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+ avctx->priv_data = s;
+ return 0;
+}
+
+static int decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
+{
+ DSDContext * s = avctx->priv_data;
+ AVFrame *frame = data;
+ int ret, i;
+ int lsbf = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR;
+ int src_next;
+ int src_stride;
+
+ frame->nb_samples = avpkt->size / avctx->channels;
+
+ if (avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR || avctx->codec_id == AV_CODEC_ID_DSD_MSBF_PLANAR) {
+ src_next = frame->nb_samples;
+ src_stride = 1;
+ } else {
+ src_next = 1;
+ src_stride = avctx->channels;
+ }
+
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+ return ret;
+
+ for (i = 0; i < avctx->channels; i++) {
+ float * dst = ((float **)frame->extended_data)[i];
+ dsd2pcm_translate(&s[i], frame->nb_samples, lsbf,
+ avpkt->data + i * src_next, src_stride,
+ dst, 1);
+ }
+
+ *got_frame_ptr = 1;
+ return frame->nb_samples * avctx->channels;
+}
+
+#define DSD_DECODER(id_, name_, long_name_) \
+AVCodec ff_##name_##_decoder = { \
+ .name = #name_, \
+ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
+ .type = AVMEDIA_TYPE_AUDIO, \
+ .id = AV_CODEC_ID_##id_, \
+ .init = decode_init, \
+ .decode = decode_frame, \
+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, \
+ AV_SAMPLE_FMT_NONE }, \
+};
+
+DSD_DECODER(DSD_LSBF, dsd_lsbf, "DSD (Direct Stream Digital), least significant bit first")
+DSD_DECODER(DSD_MSBF, dsd_msbf, "DSD (Direct Stream Digital), most significant bit first")
+DSD_DECODER(DSD_MSBF_PLANAR, dsd_msbf_planar, "DSD (Direct Stream Digital), most significant bit first, planar")
+DSD_DECODER(DSD_LSBF_PLANAR, dsd_lsbf_planar, "DSD (Direct Stream Digital), least significant bit first, planar")
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsputil.c b/chromium/third_party/ffmpeg/libavcodec/dsputil.c
index 0e9e34798ef..21e3feaca9a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dsputil.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dsputil.c
@@ -43,34 +43,24 @@
#include "config.h"
#include "diracdsp.h"
-uint32_t ff_squareTbl[512] = {0, };
+uint32_t ff_square_tab[512] = { 0, };
#define BIT_DEPTH 16
-#include "dsputil_template.c"
+#include "dsputilenc_template.c"
#undef BIT_DEPTH
#define BIT_DEPTH 8
+#include "hpel_template.c"
+#include "tpel_template.c"
#include "dsputil_template.c"
+#include "dsputilenc_template.c"
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
-#define pb_7f (~0UL/255 * 0x7f)
-#define pb_80 (~0UL/255 * 0x80)
-
-/* Specific zigzag scan for 248 idct. NOTE that unlike the
- specification, we interleave the fields */
-const uint8_t ff_zigzag248_direct[64] = {
- 0, 8, 1, 9, 16, 24, 2, 10,
- 17, 25, 32, 40, 48, 56, 33, 41,
- 18, 26, 3, 11, 4, 12, 19, 27,
- 34, 42, 49, 57, 50, 58, 35, 43,
- 20, 28, 5, 13, 6, 14, 21, 29,
- 36, 44, 51, 59, 52, 60, 37, 45,
- 22, 30, 7, 15, 23, 31, 38, 46,
- 53, 61, 54, 62, 39, 47, 55, 63,
-};
+#define pb_7f (~0UL / 255 * 0x7f)
+#define pb_80 (~0UL / 255 * 0x80)
const uint8_t ff_alternate_horizontal_scan[64] = {
- 0, 1, 2, 3, 8, 9, 16, 17,
+ 0, 1, 2, 3, 8, 9, 16, 17,
10, 11, 4, 5, 6, 7, 15, 14,
13, 12, 19, 18, 24, 25, 32, 33,
26, 27, 20, 21, 22, 23, 28, 29,
@@ -81,7 +71,7 @@ const uint8_t ff_alternate_horizontal_scan[64] = {
};
const uint8_t ff_alternate_vertical_scan[64] = {
- 0, 8, 16, 24, 1, 9, 2, 10,
+ 0, 8, 16, 24, 1, 9, 2, 10,
17, 25, 32, 40, 48, 56, 57, 49,
41, 33, 26, 18, 3, 11, 4, 12,
19, 27, 34, 42, 50, 58, 35, 43,
@@ -92,39 +82,37 @@ const uint8_t ff_alternate_vertical_scan[64] = {
};
/* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64]={
- 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
- 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
- 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
- 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
- 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
- 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
- 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
- 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
+static const uint8_t simple_mmx_permutation[64] = {
+ 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
+ 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
+ 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
+ 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
+ 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
+ 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
+ 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
+ 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
};
-static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
+static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
const uint8_t *src_scantable)
{
- int i;
- int end;
+ int i, end;
- st->scantable= src_scantable;
+ st->scantable = src_scantable;
- for(i=0; i<64; i++){
- int j;
- j = src_scantable[i];
+ for (i = 0; i < 64; i++) {
+ int j = src_scantable[i];
st->permutated[i] = permutation[j];
}
- end=-1;
- for(i=0; i<64; i++){
- int j;
- j = st->permutated[i];
- if(j>end) end=j;
- st->raster_end[i]= end;
+ end = -1;
+ for (i = 0; i < 64; i++) {
+ int j = st->permutated[i];
+ if (j > end)
+ end = j;
+ st->raster_end[i] = end;
}
}
@@ -133,51 +121,51 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
{
int i;
- switch(idct_permutation_type){
+ switch (idct_permutation_type) {
case FF_NO_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= i;
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = i;
break;
case FF_LIBMPEG2_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
break;
case FF_SIMPLE_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= simple_mmx_permutation[i];
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = simple_mmx_permutation[i];
break;
case FF_TRANSPOSE_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= ((i&7)<<3) | (i>>3);
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
break;
case FF_PARTTRANS_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
break;
case FF_SSE2_IDCT_PERM:
- for(i=0; i<64; i++)
- idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
+ for (i = 0; i < 64; i++)
+ idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
break;
default:
- av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
+ av_log(NULL, AV_LOG_ERROR,
+ "Internal error, IDCT permutation not set\n");
}
}
-static int pix_sum_c(uint8_t * pix, int line_size)
+static int pix_sum_c(uint8_t *pix, int line_size)
{
- int s, i, j;
+ int s = 0, i, j;
- s = 0;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j += 8) {
- s += pix[0];
- s += pix[1];
- s += pix[2];
- s += pix[3];
- s += pix[4];
- s += pix[5];
- s += pix[6];
- s += pix[7];
+ s += pix[0];
+ s += pix[1];
+ s += pix[2];
+ s += pix[3];
+ s += pix[4];
+ s += pix[5];
+ s += pix[6];
+ s += pix[7];
pix += 8;
}
pix += line_size - 16;
@@ -185,12 +173,11 @@ static int pix_sum_c(uint8_t * pix, int line_size)
return s;
}
-static int pix_norm1_c(uint8_t * pix, int line_size)
+static int pix_norm1_c(uint8_t *pix, int line_size)
{
- int s, i, j;
- uint32_t *sq = ff_squareTbl + 256;
+ int s = 0, i, j;
+ uint32_t *sq = ff_square_tab + 256;
- s = 0;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j += 8) {
#if 0
@@ -204,26 +191,26 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
s += sq[pix[7]];
#else
#if HAVE_FAST_64BIT
- register uint64_t x=*(uint64_t*)pix;
- s += sq[x&0xff];
- s += sq[(x>>8)&0xff];
- s += sq[(x>>16)&0xff];
- s += sq[(x>>24)&0xff];
- s += sq[(x>>32)&0xff];
- s += sq[(x>>40)&0xff];
- s += sq[(x>>48)&0xff];
- s += sq[(x>>56)&0xff];
+ register uint64_t x = *(uint64_t *) pix;
+ s += sq[x & 0xff];
+ s += sq[(x >> 8) & 0xff];
+ s += sq[(x >> 16) & 0xff];
+ s += sq[(x >> 24) & 0xff];
+ s += sq[(x >> 32) & 0xff];
+ s += sq[(x >> 40) & 0xff];
+ s += sq[(x >> 48) & 0xff];
+ s += sq[(x >> 56) & 0xff];
#else
- register uint32_t x=*(uint32_t*)pix;
- s += sq[x&0xff];
- s += sq[(x>>8)&0xff];
- s += sq[(x>>16)&0xff];
- s += sq[(x>>24)&0xff];
- x=*(uint32_t*)(pix+4);
- s += sq[x&0xff];
- s += sq[(x>>8)&0xff];
- s += sq[(x>>16)&0xff];
- s += sq[(x>>24)&0xff];
+ register uint32_t x = *(uint32_t *) pix;
+ s += sq[x & 0xff];
+ s += sq[(x >> 8) & 0xff];
+ s += sq[(x >> 16) & 0xff];
+ s += sq[(x >> 24) & 0xff];
+ x = *(uint32_t *) (pix + 4);
+ s += sq[x & 0xff];
+ s += sq[(x >> 8) & 0xff];
+ s += sq[(x >> 16) & 0xff];
+ s += sq[(x >> 24) & 0xff];
#endif
#endif
pix += 8;
@@ -233,22 +220,22 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
return s;
}
-static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
+static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
+{
int i;
- for(i=0; i+8<=w; i+=8){
- dst[i+0]= av_bswap32(src[i+0]);
- dst[i+1]= av_bswap32(src[i+1]);
- dst[i+2]= av_bswap32(src[i+2]);
- dst[i+3]= av_bswap32(src[i+3]);
- dst[i+4]= av_bswap32(src[i+4]);
- dst[i+5]= av_bswap32(src[i+5]);
- dst[i+6]= av_bswap32(src[i+6]);
- dst[i+7]= av_bswap32(src[i+7]);
- }
- for(;i<w; i++){
- dst[i+0]= av_bswap32(src[i+0]);
+ for (i = 0; i + 8 <= w; i += 8) {
+ dst[i + 0] = av_bswap32(src[i + 0]);
+ dst[i + 1] = av_bswap32(src[i + 1]);
+ dst[i + 2] = av_bswap32(src[i + 2]);
+ dst[i + 3] = av_bswap32(src[i + 3]);
+ dst[i + 4] = av_bswap32(src[i + 4]);
+ dst[i + 5] = av_bswap32(src[i + 5]);
+ dst[i + 6] = av_bswap32(src[i + 6]);
+ dst[i + 7] = av_bswap32(src[i + 7]);
}
+ for (; i < w; i++)
+ dst[i + 0] = av_bswap32(src[i + 0]);
}
static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
@@ -257,61 +244,61 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
*dst++ = av_bswap16(*src++);
}
-static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
- uint32_t *sq = ff_squareTbl + 256;
+ int s = 0, i;
+ uint32_t *sq = ff_square_tab + 256;
- s = 0;
for (i = 0; i < h; i++) {
- s += sq[pix1[0] - pix2[0]];
- s += sq[pix1[1] - pix2[1]];
- s += sq[pix1[2] - pix2[2]];
- s += sq[pix1[3] - pix2[3]];
+ s += sq[pix1[0] - pix2[0]];
+ s += sq[pix1[1] - pix2[1]];
+ s += sq[pix1[2] - pix2[2]];
+ s += sq[pix1[3] - pix2[3]];
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
- uint32_t *sq = ff_squareTbl + 256;
+ int s = 0, i;
+ uint32_t *sq = ff_square_tab + 256;
- s = 0;
for (i = 0; i < h; i++) {
- s += sq[pix1[0] - pix2[0]];
- s += sq[pix1[1] - pix2[1]];
- s += sq[pix1[2] - pix2[2]];
- s += sq[pix1[3] - pix2[3]];
- s += sq[pix1[4] - pix2[4]];
- s += sq[pix1[5] - pix2[5]];
- s += sq[pix1[6] - pix2[6]];
- s += sq[pix1[7] - pix2[7]];
+ s += sq[pix1[0] - pix2[0]];
+ s += sq[pix1[1] - pix2[1]];
+ s += sq[pix1[2] - pix2[2]];
+ s += sq[pix1[3] - pix2[3]];
+ s += sq[pix1[4] - pix2[4]];
+ s += sq[pix1[5] - pix2[5]];
+ s += sq[pix1[6] - pix2[6]];
+ s += sq[pix1[7] - pix2[7]];
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
- uint32_t *sq = ff_squareTbl + 256;
+ int s = 0, i;
+ uint32_t *sq = ff_square_tab + 256;
- s = 0;
for (i = 0; i < h; i++) {
- s += sq[pix1[ 0] - pix2[ 0]];
- s += sq[pix1[ 1] - pix2[ 1]];
- s += sq[pix1[ 2] - pix2[ 2]];
- s += sq[pix1[ 3] - pix2[ 3]];
- s += sq[pix1[ 4] - pix2[ 4]];
- s += sq[pix1[ 5] - pix2[ 5]];
- s += sq[pix1[ 6] - pix2[ 6]];
- s += sq[pix1[ 7] - pix2[ 7]];
- s += sq[pix1[ 8] - pix2[ 8]];
- s += sq[pix1[ 9] - pix2[ 9]];
+ s += sq[pix1[0] - pix2[0]];
+ s += sq[pix1[1] - pix2[1]];
+ s += sq[pix1[2] - pix2[2]];
+ s += sq[pix1[3] - pix2[3]];
+ s += sq[pix1[4] - pix2[4]];
+ s += sq[pix1[5] - pix2[5]];
+ s += sq[pix1[6] - pix2[6]];
+ s += sq[pix1[7] - pix2[7]];
+ s += sq[pix1[8] - pix2[8]];
+ s += sq[pix1[9] - pix2[9]];
s += sq[pix1[10] - pix2[10]];
s += sq[pix1[11] - pix2[11]];
s += sq[pix1[12] - pix2[12]];
@@ -326,11 +313,12 @@ static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
}
static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1,
- const uint8_t *s2, int stride){
+ const uint8_t *s2, int stride)
+{
int i;
/* read the pixels */
- for(i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
block[0] = s1[0] - s2[0];
block[1] = s1[1] - s2[1];
block[2] = s1[2] - s2[2];
@@ -339,9 +327,9 @@ static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1,
block[5] = s1[5] - s2[5];
block[6] = s1[6] - s2[6];
block[7] = s1[7] - s2[7];
- s1 += stride;
- s2 += stride;
- block += 8;
+ s1 += stride;
+ s2 += stride;
+ block += 8;
}
}
@@ -351,7 +339,7 @@ static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixe
int i;
/* read the pixels */
- for(i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
pixels[0] = av_clip_uint8(block[0]);
pixels[1] = av_clip_uint8(block[1]);
pixels[2] = av_clip_uint8(block[2]);
@@ -362,7 +350,7 @@ static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixe
pixels[7] = av_clip_uint8(block[7]);
pixels += line_size;
- block += 8;
+ block += 8;
}
}
@@ -411,7 +399,7 @@ static void put_signed_pixels_clamped_c(const int16_t *block,
else if (*block > 127)
*pixels = 255;
else
- *pixels = (uint8_t)(*block + 128);
+ *pixels = (uint8_t) (*block + 128);
block++;
pixels++;
}
@@ -419,13 +407,12 @@ static void put_signed_pixels_clamped_c(const int16_t *block,
}
}
-static void add_pixels8_c(uint8_t *av_restrict pixels,
- int16_t *block,
+static void add_pixels8_c(uint8_t *av_restrict pixels, int16_t *block,
int line_size)
{
int i;
- for(i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
pixels[0] += block[0];
pixels[1] += block[1];
pixels[2] += block[2];
@@ -434,8 +421,8 @@ static void add_pixels8_c(uint8_t *av_restrict pixels,
pixels[5] += block[5];
pixels[6] += block[6];
pixels[7] += block[7];
- pixels += line_size;
- block += 8;
+ pixels += line_size;
+ block += 8;
}
}
@@ -445,7 +432,7 @@ static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixe
int i;
/* read the pixels */
- for(i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
pixels[0] = av_clip_uint8(pixels[0] + block[0]);
pixels[1] = av_clip_uint8(pixels[1] + block[1]);
pixels[2] = av_clip_uint8(pixels[2] + block[2]);
@@ -454,8 +441,8 @@ static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixe
pixels[5] = av_clip_uint8(pixels[5] + block[5]);
pixels[6] = av_clip_uint8(pixels[6] + block[6]);
pixels[7] = av_clip_uint8(pixels[7] + block[7]);
- pixels += line_size;
- block += 8;
+ pixels += line_size;
+ block += 8;
}
}
@@ -491,9 +478,10 @@ static void add_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pix
static int sum_abs_dctelem_c(int16_t *block)
{
- int sum=0, i;
- for(i=0; i<64; i++)
- sum+= FFABS(block[i]);
+ int sum = 0, i;
+
+ for (i = 0; i < 64; i++)
+ sum += FFABS(block[i]);
return sum;
}
@@ -517,813 +505,752 @@ static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
}
}
-#define avg2(a,b) ((a+b+1)>>1)
-#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
+#define avg2(a, b) ((a + b + 1) >> 1)
+#define avg4(a, b, c, d) ((a + b + c + d + 2) >> 2)
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
+static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
+ int x16, int y16, int rounder)
{
- const int A=(16-x16)*(16-y16);
- const int B=( x16)*(16-y16);
- const int C=(16-x16)*( y16);
- const int D=( x16)*( y16);
+ const int A = (16 - x16) * (16 - y16);
+ const int B = (x16) * (16 - y16);
+ const int C = (16 - x16) * (y16);
+ const int D = (x16) * (y16);
int i;
- for(i=0; i<h; i++)
- {
- dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
- dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
- dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
- dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
- dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
- dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
- dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
- dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
- dst+= stride;
- src+= stride;
+ for (i = 0; i < h; i++) {
+ dst[0] = (A * src[0] + B * src[1] + C * src[stride + 0] + D * src[stride + 1] + rounder) >> 8;
+ dst[1] = (A * src[1] + B * src[2] + C * src[stride + 1] + D * src[stride + 2] + rounder) >> 8;
+ dst[2] = (A * src[2] + B * src[3] + C * src[stride + 2] + D * src[stride + 3] + rounder) >> 8;
+ dst[3] = (A * src[3] + B * src[4] + C * src[stride + 3] + D * src[stride + 4] + rounder) >> 8;
+ dst[4] = (A * src[4] + B * src[5] + C * src[stride + 4] + D * src[stride + 5] + rounder) >> 8;
+ dst[5] = (A * src[5] + B * src[6] + C * src[stride + 5] + D * src[stride + 6] + rounder) >> 8;
+ dst[6] = (A * src[6] + B * src[7] + C * src[stride + 6] + D * src[stride + 7] + rounder) >> 8;
+ dst[7] = (A * src[7] + B * src[8] + C * src[stride + 7] + D * src[stride + 8] + rounder) >> 8;
+ dst += stride;
+ src += stride;
}
}
void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
- int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+ int dxx, int dxy, int dyx, int dyy, int shift, int r,
+ int width, int height)
{
int y, vx, vy;
- const int s= 1<<shift;
+ const int s = 1 << shift;
width--;
height--;
- for(y=0; y<h; y++){
+ for (y = 0; y < h; y++) {
int x;
- vx= ox;
- vy= oy;
- for(x=0; x<8; x++){ //XXX FIXME optimize
- int src_x, src_y, frac_x, frac_y, index;
-
- src_x= vx>>16;
- src_y= vy>>16;
- frac_x= src_x&(s-1);
- frac_y= src_y&(s-1);
- src_x>>=shift;
- src_y>>=shift;
-
- if((unsigned)src_x < width){
- if((unsigned)src_y < height){
- index= src_x + src_y*stride;
- dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
- + src[index +1]* frac_x )*(s-frac_y)
- + ( src[index+stride ]*(s-frac_x)
- + src[index+stride+1]* frac_x )* frac_y
- + r)>>(shift*2);
- }else{
- index= src_x + av_clip(src_y, 0, height)*stride;
- dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
- + src[index +1]* frac_x )*s
- + r)>>(shift*2);
+ vx = ox;
+ vy = oy;
+ for (x = 0; x < 8; x++) { // FIXME: optimize
+ int index;
+ int src_x = vx >> 16;
+ int src_y = vy >> 16;
+ int frac_x = src_x & (s - 1);
+ int frac_y = src_y & (s - 1);
+
+ src_x >>= shift;
+ src_y >>= shift;
+
+ if ((unsigned) src_x < width) {
+ if ((unsigned) src_y < height) {
+ index = src_x + src_y * stride;
+ dst[y * stride + x] =
+ ((src[index] * (s - frac_x) +
+ src[index + 1] * frac_x) * (s - frac_y) +
+ (src[index + stride] * (s - frac_x) +
+ src[index + stride + 1] * frac_x) * frac_y +
+ r) >> (shift * 2);
+ } else {
+ index = src_x + av_clip(src_y, 0, height) * stride;
+ dst[y * stride + x] =
+ ((src[index] * (s - frac_x) +
+ src[index + 1] * frac_x) * s +
+ r) >> (shift * 2);
}
- }else{
- if((unsigned)src_y < height){
- index= av_clip(src_x, 0, width) + src_y*stride;
- dst[y*stride + x]= ( ( src[index ]*(s-frac_y)
- + src[index+stride ]* frac_y )*s
- + r)>>(shift*2);
- }else{
- index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride;
- dst[y*stride + x]= src[index ];
+ } else {
+ if ((unsigned) src_y < height) {
+ index = av_clip(src_x, 0, width) + src_y * stride;
+ dst[y * stride + x] =
+ ((src[index] * (s - frac_y) +
+ src[index + stride] * frac_y) * s +
+ r) >> (shift * 2);
+ } else {
+ index = av_clip(src_x, 0, width) +
+ av_clip(src_y, 0, height) * stride;
+ dst[y * stride + x] = src[index];
}
}
- vx+= dxx;
- vy+= dyx;
+ vx += dxx;
+ vy += dyx;
}
ox += dxy;
oy += dyy;
}
}
-static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- switch(width){
- case 2: put_pixels2_8_c (dst, src, stride, height); break;
- case 4: put_pixels4_8_c (dst, src, stride, height); break;
- case 8: put_pixels8_8_c (dst, src, stride, height); break;
- case 16:put_pixels16_8_c(dst, src, stride, height); break;
- }
-}
-
-static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- switch(width){
- case 2: avg_pixels2_8_c (dst, src, stride, height); break;
- case 4: avg_pixels4_8_c (dst, src, stride, height); break;
- case 8: avg_pixels8_8_c (dst, src, stride, height); break;
- case 16:avg_pixels16_8_c(dst, src, stride, height); break;
- }
-}
-
-static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
- int i,j;
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
-}
-
-#define QPEL_MC(r, OPNAME, RND, OP) \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i=0; i<h; i++)\
- {\
- OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
- OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
- OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
- OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
- OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
- OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
- OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
- OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
- dst+=dstStride;\
- src+=srcStride;\
- }\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- const int w=8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i=0; i<w; i++)\
- {\
- const int src0= src[0*srcStride];\
- const int src1= src[1*srcStride];\
- const int src2= src[2*srcStride];\
- const int src3= src[3*srcStride];\
- const int src4= src[4*srcStride];\
- const int src5= src[5*srcStride];\
- const int src6= src[6*srcStride];\
- const int src7= src[7*srcStride];\
- const int src8= src[8*srcStride];\
- OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
- OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
- OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
- OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
- OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
- OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
- OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
- OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
- dst++;\
- src++;\
- }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- \
- for(i=0; i<h; i++)\
- {\
- OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
- OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
- OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
- OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
- OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
- OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
- OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
- OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
- OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
- OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
- OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
- OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
- OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
- OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
- OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
- OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
- dst+=dstStride;\
- src+=srcStride;\
- }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- const int w=16;\
- for(i=0; i<w; i++)\
- {\
- const int src0= src[0*srcStride];\
- const int src1= src[1*srcStride];\
- const int src2= src[2*srcStride];\
- const int src3= src[3*srcStride];\
- const int src4= src[4*srcStride];\
- const int src5= src[5*srcStride];\
- const int src6= src[6*srcStride];\
- const int src7= src[7*srcStride];\
- const int src8= src[8*srcStride];\
- const int src9= src[9*srcStride];\
- const int src10= src[10*srcStride];\
- const int src11= src[11*srcStride];\
- const int src12= src[12*srcStride];\
- const int src13= src[13*srcStride];\
- const int src14= src[14*srcStride];\
- const int src15= src[15*srcStride];\
- const int src16= src[16*srcStride];\
- OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
- OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
- OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
- OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
- OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
- OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
- OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
- OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
- OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
- OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
- OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
- OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
- OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
- OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
- OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
- OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
- dst++;\
- src++;\
- }\
-}\
-\
-static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t half[64];\
- put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
- OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t half[64];\
- put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
- OPNAME ## pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t half[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
- OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- copy_block9(full, src, 16, stride, 9);\
- OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
-}\
-\
-static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t half[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
- OPNAME ## pixels8_l2_8(dst, full+16, half, stride, 16, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l4_8(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l4_8(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[72];\
- uint8_t halfHV[64];\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
- OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- uint8_t halfV[64];\
- uint8_t halfHV[64];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
- put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
- OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[16*9];\
- uint8_t halfH[72];\
- copy_block9(full, src, 16, stride, 9);\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
- put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
- OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[72];\
- put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
- OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-\
-static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t half[256];\
- put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
- OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t half[256];\
- put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
- OPNAME ## pixels16_l2_8(dst, src+1, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t half[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
- OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- copy_block17(full, src, 24, stride, 17);\
- OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
-}\
-\
-static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t half[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
- OPNAME ## pixels16_l2_8(dst, full+24, half, stride, 24, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l4_8(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l4_8(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[272];\
- uint8_t halfHV[256];\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
- OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- uint8_t halfV[256];\
- uint8_t halfHV[256];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
- put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
- OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t full[24*17];\
- uint8_t halfH[272];\
- copy_block17(full, src, 24, stride, 17);\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
- put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
- OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
- uint8_t halfH[272];\
- put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
- OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}
-
-#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
-#define op_put(a, b) a = cm[((b) + 16)>>5]
-#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
-
-QPEL_MC(0, put_ , _ , op_put)
+#define QPEL_MC(r, OPNAME, RND, OP) \
+static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, \
+ int dstStride, int srcStride, \
+ int h) \
+{ \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
+ OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
+ OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
+ OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
+ OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
+ OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
+ OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
+ OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
+ dst += dstStride; \
+ src += srcStride; \
+ } \
+} \
+ \
+static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, \
+ int dstStride, int srcStride) \
+{ \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ const int w = 8; \
+ int i; \
+ \
+ for (i = 0; i < w; i++) { \
+ const int src0 = src[0 * srcStride]; \
+ const int src1 = src[1 * srcStride]; \
+ const int src2 = src[2 * srcStride]; \
+ const int src3 = src[3 * srcStride]; \
+ const int src4 = src[4 * srcStride]; \
+ const int src5 = src[5 * srcStride]; \
+ const int src6 = src[6 * srcStride]; \
+ const int src7 = src[7 * srcStride]; \
+ const int src8 = src[8 * srcStride]; \
+ OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
+ OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
+ OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
+ OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
+ OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
+ OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
+ OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
+ OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
+ dst++; \
+ src++; \
+ } \
+} \
+ \
+static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, \
+ int dstStride, int srcStride, \
+ int h) \
+{ \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
+ OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
+ OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
+ OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
+ OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
+ OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[9])); \
+ OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[9]) * 3 - (src[3] + src[10])); \
+ OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[9]) * 6 + (src[5] + src[10]) * 3 - (src[4] + src[11])); \
+ OP(dst[8], (src[8] + src[9]) * 20 - (src[7] + src[10]) * 6 + (src[6] + src[11]) * 3 - (src[5] + src[12])); \
+ OP(dst[9], (src[9] + src[10]) * 20 - (src[8] + src[11]) * 6 + (src[7] + src[12]) * 3 - (src[6] + src[13])); \
+ OP(dst[10], (src[10] + src[11]) * 20 - (src[9] + src[12]) * 6 + (src[8] + src[13]) * 3 - (src[7] + src[14])); \
+ OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9] + src[14]) * 3 - (src[8] + src[15])); \
+ OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9] + src[16])); \
+ OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
+ OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
+ OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
+ dst += dstStride; \
+ src += srcStride; \
+ } \
+} \
+ \
+static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, \
+ int dstStride, int srcStride) \
+{ \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ const int w = 16; \
+ int i; \
+ \
+ for (i = 0; i < w; i++) { \
+ const int src0 = src[0 * srcStride]; \
+ const int src1 = src[1 * srcStride]; \
+ const int src2 = src[2 * srcStride]; \
+ const int src3 = src[3 * srcStride]; \
+ const int src4 = src[4 * srcStride]; \
+ const int src5 = src[5 * srcStride]; \
+ const int src6 = src[6 * srcStride]; \
+ const int src7 = src[7 * srcStride]; \
+ const int src8 = src[8 * srcStride]; \
+ const int src9 = src[9 * srcStride]; \
+ const int src10 = src[10 * srcStride]; \
+ const int src11 = src[11 * srcStride]; \
+ const int src12 = src[12 * srcStride]; \
+ const int src13 = src[13 * srcStride]; \
+ const int src14 = src[14 * srcStride]; \
+ const int src15 = src[15 * srcStride]; \
+ const int src16 = src[16 * srcStride]; \
+ OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
+ OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
+ OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
+ OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
+ OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
+ OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src9)); \
+ OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src9) * 3 - (src3 + src10)); \
+ OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src9) * 6 + (src5 + src10) * 3 - (src4 + src11)); \
+ OP(dst[8 * dstStride], (src8 + src9) * 20 - (src7 + src10) * 6 + (src6 + src11) * 3 - (src5 + src12)); \
+ OP(dst[9 * dstStride], (src9 + src10) * 20 - (src8 + src11) * 6 + (src7 + src12) * 3 - (src6 + src13)); \
+ OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9 + src12) * 6 + (src8 + src13) * 3 - (src7 + src14)); \
+ OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9 + src14) * 3 - (src8 + src15)); \
+ OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9 + src16)); \
+ OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
+ OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
+ OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
+ dst++; \
+ src++; \
+ } \
+} \
+ \
+static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t half[64]; \
+ \
+ put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
+ OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t half[64]; \
+ \
+ put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
+ OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t half[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
+ OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
+} \
+ \
+static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t half[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
+ OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, \
+ stride, 16, 8, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV, \
+ stride, 16, 8, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV, \
+ stride, 16, 8, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV, \
+ stride, 16, 8, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[72]; \
+ uint8_t halfHV[64]; \
+ \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
+ OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
+} \
+ \
+void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ uint8_t halfV[64]; \
+ uint8_t halfHV[64]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
+ put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
+ OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[16 * 9]; \
+ uint8_t halfH[72]; \
+ \
+ copy_block9(full, src, 16, stride, 9); \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
+ put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
+ OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
+} \
+ \
+static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[72]; \
+ \
+ put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
+ OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
+} \
+ \
+static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t half[256]; \
+ \
+ put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
+ OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t half[256]; \
+ \
+ put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
+ OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t half[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
+ OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
+} \
+ \
+static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t half[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
+ OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, \
+ stride, 24, 16, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV, \
+ stride, 24, 16, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV, \
+ stride, 24, 16, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV, \
+ stride, 24, 16, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[272]; \
+ uint8_t halfHV[256]; \
+ \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
+ OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
+} \
+ \
+void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ uint8_t halfV[256]; \
+ uint8_t halfHV[256]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
+ put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
+ OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t full[24 * 17]; \
+ uint8_t halfH[272]; \
+ \
+ copy_block17(full, src, 24, stride, 17); \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
+ put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
+ OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
+} \
+ \
+static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
+{ \
+ uint8_t halfH[272]; \
+ \
+ put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
+ OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
+}
+
+#define op_avg(a, b) a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
+#define op_avg_no_rnd(a, b) a = (((a) + cm[((b) + 15) >> 5]) >> 1)
+#define op_put(a, b) a = cm[((b) + 16) >> 5]
+#define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
+
+QPEL_MC(0, put_, _, op_put)
QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
-QPEL_MC(0, avg_ , _ , op_avg)
-//QPEL_MC(1, avg_no_rnd , _ , op_avg)
+QPEL_MC(0, avg_, _, op_avg)
+
#undef op_avg
-#undef op_avg_no_rnd
#undef op_put
#undef op_put_no_rnd
@@ -1331,63 +1258,49 @@ void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
put_pixels8_8_c(dst, src, stride, 8);
}
+
void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
avg_pixels8_8_c(dst, src, stride, 8);
}
+
void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
put_pixels16_8_c(dst, src, stride, 16);
}
+
void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
avg_pixels16_8_c(dst, src, stride, 16);
}
-#define put_qpel8_mc00_c ff_put_pixels8x8_c
-#define avg_qpel8_mc00_c ff_avg_pixels8x8_c
-#define put_qpel16_mc00_c ff_put_pixels16x16_c
-#define avg_qpel16_mc00_c ff_avg_pixels16x16_c
+#define put_qpel8_mc00_c ff_put_pixels8x8_c
+#define avg_qpel8_mc00_c ff_avg_pixels8x8_c
+#define put_qpel16_mc00_c ff_put_pixels16x16_c
+#define avg_qpel16_mc00_c ff_avg_pixels16x16_c
#define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src,
+ int dstStride, int srcStride, int h)
+{
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int i;
- for(i=0; i<h; i++){
- dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
- dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
- dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
- dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
- dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
- dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
- dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
- dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
- dst+=dstStride;
- src+=srcStride;
+ for (i = 0; i < h; i++) {
+ dst[0] = cm[(9 * (src[0] + src[1]) - (src[-1] + src[2]) + 8) >> 4];
+ dst[1] = cm[(9 * (src[1] + src[2]) - (src[0] + src[3]) + 8) >> 4];
+ dst[2] = cm[(9 * (src[2] + src[3]) - (src[1] + src[4]) + 8) >> 4];
+ dst[3] = cm[(9 * (src[3] + src[4]) - (src[2] + src[5]) + 8) >> 4];
+ dst[4] = cm[(9 * (src[4] + src[5]) - (src[3] + src[6]) + 8) >> 4];
+ dst[5] = cm[(9 * (src[5] + src[6]) - (src[4] + src[7]) + 8) >> 4];
+ dst[6] = cm[(9 * (src[6] + src[7]) - (src[5] + src[8]) + 8) >> 4];
+ dst[7] = cm[(9 * (src[7] + src[8]) - (src[6] + src[9]) + 8) >> 4];
+ dst += dstStride;
+ src += srcStride;
}
}
-#if CONFIG_RV40_DECODER
-void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- put_pixels16_xy2_8_c(dst, src, stride, 16);
-}
-void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- avg_pixels16_xy2_8_c(dst, src, stride, 16);
-}
-void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- put_pixels8_xy2_8_c(dst, src, stride, 8);
-}
-void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- avg_pixels8_xy2_8_c(dst, src, stride, 8);
-}
-#endif /* CONFIG_RV40_DECODER */
-
#if CONFIG_DIRAC_DECODER
#define DIRAC_MC(OPNAME)\
void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
@@ -1433,30 +1346,32 @@ DIRAC_MC(put)
DIRAC_MC(avg)
#endif
-static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src,
+ int dstStride, int srcStride, int w)
+{
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int i;
- for(i=0; i<w; i++){
- const int src_1= src[ -srcStride];
- const int src0 = src[0 ];
- const int src1 = src[ srcStride];
- const int src2 = src[2*srcStride];
- const int src3 = src[3*srcStride];
- const int src4 = src[4*srcStride];
- const int src5 = src[5*srcStride];
- const int src6 = src[6*srcStride];
- const int src7 = src[7*srcStride];
- const int src8 = src[8*srcStride];
- const int src9 = src[9*srcStride];
- dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
- dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4];
- dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4];
- dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4];
- dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4];
- dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4];
- dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4];
- dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4];
+ for (i = 0; i < w; i++) {
+ const int src_1 = src[-srcStride];
+ const int src0 = src[0];
+ const int src1 = src[srcStride];
+ const int src2 = src[2 * srcStride];
+ const int src3 = src[3 * srcStride];
+ const int src4 = src[4 * srcStride];
+ const int src5 = src[5 * srcStride];
+ const int src6 = src[6 * srcStride];
+ const int src7 = src[7 * srcStride];
+ const int src8 = src[8 * srcStride];
+ const int src9 = src[9 * srcStride];
+ dst[0 * dstStride] = cm[(9 * (src0 + src1) - (src_1 + src2) + 8) >> 4];
+ dst[1 * dstStride] = cm[(9 * (src1 + src2) - (src0 + src3) + 8) >> 4];
+ dst[2 * dstStride] = cm[(9 * (src2 + src3) - (src1 + src4) + 8) >> 4];
+ dst[3 * dstStride] = cm[(9 * (src3 + src4) - (src2 + src5) + 8) >> 4];
+ dst[4 * dstStride] = cm[(9 * (src4 + src5) - (src3 + src6) + 8) >> 4];
+ dst[5 * dstStride] = cm[(9 * (src5 + src6) - (src4 + src7) + 8) >> 4];
+ dst[6 * dstStride] = cm[(9 * (src6 + src7) - (src5 + src8) + 8) >> 4];
+ dst[7 * dstStride] = cm[(9 * (src7 + src8) - (src6 + src9) + 8) >> 4];
src++;
dst++;
}
@@ -1465,6 +1380,7 @@ static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int
static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
uint8_t half[64];
+
wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
}
@@ -1477,8 +1393,9 @@ static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
uint8_t half[64];
+
wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
- put_pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);
+ put_pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);
}
static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
@@ -1491,107 +1408,112 @@ static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
uint8_t halfH[88];
uint8_t halfV[64];
uint8_t halfHV[64];
- wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
- wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
+ wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
}
+
static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
uint8_t halfH[88];
uint8_t halfV[64];
uint8_t halfHV[64];
- wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
- wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
- wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+ wmv2_mspel8_v_lowpass(halfV, src + 1, 8, stride, 8);
+ wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
}
+
static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
uint8_t halfH[88];
- wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
- wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
-}
-
-static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
- int s, i;
-
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - pix2[0]);
- s += abs(pix1[1] - pix2[1]);
- s += abs(pix1[2] - pix2[2]);
- s += abs(pix1[3] - pix2[3]);
- s += abs(pix1[4] - pix2[4]);
- s += abs(pix1[5] - pix2[5]);
- s += abs(pix1[6] - pix2[6]);
- s += abs(pix1[7] - pix2[7]);
- s += abs(pix1[8] - pix2[8]);
- s += abs(pix1[9] - pix2[9]);
- s += abs(pix1[10] - pix2[10]);
- s += abs(pix1[11] - pix2[11]);
- s += abs(pix1[12] - pix2[12]);
- s += abs(pix1[13] - pix2[13]);
- s += abs(pix1[14] - pix2[14]);
- s += abs(pix1[15] - pix2[15]);
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+ wmv2_mspel8_v_lowpass(dst, halfH + 8, stride, 8, 8);
+}
+
+static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
+ int s = 0, i;
+
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - pix2[0]);
+ s += abs(pix1[1] - pix2[1]);
+ s += abs(pix1[2] - pix2[2]);
+ s += abs(pix1[3] - pix2[3]);
+ s += abs(pix1[4] - pix2[4]);
+ s += abs(pix1[5] - pix2[5]);
+ s += abs(pix1[6] - pix2[6]);
+ s += abs(pix1[7] - pix2[7]);
+ s += abs(pix1[8] - pix2[8]);
+ s += abs(pix1[9] - pix2[9]);
+ s += abs(pix1[10] - pix2[10]);
+ s += abs(pix1[11] - pix2[11]);
+ s += abs(pix1[12] - pix2[12]);
+ s += abs(pix1[13] - pix2[13]);
+ s += abs(pix1[14] - pix2[14]);
+ s += abs(pix1[15] - pix2[15]);
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
- int s, i;
-
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
- s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
- s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
- s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
- s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
- s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
- s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
- s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
- s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
- s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
- s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
- s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
- s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
- s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
- s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
- s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
+static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
+ int s = 0, i;
+
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
+ s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
+ s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
+ s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
+ s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
+ s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
+ s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
+ s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
+ s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
+ s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
+ s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
+ s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
+ s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
+ s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
+ s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
+ s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
uint8_t *pix3 = pix2 + line_size;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
- s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
- s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
- s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
- s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
- s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
- s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
- s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
- s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
- s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
- s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
- s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
- s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
- s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
- s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
- s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
+ s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
+ s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
+ s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
+ s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
+ s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
+ s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
+ s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
+ s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
+ s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
+ s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
+ s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
+ s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
+ s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
+ s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
+ s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
pix1 += line_size;
pix2 += line_size;
pix3 += line_size;
@@ -1599,29 +1521,29 @@ static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
return s;
}
-static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
uint8_t *pix3 = pix2 + line_size;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
- s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
- s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
- s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
- s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
- s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
- s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
- s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
- s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
- s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
- s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
- s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
- s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
- s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
- s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
- s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
+ s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
+ s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
+ s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
+ s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
+ s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
+ s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
+ s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
+ s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
+ s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
+ s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
+ s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
+ s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
+ s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
+ s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
+ s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
pix1 += line_size;
pix2 += line_size;
pix3 += line_size;
@@ -1629,61 +1551,61 @@ static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
return s;
}
-static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - pix2[0]);
- s += abs(pix1[1] - pix2[1]);
- s += abs(pix1[2] - pix2[2]);
- s += abs(pix1[3] - pix2[3]);
- s += abs(pix1[4] - pix2[4]);
- s += abs(pix1[5] - pix2[5]);
- s += abs(pix1[6] - pix2[6]);
- s += abs(pix1[7] - pix2[7]);
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - pix2[0]);
+ s += abs(pix1[1] - pix2[1]);
+ s += abs(pix1[2] - pix2[2]);
+ s += abs(pix1[3] - pix2[3]);
+ s += abs(pix1[4] - pix2[4]);
+ s += abs(pix1[5] - pix2[5]);
+ s += abs(pix1[6] - pix2[6]);
+ s += abs(pix1[7] - pix2[7]);
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
- s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
- s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
- s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
- s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
- s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
- s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
- s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
+ s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
+ s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
+ s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
+ s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
+ s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
+ s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
+ s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
pix1 += line_size;
pix2 += line_size;
}
return s;
}
-static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
uint8_t *pix3 = pix2 + line_size;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
- s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
- s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
- s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
- s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
- s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
- s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
- s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
+ s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
+ s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
+ s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
+ s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
+ s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
+ s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
+ s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
pix1 += line_size;
pix2 += line_size;
pix3 += line_size;
@@ -1691,21 +1613,21 @@ static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
return s;
}
-static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int s, i;
+ int s = 0, i;
uint8_t *pix3 = pix2 + line_size;
- s = 0;
- for(i=0;i<h;i++) {
- s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
- s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
- s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
- s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
- s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
- s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
- s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
- s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
+ for (i = 0; i < h; i++) {
+ s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
+ s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
+ s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
+ s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
+ s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
+ s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
+ s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
+ s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
pix1 += line_size;
pix2 += line_size;
pix3 += line_size;
@@ -1713,130 +1635,135 @@ static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
return s;
}
-static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
- MpegEncContext *c = v;
- int score1=0;
- int score2=0;
- int x,y;
-
- for(y=0; y<h; y++){
- for(x=0; x<16; x++){
- score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
- }
- if(y+1<h){
- for(x=0; x<15; x++){
- score2+= FFABS( s1[x ] - s1[x +stride]
- - s1[x+1] + s1[x+1+stride])
- -FFABS( s2[x ] - s2[x +stride]
- - s2[x+1] + s2[x+1+stride]);
- }
+static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
+{
+ int score1 = 0, score2 = 0, x, y;
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < 16; x++)
+ score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
+ if (y + 1 < h) {
+ for (x = 0; x < 15; x++)
+ score2 += FFABS(s1[x] - s1[x + stride] -
+ s1[x + 1] + s1[x + stride + 1]) -
+ FFABS(s2[x] - s2[x + stride] -
+ s2[x + 1] + s2[x + stride + 1]);
}
- s1+= stride;
- s2+= stride;
+ s1 += stride;
+ s2 += stride;
}
- if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
- else return score1 + FFABS(score2)*8;
+ if (c)
+ return score1 + FFABS(score2) * c->avctx->nsse_weight;
+ else
+ return score1 + FFABS(score2) * 8;
}
-static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
- MpegEncContext *c = v;
- int score1=0;
- int score2=0;
- int x,y;
-
- for(y=0; y<h; y++){
- for(x=0; x<8; x++){
- score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
- }
- if(y+1<h){
- for(x=0; x<7; x++){
- score2+= FFABS( s1[x ] - s1[x +stride]
- - s1[x+1] + s1[x+1+stride])
- -FFABS( s2[x ] - s2[x +stride]
- - s2[x+1] + s2[x+1+stride]);
- }
+static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
+{
+ int score1 = 0, score2 = 0, x, y;
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < 8; x++)
+ score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
+ if (y + 1 < h) {
+ for (x = 0; x < 7; x++)
+ score2 += FFABS(s1[x] - s1[x + stride] -
+ s1[x + 1] + s1[x + stride + 1]) -
+ FFABS(s2[x] - s2[x + stride] -
+ s2[x + 1] + s2[x + stride + 1]);
}
- s1+= stride;
- s2+= stride;
+ s1 += stride;
+ s2 += stride;
}
- if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
- else return score1 + FFABS(score2)*8;
+ if (c)
+ return score1 + FFABS(score2) * c->avctx->nsse_weight;
+ else
+ return score1 + FFABS(score2) * 8;
}
-static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
+static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
+ int16_t basis[64], int scale)
+{
int i;
- unsigned int sum=0;
+ unsigned int sum = 0;
- for(i=0; i<8*8; i++){
- int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT));
- int w= weight[i];
- b>>= RECON_SHIFT;
- av_assert2(-512<b && b<512);
+ for (i = 0; i < 8 * 8; i++) {
+ int b = rem[i] + ((basis[i] * scale +
+ (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
+ (BASIS_SHIFT - RECON_SHIFT));
+ int w = weight[i];
+ b >>= RECON_SHIFT;
+ av_assert2(-512 < b && b < 512);
- sum += (w*b)*(w*b)>>4;
+ sum += (w * b) * (w * b) >> 4;
}
- return sum>>2;
+ return sum >> 2;
}
-static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){
+static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
+{
int i;
- for(i=0; i<8*8; i++){
- rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
- }
+ for (i = 0; i < 8 * 8; i++)
+ rem[i] += (basis[i] * scale +
+ (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
+ (BASIS_SHIFT - RECON_SHIFT);
}
-static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
+static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
+ int stride, int h)
+{
return 0;
}
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
+void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type)
+{
int i;
- memset(cmp, 0, sizeof(void*)*6);
+ memset(cmp, 0, sizeof(void *) * 6);
- for(i=0; i<6; i++){
- switch(type&0xFF){
+ for (i = 0; i < 6; i++) {
+ switch (type & 0xFF) {
case FF_CMP_SAD:
- cmp[i]= c->sad[i];
+ cmp[i] = c->sad[i];
break;
case FF_CMP_SATD:
- cmp[i]= c->hadamard8_diff[i];
+ cmp[i] = c->hadamard8_diff[i];
break;
case FF_CMP_SSE:
- cmp[i]= c->sse[i];
+ cmp[i] = c->sse[i];
break;
case FF_CMP_DCT:
- cmp[i]= c->dct_sad[i];
+ cmp[i] = c->dct_sad[i];
break;
case FF_CMP_DCT264:
- cmp[i]= c->dct264_sad[i];
+ cmp[i] = c->dct264_sad[i];
break;
case FF_CMP_DCTMAX:
- cmp[i]= c->dct_max[i];
+ cmp[i] = c->dct_max[i];
break;
case FF_CMP_PSNR:
- cmp[i]= c->quant_psnr[i];
+ cmp[i] = c->quant_psnr[i];
break;
case FF_CMP_BIT:
- cmp[i]= c->bit[i];
+ cmp[i] = c->bit[i];
break;
case FF_CMP_RD:
- cmp[i]= c->rd[i];
+ cmp[i] = c->rd[i];
break;
case FF_CMP_VSAD:
- cmp[i]= c->vsad[i];
+ cmp[i] = c->vsad[i];
break;
case FF_CMP_VSSE:
- cmp[i]= c->vsse[i];
+ cmp[i] = c->vsse[i];
break;
case FF_CMP_ZERO:
- cmp[i]= zero_cmp;
+ cmp[i] = zero_cmp;
break;
case FF_CMP_NSSE:
- cmp[i]= c->nsse[i];
+ cmp[i] = c->nsse[i];
break;
#if CONFIG_DWT
case FF_CMP_W53:
@@ -1847,96 +1774,110 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
break;
#endif
default:
- av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
+ av_log(NULL, AV_LOG_ERROR,
+ "internal error in cmp function selection\n");
}
}
}
-static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
+static void add_bytes_c(uint8_t *dst, uint8_t *src, int w)
+{
long i;
- for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
- long a = *(long*)(src+i);
- long b = *(long*)(dst+i);
- *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
+
+ for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
+ long a = *(long *) (src + i);
+ long b = *(long *) (dst + i);
+ *(long *) (dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
}
- for(; i<w; i++)
- dst[i+0] += src[i+0];
+ for (; i < w; i++)
+ dst[i + 0] += src[i + 0];
}
-static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w){
+static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w)
+{
long i;
+
#if !HAVE_FAST_UNALIGNED
- if((long)src2 & (sizeof(long)-1)){
- for(i=0; i+7<w; i+=8){
- dst[i+0] = src1[i+0]-src2[i+0];
- dst[i+1] = src1[i+1]-src2[i+1];
- dst[i+2] = src1[i+2]-src2[i+2];
- dst[i+3] = src1[i+3]-src2[i+3];
- dst[i+4] = src1[i+4]-src2[i+4];
- dst[i+5] = src1[i+5]-src2[i+5];
- dst[i+6] = src1[i+6]-src2[i+6];
- dst[i+7] = src1[i+7]-src2[i+7];
+ if ((long) src2 & (sizeof(long) - 1)) {
+ for (i = 0; i + 7 < w; i += 8) {
+ dst[i + 0] = src1[i + 0] - src2[i + 0];
+ dst[i + 1] = src1[i + 1] - src2[i + 1];
+ dst[i + 2] = src1[i + 2] - src2[i + 2];
+ dst[i + 3] = src1[i + 3] - src2[i + 3];
+ dst[i + 4] = src1[i + 4] - src2[i + 4];
+ dst[i + 5] = src1[i + 5] - src2[i + 5];
+ dst[i + 6] = src1[i + 6] - src2[i + 6];
+ dst[i + 7] = src1[i + 7] - src2[i + 7];
}
- }else
+ } else
#endif
- for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
- long a = *(long*)(src1+i);
- long b = *(long*)(src2+i);
- *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
+ for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
+ long a = *(long *) (src1 + i);
+ long b = *(long *) (src2 + i);
+ *(long *) (dst + i) = ((a | pb_80) - (b & pb_7f)) ^
+ ((a ^ b ^ pb_80) & pb_80);
}
- for(; i<w; i++)
- dst[i+0] = src1[i+0]-src2[i+0];
+ for (; i < w; i++)
+ dst[i + 0] = src1[i + 0] - src2[i + 0];
}
-static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *diff, int w, int *left, int *left_top){
+static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1,
+ const uint8_t *diff, int w,
+ int *left, int *left_top)
+{
int i;
uint8_t l, lt;
- l= *left;
- lt= *left_top;
+ l = *left;
+ lt = *left_top;
- for(i=0; i<w; i++){
- l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
- lt= src1[i];
- dst[i]= l;
+ for (i = 0; i < w; i++) {
+ l = mid_pred(l, src1[i], (l + src1[i] - lt) & 0xFF) + diff[i];
+ lt = src1[i];
+ dst[i] = l;
}
- *left= l;
- *left_top= lt;
+ *left = l;
+ *left_top = lt;
}
-static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top){
+static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1,
+ const uint8_t *src2, int w,
+ int *left, int *left_top)
+{
int i;
uint8_t l, lt;
- l= *left;
- lt= *left_top;
+ l = *left;
+ lt = *left_top;
- for(i=0; i<w; i++){
- const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
- lt= src1[i];
- l= src2[i];
- dst[i]= l - pred;
+ for (i = 0; i < w; i++) {
+ const int pred = mid_pred(l, src1[i], (l + src1[i] - lt) & 0xFF);
+ lt = src1[i];
+ l = src2[i];
+ dst[i] = l - pred;
}
- *left= l;
- *left_top= lt;
+ *left = l;
+ *left_top = lt;
}
-static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, int acc){
+static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src,
+ int w, int acc)
+{
int i;
- for(i=0; i<w-1; i++){
- acc+= src[i];
- dst[i]= acc;
+ for (i = 0; i < w - 1; i++) {
+ acc += src[i];
+ dst[i] = acc;
i++;
- acc+= src[i];
- dst[i]= acc;
+ acc += src[i];
+ dst[i] = acc;
}
- for(; i<w; i++){
- acc+= src[i];
- dst[i]= acc;
+ for (; i < w; i++) {
+ acc += src[i];
+ dst[i] = acc;
}
return acc;
@@ -1953,149 +1894,159 @@ static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, i
#define R 2
#define A 3
#endif
-static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha){
- int i;
- int r,g,b,a;
- r= *red;
- g= *green;
- b= *blue;
- a= *alpha;
+static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src,
+ int w, int *red, int *green,
+ int *blue, int *alpha)
+{
+ int i, r = *red, g = *green, b = *blue, a = *alpha;
- for(i=0; i<w; i++){
- b+= src[4*i+B];
- g+= src[4*i+G];
- r+= src[4*i+R];
- a+= src[4*i+A];
+ for (i = 0; i < w; i++) {
+ b += src[4 * i + B];
+ g += src[4 * i + G];
+ r += src[4 * i + R];
+ a += src[4 * i + A];
- dst[4*i+B]= b;
- dst[4*i+G]= g;
- dst[4*i+R]= r;
- dst[4*i+A]= a;
+ dst[4 * i + B] = b;
+ dst[4 * i + G] = g;
+ dst[4 * i + R] = r;
+ dst[4 * i + A] = a;
}
- *red= r;
- *green= g;
- *blue= b;
- *alpha= a;
+ *red = r;
+ *green = g;
+ *blue = b;
+ *alpha = a;
}
#undef B
#undef G
#undef R
#undef A
-#define BUTTERFLY2(o1,o2,i1,i2) \
-o1= (i1)+(i2);\
-o2= (i1)-(i2);
-
-#define BUTTERFLY1(x,y) \
-{\
- int a,b;\
- a= x;\
- b= y;\
- x= a+b;\
- y= a-b;\
-}
+#define BUTTERFLY2(o1, o2, i1, i2) \
+ o1 = (i1) + (i2); \
+ o2 = (i1) - (i2);
-#define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y)))
-
-static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
- int i;
- int temp[64];
- int sum=0;
+#define BUTTERFLY1(x, y) \
+ { \
+ int a, b; \
+ a = x; \
+ b = y; \
+ x = a + b; \
+ y = a - b; \
+ }
- av_assert2(h==8);
+#define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
- for(i=0; i<8; i++){
- //FIXME try pointer walks
- BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]);
- BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]);
- BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]);
- BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]);
+static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
+ uint8_t *src, int stride, int h)
+{
+ int i, temp[64], sum = 0;
- BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
- BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
- BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
- BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
+ av_assert2(h == 8);
- BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
- BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
- BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
- BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
+ for (i = 0; i < 8; i++) {
+ // FIXME: try pointer walks
+ BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
+ src[stride * i + 0] - dst[stride * i + 0],
+ src[stride * i + 1] - dst[stride * i + 1]);
+ BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
+ src[stride * i + 2] - dst[stride * i + 2],
+ src[stride * i + 3] - dst[stride * i + 3]);
+ BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
+ src[stride * i + 4] - dst[stride * i + 4],
+ src[stride * i + 5] - dst[stride * i + 5]);
+ BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
+ src[stride * i + 6] - dst[stride * i + 6],
+ src[stride * i + 7] - dst[stride * i + 7]);
+
+ BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
+ BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
+ BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
+ BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
+
+ BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
+ BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
+ BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
+ BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
}
- for(i=0; i<8; i++){
- BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
- BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
- BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
- BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
+ for (i = 0; i < 8; i++) {
+ BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
+ BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
+ BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
+ BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
- BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
- BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
- BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
- BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
+ BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
+ BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
+ BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
+ BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
- sum +=
- BUTTERFLYA(temp[8*0+i], temp[8*4+i])
- +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
- +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
- +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
+ sum += BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i]) +
+ BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i]) +
+ BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i]) +
+ BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
}
return sum;
}
-static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
- int i;
- int temp[64];
- int sum=0;
-
- av_assert2(h==8);
-
- for(i=0; i<8; i++){
- //FIXME try pointer walks
- BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
- BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
- BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
- BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
+static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
+ uint8_t *dummy, int stride, int h)
+{
+ int i, temp[64], sum = 0;
- BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
- BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
- BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
- BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
+ av_assert2(h == 8);
- BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
- BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
- BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
- BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
+ for (i = 0; i < 8; i++) {
+ // FIXME: try pointer walks
+ BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
+ src[stride * i + 0], src[stride * i + 1]);
+ BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
+ src[stride * i + 2], src[stride * i + 3]);
+ BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
+ src[stride * i + 4], src[stride * i + 5]);
+ BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
+ src[stride * i + 6], src[stride * i + 7]);
+
+ BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
+ BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
+ BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
+ BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
+
+ BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
+ BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
+ BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
+ BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
}
- for(i=0; i<8; i++){
- BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
- BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
- BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
- BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
+ for (i = 0; i < 8; i++) {
+ BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
+ BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
+ BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
+ BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
- BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
- BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
- BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
- BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
+ BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
+ BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
+ BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
+ BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
sum +=
- BUTTERFLYA(temp[8*0+i], temp[8*4+i])
- +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
- +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
- +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
+ BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i])
+ + BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i])
+ + BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i])
+ + BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
}
- sum -= FFABS(temp[8*0] + temp[8*4]); // -mean
+ sum -= FFABS(temp[8 * 0] + temp[8 * 4]); // -mean
return sum;
}
-static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
+static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
+ uint8_t *src2, int stride, int h)
+{
LOCAL_ALIGNED_16(int16_t, temp, [64]);
- av_assert2(h==8);
+ av_assert2(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp);
@@ -2103,161 +2054,166 @@ static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
}
#if CONFIG_GPL
-#define DCT8_1D {\
- const int s07 = SRC(0) + SRC(7);\
- const int s16 = SRC(1) + SRC(6);\
- const int s25 = SRC(2) + SRC(5);\
- const int s34 = SRC(3) + SRC(4);\
- const int a0 = s07 + s34;\
- const int a1 = s16 + s25;\
- const int a2 = s07 - s34;\
- const int a3 = s16 - s25;\
- const int d07 = SRC(0) - SRC(7);\
- const int d16 = SRC(1) - SRC(6);\
- const int d25 = SRC(2) - SRC(5);\
- const int d34 = SRC(3) - SRC(4);\
- const int a4 = d16 + d25 + (d07 + (d07>>1));\
- const int a5 = d07 - d34 - (d25 + (d25>>1));\
- const int a6 = d07 + d34 - (d16 + (d16>>1));\
- const int a7 = d16 - d25 + (d34 + (d34>>1));\
- DST(0, a0 + a1 ) ;\
- DST(1, a4 + (a7>>2)) ;\
- DST(2, a2 + (a3>>1)) ;\
- DST(3, a5 + (a6>>2)) ;\
- DST(4, a0 - a1 ) ;\
- DST(5, a6 - (a5>>2)) ;\
- DST(6, (a2>>1) - a3 ) ;\
- DST(7, (a4>>2) - a7 ) ;\
-}
-
-static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
+#define DCT8_1D \
+ { \
+ const int s07 = SRC(0) + SRC(7); \
+ const int s16 = SRC(1) + SRC(6); \
+ const int s25 = SRC(2) + SRC(5); \
+ const int s34 = SRC(3) + SRC(4); \
+ const int a0 = s07 + s34; \
+ const int a1 = s16 + s25; \
+ const int a2 = s07 - s34; \
+ const int a3 = s16 - s25; \
+ const int d07 = SRC(0) - SRC(7); \
+ const int d16 = SRC(1) - SRC(6); \
+ const int d25 = SRC(2) - SRC(5); \
+ const int d34 = SRC(3) - SRC(4); \
+ const int a4 = d16 + d25 + (d07 + (d07 >> 1)); \
+ const int a5 = d07 - d34 - (d25 + (d25 >> 1)); \
+ const int a6 = d07 + d34 - (d16 + (d16 >> 1)); \
+ const int a7 = d16 - d25 + (d34 + (d34 >> 1)); \
+ DST(0, a0 + a1); \
+ DST(1, a4 + (a7 >> 2)); \
+ DST(2, a2 + (a3 >> 1)); \
+ DST(3, a5 + (a6 >> 2)); \
+ DST(4, a0 - a1); \
+ DST(5, a6 - (a5 >> 2)); \
+ DST(6, (a2 >> 1) - a3); \
+ DST(7, (a4 >> 2) - a7); \
+ }
+
+static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
+ uint8_t *src2, int stride, int h)
+{
int16_t dct[8][8];
- int i;
- int sum=0;
+ int i, sum = 0;
s->dsp.diff_pixels(dct[0], src1, src2, stride);
#define SRC(x) dct[i][x]
-#define DST(x,v) dct[i][x]= v
- for( i = 0; i < 8; i++ )
+#define DST(x, v) dct[i][x] = v
+ for (i = 0; i < 8; i++)
DCT8_1D
#undef SRC
#undef DST
#define SRC(x) dct[x][i]
-#define DST(x,v) sum += FFABS(v)
- for( i = 0; i < 8; i++ )
- DCT8_1D
+#define DST(x, v) sum += FFABS(v)
+ for (i = 0; i < 8; i++)
+ DCT8_1D
#undef SRC
#undef DST
- return sum;
+ return sum;
}
#endif
-static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
+static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
+ uint8_t *src2, int stride, int h)
+{
LOCAL_ALIGNED_16(int16_t, temp, [64]);
- int sum=0, i;
+ int sum = 0, i;
- av_assert2(h==8);
+ av_assert2(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride);
s->dsp.fdct(temp);
- for(i=0; i<64; i++)
- sum= FFMAX(sum, FFABS(temp[i]));
+ for (i = 0; i < 64; i++)
+ sum = FFMAX(sum, FFABS(temp[i]));
return sum;
}
-static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
- LOCAL_ALIGNED_16(int16_t, temp, [64*2]);
- int16_t * const bak = temp+64;
- int sum=0, i;
+static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
+ uint8_t *src2, int stride, int h)
+{
+ LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
+ int16_t *const bak = temp + 64;
+ int sum = 0, i;
- av_assert2(h==8);
- s->mb_intra=0;
+ av_assert2(h == 8);
+ s->mb_intra = 0;
s->dsp.diff_pixels(temp, src1, src2, stride);
- memcpy(bak, temp, 64*sizeof(int16_t));
+ memcpy(bak, temp, 64 * sizeof(int16_t));
- s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+ s->block_last_index[0 /* FIXME */] =
+ s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
s->dct_unquantize_inter(s, temp, 0, s->qscale);
- ff_simple_idct_8(temp); //FIXME
+ ff_simple_idct_8(temp); // FIXME
- for(i=0; i<64; i++)
- sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
+ for (i = 0; i < 64; i++)
+ sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
return sum;
}
-static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
- const uint8_t *scantable= s->intra_scantable.permutated;
+static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
+ int stride, int h)
+{
+ const uint8_t *scantable = s->intra_scantable.permutated;
LOCAL_ALIGNED_16(int16_t, temp, [64]);
LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
int i, last, run, bits, level, distortion, start_i;
- const int esc_length= s->ac_esc_length;
- uint8_t * length;
- uint8_t * last_length;
+ const int esc_length = s->ac_esc_length;
+ uint8_t *length, *last_length;
- av_assert2(h==8);
+ av_assert2(h == 8);
copy_block8(lsrc1, src1, 8, stride, 8);
copy_block8(lsrc2, src2, 8, stride, 8);
s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
- s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+ s->block_last_index[0 /* FIXME */] =
+ last =
+ s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
- bits=0;
+ bits = 0;
if (s->mb_intra) {
- start_i = 1;
- length = s->intra_ac_vlc_length;
- last_length= s->intra_ac_vlc_last_length;
- bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
+ start_i = 1;
+ length = s->intra_ac_vlc_length;
+ last_length = s->intra_ac_vlc_last_length;
+ bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
} else {
- start_i = 0;
- length = s->inter_ac_vlc_length;
- last_length= s->inter_ac_vlc_last_length;
- }
-
- if(last>=start_i){
- run=0;
- for(i=start_i; i<last; i++){
- int j= scantable[i];
- level= temp[j];
-
- if(level){
- level+=64;
- if((level&(~127)) == 0){
- bits+= length[UNI_AC_ENC_INDEX(run, level)];
- }else
- bits+= esc_length;
- run=0;
- }else
+ start_i = 0;
+ length = s->inter_ac_vlc_length;
+ last_length = s->inter_ac_vlc_last_length;
+ }
+
+ if (last >= start_i) {
+ run = 0;
+ for (i = start_i; i < last; i++) {
+ int j = scantable[i];
+ level = temp[j];
+
+ if (level) {
+ level += 64;
+ if ((level & (~127)) == 0)
+ bits += length[UNI_AC_ENC_INDEX(run, level)];
+ else
+ bits += esc_length;
+ run = 0;
+ } else
run++;
}
- i= scantable[last];
+ i = scantable[last];
- level= temp[i] + 64;
+ level = temp[i] + 64;
av_assert2(level - 64);
- if((level&(~127)) == 0){
- bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
- }else
- bits+= esc_length;
-
+ if ((level & (~127)) == 0) {
+ bits += last_length[UNI_AC_ENC_INDEX(run, level)];
+ } else
+ bits += esc_length;
}
- if(last>=0){
- if(s->mb_intra)
+ if (last >= 0) {
+ if (s->mb_intra)
s->dct_unquantize_intra(s, temp, 0, s->qscale);
else
s->dct_unquantize_inter(s, temp, 0, s->qscale);
@@ -2265,158 +2221,172 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int
s->dsp.idct_add(lsrc2, 8, temp);
- distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
+ distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
- return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
+ return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
}
-static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
- MpegEncContext * const s= (MpegEncContext *)c;
- const uint8_t *scantable= s->intra_scantable.permutated;
+static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
+ int stride, int h)
+{
+ const uint8_t *scantable = s->intra_scantable.permutated;
LOCAL_ALIGNED_16(int16_t, temp, [64]);
int i, last, run, bits, level, start_i;
- const int esc_length= s->ac_esc_length;
- uint8_t * length;
- uint8_t * last_length;
+ const int esc_length = s->ac_esc_length;
+ uint8_t *length, *last_length;
- av_assert2(h==8);
+ av_assert2(h == 8);
s->dsp.diff_pixels(temp, src1, src2, stride);
- s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+ s->block_last_index[0 /* FIXME */] =
+ last =
+ s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
- bits=0;
+ bits = 0;
if (s->mb_intra) {
- start_i = 1;
- length = s->intra_ac_vlc_length;
- last_length= s->intra_ac_vlc_last_length;
- bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
+ start_i = 1;
+ length = s->intra_ac_vlc_length;
+ last_length = s->intra_ac_vlc_last_length;
+ bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
} else {
- start_i = 0;
- length = s->inter_ac_vlc_length;
- last_length= s->inter_ac_vlc_last_length;
- }
-
- if(last>=start_i){
- run=0;
- for(i=start_i; i<last; i++){
- int j= scantable[i];
- level= temp[j];
-
- if(level){
- level+=64;
- if((level&(~127)) == 0){
- bits+= length[UNI_AC_ENC_INDEX(run, level)];
- }else
- bits+= esc_length;
- run=0;
- }else
+ start_i = 0;
+ length = s->inter_ac_vlc_length;
+ last_length = s->inter_ac_vlc_last_length;
+ }
+
+ if (last >= start_i) {
+ run = 0;
+ for (i = start_i; i < last; i++) {
+ int j = scantable[i];
+ level = temp[j];
+
+ if (level) {
+ level += 64;
+ if ((level & (~127)) == 0)
+ bits += length[UNI_AC_ENC_INDEX(run, level)];
+ else
+ bits += esc_length;
+ run = 0;
+ } else
run++;
}
- i= scantable[last];
+ i = scantable[last];
- level= temp[i] + 64;
+ level = temp[i] + 64;
av_assert2(level - 64);
- if((level&(~127)) == 0){
- bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
- }else
- bits+= esc_length;
+ if ((level & (~127)) == 0)
+ bits += last_length[UNI_AC_ENC_INDEX(run, level)];
+ else
+ bits += esc_length;
}
return bits;
}
-#define VSAD_INTRA(size) \
-static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
- int score=0; \
- int x,y; \
- \
- for(y=1; y<h; y++){ \
- for(x=0; x<size; x+=4){ \
- score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) \
- +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); \
- } \
- s+= stride; \
- } \
- \
- return score; \
+#define VSAD_INTRA(size) \
+static int vsad_intra ## size ## _c(MpegEncContext *c, \
+ uint8_t *s, uint8_t *dummy, \
+ int stride, int h) \
+{ \
+ int score = 0, x, y; \
+ \
+ for (y = 1; y < h; y++) { \
+ for (x = 0; x < size; x += 4) { \
+ score += FFABS(s[x] - s[x + stride]) + \
+ FFABS(s[x + 1] - s[x + stride + 1]) + \
+ FFABS(s[x + 2] - s[x + 2 + stride]) + \
+ FFABS(s[x + 3] - s[x + 3 + stride]); \
+ } \
+ s += stride; \
+ } \
+ \
+ return score; \
}
VSAD_INTRA(8)
VSAD_INTRA(16)
-static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
- int score=0;
- int x,y;
+static int vsad16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
+ int stride, int h)
+{
+ int score = 0, x, y;
- for(y=1; y<h; y++){
- for(x=0; x<16; x++){
- score+= FFABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
- }
- s1+= stride;
- s2+= stride;
+ for (y = 1; y < h; y++) {
+ for (x = 0; x < 16; x++)
+ score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
+ s1 += stride;
+ s2 += stride;
}
return score;
}
-#define SQ(a) ((a)*(a))
-#define VSSE_INTRA(size) \
-static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
- int score=0; \
- int x,y; \
- \
- for(y=1; y<h; y++){ \
- for(x=0; x<size; x+=4){ \
- score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) \
- +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); \
- } \
- s+= stride; \
- } \
- \
- return score; \
+#define SQ(a) ((a) * (a))
+#define VSSE_INTRA(size) \
+static int vsse_intra ## size ## _c(MpegEncContext *c, \
+ uint8_t *s, uint8_t *dummy, \
+ int stride, int h) \
+{ \
+ int score = 0, x, y; \
+ \
+ for (y = 1; y < h; y++) { \
+ for (x = 0; x < size; x += 4) { \
+ score += SQ(s[x] - s[x + stride]) + \
+ SQ(s[x + 1] - s[x + stride + 1]) + \
+ SQ(s[x + 2] - s[x + stride + 2]) + \
+ SQ(s[x + 3] - s[x + stride + 3]); \
+ } \
+ s += stride; \
+ } \
+ \
+ return score; \
}
VSSE_INTRA(8)
VSSE_INTRA(16)
-static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
- int score=0;
- int x,y;
+static int vsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
+ int stride, int h)
+{
+ int score = 0, x, y;
- for(y=1; y<h; y++){
- for(x=0; x<16; x++){
- score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
- }
- s1+= stride;
- s2+= stride;
+ for (y = 1; y < h; y++) {
+ for (x = 0; x < 16; x++)
+ score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
+ s1 += stride;
+ s2 += stride;
}
return score;
}
static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
- int size){
- int score=0;
- int i;
- for(i=0; i<size; i++)
- score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
+ int size)
+{
+ int score = 0, i;
+
+ for (i = 0; i < size; i++)
+ score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
return score;
}
-#define WRAPPER8_16_SQ(name8, name16)\
-static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
- int score=0;\
- score +=name8(s, dst , src , stride, 8);\
- score +=name8(s, dst+8 , src+8 , stride, 8);\
- if(h==16){\
- dst += 8*stride;\
- src += 8*stride;\
- score +=name8(s, dst , src , stride, 8);\
- score +=name8(s, dst+8 , src+8 , stride, 8);\
- }\
- return score;\
+#define WRAPPER8_16_SQ(name8, name16) \
+static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \
+ int stride, int h) \
+{ \
+ int score = 0; \
+ \
+ score += name8(s, dst, src, stride, 8); \
+ score += name8(s, dst + 8, src + 8, stride, 8); \
+ if (h == 16) { \
+ dst += 8 * stride; \
+ src += 8 * stride; \
+ score += name8(s, dst, src, stride, 8); \
+ score += name8(s, dst + 8, src + 8, stride, 8); \
+ } \
+ return score; \
}
WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
@@ -2431,22 +2401,27 @@ WRAPPER8_16_SQ(rd8x8_c, rd16_c)
WRAPPER8_16_SQ(bit8x8_c, bit16_c)
static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
- uint32_t maxi, uint32_t maxisign)
+ uint32_t maxi, uint32_t maxisign)
{
-
- if(a > mini) return mini;
- else if((a^(1U<<31)) > maxisign) return maxi;
- else return a;
+ if (a > mini)
+ return mini;
+ else if ((a ^ (1U << 31)) > maxisign)
+ return maxi;
+ else
+ return a;
}
-static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *min, float *max, int len){
+static void vector_clipf_c_opposite_sign(float *dst, const float *src,
+ float *min, float *max, int len)
+{
int i;
- uint32_t mini = *(uint32_t*)min;
- uint32_t maxi = *(uint32_t*)max;
- uint32_t maxisign = maxi ^ (1U<<31);
- uint32_t *dsti = (uint32_t*)dst;
- const uint32_t *srci = (const uint32_t*)src;
- for(i=0; i<len; i+=8) {
+ uint32_t mini = *(uint32_t *) min;
+ uint32_t maxi = *(uint32_t *) max;
+ uint32_t maxisign = maxi ^ (1U << 31);
+ uint32_t *dsti = (uint32_t *) dst;
+ const uint32_t *srci = (const uint32_t *) src;
+
+ for (i = 0; i < len; i += 8) {
dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
@@ -2457,13 +2432,17 @@ static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *mi
dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
}
}
-static void vector_clipf_c(float *dst, const float *src, float min, float max, int len){
+
+static void vector_clipf_c(float *dst, const float *src,
+ float min, float max, int len)
+{
int i;
- if(min < 0 && max > 0) {
+
+ if (min < 0 && max > 0) {
vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
} else {
- for(i=0; i < len; i+=8) {
- dst[i ] = av_clipf(src[i ], min, max);
+ for (i = 0; i < len; i += 8) {
+ dst[i] = av_clipf(src[i], min, max);
dst[i + 1] = av_clipf(src[i + 1], min, max);
dst[i + 2] = av_clipf(src[i + 2], min, max);
dst[i + 3] = av_clipf(src[i + 3], min, max);
@@ -2475,19 +2454,23 @@ static void vector_clipf_c(float *dst, const float *src, float min, float max, i
}
}
-static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order)
+static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
+ int order)
{
int res = 0;
while (order--)
- res += *v1++ * *v2++;
+ res += *v1++ **v2++;
return res;
}
-static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
+static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
+ const int16_t *v3,
+ int order, int mul)
{
int res = 0;
+
while (order--) {
res += *v1 * *v2++;
*v1++ += mul * *v3++;
@@ -2507,18 +2490,19 @@ static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
*dst++ = av_clip(*src++, min, max);
*dst++ = av_clip(*src++, min, max);
*dst++ = av_clip(*src++, min, max);
- len -= 8;
+ len -= 8;
} while (len > 0);
}
static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
{
- ff_j_rev_dct (block);
+ ff_j_rev_dct(block);
put_pixels_clamped_c(block, dest, line_size);
}
+
static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
{
- ff_j_rev_dct (block);
+ ff_j_rev_dct(block);
add_pixels_clamped_c(block, dest, line_size);
}
@@ -2553,22 +2537,60 @@ static void ff_jref_idct1_add(uint8_t *dest, int line_size, int16_t *block)
dest[0] = av_clip_uint8(dest[0] + ((block[0] + 4)>>3));
}
+/* draw the edges of width 'w' of an image of size width, height */
+// FIXME: Check that this is OK for MPEG-4 interlaced.
+static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
+ int w, int h, int sides)
+{
+ uint8_t *ptr = buf, *last_line;
+ int i;
+
+ /* left and right */
+ for (i = 0; i < height; i++) {
+ memset(ptr - w, ptr[0], w);
+ memset(ptr + width, ptr[width - 1], w);
+ ptr += wrap;
+ }
+
+ /* top and bottom + corners */
+ buf -= w;
+ last_line = buf + (height - 1) * wrap;
+ if (sides & EDGE_TOP)
+ for (i = 0; i < h; i++)
+ // top
+ memcpy(buf - (i + 1) * wrap, buf, width + w + w);
+ if (sides & EDGE_BOTTOM)
+ for (i = 0; i < h; i++)
+ // bottom
+ memcpy(last_line + (i + 1) * wrap, last_line, width + w + w);
+}
+
+static void clear_block_8_c(int16_t *block)
+{
+ memset(block, 0, sizeof(int16_t) * 64);
+}
+
+static void clear_blocks_8_c(int16_t *blocks)
+{
+ memset(blocks, 0, sizeof(int16_t) * 6 * 64);
+}
+
/* init static data */
av_cold void ff_dsputil_static_init(void)
{
int i;
- for(i=0;i<512;i++) {
- ff_squareTbl[i] = (i - 256) * (i - 256);
- }
+ for (i = 0; i < 512; i++)
+ ff_square_tab[i] = (i - 256) * (i - 256);
}
-int ff_check_alignment(void){
- static int did_fail=0;
+int ff_check_alignment(void)
+{
+ static int did_fail = 0;
LOCAL_ALIGNED_16(int, aligned, [4]);
- if((intptr_t)aligned & 15){
- if(!did_fail){
+ if ((intptr_t)aligned & 15) {
+ if (!did_fail) {
#if HAVE_MMX || HAVE_ALTIVEC
av_log(NULL, AV_LOG_ERROR,
"Compiler did not align stack variables. Libavcodec has been miscompiled\n"
@@ -2583,8 +2605,10 @@ int ff_check_alignment(void){
return 0;
}
-av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
{
+ const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
+
ff_check_alignment();
#if CONFIG_ENCODERS
@@ -2592,37 +2616,35 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->fdct = ff_jpeg_fdct_islow_10;
c->fdct248 = ff_fdct248_islow_10;
} else {
- if(avctx->dct_algo==FF_DCT_FASTINT) {
+ if (avctx->dct_algo == FF_DCT_FASTINT) {
c->fdct = ff_fdct_ifast;
c->fdct248 = ff_fdct_ifast248;
- }
- else if(avctx->dct_algo==FF_DCT_FAAN) {
+ } else if (avctx->dct_algo == FF_DCT_FAAN) {
c->fdct = ff_faandct;
c->fdct248 = ff_faandct248;
- }
- else {
- c->fdct = ff_jpeg_fdct_islow_8; //slow/accurate/default
+ } else {
+ c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
c->fdct248 = ff_fdct248_islow_8;
}
}
-#endif //CONFIG_ENCODERS
-
- if(avctx->lowres==1){
- c->idct_put= ff_jref_idct4_put;
- c->idct_add= ff_jref_idct4_add;
- c->idct = ff_j_rev_dct4;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }else if(avctx->lowres==2){
- c->idct_put= ff_jref_idct2_put;
- c->idct_add= ff_jref_idct2_add;
- c->idct = ff_j_rev_dct2;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }else if(avctx->lowres==3){
- c->idct_put= ff_jref_idct1_put;
- c->idct_add= ff_jref_idct1_add;
- c->idct = ff_j_rev_dct1;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }else{
+#endif /* CONFIG_ENCODERS */
+
+ if (avctx->lowres==1) {
+ c->idct_put = ff_jref_idct4_put;
+ c->idct_add = ff_jref_idct4_add;
+ c->idct = ff_j_rev_dct4;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else if (avctx->lowres==2) {
+ c->idct_put = ff_jref_idct2_put;
+ c->idct_add = ff_jref_idct2_add;
+ c->idct = ff_j_rev_dct2;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else if (avctx->lowres==3) {
+ c->idct_put = ff_jref_idct1_put;
+ c->idct_add = ff_jref_idct1_add;
+ c->idct = ff_j_rev_dct1;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else {
if (avctx->bits_per_raw_sample == 10) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
@@ -2634,33 +2656,37 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct = ff_simple_idct_12;
c->idct_permutation_type = FF_NO_IDCT_PERM;
} else {
- if(avctx->idct_algo==FF_IDCT_INT){
- c->idct_put= jref_idct_put;
- c->idct_add= jref_idct_add;
- c->idct = ff_j_rev_dct;
- c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
- }else if(avctx->idct_algo==FF_IDCT_FAAN){
- c->idct_put= ff_faanidct_put;
- c->idct_add= ff_faanidct_add;
- c->idct = ff_faanidct;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }else{ //accurate/default
- c->idct_put = ff_simple_idct_put_8;
- c->idct_add = ff_simple_idct_add_8;
- c->idct = ff_simple_idct_8;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
+ if (avctx->idct_algo == FF_IDCT_INT) {
+ c->idct_put = jref_idct_put;
+ c->idct_add = jref_idct_add;
+ c->idct = ff_j_rev_dct;
+ c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+ } else if (avctx->idct_algo == FF_IDCT_FAAN) {
+ c->idct_put = ff_faanidct_put;
+ c->idct_add = ff_faanidct_add;
+ c->idct = ff_faanidct;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else { // accurate/default
+ c->idct_put = ff_simple_idct_put_8;
+ c->idct_add = ff_simple_idct_add_8;
+ c->idct = ff_simple_idct_8;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
}
}
}
c->diff_pixels = diff_pixels_c;
- c->put_pixels_clamped = put_pixels_clamped_c;
+
+ c->put_pixels_clamped = put_pixels_clamped_c;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
- c->add_pixels_clamped = add_pixels_clamped_c;
+ c->add_pixels_clamped = add_pixels_clamped_c;
+
c->sum_abs_dctelem = sum_abs_dctelem_c;
+
c->gmc1 = gmc1_c;
- c->gmc = ff_gmc_c;
- c->pix_sum = pix_sum_c;
+ c->gmc = ff_gmc_c;
+
+ c->pix_sum = pix_sum_c;
c->pix_norm1 = pix_norm1_c;
c->fill_block_tab[0] = fill_block16_c;
@@ -2676,37 +2702,17 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->pix_abs[1][2] = pix_abs8_y2_c;
c->pix_abs[1][3] = pix_abs8_xy2_c;
- c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
- c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
- c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
- c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
- c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
- c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
- c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
- c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
- c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
-
- c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
- c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
- c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
- c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
- c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
- c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
- c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
- c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
- c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
-
-#define dspfunc(PFX, IDX, NUM) \
- c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
- c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
- c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
- c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
- c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
- c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
- c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
- c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
- c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
- c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
+#define dspfunc(PFX, IDX, NUM) \
+ c->PFX ## _pixels_tab[IDX][0] = PFX ## NUM ## _mc00_c; \
+ c->PFX ## _pixels_tab[IDX][1] = PFX ## NUM ## _mc10_c; \
+ c->PFX ## _pixels_tab[IDX][2] = PFX ## NUM ## _mc20_c; \
+ c->PFX ## _pixels_tab[IDX][3] = PFX ## NUM ## _mc30_c; \
+ c->PFX ## _pixels_tab[IDX][4] = PFX ## NUM ## _mc01_c; \
+ c->PFX ## _pixels_tab[IDX][5] = PFX ## NUM ## _mc11_c; \
+ c->PFX ## _pixels_tab[IDX][6] = PFX ## NUM ## _mc21_c; \
+ c->PFX ## _pixels_tab[IDX][7] = PFX ## NUM ## _mc31_c; \
+ c->PFX ## _pixels_tab[IDX][8] = PFX ## NUM ## _mc02_c; \
+ c->PFX ## _pixels_tab[IDX][9] = PFX ## NUM ## _mc12_c; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
@@ -2715,108 +2721,101 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
dspfunc(put_qpel, 0, 16);
- dspfunc(put_no_rnd_qpel, 0, 16);
-
- dspfunc(avg_qpel, 0, 16);
- /* dspfunc(avg_no_rnd_qpel, 0, 16); */
-
dspfunc(put_qpel, 1, 8);
+
+ dspfunc(put_no_rnd_qpel, 0, 16);
dspfunc(put_no_rnd_qpel, 1, 8);
+ dspfunc(avg_qpel, 0, 16);
dspfunc(avg_qpel, 1, 8);
- /* dspfunc(avg_no_rnd_qpel, 1, 8); */
#undef dspfunc
- c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
- c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
- c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
- c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
- c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
- c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
- c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
- c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
+ c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
+ c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
+ c->put_mspel_pixels_tab[2] = put_mspel8_mc20_c;
+ c->put_mspel_pixels_tab[3] = put_mspel8_mc30_c;
+ c->put_mspel_pixels_tab[4] = put_mspel8_mc02_c;
+ c->put_mspel_pixels_tab[5] = put_mspel8_mc12_c;
+ c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
+ c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
-#define SET_CMP_FUNC(name) \
- c->name[0]= name ## 16_c;\
- c->name[1]= name ## 8x8_c;
+#define SET_CMP_FUNC(name) \
+ c->name[0] = name ## 16_c; \
+ c->name[1] = name ## 8x8_c;
SET_CMP_FUNC(hadamard8_diff)
- c->hadamard8_diff[4]= hadamard8_intra16_c;
- c->hadamard8_diff[5]= hadamard8_intra8x8_c;
+ c->hadamard8_diff[4] = hadamard8_intra16_c;
+ c->hadamard8_diff[5] = hadamard8_intra8x8_c;
SET_CMP_FUNC(dct_sad)
SET_CMP_FUNC(dct_max)
#if CONFIG_GPL
SET_CMP_FUNC(dct264_sad)
#endif
- c->sad[0]= pix_abs16_c;
- c->sad[1]= pix_abs8_c;
- c->sse[0]= sse16_c;
- c->sse[1]= sse8_c;
- c->sse[2]= sse4_c;
+ c->sad[0] = pix_abs16_c;
+ c->sad[1] = pix_abs8_c;
+ c->sse[0] = sse16_c;
+ c->sse[1] = sse8_c;
+ c->sse[2] = sse4_c;
SET_CMP_FUNC(quant_psnr)
SET_CMP_FUNC(rd)
SET_CMP_FUNC(bit)
- c->vsad[0]= vsad16_c;
- c->vsad[4]= vsad_intra16_c;
- c->vsad[5]= vsad_intra8_c;
- c->vsse[0]= vsse16_c;
- c->vsse[4]= vsse_intra16_c;
- c->vsse[5]= vsse_intra8_c;
- c->nsse[0]= nsse16_c;
- c->nsse[1]= nsse8_c;
+ c->vsad[0] = vsad16_c;
+ c->vsad[4] = vsad_intra16_c;
+ c->vsad[5] = vsad_intra8_c;
+ c->vsse[0] = vsse16_c;
+ c->vsse[4] = vsse_intra16_c;
+ c->vsse[5] = vsse_intra8_c;
+ c->nsse[0] = nsse16_c;
+ c->nsse[1] = nsse8_c;
#if CONFIG_SNOW_DECODER || CONFIG_SNOW_ENCODER
ff_dsputil_init_dwt(c);
#endif
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
- c->add_bytes= add_bytes_c;
- c->diff_bytes= diff_bytes_c;
- c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
- c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
- c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
+ c->add_bytes = add_bytes_c;
+ c->add_hfyu_median_prediction = add_hfyu_median_prediction_c;
+ c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
- c->bswap_buf= bswap_buf;
+
+ c->diff_bytes = diff_bytes_c;
+ c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_c;
+
+ c->bswap_buf = bswap_buf;
c->bswap16_buf = bswap16_buf;
- c->try_8x8basis= try_8x8basis_c;
- c->add_8x8basis= add_8x8basis_c;
+ c->try_8x8basis = try_8x8basis_c;
+ c->add_8x8basis = add_8x8basis_c;
- c->vector_clipf = vector_clipf_c;
- c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
- c->vector_clip_int32 = vector_clip_int32_c;
- c->shrink[0]= av_image_copy_plane;
- c->shrink[1]= ff_shrink22;
- c->shrink[2]= ff_shrink44;
- c->shrink[3]= ff_shrink88;
+ c->scalarproduct_int16 = scalarproduct_int16_c;
+ c->vector_clip_int32 = vector_clip_int32_c;
+ c->vector_clipf = vector_clipf_c;
+
+ c->shrink[0] = av_image_copy_plane;
+ c->shrink[1] = ff_shrink22;
+ c->shrink[2] = ff_shrink44;
+ c->shrink[3] = ff_shrink88;
c->add_pixels8 = add_pixels8_c;
-#undef FUNC
-#undef FUNCC
-#define FUNC(f, depth) f ## _ ## depth
-#define FUNCC(f, depth) f ## _ ## depth ## _c
-
- c->draw_edges = FUNCC(draw_edges, 8);
- c->clear_block = FUNCC(clear_block, 8);
- c->clear_blocks = FUNCC(clear_blocks, 8);
+ c->draw_edges = draw_edges_8_c;
-#define BIT_DEPTH_FUNCS(depth) \
- c->get_pixels = FUNCC(get_pixels, depth);
+ c->clear_block = clear_block_8_c;
+ c->clear_blocks = clear_blocks_8_c;
switch (avctx->bits_per_raw_sample) {
case 9:
case 10:
case 12:
case 14:
- BIT_DEPTH_FUNCS(16);
+ c->get_pixels = get_pixels_16_c;
break;
default:
- if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
- BIT_DEPTH_FUNCS(8);
+ if (avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
+ c->get_pixels = get_pixels_8_c;
}
break;
}
@@ -2825,17 +2824,13 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
if (ARCH_ALPHA)
ff_dsputil_init_alpha(c, avctx);
if (ARCH_ARM)
- ff_dsputil_init_arm(c, avctx);
+ ff_dsputil_init_arm(c, avctx, high_bit_depth);
if (ARCH_BFIN)
- ff_dsputil_init_bfin(c, avctx);
+ ff_dsputil_init_bfin(c, avctx, high_bit_depth);
if (ARCH_PPC)
- ff_dsputil_init_ppc(c, avctx);
- if (ARCH_SH4)
- ff_dsputil_init_sh4(c, avctx);
- if (HAVE_VIS)
- ff_dsputil_init_vis(c, avctx);
+ ff_dsputil_init_ppc(c, avctx, high_bit_depth);
if (ARCH_X86)
- ff_dsputil_init_x86(c, avctx);
+ ff_dsputil_init_x86(c, avctx, high_bit_depth);
ff_init_scantable_permutation(c->idct_permutation,
c->idct_permutation_type);
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsputil.h b/chromium/third_party/ffmpeg/libavcodec/dsputil.h
index 0897c560b43..f8eb8fd0086 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dsputil.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dsputil.h
@@ -23,69 +23,60 @@
/**
* @file
* DSP utils.
- * note, many functions in here may use MMX which trashes the FPU state, it is
- * absolutely necessary to call emms_c() between dsp & float/double code
+ * Note, many functions in here may use MMX which trashes the FPU state, it is
+ * absolutely necessary to call emms_c() between DSP & float/double code.
*/
#ifndef AVCODEC_DSPUTIL_H
#define AVCODEC_DSPUTIL_H
-#include "libavutil/intreadwrite.h"
#include "avcodec.h"
-#include "rnd_avg.h"
/* encoding scans */
extern const uint8_t ff_alternate_horizontal_scan[64];
extern const uint8_t ff_alternate_vertical_scan[64];
-extern const uint8_t ff_zigzag_direct[64];
-extern const uint8_t ff_zigzag248_direct[64];
-/* pixel operations */
-#define MAX_NEG_CROP 1024
-
-/* temporary */
-extern uint32_t ff_squareTbl[512];
-extern const uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
+extern uint32_t ff_square_tab[512];
void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-/* RV40 functions */
-void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
-
void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
- int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
+ int dxx, int dxy, int dyx, int dyy, int shift, int r,
+ int width, int height);
/* minimum alignment rules ;)
-If you notice errors in the align stuff, need more alignment for some ASM code
-for some CPU or need to use a function with less aligned data then send a mail
-to the ffmpeg-devel mailing list, ...
-
-!warning These alignments might not match reality, (missing attribute((align))
-stuff somewhere possible).
-I (Michael) did not check them, these are just the alignments which I think
-could be reached easily ...
-
-!future video codecs might need functions with less strict alignment
-*/
+ * If you notice errors in the align stuff, need more alignment for some ASM code
+ * for some CPU or need to use a function with less aligned data then send a mail
+ * to the ffmpeg-devel mailing list, ...
+ *
+ * !warning These alignments might not match reality, (missing attribute((align))
+ * stuff somewhere possible).
+ * I (Michael) did not check them, these are just the alignments which I think
+ * could be reached easily ...
+ *
+ * !future video codecs might need functions with less strict alignment
+ */
-/* add and put pixel (decoding) */
-// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
-//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4
-typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
-typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);
+/* add and put pixel (decoding)
+ * Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16.
+ * h for op_pixels_func is limited to { width / 2, width },
+ * but never larger than 16 and never smaller than 4. */
+typedef void (*qpel_mc_func)(uint8_t *dst /* align width (8 or 16) */,
+ uint8_t *src /* align 1 */, ptrdiff_t stride);
-typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
+typedef void (*op_fill_func)(uint8_t *block /* align width (8 or 16) */,
+ uint8_t value, int line_size, int h);
-#define DEF_OLD_QPEL(name)\
-void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);\
-void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);\
-void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);
+#define DEF_OLD_QPEL(name) \
+ void ff_put_ ## name(uint8_t *dst /* align width (8 or 16) */, \
+ uint8_t *src /* align 1 */, ptrdiff_t stride); \
+ void ff_put_no_rnd_ ## name(uint8_t *dst /* align width (8 or 16) */, \
+ uint8_t *src /* align 1 */, ptrdiff_t stride); \
+ void ff_avg_ ## name(uint8_t *dst /* align width (8 or 16) */, \
+ uint8_t *src /* align 1 */, ptrdiff_t stride);
DEF_OLD_QPEL(qpel16_mc11_old_c)
DEF_OLD_QPEL(qpel16_mc31_old_c)
@@ -100,21 +91,27 @@ DEF_OLD_QPEL(qpel8_mc32_old_c)
DEF_OLD_QPEL(qpel8_mc13_old_c)
DEF_OLD_QPEL(qpel8_mc33_old_c)
-/* motion estimation */
-// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2
-// although currently h<4 is not used as functions with width <8 are neither used nor implemented
-typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
+struct MpegEncContext;
+/* Motion estimation:
+ * h is limited to { width / 2, width, 2 * width },
+ * but never larger than 16 and never smaller than 2.
+ * Although currently h < 4 is not used as functions with
+ * width < 8 are neither used nor implemented. */
+typedef int (*me_cmp_func)(struct MpegEncContext *c,
+ uint8_t *blk1 /* align width (8 or 16) */,
+ uint8_t *blk2 /* align 1 */, int line_size, int h);
/**
* Scantable.
*/
-typedef struct ScanTable{
+typedef struct ScanTable {
const uint8_t *scantable;
uint8_t permutated[64];
uint8_t raster_end[64];
} ScanTable;
-void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
+void ff_init_scantable(uint8_t *permutation, ScanTable *st,
+ const uint8_t *src_scantable);
void ff_init_scantable_permutation(uint8_t *idct_permutation,
int idct_permutation_type);
@@ -123,27 +120,40 @@ void ff_init_scantable_permutation(uint8_t *idct_permutation,
*/
typedef struct DSPContext {
/* pixel ops : interface with DCT */
- void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
- void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
- void (*put_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
- void (*put_signed_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
- void (*add_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
+ void (*get_pixels)(int16_t *block /* align 16 */,
+ const uint8_t *pixels /* align 8 */,
+ int line_size);
+ void (*diff_pixels)(int16_t *block /* align 16 */,
+ const uint8_t *s1 /* align 8 */,
+ const uint8_t *s2 /* align 8 */,
+ int stride);
+ void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
+ uint8_t *pixels /* align 8 */,
+ int line_size);
+ void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
+ uint8_t *pixels /* align 8 */,
+ int line_size);
+ void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
+ uint8_t *pixels /* align 8 */,
+ int line_size);
void (*add_pixels8)(uint8_t *pixels, int16_t *block, int line_size);
- int (*sum_abs_dctelem)(int16_t *block/*align 16*/);
+ int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
/**
* translational global motion compensation.
*/
- void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
+ void (*gmc1)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+ int srcStride, int h, int x16, int y16, int rounder);
/**
* global motion compensation.
*/
- void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
- int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
- void (*clear_block)(int16_t *block/*align 16*/);
- void (*clear_blocks)(int16_t *blocks/*align 16*/);
- int (*pix_sum)(uint8_t * pix, int line_size);
- int (*pix_norm1)(uint8_t * pix, int line_size);
-// 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
+ void (*gmc)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+ int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy,
+ int shift, int r, int width, int height);
+ void (*clear_block)(int16_t *block /* align 16 */);
+ void (*clear_blocks)(int16_t *blocks /* align 16 */);
+ int (*pix_sum)(uint8_t *pix, int line_size);
+ int (*pix_norm1)(uint8_t *pix, int line_size);
me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
me_cmp_func sse[6];
@@ -164,25 +174,12 @@ typedef struct DSPContext {
me_cmp_func me_cmp[6];
me_cmp_func me_sub_cmp[6];
me_cmp_func mb_cmp[6];
- me_cmp_func ildct_cmp[6]; //only width 16 used
- me_cmp_func frame_skip_cmp[6]; //only width 8 used
+ me_cmp_func ildct_cmp[6]; // only width 16 used
+ me_cmp_func frame_skip_cmp[6]; // only width 8 used
int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
int size);
- /**
- * Thirdpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[12] of motion compensation functions for the 9 thirdpe
- * positions<br>
- * *pixels_tab[ xthirdpel + 4*ythirdpel ]
- * @param block destination where the result is stored
- * @param pixels source
- * @param line_size number of bytes in a horizontal line of block
- * @param h height
- */
- tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
- tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
-
qpel_mc_func put_qpel_pixels_tab[2][16];
qpel_mc_func avg_qpel_pixels_tab[2][16];
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
@@ -190,55 +187,73 @@ typedef struct DSPContext {
me_cmp_func pix_abs[2][4];
- /* huffyuv specific */
- void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
- void (*diff_bytes)(uint8_t *dst/*align 16*/, const uint8_t *src1/*align 16*/, const uint8_t *src2/*align 1*/,int w);
+ /* HuffYUV specific */
+ void (*add_bytes)(uint8_t *dst /* align 16 */,
+ uint8_t *src /* align 16 */,
+ int w);
+ void (*diff_bytes)(uint8_t *dst /* align 16 */,
+ const uint8_t *src1 /* align 16 */,
+ const uint8_t *src2 /* align 1 */,
+ int w);
/**
- * subtract huffyuv's variant of median prediction
- * note, this might read from src1[-1], src2[-1]
+ * Subtract HuffYUV's variant of median prediction.
+ * Note, this might read from src1[-1], src2[-1].
*/
- void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
- void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
- int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
- void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
+ void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1,
+ const uint8_t *src2, int w,
+ int *left, int *left_top);
+ void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top,
+ const uint8_t *diff, int w,
+ int *left, int *left_top);
+ int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src,
+ int w, int left);
+ void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src,
+ int w, int *red, int *green,
+ int *blue, int *alpha);
/* this might write to dst[w] */
void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
- void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
+ void (*vector_clipf)(float *dst /* align 16 */,
+ const float *src /* align 16 */,
+ float min, float max, int len /* align 16 */);
/* (I)DCT */
- void (*fdct)(int16_t *block/* align 16*/);
- void (*fdct248)(int16_t *block/* align 16*/);
+ void (*fdct)(int16_t *block /* align 16 */);
+ void (*fdct248)(int16_t *block /* align 16 */);
- /* IDCT really*/
- void (*idct)(int16_t *block/* align 16*/);
+ /* IDCT really */
+ void (*idct)(int16_t *block /* align 16 */);
/**
* block -> idct -> clip to unsigned 8 bit -> dest.
* (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
* @param line_size size in bytes of a horizontal line of dest
*/
- void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
+ void (*idct_put)(uint8_t *dest /* align 8 */,
+ int line_size, int16_t *block /* align 16 */);
/**
* block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
* @param line_size size in bytes of a horizontal line of dest
*/
- void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
+ void (*idct_add)(uint8_t *dest /* align 8 */,
+ int line_size, int16_t *block /* align 16 */);
/**
- * idct input permutation.
- * several optimized IDCTs need a permutated input (relative to the normal order of the reference
- * IDCT)
- * this permutation must be performed before the idct_put/add, note, normally this can be merged
- * with the zigzag/alternate scan<br>
- * an example to avoid confusion:
- * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
- * - (x -> reference dct -> reference idct -> x)
- * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
- * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
+ * IDCT input permutation.
+ * Several optimized IDCTs need a permutated input (relative to the
+ * normal order of the reference IDCT).
+ * This permutation must be performed before the idct_put/add.
+ * Note, normally this can be merged with the zigzag/alternate scan<br>
+ * An example to avoid confusion:
+ * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
+ * - (x -> reference DCT -> reference IDCT -> x)
+ * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
+ * -> simple_idct_mmx -> x)
+ * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
+ * -> simple_idct_mmx -> ...)
*/
uint8_t idct_permutation[64];
int idct_permutation_type;
@@ -249,33 +264,41 @@ typedef struct DSPContext {
#define FF_PARTTRANS_IDCT_PERM 5
#define FF_SSE2_IDCT_PERM 6
- int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
+ int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],
+ int16_t basis[64], int scale);
void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
#define BASIS_SHIFT 16
#define RECON_SHIFT 6
- void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides);
+ void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
+ int w, int h, int sides);
#define EDGE_WIDTH 16
#define EDGE_TOP 1
#define EDGE_BOTTOM 2
- void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
+ void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
+ int src_wrap, int width, int height);
/**
* Calculate scalar product of two vectors.
* @param len length of vectors, should be multiple of 16
*/
- int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len);
+ int32_t (*scalarproduct_int16)(const int16_t *v1,
+ const int16_t *v2 /* align 16 */, int len);
/* ape functions */
/**
* Calculate scalar product of v1 and v2,
* and v1[i] += v3[i] * mul
* @param len length of vectors, should be multiple of 16
*/
- int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
+ int32_t (*scalarproduct_and_madd_int16)(int16_t *v1 /* align 16 */,
+ const int16_t *v2,
+ const int16_t *v3,
+ int len, int mul);
/**
- * Clip each element in an array of int32_t to a given minimum and maximum value.
+ * Clip each element in an array of int32_t to a given minimum and
+ * maximum value.
* @param dst destination array
* constraints: 16-byte aligned
* @param src source array
@@ -294,21 +317,23 @@ typedef struct DSPContext {
} DSPContext;
void ff_dsputil_static_init(void);
-void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx);
+void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
void avpriv_dsputil_init(DSPContext* p, AVCodecContext *avctx);
attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
int ff_check_alignment(void);
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
+void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_x86(DSPContext* c, AVCodecContext *avctx);
+void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
void ff_dsputil_init_dwt(DSPContext *c);
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsputil_template.c b/chromium/third_party/ffmpeg/libavcodec/dsputil_template.c
index 96be7a6a654..95d966e721a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dsputil_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dsputil_template.c
@@ -27,231 +27,197 @@
* DSP utils
*/
-#include "bit_depth_template.c"
+#define PIXOP2(OPNAME, OP) \
+static inline void OPNAME ## _no_rnd_pixels8_l2_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ uint32_t a, b; \
+ a = AV_RN32(&src1[i * src_stride1]); \
+ b = AV_RN32(&src2[i * src_stride2]); \
+ OP(*((uint32_t *) &dst[i * dst_stride]), \
+ no_rnd_avg32(a, b)); \
+ a = AV_RN32(&src1[i * src_stride1 + 4]); \
+ b = AV_RN32(&src2[i * src_stride2 + 4]); \
+ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
+ no_rnd_avg32(a, b)); \
+ } \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels16_l2_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ OPNAME ## _no_rnd_pixels8_l2_8(dst, src1, src2, dst_stride, \
+ src_stride1, src_stride2, h); \
+ OPNAME ## _no_rnd_pixels8_l2_8(dst + 8, \
+ src1 + 8, \
+ src2 + 8, \
+ dst_stride, src_stride1, \
+ src_stride2, h); \
+} \
+ \
+static inline void OPNAME ## _pixels8_l4_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ const uint8_t *src3, \
+ const uint8_t *src4, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int src_stride3, \
+ int src_stride4, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ uint32_t a, b, c, d, l0, l1, h0, h1; \
+ a = AV_RN32(&src1[i * src_stride1]); \
+ b = AV_RN32(&src2[i * src_stride2]); \
+ c = AV_RN32(&src3[i * src_stride3]); \
+ d = AV_RN32(&src4[i * src_stride4]); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ l1 = (c & 0x03030303UL) + \
+ (d & 0x03030303UL); \
+ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ ((d & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) &dst[i * dst_stride]), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ a = AV_RN32(&src1[i * src_stride1 + 4]); \
+ b = AV_RN32(&src2[i * src_stride2 + 4]); \
+ c = AV_RN32(&src3[i * src_stride3 + 4]); \
+ d = AV_RN32(&src4[i * src_stride4 + 4]); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ l1 = (c & 0x03030303UL) + \
+ (d & 0x03030303UL); \
+ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ ((d & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ } \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels8_l4_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ const uint8_t *src3, \
+ const uint8_t *src4, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int src_stride3, \
+ int src_stride4, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ uint32_t a, b, c, d, l0, l1, h0, h1; \
+ a = AV_RN32(&src1[i * src_stride1]); \
+ b = AV_RN32(&src2[i * src_stride2]); \
+ c = AV_RN32(&src3[i * src_stride3]); \
+ d = AV_RN32(&src4[i * src_stride4]); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x01010101UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ l1 = (c & 0x03030303UL) + \
+ (d & 0x03030303UL); \
+ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ ((d & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) &dst[i * dst_stride]), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ a = AV_RN32(&src1[i * src_stride1 + 4]); \
+ b = AV_RN32(&src2[i * src_stride2 + 4]); \
+ c = AV_RN32(&src3[i * src_stride3 + 4]); \
+ d = AV_RN32(&src4[i * src_stride4 + 4]); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x01010101UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ l1 = (c & 0x03030303UL) + \
+ (d & 0x03030303UL); \
+ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ ((d & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ } \
+} \
+ \
+static inline void OPNAME ## _pixels16_l4_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ const uint8_t *src3, \
+ const uint8_t *src4, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int src_stride3, \
+ int src_stride4, \
+ int h) \
+{ \
+ OPNAME ## _pixels8_l4_8(dst, src1, src2, src3, src4, dst_stride, \
+ src_stride1, src_stride2, src_stride3, \
+ src_stride4, h); \
+ OPNAME ## _pixels8_l4_8(dst + 8, \
+ src1 + 8, src2 + 8, \
+ src3 + 8, src4 + 8, \
+ dst_stride, src_stride1, src_stride2, \
+ src_stride3, src_stride4, h); \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels16_l4_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ const uint8_t *src3, \
+ const uint8_t *src4, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int src_stride3, \
+ int src_stride4, \
+ int h) \
+{ \
+ OPNAME ## _no_rnd_pixels8_l4_8(dst, src1, src2, src3, src4, \
+ dst_stride, src_stride1, \
+ src_stride2, src_stride3, \
+ src_stride4, h); \
+ OPNAME ## _no_rnd_pixels8_l4_8(dst + 8, \
+ src1 + 8, src2 + 8, \
+ src3 + 8, src4 + 8, \
+ dst_stride, src_stride1, \
+ src_stride2, src_stride3, \
+ src_stride4, h); \
+} \
-#if BIT_DEPTH == 8
-/* draw the edges of width 'w' of an image of size width, height */
-//FIXME check that this is ok for mpeg4 interlaced
-static void FUNCC(draw_edges)(uint8_t *p_buf, int p_wrap, int width, int height, int w, int h, int sides)
-{
- pixel *buf = (pixel*)p_buf;
- int wrap = p_wrap / sizeof(pixel);
- pixel *ptr, *last_line;
- int i;
-
- /* left and right */
- ptr = buf;
- for(i=0;i<height;i++) {
- memset(ptr - w, ptr[0], w);
- memset(ptr + width, ptr[width-1], w);
- ptr += wrap;
- }
-
- /* top and bottom + corners */
- buf -= w;
- last_line = buf + (height - 1) * wrap;
- if (sides & EDGE_TOP)
- for(i = 0; i < h; i++)
- memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel)); // top
- if (sides & EDGE_BOTTOM)
- for (i = 0; i < h; i++)
- memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom
-}
-#endif
-
-static void FUNCC(get_pixels)(int16_t *av_restrict block,
- const uint8_t *_pixels,
- int line_size)
-{
- const pixel *pixels = (const pixel *) _pixels;
- int i;
-
- /* read the pixels */
- for(i=0;i<8;i++) {
- block[0] = pixels[0];
- block[1] = pixels[1];
- block[2] = pixels[2];
- block[3] = pixels[3];
- block[4] = pixels[4];
- block[5] = pixels[5];
- block[6] = pixels[6];
- block[7] = pixels[7];
- pixels += line_size / sizeof(pixel);
- block += 8;
- }
-}
-
-#if BIT_DEPTH == 8
-static void FUNCC(clear_block)(int16_t *block)
-{
- memset(block, 0, sizeof(int16_t)*64);
-}
-
-static void FUNCC(clear_blocks)(int16_t *blocks)
-{
- memset(blocks, 0, sizeof(int16_t)*6*64);
-}
-#endif
-
-#if BIT_DEPTH == 8
-#include "hpel_template.c"
-#endif
-
-#define PIXOP2(OPNAME, OP) \
-static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- int i;\
- for(i=0; i<h; i++){\
- pixel4 a,b;\
- a= AV_RN4P(&src1[i*src_stride1 ]);\
- b= AV_RN4P(&src2[i*src_stride2 ]);\
- OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\
- a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
- b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
- OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
- FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
- int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
- /* FIXME HIGH BIT DEPTH */\
- int i;\
- for(i=0; i<h; i++){\
- uint32_t a, b, c, d, l0, l1, h0, h1;\
- a= AV_RN32(&src1[i*src_stride1]);\
- b= AV_RN32(&src2[i*src_stride2]);\
- c= AV_RN32(&src3[i*src_stride3]);\
- d= AV_RN32(&src4[i*src_stride4]);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- l1= (c&0x03030303UL)\
- + (d&0x03030303UL);\
- h1= ((c&0xFCFCFCFCUL)>>2)\
- + ((d&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- a= AV_RN32(&src1[i*src_stride1+4]);\
- b= AV_RN32(&src2[i*src_stride2+4]);\
- c= AV_RN32(&src3[i*src_stride3+4]);\
- d= AV_RN32(&src4[i*src_stride4+4]);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- l1= (c&0x03030303UL)\
- + (d&0x03030303UL);\
- h1= ((c&0xFCFCFCFCUL)>>2)\
- + ((d&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
- int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
- /* FIXME HIGH BIT DEPTH*/\
- int i;\
- for(i=0; i<h; i++){\
- uint32_t a, b, c, d, l0, l1, h0, h1;\
- a= AV_RN32(&src1[i*src_stride1]);\
- b= AV_RN32(&src2[i*src_stride2]);\
- c= AV_RN32(&src3[i*src_stride3]);\
- d= AV_RN32(&src4[i*src_stride4]);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x01010101UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- l1= (c&0x03030303UL)\
- + (d&0x03030303UL);\
- h1= ((c&0xFCFCFCFCUL)>>2)\
- + ((d&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- a= AV_RN32(&src1[i*src_stride1+4]);\
- b= AV_RN32(&src2[i*src_stride2+4]);\
- c= AV_RN32(&src3[i*src_stride3+4]);\
- d= AV_RN32(&src4[i*src_stride4+4]);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x01010101UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- l1= (c&0x03030303UL)\
- + (d&0x03030303UL);\
- h1= ((c&0xFCFCFCFCUL)>>2)\
- + ((d&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- }\
-}\
-static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
- int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
- FUNC(OPNAME ## _pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
- FUNC(OPNAME ## _pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
- int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
- FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
- FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\
-{\
- /* FIXME HIGH BIT DEPTH */\
- int j;\
- for(j=0; j<2; j++){\
- int i;\
- const uint32_t a= AV_RN32(pixels );\
- const uint32_t b= AV_RN32(pixels+1);\
- uint32_t l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- uint32_t l1,h1;\
-\
- pixels+=line_size;\
- for(i=0; i<h; i+=2){\
- uint32_t a= AV_RN32(pixels );\
- uint32_t b= AV_RN32(pixels+1);\
- l1= (a&0x03030303UL)\
- + (b&0x03030303UL);\
- h1= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- a= AV_RN32(pixels );\
- b= AV_RN32(pixels+1);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- }\
- pixels+=4-line_size*(h+1);\
- block +=4-line_size*h;\
- }\
-}\
-\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
-
-#define op_avg(a, b) a = rnd_avg_pixel4(a, b)
+#define op_avg(a, b) a = rnd_avg32(a, b)
#define op_put(a, b) a = b
-#if BIT_DEPTH == 8
#define put_no_rnd_pixels8_8_c put_pixels8_8_c
PIXOP2(avg, op_avg)
PIXOP2(put, op_put)
-#endif
#undef op_avg
#undef op_put
diff --git a/chromium/third_party/ffmpeg/libavcodec/dsputilenc_template.c b/chromium/third_party/ffmpeg/libavcodec/dsputilenc_template.c
new file mode 100644
index 00000000000..711c404a972
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/dsputilenc_template.c
@@ -0,0 +1,51 @@
+/*
+ * DSP utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * DSP utils
+ */
+
+#include "bit_depth_template.c"
+
+static void FUNCC(get_pixels)(int16_t *av_restrict block, const uint8_t *_pixels,
+ int line_size)
+{
+ const pixel *pixels = (const pixel *) _pixels;
+ int i;
+
+ /* read the pixels */
+ for (i = 0; i < 8; i++) {
+ block[0] = pixels[0];
+ block[1] = pixels[1];
+ block[2] = pixels[2];
+ block[3] = pixels[3];
+ block[4] = pixels[4];
+ block[5] = pixels[5];
+ block[6] = pixels[6];
+ block[7] = pixels[7];
+ pixels += line_size / sizeof(pixel);
+ block += 8;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dv.c b/chromium/third_party/ffmpeg/libavcodec/dv.c
index ea05e9dd887..a9f64b4a8d3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dv.c
@@ -314,11 +314,11 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx)
s->idct_put[1] = ff_simple_idct248_put; // FIXME: need to add it to DSP
if (avctx->lowres){
for (i = 0; i < 64; i++){
- int j = ff_zigzag248_direct[i];
+ int j = ff_dv_zigzag248_direct[i];
s->dv_zigzag[1][i] = dsp.idct_permutation[(j & 7) + (j & 8) * 4 + (j & 48) / 2];
}
}else
- memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64);
+ memcpy(s->dv_zigzag[1], ff_dv_zigzag248_direct, 64);
s->avctx = avctx;
avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvbsub.c b/chromium/third_party/ffmpeg/libavcodec/dvbsub.c
index f30b7674f77..f6b46e64a93 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvbsub.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvbsub.c
@@ -261,8 +261,6 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
if (h->num_rects && h->rects == NULL)
return -1;
- *q++ = 0x00; /* subtitle_stream_id */
-
/* page composition segment */
*q++ = 0x0f; /* sync_byte */
@@ -437,8 +435,6 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
bytestream_put_be16(&pseg_len, q - pseg_len - 2);
- *q++ = 0xff; /* end of PES data */
-
s->object_version = (s->object_version + 1) & 0xf;
return q - outbuf;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvbsubdec.c b/chromium/third_party/ffmpeg/libavcodec/dvbsubdec.c
index b8b414343d5..9d74b1a0c06 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvbsubdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvbsubdec.c
@@ -18,8 +18,8 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include "avcodec.h"
-#include "dsputil.h"
#include "get_bits.h"
#include "bytestream.h"
#include "libavutil/colorspace.h"
@@ -31,7 +31,7 @@
#define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14
#define DVBSUB_DISPLAY_SEGMENT 0x80
-#define cm (ff_cropTbl + MAX_NEG_CROP)
+#define cm (ff_crop_tab + MAX_NEG_CROP)
#ifdef DEBUG
#if 0
@@ -236,7 +236,6 @@ typedef struct DVBSubContext {
DVBSubCLUT *clut_list;
DVBSubObject *object_list;
- int display_list_size;
DVBSubRegionDisplay *display_list;
DVBSubDisplayDefinition *display_definition;
} DVBSubContext;
@@ -368,11 +367,15 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
int i, r, g, b, a = 0;
DVBSubContext *ctx = avctx->priv_data;
- if (!avctx->extradata || avctx->extradata_size != 4) {
- av_log(avctx, AV_LOG_WARNING, "Invalid extradata, subtitle streams may be combined!\n");
+ if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
+ av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream extradata!\n");
ctx->composition_id = -1;
ctx->ancillary_id = -1;
} else {
+ if (avctx->extradata_size > 5) {
+ av_log(avctx, AV_LOG_WARNING, "Decoding first DVB subtitles sub-stream\n");
+ }
+
ctx->composition_id = AV_RB16(avctx->extradata);
ctx->ancillary_id = AV_RB16(avctx->extradata + 2);
}
@@ -1179,7 +1182,6 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
tmp_display_list = ctx->display_list;
ctx->display_list = NULL;
- ctx->display_list_size = 0;
while (buf + 5 < buf_end) {
region_id = *buf++;
@@ -1207,7 +1209,6 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
display->next = ctx->display_list;
ctx->display_list = display;
- ctx->display_list_size++;
av_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
}
@@ -1357,8 +1358,8 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
if (info_byte & 1<<3) { // display_window_flag
display_def->x = bytestream_get_be16(&buf);
- display_def->y = bytestream_get_be16(&buf);
display_def->width = bytestream_get_be16(&buf) - display_def->x + 1;
+ display_def->y = bytestream_get_be16(&buf);
display_def->height = bytestream_get_be16(&buf) - display_def->y + 1;
}
}
@@ -1384,10 +1385,16 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
offset_y = display_def->y;
}
- sub->num_rects = ctx->display_list_size;
+ sub->num_rects = 0;
+ for (display = ctx->display_list; display; display = display->next)
+ {
+ region = get_region(ctx, display->region_id);
+ if (region && region->dirty)
+ sub->num_rects++;
+ }
if (sub->num_rects > 0){
- sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects);
+ sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects);
for(i=0; i<sub->num_rects; i++)
sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));
@@ -1437,8 +1444,6 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
i++;
}
-
- sub->num_rects = i;
}
#ifdef DEBUG
save_display_set(ctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvdata.c b/chromium/third_party/ffmpeg/libavcodec/dvdata.c
index a3be7fd7adf..ace01ffda27 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvdata.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvdata.c
@@ -28,6 +28,19 @@
#include "dvdata.h"
+/* Specific zigzag scan for 248 idct. NOTE that unlike the
+ * specification, we interleave the fields */
+const uint8_t ff_dv_zigzag248_direct[64] = {
+ 0, 8, 1, 9, 16, 24, 2, 10,
+ 17, 25, 32, 40, 48, 56, 33, 41,
+ 18, 26, 3, 11, 4, 12, 19, 27,
+ 34, 42, 49, 57, 50, 58, 35, 43,
+ 20, 28, 5, 13, 6, 14, 21, 29,
+ 36, 44, 51, 59, 52, 60, 37, 45,
+ 22, 30, 7, 15, 23, 31, 38, 46,
+ 53, 61, 54, 62, 39, 47, 55, 63,
+};
+
/* unquant tables (not used directly) */
const uint8_t ff_dv_quant_shifts[22][4] = {
{ 3,3,4,4 },
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvdata.h b/chromium/third_party/ffmpeg/libavcodec/dvdata.h
index 8c120df7221..0932d3ad152 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvdata.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dvdata.h
@@ -21,6 +21,8 @@
#include <stdint.h>
+extern const uint8_t ff_dv_zigzag248_direct[64];
+
extern const uint8_t ff_dv_quant_shifts[22][4];
extern const uint8_t ff_dv_quant_offset[4];
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvdsubdec.c b/chromium/third_party/ffmpeg/libavcodec/dvdsubdec.c
index 31ce0accc69..53287bd1226 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvdsubdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvdsubdec.c
@@ -18,9 +18,9 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include "avcodec.h"
#include "get_bits.h"
-#include "dsputil.h"
#include "internal.h"
#include "libavutil/attributes.h"
@@ -46,7 +46,7 @@ typedef struct DVDSubContext
static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
uint8_t r, g, b;
int i, y, cb, cr;
int r_add, g_add, b_add;
@@ -599,8 +599,10 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx)
int w, h;
if (sscanf(data + 5, "%dx%d", &w, &h) == 2) {
int ret = ff_set_dimensions(avctx, w, h);
- if (ret < 0)
+ if (ret < 0) {
+ av_free(dataorig);
return ret;
+ }
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvdsubenc.c b/chromium/third_party/ffmpeg/libavcodec/dvdsubenc.c
index 8130b74a7ae..11858c7f976 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvdsubenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvdsubenc.c
@@ -383,7 +383,7 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
qq = outbuf;
bytestream_put_be16(&qq, q - outbuf);
- av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
+ av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%"PTRDIFF_SPECIFIER"\n", q - outbuf);
ret = q - outbuf;
fail:
diff --git a/chromium/third_party/ffmpeg/libavcodec/dvenc.c b/chromium/third_party/ffmpeg/libavcodec/dvenc.c
index 6e887dc840e..052b631863a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dvenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dvenc.c
@@ -33,7 +33,7 @@
#include "dv.h"
#include "dv_tablegen.h"
-static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
+static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
{
if (!avpriv_dv_codec_profile(avctx)) {
av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
@@ -249,7 +249,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i
}
bi->mb[0] = blk[0];
- zigzag_scan = bi->dct_mode ? ff_zigzag248_direct : ff_zigzag_direct;
+ zigzag_scan = bi->dct_mode ? ff_dv_zigzag248_direct : ff_zigzag_direct;
weight = bi->dct_mode ? dv_weight_248 : dv_weight_88;
for (area = 0; area < 4; area++) {
@@ -702,7 +702,7 @@ AVCodec ff_dvvideo_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DVVIDEO,
.priv_data_size = sizeof(DVVideoContext),
- .init = dvvideo_init_encoder,
+ .init = dvvideo_encode_init,
.encode2 = dvvideo_encode_frame,
.close = dvvideo_encode_close,
.capabilities = CODEC_CAP_SLICE_THREADS,
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxa.c b/chromium/third_party/ffmpeg/libavcodec/dxa.c
index 1d96f10ef47..0f64b5e6194 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxa.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxa.c
@@ -42,6 +42,7 @@ typedef struct DxaDecContext {
AVFrame *prev;
int dsize;
+#define DECOMP_BUF_PADDING 16
uint8_t *decomp_buf;
uint32_t pal[256];
} DxaDecContext;
@@ -50,13 +51,17 @@ static const int shift1[6] = { 0, 8, 8, 8, 4, 4 };
static const int shift2[6] = { 0, 0, 8, 4, 0, 4 };
static int decode_13(AVCodecContext *avctx, DxaDecContext *c, uint8_t* dst,
- int stride, uint8_t *src, uint8_t *ref)
+ int stride, uint8_t *src, int srcsize, uint8_t *ref)
{
uint8_t *code, *data, *mv, *msk, *tmp, *tmp2;
+ uint8_t *src_end = src + srcsize;
int i, j, k;
int type, x, y, d, d2;
uint32_t mask;
+ if (12ULL + ((avctx->width * avctx->height) >> 4) + AV_RB32(src + 0) + AV_RB32(src + 4) > srcsize)
+ return AVERROR_INVALIDDATA;
+
code = src + 12;
data = code + ((avctx->width * avctx->height) >> 4);
mv = data + AV_RB32(src + 0);
@@ -64,6 +69,8 @@ static int decode_13(AVCodecContext *avctx, DxaDecContext *c, uint8_t* dst,
for(j = 0; j < avctx->height; j += 4){
for(i = 0; i < avctx->width; i += 4){
+ if (data > src_end || mv > src_end || msk > src_end)
+ return AVERROR_INVALIDDATA;
tmp = dst + i;
tmp2 = ref + i;
type = *code++;
@@ -245,6 +252,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_UNKNOWN;
}
+ memset(c->decomp_buf + dsize, 0, DECOMP_BUF_PADDING);
}
if (avctx->debug & FF_DEBUG_PICT_INFO)
@@ -300,7 +308,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
av_log(avctx, AV_LOG_ERROR, "Missing reference frame\n");
return AVERROR_INVALIDDATA;
}
- decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);
+ decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, dsize, c->prev->data[0]);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", compr);
@@ -328,7 +336,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_PAL8;
c->dsize = avctx->width * avctx->height * 2;
- c->decomp_buf = av_malloc(c->dsize);
+ c->decomp_buf = av_malloc(c->dsize + DECOMP_BUF_PADDING);
if (!c->decomp_buf) {
av_frame_free(&c->prev);
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxtory.c b/chromium/third_party/ffmpeg/libavcodec/dxtory.c
index 21282b804b5..1a59ae7a048 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxtory.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxtory.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "bytestream.h"
@@ -29,14 +31,84 @@
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
-static int dxtory_decode_v1(AVCodecContext *avctx, AVFrame *pic,
- const uint8_t *src, int src_size)
+static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size,
+ int id, int bpp)
+{
+ int h;
+ uint8_t *dst;
+ int ret;
+
+ if (src_size < avctx->width * avctx->height * (int64_t)bpp) {
+ av_log(avctx, AV_LOG_ERROR, "packet too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ avctx->pix_fmt = id;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ dst = pic->data[0];
+ for (h = 0; h < avctx->height; h++) {
+ memcpy(dst, src, avctx->width * bpp);
+ src += avctx->width * bpp;
+ dst += pic->linesize[0];
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
+{
+ int h, w;
+ uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
+ int ret;
+
+ if (src_size < avctx->width * avctx->height * 9L / 8) {
+ av_log(avctx, AV_LOG_ERROR, "packet too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV410P;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ Y1 = pic->data[0];
+ Y2 = pic->data[0] + pic->linesize[0];
+ Y3 = pic->data[0] + pic->linesize[0] * 2;
+ Y4 = pic->data[0] + pic->linesize[0] * 3;
+ U = pic->data[1];
+ V = pic->data[2];
+ for (h = 0; h < avctx->height; h += 4) {
+ for (w = 0; w < avctx->width; w += 4) {
+ AV_COPY32(Y1 + w, src);
+ AV_COPY32(Y2 + w, src + 4);
+ AV_COPY32(Y3 + w, src + 8);
+ AV_COPY32(Y4 + w, src + 12);
+ U[w >> 2] = src[16] + 0x80;
+ V[w >> 2] = src[17] + 0x80;
+ src += 18;
+ }
+ Y1 += pic->linesize[0] << 2;
+ Y2 += pic->linesize[0] << 2;
+ Y3 += pic->linesize[0] << 2;
+ Y4 += pic->linesize[0] << 2;
+ U += pic->linesize[1];
+ V += pic->linesize[2];
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
{
int h, w;
uint8_t *Y1, *Y2, *U, *V;
int ret;
- if (src_size < avctx->width * avctx->height * 3 / 2) {
+ if (src_size < avctx->width * avctx->height * 3L / 2) {
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
return AVERROR_INVALIDDATA;
}
@@ -66,7 +138,42 @@ static int dxtory_decode_v1(AVCodecContext *avctx, AVFrame *pic,
return 0;
}
+static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
+{
+ int h, w;
+ uint8_t *Y, *U, *V;
+ int ret;
+
+ if (src_size < avctx->width * avctx->height * 3L) {
+ av_log(avctx, AV_LOG_ERROR, "packet too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ Y = pic->data[0];
+ U = pic->data[1];
+ V = pic->data[2];
+ for (h = 0; h < avctx->height; h++) {
+ for (w = 0; w < avctx->width; w++) {
+ Y[w] = *src++;
+ U[w] = *src++ ^ 0x80;
+ V[w] = *src++ ^ 0x80;
+ }
+ Y += pic->linesize[0];
+ U += pic->linesize[1];
+ V += pic->linesize[2];
+ }
+
+ return 0;
+}
+
static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
+static const uint8_t def_lru_555[8] = { 0x00, 0x08, 0x10, 0x18, 0x1F };
+static const uint8_t def_lru_565[8] = { 0x00, 0x08, 0x10, 0x20, 0x30, 0x3F };
static inline uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
{
@@ -85,9 +192,298 @@ static inline uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
return val;
}
-static int dx2_decode_slice(GetBitContext *gb, int width, int height,
- uint8_t *Y, uint8_t *U, uint8_t *V,
- int ystride, int ustride, int vstride)
+static inline uint8_t decode_sym_565(GetBitContext *gb, uint8_t lru[8],
+ int bits)
+{
+ uint8_t c, val;
+
+ c = get_unary(gb, 0, bits);
+ if (!c) {
+ val = get_bits(gb, bits);
+ memmove(lru + 1, lru, sizeof(*lru) * (6 - 1));
+ } else {
+ val = lru[c - 1];
+ memmove(lru + 1, lru, sizeof(*lru) * (c - 1));
+ }
+ lru[0] = val;
+
+ return val;
+}
+
+static int dx2_decode_slice_565(GetBitContext *gb, int width, int height,
+ uint8_t *dst, int stride, int is_565)
+{
+ int x, y;
+ int r, g, b;
+ uint8_t lru[3][8];
+
+ memcpy(lru[0], def_lru_555, 8 * sizeof(*def_lru));
+ memcpy(lru[1], is_565 ? def_lru_565 : def_lru_555, 8 * sizeof(*def_lru));
+ memcpy(lru[2], def_lru_555, 8 * sizeof(*def_lru));
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ b = decode_sym_565(gb, lru[0], 5);
+ g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5);
+ r = decode_sym_565(gb, lru[2], 5);
+ dst[x * 3 + 0] = (r << 3) | (r >> 2);
+ dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
+ dst[x * 3 + 2] = (b << 3) | (b >> 2);
+ }
+
+ dst += stride;
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size, int is_565)
+{
+ GetByteContext gb;
+ GetBitContext gb2;
+ int nslices, slice, slice_height;
+ uint32_t off, slice_size;
+ uint8_t *dst;
+ int ret;
+
+ bytestream2_init(&gb, src, src_size);
+ nslices = bytestream2_get_le16(&gb);
+ off = FFALIGN(nslices * 4 + 2, 16);
+ if (src_size < off) {
+ av_log(avctx, AV_LOG_ERROR, "no slice data\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!nslices || avctx->height % nslices) {
+ avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
+ avctx->width, avctx->height);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ slice_height = avctx->height / nslices;
+ avctx->pix_fmt = AV_PIX_FMT_RGB24;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ dst = pic->data[0];
+ for (slice = 0; slice < nslices; slice++) {
+ slice_size = bytestream2_get_le32(&gb);
+ if (slice_size > src_size - off) {
+ av_log(avctx, AV_LOG_ERROR,
+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n",
+ slice_size, src_size - off);
+ return AVERROR_INVALIDDATA;
+ }
+ if (slice_size <= 16) {
+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (AV_RL32(src + off) != slice_size - 16) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n",
+ AV_RL32(src + off), slice_size - 16);
+ }
+ init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
+ dx2_decode_slice_565(&gb2, avctx->width, slice_height, dst,
+ pic->linesize[0], is_565);
+
+ dst += pic->linesize[0] * slice_height;
+ off += slice_size;
+ }
+
+ return 0;
+}
+
+static int dx2_decode_slice_rgb(GetBitContext *gb, int width, int height,
+ uint8_t *dst, int stride)
+{
+ int x, y, i;
+ uint8_t lru[3][8];
+
+ for (i = 0; i < 3; i++)
+ memcpy(lru[i], def_lru, 8 * sizeof(*def_lru));
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dst[x * 3 + 0] = decode_sym(gb, lru[0]);
+ dst[x * 3 + 1] = decode_sym(gb, lru[1]);
+ dst[x * 3 + 2] = decode_sym(gb, lru[2]);
+ }
+
+ dst += stride;
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
+{
+ GetByteContext gb;
+ GetBitContext gb2;
+ int nslices, slice, slice_height;
+ uint32_t off, slice_size;
+ uint8_t *dst;
+ int ret;
+
+ bytestream2_init(&gb, src, src_size);
+ nslices = bytestream2_get_le16(&gb);
+ off = FFALIGN(nslices * 4 + 2, 16);
+ if (src_size < off) {
+ av_log(avctx, AV_LOG_ERROR, "no slice data\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!nslices || avctx->height % nslices) {
+ avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
+ avctx->width, avctx->height);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ slice_height = avctx->height / nslices;
+ avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ dst = pic->data[0];
+ for (slice = 0; slice < nslices; slice++) {
+ slice_size = bytestream2_get_le32(&gb);
+ if (slice_size > src_size - off) {
+ av_log(avctx, AV_LOG_ERROR,
+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n",
+ slice_size, src_size - off);
+ return AVERROR_INVALIDDATA;
+ }
+ if (slice_size <= 16) {
+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n",
+ slice_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (AV_RL32(src + off) != slice_size - 16) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n",
+ AV_RL32(src + off), slice_size - 16);
+ }
+ init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
+ dx2_decode_slice_rgb(&gb2, avctx->width, slice_height, dst,
+ pic->linesize[0]);
+
+ dst += pic->linesize[0] * slice_height;
+ off += slice_size;
+ }
+
+ return 0;
+}
+
+static int dx2_decode_slice_410(GetBitContext *gb, int width, int height,
+ uint8_t *Y, uint8_t *U, uint8_t *V,
+ int ystride, int ustride, int vstride)
+{
+ int x, y, i, j;
+ uint8_t lru[3][8];
+
+ for (i = 0; i < 3; i++)
+ memcpy(lru[i], def_lru, 8 * sizeof(*def_lru));
+
+ for (y = 0; y < height; y += 4) {
+ for (x = 0; x < width; x += 4) {
+ for (j = 0; j < 4; j++)
+ for (i = 0; i < 4; i++)
+ Y[x + i + j * ystride] = decode_sym(gb, lru[0]);
+ U[x >> 2] = decode_sym(gb, lru[1]) ^ 0x80;
+ V[x >> 2] = decode_sym(gb, lru[2]) ^ 0x80;
+ }
+
+ Y += ystride << 2;
+ U += ustride;
+ V += vstride;
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v2_410(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
+{
+ GetByteContext gb;
+ GetBitContext gb2;
+ int nslices, slice, slice_height, ref_slice_height;
+ int cur_y, next_y;
+ uint32_t off, slice_size;
+ uint8_t *Y, *U, *V;
+ int ret;
+
+ bytestream2_init(&gb, src, src_size);
+ nslices = bytestream2_get_le16(&gb);
+ off = FFALIGN(nslices * 4 + 2, 16);
+ if (src_size < off) {
+ av_log(avctx, AV_LOG_ERROR, "no slice data\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!nslices || avctx->height % nslices) {
+ avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
+ avctx->width, avctx->height);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ ref_slice_height = avctx->height / nslices;
+ if ((avctx->width & 3) || (avctx->height & 3)) {
+ avpriv_request_sample(avctx, "Frame dimensions %dx%d",
+ avctx->width, avctx->height);
+ }
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV410P;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ Y = pic->data[0];
+ U = pic->data[1];
+ V = pic->data[2];
+
+ cur_y = 0;
+ next_y = ref_slice_height;
+ for (slice = 0; slice < nslices; slice++) {
+ slice_size = bytestream2_get_le32(&gb);
+ slice_height = (next_y & ~3) - (cur_y & ~3);
+ if (slice_size > src_size - off) {
+ av_log(avctx, AV_LOG_ERROR,
+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n",
+ slice_size, src_size - off);
+ return AVERROR_INVALIDDATA;
+ }
+ if (slice_size <= 16) {
+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (AV_RL32(src + off) != slice_size - 16) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n",
+ AV_RL32(src + off), slice_size - 16);
+ }
+ init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
+ dx2_decode_slice_410(&gb2, avctx->width, slice_height, Y, U, V,
+ pic->linesize[0], pic->linesize[1],
+ pic->linesize[2]);
+
+ Y += pic->linesize[0] * slice_height;
+ U += pic->linesize[1] * (slice_height >> 2);
+ V += pic->linesize[2] * (slice_height >> 2);
+ off += slice_size;
+ cur_y = next_y;
+ next_y += ref_slice_height;
+ }
+
+ return 0;
+}
+
+static int dx2_decode_slice_420(GetBitContext *gb, int width, int height,
+ uint8_t *Y, uint8_t *U, uint8_t *V,
+ int ystride, int ustride, int vstride)
{
int x, y, i;
uint8_t lru[3][8];
@@ -113,12 +509,13 @@ static int dx2_decode_slice(GetBitContext *gb, int width, int height,
return 0;
}
-static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
- const uint8_t *src, int src_size)
+static int dxtory_decode_v2_420(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
{
GetByteContext gb;
GetBitContext gb2;
- int nslices, slice, slice_height;
+ int nslices, slice, slice_height, ref_slice_height;
+ int cur_y, next_y;
uint32_t off, slice_size;
uint8_t *Y, *U, *V;
int ret;
@@ -134,13 +531,13 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
if (!nslices || avctx->height % nslices) {
avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
avctx->width, avctx->height);
- return AVERROR(ENOSYS);
+ return AVERROR_PATCHWELCOME;
}
- slice_height = avctx->height / nslices;
- if ((avctx->width & 1) || (slice_height & 1)) {
- avpriv_request_sample(avctx, "slice dimensions %dx%d",
- avctx->width, slice_height);
+ ref_slice_height = avctx->height / nslices;
+ if ((avctx->width & 1) || (avctx->height & 1)) {
+ avpriv_request_sample(avctx, "Frame dimensions %dx%d",
+ avctx->width, avctx->height);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@ -151,32 +548,129 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
U = pic->data[1];
V = pic->data[2];
+ cur_y = 0;
+ next_y = ref_slice_height;
for (slice = 0; slice < nslices; slice++) {
- slice_size = bytestream2_get_le32(&gb);
+ slice_size = bytestream2_get_le32(&gb);
+ slice_height = (next_y & ~1) - (cur_y & ~1);
if (slice_size > src_size - off) {
av_log(avctx, AV_LOG_ERROR,
- "invalid slice size %d (only %d bytes left)\n",
+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n",
slice_size, src_size - off);
return AVERROR_INVALIDDATA;
}
if (slice_size <= 16) {
- av_log(avctx, AV_LOG_ERROR, "invalid slice size %d\n", slice_size);
+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size);
return AVERROR_INVALIDDATA;
}
if (AV_RL32(src + off) != slice_size - 16) {
av_log(avctx, AV_LOG_ERROR,
- "Slice sizes mismatch: got %d instead of %d\n",
+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n",
AV_RL32(src + off), slice_size - 16);
}
init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
- dx2_decode_slice(&gb2, avctx->width, slice_height, Y, U, V,
- pic->linesize[0], pic->linesize[1], pic->linesize[2]);
+ dx2_decode_slice_420(&gb2, avctx->width, slice_height, Y, U, V,
+ pic->linesize[0], pic->linesize[1],
+ pic->linesize[2]);
Y += pic->linesize[0] * slice_height;
U += pic->linesize[1] * (slice_height >> 1);
V += pic->linesize[2] * (slice_height >> 1);
off += slice_size;
+ cur_y = next_y;
+ next_y += ref_slice_height;
+ }
+
+ return 0;
+}
+
+static int dx2_decode_slice_444(GetBitContext *gb, int width, int height,
+ uint8_t *Y, uint8_t *U, uint8_t *V,
+ int ystride, int ustride, int vstride)
+{
+ int x, y, i;
+ uint8_t lru[3][8];
+
+ for (i = 0; i < 3; i++)
+ memcpy(lru[i], def_lru, 8 * sizeof(*def_lru));
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ Y[x] = decode_sym(gb, lru[0]);
+ U[x] = decode_sym(gb, lru[1]) ^ 0x80;
+ V[x] = decode_sym(gb, lru[2]) ^ 0x80;
+ }
+
+ Y += ystride;
+ U += ustride;
+ V += vstride;
+ }
+
+ return 0;
+}
+
+static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic,
+ const uint8_t *src, int src_size)
+{
+ GetByteContext gb;
+ GetBitContext gb2;
+ int nslices, slice, slice_height;
+ uint32_t off, slice_size;
+ uint8_t *Y, *U, *V;
+ int ret;
+
+ bytestream2_init(&gb, src, src_size);
+ nslices = bytestream2_get_le16(&gb);
+ off = FFALIGN(nslices * 4 + 2, 16);
+ if (src_size < off) {
+ av_log(avctx, AV_LOG_ERROR, "no slice data\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!nslices || avctx->height % nslices) {
+ avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
+ avctx->width, avctx->height);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ slice_height = avctx->height / nslices;
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+ if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
+ return ret;
+
+ Y = pic->data[0];
+ U = pic->data[1];
+ V = pic->data[2];
+
+ for (slice = 0; slice < nslices; slice++) {
+ slice_size = bytestream2_get_le32(&gb);
+ if (slice_size > src_size - off) {
+ av_log(avctx, AV_LOG_ERROR,
+ "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n",
+ slice_size, src_size - off);
+ return AVERROR_INVALIDDATA;
+ }
+ if (slice_size <= 16) {
+ av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (AV_RL32(src + off) != slice_size - 16) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n",
+ AV_RL32(src + off), slice_size - 16);
+ }
+ init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
+ dx2_decode_slice_444(&gb2, avctx->width, slice_height, Y, U, V,
+ pic->linesize[0], pic->linesize[1],
+ pic->linesize[2]);
+
+ Y += pic->linesize[0] * slice_height;
+ U += pic->linesize[1] * slice_height;
+ V += pic->linesize[2] * slice_height;
+ off += slice_size;
}
return 0;
@@ -195,14 +689,49 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
}
switch (AV_RB32(src)) {
+ case 0x01000001:
+ ret = dxtory_decode_v1_rgb(avctx, pic, src + 16, avpkt->size - 16,
+ AV_PIX_FMT_BGR24, 3);
+ break;
+ case 0x01000009:
+ ret = dxtory_decode_v2_rgb(avctx, pic, src + 16, avpkt->size - 16);
+ break;
case 0x02000001:
- ret = dxtory_decode_v1(avctx, pic, src + 16, avpkt->size - 16);
+ ret = dxtory_decode_v1_420(avctx, pic, src + 16, avpkt->size - 16);
break;
case 0x02000009:
- ret = dxtory_decode_v2(avctx, pic, src + 16, avpkt->size - 16);
+ ret = dxtory_decode_v2_420(avctx, pic, src + 16, avpkt->size - 16);
+ break;
+ case 0x03000001:
+ ret = dxtory_decode_v1_410(avctx, pic, src + 16, avpkt->size - 16);
+ break;
+ case 0x03000009:
+ ret = dxtory_decode_v2_410(avctx, pic, src + 16, avpkt->size - 16);
+ break;
+ case 0x04000001:
+ ret = dxtory_decode_v1_444(avctx, pic, src + 16, avpkt->size - 16);
+ break;
+ case 0x04000009:
+ ret = dxtory_decode_v2_444(avctx, pic, src + 16, avpkt->size - 16);
+ break;
+ case 0x17000001:
+ ret = dxtory_decode_v1_rgb(avctx, pic, src + 16, avpkt->size - 16,
+ AV_PIX_FMT_RGB565LE, 2);
+ break;
+ case 0x17000009:
+ ret = dxtory_decode_v2_565(avctx, pic, src + 16, avpkt->size - 16, 1);
+ break;
+ case 0x18000001:
+ case 0x19000001:
+ ret = dxtory_decode_v1_rgb(avctx, pic, src + 16, avpkt->size - 16,
+ AV_PIX_FMT_RGB555LE, 2);
+ break;
+ case 0x18000009:
+ case 0x19000009:
+ ret = dxtory_decode_v2_565(avctx, pic, src + 16, avpkt->size - 16, 0);
break;
default:
- avpriv_request_sample(avctx, "Frame header %X", AV_RB32(src));
+ avpriv_request_sample(avctx, "Frame header %"PRIX32, AV_RB32(src));
return AVERROR_PATCHWELCOME;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2.c b/chromium/third_party/ffmpeg/libavcodec/dxva2.c
index 0997c736778..c1c7681402a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2.c
@@ -20,17 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <assert.h>
+#include <string.h>
+
+#include "libavutil/log.h"
+#include "libavutil/time.h"
+
+#include "avcodec.h"
+#include "mpegvideo.h"
#include "dxva2_internal.h"
-void *ff_dxva2_get_surface(const Picture *picture)
+void *ff_dxva2_get_surface(const AVFrame *frame)
{
- return picture->f.data[3];
+ return frame->data[3];
}
unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx,
- const Picture *picture)
+ const AVFrame *frame)
{
- void *surface = ff_dxva2_get_surface(picture);
+ void *surface = ff_dxva2_get_surface(frame);
unsigned i;
for (i = 0; i < ctx->surface_count; i++)
@@ -50,10 +58,13 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
void *dxva_data;
unsigned dxva_size;
int result;
+ HRESULT hr;
- if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder, type,
- &dxva_data, &dxva_size))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %d\n", type);
+ hr = IDirectXVideoDecoder_GetBuffer(ctx->decoder, type,
+ &dxva_data, &dxva_size);
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%lx\n",
+ type, hr);
return -1;
}
if (size <= dxva_size) {
@@ -66,17 +77,21 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
result = 0;
} else {
- av_log(avctx, AV_LOG_ERROR, "Buffer for type %d was too small\n", type);
+ av_log(avctx, AV_LOG_ERROR, "Buffer for type %u was too small\n", type);
result = -1;
}
- if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder, type))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to release buffer type %d\n", type);
+
+ hr = IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder, type);
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Failed to release buffer type %u: 0x%lx\n",
+ type, hr);
result = -1;
}
return result;
}
-int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
+int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *,
@@ -87,12 +102,19 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
unsigned buffer_count = 0;
DXVA2_DecodeBufferDesc buffer[4];
DXVA2_DecodeExecuteParams exec = { 0 };
- int result;
-
- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
- ff_dxva2_get_surface(pic),
- NULL))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
+ int result, runs = 0;
+ HRESULT hr;
+
+ do {
+ hr = IDirectXVideoDecoder_BeginFrame(ctx->decoder,
+ ff_dxva2_get_surface(frame),
+ NULL);
+ if (hr == E_PENDING)
+ av_usleep(2000);
+ } while (hr == E_PENDING && ++runs < 50);
+
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);
return -1;
}
@@ -135,14 +157,16 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
exec.NumCompBuffers = buffer_count;
exec.pCompressedBuffers = buffer;
exec.pExtensionData = NULL;
- if (FAILED(IDirectXVideoDecoder_Execute(ctx->decoder, &exec))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to execute\n");
+ hr = IDirectXVideoDecoder_Execute(ctx->decoder, &exec);
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%lx\n", hr);
result = -1;
}
end:
- if (FAILED(IDirectXVideoDecoder_EndFrame(ctx->decoder, NULL))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to end frame\n");
+ hr = IDirectXVideoDecoder_EndFrame(ctx->decoder, NULL);
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%lx\n", hr);
result = -1;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2.h b/chromium/third_party/ffmpeg/libavcodec/dxva2.h
index ac39e06917b..2639d89d909 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2.h
@@ -49,6 +49,7 @@
*/
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
+#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for DXVA2 and old Intel GPUs with ClearVideo interface
/**
* This structure is used to provides the necessary configurations and data
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2_h264.c b/chromium/third_party/ffmpeg/libavcodec/dxva2_h264.c
index 10905026be6..1174188959c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2_h264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2_h264.c
@@ -23,6 +23,7 @@
#include "dxva2_internal.h"
#include "h264.h"
#include "h264data.h"
+#include "mpegutils.h"
struct dxva2_picture_context {
DXVA_PicParams_H264 pp;
@@ -44,19 +45,19 @@ static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
static void fill_picture_parameters(struct dxva_context *ctx, const H264Context *h,
DXVA_PicParams_H264 *pp)
{
- const Picture *current_picture = h->cur_pic_ptr;
+ const H264Picture *current_picture = h->cur_pic_ptr;
int i, j;
memset(pp, 0, sizeof(*pp));
/* Configure current picture */
fill_picture_entry(&pp->CurrPic,
- ff_dxva2_get_surface_index(ctx, current_picture),
+ ff_dxva2_get_surface_index(ctx, &current_picture->f),
h->picture_structure == PICT_BOTTOM_FIELD);
/* Configure the set of references */
pp->UsedForReferenceFlags = 0;
pp->NonExistingFrameFlags = 0;
for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->RefFrameList); i++) {
- const Picture *r;
+ const H264Picture *r;
if (j < h->short_ref_count) {
r = h->short_ref[j++];
} else {
@@ -66,7 +67,7 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
}
if (r) {
fill_picture_entry(&pp->RefFrameList[i],
- ff_dxva2_get_surface_index(ctx, r),
+ ff_dxva2_get_surface_index(ctx, &r->f),
r->long_ref != 0);
if ((r->reference & PICT_TOP_FIELD) && r->field_poc[0] != INT_MAX)
@@ -115,6 +116,8 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
pp->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8;
if (ctx->workaround & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG)
pp->Reserved16Bits = 0;
+ else if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
+ pp->Reserved16Bits = 0x34c;
else
pp->Reserved16Bits = 3; /* FIXME is there a way to detect the right mode ? */
pp->StatusReportFeedbackNumber = 1 + ctx->report_id++;
@@ -194,8 +197,18 @@ static void fill_slice_short(DXVA_Slice_H264_Short *slice,
slice->wBadSliceChopping = 0;
}
+static int get_refpic_index(const DXVA_PicParams_H264 *pp, int surface_index)
+{
+ int i;
+ for (i = 0; i < FF_ARRAY_ELEMS(pp->RefFrameList); i++) {
+ if ((pp->RefFrameList[i].bPicEntry & 0x7f) == surface_index)
+ return i;
+ }
+ return 0x7f;
+}
+
static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
- unsigned position, unsigned size)
+ const DXVA_PicParams_H264 *pp, unsigned position, unsigned size)
{
const H264Context *h = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context;
@@ -218,18 +231,22 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1;
if (h->list_count > 1)
slice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1;
- slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2 - 26;
- slice->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26;
+ slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
+ slice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice->Reserved8Bits = 0;
for (list = 0; list < 2; list++) {
unsigned i;
for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) {
if (list < h->list_count && i < h->ref_count[list]) {
- const Picture *r = &h->ref_list[list][i];
+ const H264Picture *r = &h->ref_list[list][i];
unsigned plane;
- fill_picture_entry(&slice->RefPicList[list][i],
- ff_dxva2_get_surface_index(ctx, r),
+ unsigned index;
+ if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
+ index = ff_dxva2_get_surface_index(ctx, &r->f);
+ else
+ index = get_refpic_index(pp, ff_dxva2_get_surface_index(ctx, &r->f));
+ fill_picture_entry(&slice->RefPicList[list][i], index,
r->reference == PICT_BOTTOM_FIELD);
for (plane = 0; plane < 3; plane++) {
int w, o;
@@ -277,7 +294,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
const H264Context *h = avctx->priv_data;
const unsigned mb_count = h->mb_width * h->mb_height;
struct dxva_context *ctx = avctx->hwaccel_context;
- const Picture *current_picture = h->cur_pic_ptr;
+ const H264Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
DXVA_Slice_H264_Short *slice = NULL;
uint8_t *dxva_data, *current, *end;
@@ -397,7 +414,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
{
const H264Context *h = avctx->priv_data;
struct dxva_context *ctx = avctx->hwaccel_context;
- const Picture *current_picture = h->cur_pic_ptr;
+ const H264Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
unsigned position;
@@ -414,7 +431,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
position, size);
else
fill_slice_long(avctx, &ctx_pic->slice_long[ctx_pic->slice_count],
- position, size);
+ &ctx_pic->pp, position, size);
ctx_pic->slice_count++;
if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI)
@@ -431,7 +448,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
- ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr,
+ ret = ff_dxva2_common_end_frame(avctx, &h->cur_pic_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
@@ -448,5 +465,5 @@ AVHWAccel ff_h264_dxva2_hwaccel = {
.start_frame = dxva2_h264_start_frame,
.decode_slice = dxva2_h264_decode_slice,
.end_frame = dxva2_h264_end_frame,
- .priv_data_size = sizeof(struct dxva2_picture_context),
+ .frame_priv_data_size = sizeof(struct dxva2_picture_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2_internal.h b/chromium/third_party/ffmpeg/libavcodec/dxva2_internal.h
index 8a454c12997..427c1ffdf80 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2_internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2_internal.h
@@ -35,10 +35,10 @@
#include "avcodec.h"
#include "mpegvideo.h"
-void *ff_dxva2_get_surface(const Picture *picture);
+void *ff_dxva2_get_surface(const AVFrame *frame);
unsigned ff_dxva2_get_surface_index(const struct dxva_context *,
- const Picture *picture);
+ const AVFrame *frame);
int ff_dxva2_commit_buffer(AVCodecContext *, struct dxva_context *,
DXVA2_DecodeBufferDesc *,
@@ -46,7 +46,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *, struct dxva_context *,
unsigned mb_count);
-int ff_dxva2_common_end_frame(AVCodecContext *, Picture *,
+int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *,
const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *,
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2_mpeg2.c b/chromium/third_party/ffmpeg/libavcodec/dxva2_mpeg2.c
index 1827dd526f4..5fa4424d5f8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2_mpeg2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2_mpeg2.c
@@ -20,9 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/log.h"
#include "dxva2_internal.h"
+#include "mpegutils.h"
-#define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1)
+#define MAX_SLICES 1024
struct dxva2_picture_context {
DXVA_PictureParameters pp;
DXVA_QmatrixData qm;
@@ -42,14 +44,14 @@ static void fill_picture_parameters(AVCodecContext *avctx,
int is_field = s->picture_structure != PICT_FRAME;
memset(pp, 0, sizeof(*pp));
- pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture);
+ pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture->f);
pp->wDeblockedPictureIndex = 0;
if (s->pict_type != AV_PICTURE_TYPE_I)
- pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture);
+ pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B)
- pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture);
+ pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
pp->wPicWidthInMBminus1 = s->mb_width - 1;
@@ -232,9 +234,11 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx,
s->current_picture_ptr->hwaccel_picture_private;
unsigned position;
- if (ctx_pic->slice_count >= MAX_SLICES)
+ if (ctx_pic->slice_count >= MAX_SLICES) {
+ avpriv_request_sample(avctx, "%d slices in dxva2",
+ ctx_pic->slice_count);
return -1;
-
+ }
if (!ctx_pic->bitstream)
ctx_pic->bitstream = buffer;
ctx_pic->bitstream_size += size;
@@ -254,7 +258,7 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
- ret = ff_dxva2_common_end_frame(avctx, s->current_picture_ptr,
+ ret = ff_dxva2_common_end_frame(avctx, s->current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
@@ -271,5 +275,5 @@ AVHWAccel ff_mpeg2_dxva2_hwaccel = {
.start_frame = dxva2_mpeg2_start_frame,
.decode_slice = dxva2_mpeg2_decode_slice,
.end_frame = dxva2_mpeg2_end_frame,
- .priv_data_size = sizeof(struct dxva2_picture_context),
+ .frame_priv_data_size = sizeof(struct dxva2_picture_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/dxva2_vc1.c b/chromium/third_party/ffmpeg/libavcodec/dxva2_vc1.c
index 2e9a00eb077..b2b5cedc178 100644
--- a/chromium/third_party/ffmpeg/libavcodec/dxva2_vc1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/dxva2_vc1.c
@@ -21,6 +21,7 @@
*/
#include "dxva2_internal.h"
+#include "mpegutils.h"
#include "vc1.h"
#include "vc1data.h"
@@ -38,16 +39,25 @@ static void fill_picture_parameters(AVCodecContext *avctx,
{
const MpegEncContext *s = &v->s;
const Picture *current_picture = s->current_picture_ptr;
+ int intcomp = 0;
+
+ // determine if intensity compensation is needed
+ if (s->pict_type == AV_PICTURE_TYPE_P) {
+ if ((v->fcm == ILACE_FRAME && v->intcomp) || (v->fcm != ILACE_FRAME && v->mv_mode == MV_PMODE_INTENSITY_COMP)) {
+ if (v->lumscale != 32 || v->lumshift != 0 || (s->picture_structure != PICT_FRAME && (v->lumscale2 != 32 || v->lumshift2 != 0)))
+ intcomp = 1;
+ }
+ }
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex =
- pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture);
+ pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture->f);
if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type)
- pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture);
+ pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type)
- pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture);
+ pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
if (v->profile == PROFILE_ADVANCED) {
@@ -74,7 +84,7 @@ static void fill_picture_parameters(AVCodecContext *avctx,
pp->bBidirectionalAveragingMode = (1 << 7) |
((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) |
((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) |
- ((v->lumscale != 32 || v->lumshift != 0) << 4) |
+ (intcomp << 4) |
((v->profile == PROFILE_ADVANCED) << 3);
pp->bMVprecisionAndChromaRelation = ((v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
(1 << 2) |
@@ -122,15 +132,25 @@ static void fill_picture_parameters(AVCodecContext *avctx,
(v->range_mapuv_flag << 3) |
(v->range_mapuv );
pp->bPicBinPB = 0;
- pp->bMV_RPS = 0;
- pp->bReservedBits = 0;
+ pp->bMV_RPS = (v->fcm == ILACE_FIELD && pp->bPicBackwardPrediction) ? v->refdist + 9 : 0;
+ pp->bReservedBits = v->pq;
if (s->picture_structure == PICT_FRAME) {
- pp->wBitstreamFcodes = v->lumscale;
- pp->wBitstreamPCEelements = v->lumshift;
+ if (intcomp) {
+ pp->wBitstreamFcodes = v->lumscale;
+ pp->wBitstreamPCEelements = v->lumshift;
+ } else {
+ pp->wBitstreamFcodes = 32;
+ pp->wBitstreamPCEelements = 0;
+ }
} else {
/* Syntax: (top_field_param << 8) | bottom_field_param */
- pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale;
- pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift;
+ if (intcomp) {
+ pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale2;
+ pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift2;
+ } else {
+ pp->wBitstreamFcodes = (32 << 8) | 32;
+ pp->wBitstreamPCEelements = 0;
+ }
}
pp->bBitstreamConcealmentNeed = 0;
pp->bBitstreamConcealmentMethod = 0;
@@ -148,8 +168,8 @@ static void fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice,
slice->dwSliceBitsInBuffer = 8 * size;
slice->dwSliceDataLocation = position;
slice->bStartCodeBitOffset = 0;
- slice->bReservedBits = 0;
- slice->wMBbitOffset = get_bits_count(&s->gb);
+ slice->bReservedBits = (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type) ? v->bfraction_lut_index + 9 : 0;
+ slice->wMBbitOffset = v->p_frame_skipped ? 0xffff : get_bits_count(&s->gb) + (avctx->codec_id == AV_CODEC_ID_VC1 ? 32 : 0);
slice->wNumberMBsInSlice = s->mb_width * s->mb_height; /* XXX We assume 1 slice */
slice->wQuantizerScaleCode = v->pq;
slice->wBadSliceChopping = 0;
@@ -263,7 +283,7 @@ static int dxva2_vc1_end_frame(AVCodecContext *avctx)
if (ctx_pic->bitstream_size <= 0)
return -1;
- ret = ff_dxva2_common_end_frame(avctx, v->s.current_picture_ptr,
+ ret = ff_dxva2_common_end_frame(avctx, v->s.current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
NULL, 0,
commit_bitstream_and_slice_buffer);
@@ -281,7 +301,7 @@ AVHWAccel ff_wmv3_dxva2_hwaccel = {
.start_frame = dxva2_vc1_start_frame,
.decode_slice = dxva2_vc1_decode_slice,
.end_frame = dxva2_vc1_end_frame,
- .priv_data_size = sizeof(struct dxva2_picture_context),
+ .frame_priv_data_size = sizeof(struct dxva2_picture_context),
};
#endif
@@ -293,5 +313,5 @@ AVHWAccel ff_vc1_dxva2_hwaccel = {
.start_frame = dxva2_vc1_start_frame,
.decode_slice = dxva2_vc1_decode_slice,
.end_frame = dxva2_vc1_end_frame,
- .priv_data_size = sizeof(struct dxva2_picture_context),
+ .frame_priv_data_size = sizeof(struct dxva2_picture_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/eac3dec.c b/chromium/third_party/ffmpeg/libavcodec/eac3dec.c
index b55ee2a34c2..8e931fddeb6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/eac3dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/eac3dec.c
@@ -345,23 +345,22 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
/* center and surround mix levels */
if (s->channel_mode > AC3_CHMODE_STEREO) {
- skip_bits(gbc, 2); // skip preferred stereo downmix mode
+ s->preferred_downmix = get_bits(gbc, 2);
if (s->channel_mode & 1) {
/* if three front channels exist */
- skip_bits(gbc, 3); //skip Lt/Rt center mix level
- s->center_mix_level = get_bits(gbc, 3);
+ s->center_mix_level_ltrt = get_bits(gbc, 3);
+ s->center_mix_level = get_bits(gbc, 3);
}
if (s->channel_mode & 4) {
/* if a surround channel exists */
- skip_bits(gbc, 3); //skip Lt/Rt surround mix level
- s->surround_mix_level = get_bits(gbc, 3);
+ s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
+ s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
}
}
/* lfe mix level */
- if (s->lfe_on && get_bits1(gbc)) {
- // TODO: use LFE mix level
- skip_bits(gbc, 5); // skip LFE mix level code
+ if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
+ s->lfe_mix_level = get_bits(gbc, 5);
}
/* info for mixing with other streams and substreams */
@@ -413,10 +412,11 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
s->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2); // skip copyright bit and original bitstream bit
if (s->channel_mode == AC3_CHMODE_STEREO) {
- skip_bits(gbc, 4); // skip Dolby surround and headphone mode
+ s->dolby_surround_mode = get_bits(gbc, 2);
+ s->dolby_headphone_mode = get_bits(gbc, 2);
}
if (s->channel_mode >= AC3_CHMODE_2F2R) {
- skip_bits(gbc, 2); // skip Dolby surround EX mode
+ s->dolby_surround_ex_mode = get_bits(gbc, 2);
}
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/eacmv.c b/chromium/third_party/ffmpeg/libavcodec/eacmv.c
index b3ffb3f07b9..4a1af8cf435 100644
--- a/chromium/third_party/ffmpeg/libavcodec/eacmv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/eacmv.c
@@ -132,7 +132,7 @@ static void cmv_decode_inter(CmvContext *s, AVFrame *frame, const uint8_t *buf,
static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)
{
- int pal_start, pal_count, i, ret;
+ int pal_start, pal_count, i, ret, fps;
if(buf_end - buf < 16) {
av_log(s->avctx, AV_LOG_WARNING, "truncated header\n");
@@ -141,16 +141,20 @@ static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *
s->width = AV_RL16(&buf[4]);
s->height = AV_RL16(&buf[6]);
- if (s->avctx->width!=s->width || s->avctx->height!=s->height) {
+
+ if (s->width != s->avctx->width ||
+ s->height != s->avctx->height) {
av_frame_unref(s->last_frame);
av_frame_unref(s->last2_frame);
- ret = ff_set_dimensions(s->avctx, s->width, s->height);
- if (ret < 0)
- return ret;
}
- s->avctx->time_base.num = 1;
- s->avctx->time_base.den = AV_RL16(&buf[10]);
+ ret = ff_set_dimensions(s->avctx, s->width, s->height);
+ if (ret < 0)
+ return ret;
+
+ fps = AV_RL16(&buf[10]);
+ if (fps > 0)
+ s->avctx->time_base = (AVRational){ 1, fps };
pal_start = AV_RL16(&buf[12]);
pal_count = AV_RL16(&buf[14]);
diff --git a/chromium/third_party/ffmpeg/libavcodec/eamad.c b/chromium/third_party/ffmpeg/libavcodec/eamad.c
index 2d34d35a545..c0433057853 100644
--- a/chromium/third_party/ffmpeg/libavcodec/eamad.c
+++ b/chromium/third_party/ffmpeg/libavcodec/eamad.c
@@ -195,7 +195,7 @@ static int decode_motion(GetBitContext *gb)
static int decode_mb(MadContext *s, AVFrame *frame, int inter)
{
int mv_map = 0;
- int mv_x, mv_y;
+ int av_uninit(mv_x), av_uninit(mv_y);
int j;
if (inter) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/eatgv.c b/chromium/third_party/ffmpeg/libavcodec/eatgv.c
index 952ebb3c34c..f204a1344cd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/eatgv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/eatgv.c
@@ -311,7 +311,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
frame->pict_type = AV_PICTURE_TYPE_I;
if (!s->frame_buffer &&
- !(s->frame_buffer = av_malloc(s->width * s->height)))
+ !(s->frame_buffer = av_mallocz(s->width * s->height)))
return AVERROR(ENOMEM);
if (unpack(buf, buf_end, s->frame_buffer, s->avctx->width, s->avctx->height) < 0) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/elbg.c b/chromium/third_party/ffmpeg/libavcodec/elbg.c
index 5c7018b4752..9bbb6d88ac9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/elbg.c
+++ b/chromium/third_party/ffmpeg/libavcodec/elbg.c
@@ -51,7 +51,7 @@ typedef struct{
int *codebook;
cell **cells;
int *utility;
- int *utility_inc;
+ int64_t *utility_inc;
int *nearest_cb;
int *points;
AVLFG *rand_state;
@@ -108,9 +108,18 @@ static int get_high_utility_cell(elbg_data *elbg)
{
int i=0;
/* Using linear search, do binary if it ever turns to be speed critical */
- int r = av_lfg_get(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1] + 1;
- while (elbg->utility_inc[i] < r)
+ uint64_t r;
+
+ if (elbg->utility_inc[elbg->numCB-1] < INT_MAX) {
+ r = av_lfg_get(elbg->rand_state) % (unsigned int)elbg->utility_inc[elbg->numCB-1] + 1;
+ } else {
+ r = av_lfg_get(elbg->rand_state);
+ r = (av_lfg_get(elbg->rand_state) + (r<<32)) % elbg->utility_inc[elbg->numCB-1] + 1;
+ }
+
+ while (elbg->utility_inc[i] < r) {
i++;
+ }
av_assert2(elbg->cells[i]);
@@ -227,7 +236,8 @@ static void shift_codebook(elbg_data *elbg, int *indexes,
static void evaluate_utility_inc(elbg_data *elbg)
{
- int i, inc=0;
+ int i;
+ int64_t inc=0;
for (i=0; i < elbg->numCB; i++) {
if (elbg->numCB*elbg->utility[i] > elbg->error)
@@ -333,7 +343,7 @@ void avpriv_init_elbg(int *points, int dim, int numpoints, int *codebook,
if (numpoints > 24*numCB) {
/* ELBG is very costly for a big number of points. So if we have a lot
of them, get a good initial codebook to save on iterations */
- int *temp_points = av_malloc(dim*(numpoints/8)*sizeof(int));
+ int *temp_points = av_malloc_array(dim, (numpoints/8)*sizeof(int));
for (i=0; i<numpoints/8; i++) {
k = (i*BIG_PRIME) % numpoints;
memcpy(temp_points + i*dim, points + k*dim, dim*sizeof(int));
@@ -359,9 +369,9 @@ void avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
elbg_data elbg_d;
elbg_data *elbg = &elbg_d;
int i, j, k, last_error, steps=0;
- int *dist_cb = av_malloc(numpoints*sizeof(int));
- int *size_part = av_malloc(numCB*sizeof(int));
- cell *list_buffer = av_malloc(numpoints*sizeof(cell));
+ int *dist_cb = av_malloc_array(numpoints, sizeof(int));
+ int *size_part = av_malloc_array(numCB, sizeof(int));
+ cell *list_buffer = av_malloc_array(numpoints, sizeof(cell));
cell *free_cells;
int best_dist, best_idx = 0;
@@ -369,12 +379,12 @@ void avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
elbg->dim = dim;
elbg->numCB = numCB;
elbg->codebook = codebook;
- elbg->cells = av_malloc(numCB*sizeof(cell *));
- elbg->utility = av_malloc(numCB*sizeof(int));
+ elbg->cells = av_malloc_array(numCB, sizeof(cell *));
+ elbg->utility = av_malloc_array(numCB, sizeof(int));
elbg->nearest_cb = closest_cb;
elbg->points = points;
- elbg->utility_inc = av_malloc(numCB*sizeof(int));
- elbg->scratchbuf = av_malloc(5*dim*sizeof(int));
+ elbg->utility_inc = av_malloc_array(numCB, sizeof(*elbg->utility_inc));
+ elbg->scratchbuf = av_malloc_array(5*dim, sizeof(int));
elbg->rand_state = rand_state;
diff --git a/chromium/third_party/ffmpeg/libavcodec/error_resilience.c b/chromium/third_party/ffmpeg/libavcodec/error_resilience.c
index 8e3fb616be1..7bb7860f91f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/error_resilience.c
+++ b/chromium/third_party/ffmpeg/libavcodec/error_resilience.c
@@ -30,6 +30,7 @@
#include "libavutil/internal.h"
#include "avcodec.h"
#include "error_resilience.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "rectangle.h"
#include "thread.h"
@@ -57,7 +58,7 @@ static void set_mv_strides(ERContext *s, int *mv_step, int *stride)
static void put_dc(ERContext *s, uint8_t *dest_y, uint8_t *dest_cb,
uint8_t *dest_cr, int mb_x, int mb_y)
{
- int *linesize = s->cur_pic->f.linesize;
+ int *linesize = s->cur_pic.f->linesize;
int dc, dcu, dcv, y, i;
for (i = 0; i < 4; i++) {
dc = s->dc_val[0][mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * s->b8_stride];
@@ -135,8 +136,8 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
int h, int stride, int is_luma)
{
int b_x, b_y;
- int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
- uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
+ int16_t (*col )[4] = av_malloc_array(stride, h*sizeof( int16_t)*4);
+ uint32_t (*dist)[4] = av_malloc_array(stride, h*sizeof(uint32_t)*4);
if(!col || !dist) {
av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
@@ -149,7 +150,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
for(b_x=0; b_x<w; b_x++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
- int intra_j = IS_INTRA(s->cur_pic->mb_type[mb_index_j]);
+ int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
@@ -162,7 +163,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
for(b_x=w-1; b_x>=0; b_x--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
- int intra_j = IS_INTRA(s->cur_pic->mb_type[mb_index_j]);
+ int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
@@ -177,7 +178,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
for(b_y=0; b_y<h; b_y++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
- int intra_j = IS_INTRA(s->cur_pic->mb_type[mb_index_j]);
+ int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
@@ -190,7 +191,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
for(b_y=h-1; b_y>=0; b_y--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
- int intra_j = IS_INTRA(s->cur_pic->mb_type[mb_index_j]);
+ int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
@@ -207,7 +208,7 @@ static void guess_dc(ERContext *s, int16_t *dc, int w,
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
error = s->error_status_table[mb_index];
- if (IS_INTER(s->cur_pic->mb_type[mb_index]))
+ if (IS_INTER(s->cur_pic.mb_type[mb_index]))
continue; // inter
if (!(error & ER_DC_ERROR))
continue; // dc-ok
@@ -238,7 +239,7 @@ static void h_block_filter(ERContext *s, uint8_t *dst, int w,
int h, int stride, int is_luma)
{
int b_x, b_y, mvx_stride, mvy_stride;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
set_mv_strides(s, &mvx_stride, &mvy_stride);
mvx_stride >>= is_luma;
mvy_stride *= mvx_stride;
@@ -248,13 +249,13 @@ static void h_block_filter(ERContext *s, uint8_t *dst, int w,
int y;
int left_status = s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride];
int right_status = s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride];
- int left_intra = IS_INTRA(s->cur_pic->mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
- int right_intra = IS_INTRA(s->cur_pic->mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
+ int left_intra = IS_INTRA(s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
+ int right_intra = IS_INTRA(s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
int left_damage = left_status & ER_MB_ERROR;
int right_damage = right_status & ER_MB_ERROR;
int offset = b_x * 8 + b_y * stride * 8;
- int16_t *left_mv = s->cur_pic->motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
- int16_t *right_mv = s->cur_pic->motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
+ int16_t *left_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
+ int16_t *right_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
if (!(left_damage || right_damage))
continue; // both undamaged
if ((!left_intra) && (!right_intra) &&
@@ -306,7 +307,7 @@ static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
int stride, int is_luma)
{
int b_x, b_y, mvx_stride, mvy_stride;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
set_mv_strides(s, &mvx_stride, &mvy_stride);
mvx_stride >>= is_luma;
mvy_stride *= mvx_stride;
@@ -316,14 +317,14 @@ static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
int x;
int top_status = s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride];
int bottom_status = s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride];
- int top_intra = IS_INTRA(s->cur_pic->mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]);
- int bottom_intra = IS_INTRA(s->cur_pic->mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
+ int top_intra = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]);
+ int bottom_intra = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
int top_damage = top_status & ER_MB_ERROR;
int bottom_damage = bottom_status & ER_MB_ERROR;
int offset = b_x * 8 + b_y * stride * 8;
- int16_t *top_mv = s->cur_pic->motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
- int16_t *bottom_mv = s->cur_pic->motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
+ int16_t *top_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
+ int16_t *bottom_mv = s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
if (!(top_damage || bottom_damage))
continue; // both undamaged
@@ -388,7 +389,7 @@ static void guess_mv(ERContext *s)
int f = 0;
int error = s->error_status_table[mb_xy];
- if (IS_INTRA(s->cur_pic->mb_type[mb_xy]))
+ if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
f = MV_FROZEN; // intra // FIXME check
if (!(error & ER_MV_ERROR))
f = MV_FROZEN; // inter with undamaged MV
@@ -396,13 +397,13 @@ static void guess_mv(ERContext *s)
fixed[mb_xy] = f;
if (f == MV_FROZEN)
num_avail++;
- else if(s->last_pic->f.data[0] && s->last_pic->motion_val[0]){
+ else if(s->last_pic.f->data[0] && s->last_pic.motion_val[0]){
const int mb_y= mb_xy / s->mb_stride;
const int mb_x= mb_xy % s->mb_stride;
const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
- s->cur_pic->motion_val[0][mot_index][0]= s->last_pic->motion_val[0][mot_index][0];
- s->cur_pic->motion_val[0][mot_index][1]= s->last_pic->motion_val[0][mot_index][1];
- s->cur_pic->ref_index[0][4*mb_xy] = s->last_pic->ref_index[0][4*mb_xy];
+ s->cur_pic.motion_val[0][mot_index][0]= s->last_pic.motion_val[0][mot_index][0];
+ s->cur_pic.motion_val[0][mot_index][1]= s->last_pic.motion_val[0][mot_index][1];
+ s->cur_pic.ref_index[0][4*mb_xy] = s->last_pic.ref_index[0][4*mb_xy];
}
}
@@ -411,9 +412,9 @@ static void guess_mv(ERContext *s)
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
- int mv_dir = (s->last_pic && s->last_pic->f.data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
+ int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
- if (IS_INTRA(s->cur_pic->mb_type[mb_xy]))
+ if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
continue;
if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
continue;
@@ -454,8 +455,8 @@ static void guess_mv(ERContext *s)
if (fixed[mb_xy] == MV_FROZEN)
continue;
- av_assert1(!IS_INTRA(s->cur_pic->mb_type[mb_xy]));
- av_assert1(s->last_pic && s->last_pic->f.data[0]);
+ av_assert1(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));
+ av_assert1(s->last_pic.f && s->last_pic.f->data[0]);
j = 0;
if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN)
@@ -485,38 +486,38 @@ static void guess_mv(ERContext *s)
if (mb_x > 0 && fixed[mb_xy - 1]) {
mv_predictor[pred_count][0] =
- s->cur_pic->motion_val[0][mot_index - mot_step][0];
+ s->cur_pic.motion_val[0][mot_index - mot_step][0];
mv_predictor[pred_count][1] =
- s->cur_pic->motion_val[0][mot_index - mot_step][1];
+ s->cur_pic.motion_val[0][mot_index - mot_step][1];
ref[pred_count] =
- s->cur_pic->ref_index[0][4 * (mb_xy - 1)];
+ s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
pred_count++;
}
if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
mv_predictor[pred_count][0] =
- s->cur_pic->motion_val[0][mot_index + mot_step][0];
+ s->cur_pic.motion_val[0][mot_index + mot_step][0];
mv_predictor[pred_count][1] =
- s->cur_pic->motion_val[0][mot_index + mot_step][1];
+ s->cur_pic.motion_val[0][mot_index + mot_step][1];
ref[pred_count] =
- s->cur_pic->ref_index[0][4 * (mb_xy + 1)];
+ s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
pred_count++;
}
if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
mv_predictor[pred_count][0] =
- s->cur_pic->motion_val[0][mot_index - mot_stride * mot_step][0];
+ s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
- s->cur_pic->motion_val[0][mot_index - mot_stride * mot_step][1];
+ s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
ref[pred_count] =
- s->cur_pic->ref_index[0][4 * (mb_xy - s->mb_stride)];
+ s->cur_pic.ref_index[0][4 * (mb_xy - s->mb_stride)];
pred_count++;
}
if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
mv_predictor[pred_count][0] =
- s->cur_pic->motion_val[0][mot_index + mot_stride * mot_step][0];
+ s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
mv_predictor[pred_count][1] =
- s->cur_pic->motion_val[0][mot_index + mot_stride * mot_step][1];
+ s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
ref[pred_count] =
- s->cur_pic->ref_index[0][4 * (mb_xy + s->mb_stride)];
+ s->cur_pic.ref_index[0][4 * (mb_xy + s->mb_stride)];
pred_count++;
}
if (pred_count == 0)
@@ -574,19 +575,19 @@ skip_mean_and_median:
if (s->avctx->codec_id == AV_CODEC_ID_H264) {
// FIXME
} else {
- ff_thread_await_progress(&s->last_pic->tf,
+ ff_thread_await_progress(s->last_pic.tf,
mb_y, 0);
}
- if (!s->last_pic->motion_val[0] ||
- !s->last_pic->ref_index[0])
+ if (!s->last_pic.motion_val[0] ||
+ !s->last_pic.ref_index[0])
goto skip_last_mv;
- prev_x = s->last_pic->motion_val[0][mot_index][0];
- prev_y = s->last_pic->motion_val[0][mot_index][1];
- prev_ref = s->last_pic->ref_index[0][4 * mb_xy];
+ prev_x = s->last_pic.motion_val[0][mot_index][0];
+ prev_y = s->last_pic.motion_val[0][mot_index][1];
+ prev_ref = s->last_pic.ref_index[0][4 * mb_xy];
} else {
- prev_x = s->cur_pic->motion_val[0][mot_index][0];
- prev_y = s->cur_pic->motion_val[0][mot_index][1];
- prev_ref = s->cur_pic->ref_index[0][4 * mb_xy];
+ prev_x = s->cur_pic.motion_val[0][mot_index][0];
+ prev_y = s->cur_pic.motion_val[0][mot_index][1];
+ prev_ref = s->cur_pic.ref_index[0][4 * mb_xy];
}
/* last MV */
@@ -598,14 +599,14 @@ skip_mean_and_median:
skip_last_mv:
for (j = 0; j < pred_count; j++) {
- int *linesize = s->cur_pic->f.linesize;
+ int *linesize = s->cur_pic.f->linesize;
int score = 0;
- uint8_t *src = s->cur_pic->f.data[0] +
+ uint8_t *src = s->cur_pic.f->data[0] +
mb_x * 16 + mb_y * 16 * linesize[0];
- s->cur_pic->motion_val[0][mot_index][0] =
+ s->cur_pic.motion_val[0][mot_index][0] =
s->mv[0][0][0] = mv_predictor[j][0];
- s->cur_pic->motion_val[0][mot_index][1] =
+ s->cur_pic.motion_val[0][mot_index][1] =
s->mv[0][0][1] = mv_predictor[j][1];
// predictor intra or otherwise not available
@@ -650,8 +651,8 @@ skip_last_mv:
for (i = 0; i < mot_step; i++)
for (j = 0; j < mot_step; j++) {
- s->cur_pic->motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
- s->cur_pic->motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
+ s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
+ s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
}
s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD,
@@ -682,9 +683,12 @@ static int is_intra_more_likely(ERContext *s)
{
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
- if (!s->last_pic || !s->last_pic->f.data[0])
+ if (!s->last_pic.f || !s->last_pic.f->data[0])
return 1; // no previous frame available -> use spatial prediction
+ if (s->avctx->error_concealment & FF_EC_FAVOR_INTER)
+ return 0;
+
undamaged_count = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
@@ -699,15 +703,11 @@ static int is_intra_more_likely(ERContext *s)
if (undamaged_count < 5)
return 0; // almost all MBs damaged -> use temporal prediction
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
// prevent dsp.sad() check, that requires access to the image
- if (CONFIG_MPEG_XVMC_DECODER &&
- s->avctx->xvmc_acceleration &&
- s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I)
+ if (CONFIG_XVMC &&
+ s->avctx->hwaccel && s->avctx->hwaccel->decode_mb &&
+ s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I)
return 1;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
is_intra_likely = 0;
@@ -727,17 +727,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((j % skip_amount) != 0)
continue;
- if (s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I) {
- int *linesize = s->cur_pic->f.linesize;
- uint8_t *mb_ptr = s->cur_pic->f.data[0] +
+ if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I) {
+ int *linesize = s->cur_pic.f->linesize;
+ uint8_t *mb_ptr = s->cur_pic.f->data[0] +
mb_x * 16 + mb_y * 16 * linesize[0];
- uint8_t *last_mb_ptr = s->last_pic->f.data[0] +
+ uint8_t *last_mb_ptr = s->last_pic.f->data[0] +
mb_x * 16 + mb_y * 16 * linesize[0];
if (s->avctx->codec_id == AV_CODEC_ID_H264) {
// FIXME
} else {
- ff_thread_await_progress(&s->last_pic->tf, mb_y, 0);
+ ff_thread_await_progress(s->last_pic.tf, mb_y, 0);
}
is_intra_likely += s->dsp->sad[0](NULL, last_mb_ptr, mb_ptr,
linesize[0], 16);
@@ -746,7 +746,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
last_mb_ptr + linesize[0] * 16,
linesize[0], 16);
} else {
- if (IS_INTRA(s->cur_pic->mb_type[mb_xy]))
+ if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
is_intra_likely++;
else
is_intra_likely--;
@@ -770,10 +770,10 @@ void ff_er_frame_start(ERContext *s)
static int er_supported(ERContext *s)
{
- if(s->avctx->hwaccel ||
+ if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
- !s->cur_pic ||
- s->cur_pic->field_picture
+ !s->cur_pic.f ||
+ s->cur_pic.field_picture
)
return 0;
return 1;
@@ -795,7 +795,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
const int end_xy = s->mb_index2xy[end_i];
int mask = -1;
- if (s->avctx->hwaccel)
+ if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)
return;
if (start_i > end_i || start_xy > end_xy) {
@@ -858,7 +858,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
void ff_er_frame_end(ERContext *s)
{
- int *linesize = s->cur_pic->f.linesize;
+ int *linesize = s->cur_pic.f->linesize;
int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
int distance;
int threshold_part[4] = { 100, 100, 100 };
@@ -890,40 +890,40 @@ void ff_er_frame_end(ERContext *s)
return;
}
- if (s->last_pic) {
- if (s->last_pic->f.width != s->cur_pic->f.width ||
- s->last_pic->f.height != s->cur_pic->f.height ||
- s->last_pic->f.format != s->cur_pic->f.format) {
+ if (s->last_pic.f) {
+ if (s->last_pic.f->width != s->cur_pic.f->width ||
+ s->last_pic.f->height != s->cur_pic.f->height ||
+ s->last_pic.f->format != s->cur_pic.f->format) {
av_log(s->avctx, AV_LOG_WARNING, "Cannot use previous picture in error concealment\n");
- s->last_pic = NULL;
+ memset(&s->last_pic, 0, sizeof(s->last_pic));
}
}
- if (s->next_pic) {
- if (s->next_pic->f.width != s->cur_pic->f.width ||
- s->next_pic->f.height != s->cur_pic->f.height ||
- s->next_pic->f.format != s->cur_pic->f.format) {
+ if (s->next_pic.f) {
+ if (s->next_pic.f->width != s->cur_pic.f->width ||
+ s->next_pic.f->height != s->cur_pic.f->height ||
+ s->next_pic.f->format != s->cur_pic.f->format) {
av_log(s->avctx, AV_LOG_WARNING, "Cannot use next picture in error concealment\n");
- s->next_pic = NULL;
+ memset(&s->next_pic, 0, sizeof(s->next_pic));
}
}
- if (s->cur_pic->motion_val[0] == NULL) {
+ if (!s->cur_pic.motion_val[0] || !s->cur_pic.ref_index[0]) {
av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
for (i = 0; i < 2; i++) {
- s->cur_pic->ref_index_buf[i] = av_buffer_allocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
- s->cur_pic->motion_val_buf[i] = av_buffer_allocz((size + 4) * 2 * sizeof(uint16_t));
- if (!s->cur_pic->ref_index_buf[i] || !s->cur_pic->motion_val_buf[i])
+ s->ref_index_buf[i] = av_buffer_allocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
+ s->motion_val_buf[i] = av_buffer_allocz((size + 4) * 2 * sizeof(uint16_t));
+ if (!s->ref_index_buf[i] || !s->motion_val_buf[i])
break;
- s->cur_pic->ref_index[i] = s->cur_pic->ref_index_buf[i]->data;
- s->cur_pic->motion_val[i] = (int16_t (*)[2])s->cur_pic->motion_val_buf[i]->data + 4;
+ s->cur_pic.ref_index[i] = s->ref_index_buf[i]->data;
+ s->cur_pic.motion_val[i] = (int16_t (*)[2])s->motion_val_buf[i]->data + 4;
}
if (i < 2) {
for (i = 0; i < 2; i++) {
- av_buffer_unref(&s->cur_pic->ref_index_buf[i]);
- av_buffer_unref(&s->cur_pic->motion_val_buf[i]);
- s->cur_pic->ref_index[i] = NULL;
- s->cur_pic->motion_val[i] = NULL;
+ av_buffer_unref(&s->ref_index_buf[i]);
+ av_buffer_unref(&s->motion_val_buf[i]);
+ s->cur_pic.ref_index[i] = NULL;
+ s->cur_pic.motion_val[i] = NULL;
}
return;
}
@@ -1077,7 +1077,7 @@ void ff_er_frame_end(ERContext *s)
mv_error++;
}
av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors in %c frame\n",
- dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic->f.pict_type));
+ dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic.f->pict_type));
is_intra_likely = is_intra_more_likely(s);
@@ -1089,26 +1089,26 @@ void ff_er_frame_end(ERContext *s)
continue;
if (is_intra_likely)
- s->cur_pic->mb_type[mb_xy] = MB_TYPE_INTRA4x4;
+ s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
else
- s->cur_pic->mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
+ s->cur_pic.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
}
// change inter to intra blocks if no reference frames are available
- if (!(s->last_pic && s->last_pic->f.data[0]) &&
- !(s->next_pic && s->next_pic->f.data[0]))
+ if (!(s->last_pic.f && s->last_pic.f->data[0]) &&
+ !(s->next_pic.f && s->next_pic.f->data[0]))
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
- if (!IS_INTRA(s->cur_pic->mb_type[mb_xy]))
- s->cur_pic->mb_type[mb_xy] = MB_TYPE_INTRA4x4;
+ if (!IS_INTRA(s->cur_pic.mb_type[mb_xy]))
+ s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
}
/* handle inter blocks with damaged AC */
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
- const int mb_type = s->cur_pic->mb_type[mb_xy];
- const int dir = !(s->last_pic && s->last_pic->f.data[0]);
+ const int mb_type = s->cur_pic.mb_type[mb_xy];
+ const int dir = !(s->last_pic.f && s->last_pic.f->data[0]);
const int mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
int mv_type;
@@ -1126,13 +1126,13 @@ void ff_er_frame_end(ERContext *s)
int j;
mv_type = MV_TYPE_8X8;
for (j = 0; j < 4; j++) {
- s->mv[0][j][0] = s->cur_pic->motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
- s->mv[0][j][1] = s->cur_pic->motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
+ s->mv[0][j][0] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
+ s->mv[0][j][1] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
}
} else {
mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = s->cur_pic->motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
- s->mv[0][0][1] = s->cur_pic->motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
+ s->mv[0][0][0] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
+ s->mv[0][0][1] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
}
s->decode_mb(s->opaque, 0 /* FIXME h264 partitioned slices need this set */,
@@ -1141,12 +1141,12 @@ void ff_er_frame_end(ERContext *s)
}
/* guess MVs */
- if (s->cur_pic->f.pict_type == AV_PICTURE_TYPE_B) {
+ if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_B) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int xy = mb_x * 2 + mb_y * 2 * s->b8_stride;
const int mb_xy = mb_x + mb_y * s->mb_stride;
- const int mb_type = s->cur_pic->mb_type[mb_xy];
+ const int mb_type = s->cur_pic.mb_type[mb_xy];
int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
error = s->error_status_table[mb_xy];
@@ -1158,9 +1158,9 @@ void ff_er_frame_end(ERContext *s)
if (!(error & ER_AC_ERROR))
continue; // undamaged inter
- if (!(s->last_pic && s->last_pic->f.data[0]))
+ if (!(s->last_pic.f && s->last_pic.f->data[0]))
mv_dir &= ~MV_DIR_FORWARD;
- if (!(s->next_pic && s->next_pic->f.data[0]))
+ if (!(s->next_pic.f && s->next_pic.f->data[0]))
mv_dir &= ~MV_DIR_BACKWARD;
if (s->pp_time) {
@@ -1168,12 +1168,12 @@ void ff_er_frame_end(ERContext *s)
int time_pb = s->pb_time;
av_assert0(s->avctx->codec_id != AV_CODEC_ID_H264);
- ff_thread_await_progress(&s->next_pic->tf, mb_y, 0);
+ ff_thread_await_progress(s->next_pic.tf, mb_y, 0);
- s->mv[0][0][0] = s->next_pic->motion_val[0][xy][0] * time_pb / time_pp;
- s->mv[0][0][1] = s->next_pic->motion_val[0][xy][1] * time_pb / time_pp;
- s->mv[1][0][0] = s->next_pic->motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
- s->mv[1][0][1] = s->next_pic->motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
+ s->mv[0][0][0] = s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
+ s->mv[0][0][1] = s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
+ s->mv[1][0][0] = s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
+ s->mv[1][0][1] = s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
} else {
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
@@ -1188,13 +1188,9 @@ void ff_er_frame_end(ERContext *s)
} else
guess_mv(s);
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- /* the filters below are not XvMC compatible, skip them */
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
+ /* the filters below manipulate raw image, skip them */
+ if (CONFIG_XVMC && s->avctx->hwaccel && s->avctx->hwaccel->decode_mb)
goto ec_clean;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
/* fill DC for inter blocks */
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
@@ -1202,7 +1198,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
int16_t *dc_ptr;
uint8_t *dest_y, *dest_cb, *dest_cr;
const int mb_xy = mb_x + mb_y * s->mb_stride;
- const int mb_type = s->cur_pic->mb_type[mb_xy];
+ const int mb_type = s->cur_pic.mb_type[mb_xy];
error = s->error_status_table[mb_xy];
@@ -1211,9 +1207,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
// if (error & ER_MV_ERROR)
// continue; // inter data damaged FIXME is this good?
- dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
- dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
- dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
+ dest_y = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
+ dest_cb = s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
+ dest_cr = s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];
for (n = 0; n < 4; n++) {
@@ -1255,7 +1251,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
uint8_t *dest_y, *dest_cb, *dest_cr;
const int mb_xy = mb_x + mb_y * s->mb_stride;
- const int mb_type = s->cur_pic->mb_type[mb_xy];
+ const int mb_type = s->cur_pic.mb_type[mb_xy];
error = s->error_status_table[mb_xy];
@@ -1264,9 +1260,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!(error & ER_AC_ERROR))
continue; // undamaged
- dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
- dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
- dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
+ dest_y = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
+ dest_cb = s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
+ dest_cr = s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
}
@@ -1275,19 +1271,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (s->avctx->error_concealment & FF_EC_DEBLOCK) {
/* filter horizontal block boundaries */
- h_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2,
+ h_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
s->mb_height * 2, linesize[0], 1);
- h_block_filter(s, s->cur_pic->f.data[1], s->mb_width,
+ h_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
s->mb_height, linesize[1], 0);
- h_block_filter(s, s->cur_pic->f.data[2], s->mb_width,
+ h_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
s->mb_height, linesize[2], 0);
/* filter vertical block boundaries */
- v_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2,
+ v_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
s->mb_height * 2, linesize[0], 1);
- v_block_filter(s, s->cur_pic->f.data[1], s->mb_width,
+ v_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
s->mb_height, linesize[1], 0);
- v_block_filter(s, s->cur_pic->f.data[2], s->mb_width,
+ v_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
s->mb_height, linesize[2], 0);
}
@@ -1297,13 +1293,21 @@ ec_clean:
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
- if (s->cur_pic->f.pict_type != AV_PICTURE_TYPE_B &&
+ if (s->cur_pic.f->pict_type != AV_PICTURE_TYPE_B &&
(error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) {
s->mbskip_table[mb_xy] = 0;
}
s->mbintra_table[mb_xy] = 1;
}
- s->cur_pic = NULL;
- s->next_pic = NULL;
- s->last_pic = NULL;
+
+ for (i = 0; i < 2; i++) {
+ av_buffer_unref(&s->ref_index_buf[i]);
+ av_buffer_unref(&s->motion_val_buf[i]);
+ s->cur_pic.ref_index[i] = NULL;
+ s->cur_pic.motion_val[i] = NULL;
+ }
+
+ memset(&s->cur_pic, 0, sizeof(ERPicture));
+ memset(&s->last_pic, 0, sizeof(ERPicture));
+ memset(&s->next_pic, 0, sizeof(ERPicture));
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/error_resilience.h b/chromium/third_party/ffmpeg/libavcodec/error_resilience.h
index 970fdc20665..9d227e87a15 100644
--- a/chromium/third_party/ffmpeg/libavcodec/error_resilience.h
+++ b/chromium/third_party/ffmpeg/libavcodec/error_resilience.h
@@ -24,6 +24,7 @@
#include "avcodec.h"
#include "dsputil.h"
+#include "thread.h"
///< current MB is the first after a resync marker
#define VP_START 1
@@ -37,6 +38,18 @@
#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END)
+typedef struct ERPicture {
+ AVFrame *f;
+ ThreadFrame *tf;
+
+ // it's the caller's responsibility to allocate these buffers
+ int16_t (*motion_val[2])[2];
+ int8_t *ref_index[2];
+
+ uint32_t *mb_type;
+ int field_picture;
+} ERPicture;
+
typedef struct ERContext {
AVCodecContext *avctx;
DSPContext *dsp;
@@ -55,9 +68,12 @@ typedef struct ERContext {
uint8_t *mbintra_table;
int mv[2][4][2];
- struct Picture *cur_pic;
- struct Picture *last_pic;
- struct Picture *next_pic;
+ ERPicture cur_pic;
+ ERPicture last_pic;
+ ERPicture next_pic;
+
+ AVBufferRef *ref_index_buf[2];
+ AVBufferRef *motion_val_buf[2];
uint16_t pp_time;
uint16_t pb_time;
diff --git a/chromium/third_party/ffmpeg/libavcodec/evrcdata.h b/chromium/third_party/ffmpeg/libavcodec/evrcdata.h
index cde1f571d8a..ebcb0ac99f4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/evrcdata.h
+++ b/chromium/third_party/ffmpeg/libavcodec/evrcdata.h
@@ -1437,21 +1437,21 @@ static const float evrc_lspq_quant_codebook2[16][5] = {
{0.22787990, 0.31779197, 0.33831909, 0.40044111, 0.41185561},
{0.27896860, 0.32261974, 0.35658112, 0.40206763, 0.42370448}};
-static const float const *evrc_lspq_full_codebooks[] = {
+static const float * const evrc_lspq_full_codebooks[] = {
evrc_lspq_full_codebook1[0], evrc_lspq_full_codebook2[0],
evrc_lspq_full_codebook3[0], evrc_lspq_full_codebook4[0],
};
-static const float const *evrc_lspq_half_codebooks[] = {
+static const float * const evrc_lspq_half_codebooks[] = {
evrc_lspq_half_codebook1[0], evrc_lspq_half_codebook2[0],
evrc_lspq_half_codebook3[0],
};
-static const float const *evrc_lspq_quant_codebooks[] = {
+static const float * const evrc_lspq_quant_codebooks[] = {
evrc_lspq_quant_codebook1[0], evrc_lspq_quant_codebook2[0],
};
-static const float const **evrc_lspq_codebooks[] = {
+static const float * const *evrc_lspq_codebooks[] = {
0,
evrc_lspq_quant_codebooks,
0,
diff --git a/chromium/third_party/ffmpeg/libavcodec/evrcdec.c b/chromium/third_party/ffmpeg/libavcodec/evrcdec.c
index 51ae9e21ffb..20d0fe7cd42 100644
--- a/chromium/third_party/ffmpeg/libavcodec/evrcdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/evrcdec.c
@@ -276,7 +276,7 @@ static av_cold int evrc_decode_init(AVCodecContext *avctx)
*/
static int decode_lspf(EVRCContext *e)
{
- const float **codebooks = evrc_lspq_codebooks[e->bitrate];
+ const float * const *codebooks = evrc_lspq_codebooks[e->bitrate];
int i, j, k = 0;
for (i = 0; i < evrc_lspq_nb_codebooks[e->bitrate]; i++) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/exif.c b/chromium/third_party/ffmpeg/libavcodec/exif.c
index 96464261c10..a980da2a7be 100644
--- a/chromium/third_party/ffmpeg/libavcodec/exif.c
+++ b/chromium/third_party/ffmpeg/libavcodec/exif.c
@@ -48,9 +48,11 @@ static int exif_add_metadata(AVCodecContext *avctx, int count, int type,
{
switch(type) {
case TIFF_DOUBLE : return ff_tadd_doubles_metadata(count, name, sep, gb, le, metadata);
- case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, metadata);
+ case TIFF_SSHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 1, metadata);
+ case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, gb, le, 0, metadata);
+ case TIFF_SBYTE : return ff_tadd_bytes_metadata(count, name, sep, gb, le, 1, metadata);
case TIFF_BYTE :
- case TIFF_UNDEFINED: return ff_tadd_bytes_metadata(count, name, sep, gb, le, metadata);
+ case TIFF_UNDEFINED: return ff_tadd_bytes_metadata(count, name, sep, gb, le, 0, metadata);
case TIFF_STRING : return ff_tadd_string_metadata(count, name, gb, le, metadata);
case TIFF_SRATIONAL:
case TIFF_RATIONAL : return ff_tadd_rational_metadata(count, name, sep, gb, le, metadata);
@@ -76,11 +78,16 @@ static int exif_decode_tag(AVCodecContext *avctx, GetByteContext *gbytes, int le
ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos);
+ if (!bytestream2_tell(gbytes)) {
+ bytestream2_seek(gbytes, cur_pos, SEEK_SET);
+ return 0;
+ }
+
// read count values and add it metadata
// store metadata or proceed with next IFD
ret = ff_tis_ifd(id);
if (ret) {
- ret = ff_exif_decode_ifd(avctx, gbytes, le, depth + 1, metadata);
+ ret = avpriv_exif_decode_ifd(avctx, gbytes, le, depth + 1, metadata);
} else {
const char *name = exif_get_tag_name(id);
char *use_name = (char*) name;
@@ -107,8 +114,8 @@ static int exif_decode_tag(AVCodecContext *avctx, GetByteContext *gbytes, int le
}
-int ff_exif_decode_ifd(AVCodecContext *avctx, GetByteContext *gbytes, int le,
- int depth, AVDictionary **metadata)
+int avpriv_exif_decode_ifd(AVCodecContext *avctx, GetByteContext *gbytes, int le,
+ int depth, AVDictionary **metadata)
{
int i, ret;
int entries;
diff --git a/chromium/third_party/ffmpeg/libavcodec/exif.h b/chromium/third_party/ffmpeg/libavcodec/exif.h
index 71fe8292e13..2f509ba1e9c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/exif.h
+++ b/chromium/third_party/ffmpeg/libavcodec/exif.h
@@ -164,7 +164,7 @@ static const struct exif_tag tag_list[] = { // JEITA CP-3451 EXIF specification:
/** Recursively decodes all IFD's and
* adds included TAGS into the metadata dictionary. */
-int ff_exif_decode_ifd(AVCodecContext *avctx, GetByteContext *gbytes, int le,
- int depth, AVDictionary **metadata);
+int avpriv_exif_decode_ifd(AVCodecContext *avctx, GetByteContext *gbytes, int le,
+ int depth, AVDictionary **metadata);
#endif /* AVCODEC_EXIF_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/exr.c b/chromium/third_party/ffmpeg/libavcodec/exr.c
index f231b703750..6ade66cb39d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/exr.c
+++ b/chromium/third_party/ffmpeg/libavcodec/exr.c
@@ -27,39 +27,46 @@
* For more information on the OpenEXR format, visit:
* http://openexr.com/
*
- * exr_flt2uint() and exr_halflt2uint() is credited to Reimar Döffinger
+ * exr_flt2uint() and exr_halflt2uint() is credited to Reimar Döffinger.
+ * exr_half2float() is credited to Aaftab Munshi; Dan Ginsburg, Dave Shreiner.
+ *
*/
#include <zlib.h>
+#include <float.h>
+
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/intfloat.h"
-#include "get_bits.h"
#include "avcodec.h"
#include "bytestream.h"
+#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
#include "thread.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/avassert.h"
enum ExrCompr {
- EXR_RAW = 0,
- EXR_RLE = 1,
- EXR_ZIP1 = 2,
- EXR_ZIP16 = 3,
- EXR_PIZ = 4,
- EXR_PXR24 = 5,
- EXR_B44 = 6,
- EXR_B44A = 7,
+ EXR_RAW,
+ EXR_RLE,
+ EXR_ZIP1,
+ EXR_ZIP16,
+ EXR_PIZ,
+ EXR_PXR24,
+ EXR_B44,
+ EXR_B44A,
+ EXR_UNKN,
};
enum ExrPixelType {
EXR_UINT,
EXR_HALF,
- EXR_FLOAT
+ EXR_FLOAT,
+ EXR_UNKNOWN,
};
typedef struct EXRChannel {
- int xsub, ysub;
+ int xsub, ysub;
enum ExrPixelType pixel_type;
} EXRChannel;
@@ -75,35 +82,108 @@ typedef struct EXRThreadData {
} EXRThreadData;
typedef struct EXRContext {
+ AVClass *class;
AVFrame *picture;
- int compr;
+ AVCodecContext *avctx;
+
+ enum ExrCompr compression;
enum ExrPixelType pixel_type;
int channel_offsets[4]; // 0 = red, 1 = green, 2 = blue and 3 = alpha
const AVPixFmtDescriptor *desc;
+ int w, h;
uint32_t xmax, xmin;
uint32_t ymax, ymin;
uint32_t xdelta, ydelta;
-
int ysize;
uint64_t scan_line_size;
int scan_lines_per_block;
- const uint8_t *buf, *table;
+ GetByteContext gb;
+ const uint8_t *buf;
int buf_size;
EXRChannel *channels;
int nb_channels;
EXRThreadData *thread_data;
- int thread_data_size;
+
+ const char *layer;
+
+ float gamma;
+
+ uint16_t gamma_table[65536];
+
} EXRContext;
+/* -15 stored using a single precision bias of 127 */
+#define HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP 0x38000000
+/* max exponent value in single precision that will be converted
+ * to Inf or Nan when stored as a half-float */
+#define HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP 0x47800000
+
+/* 255 is the max exponent biased value */
+#define FLOAT_MAX_BIASED_EXP (0xFF << 23)
+
+#define HALF_FLOAT_MAX_BIASED_EXP (0x1F << 10)
+
+/*
+ * Convert a half float as a uint16_t into a full float.
+ *
+ * @param hf half float as uint16_t
+ *
+ * @return float value
+ */
+static union av_intfloat32 exr_half2float(uint16_t hf)
+{
+ unsigned int sign = (unsigned int)(hf >> 15);
+ unsigned int mantissa = (unsigned int)(hf & ((1 << 10) - 1));
+ unsigned int exp = (unsigned int)(hf & HALF_FLOAT_MAX_BIASED_EXP);
+ union av_intfloat32 f;
+
+ if (exp == HALF_FLOAT_MAX_BIASED_EXP) {
+ // we have a half-float NaN or Inf
+ // half-float NaNs will be converted to a single precision NaN
+ // half-float Infs will be converted to a single precision Inf
+ exp = FLOAT_MAX_BIASED_EXP;
+ if (mantissa)
+ mantissa = (1 << 23) - 1; // set all bits to indicate a NaN
+ } else if (exp == 0x0) {
+ // convert half-float zero/denorm to single precision value
+ if (mantissa) {
+ mantissa <<= 1;
+ exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+ // check for leading 1 in denorm mantissa
+ while ((mantissa & (1 << 10))) {
+ // for every leading 0, decrement single precision exponent by 1
+ // and shift half-float mantissa value to the left
+ mantissa <<= 1;
+ exp -= (1 << 23);
+ }
+ // clamp the mantissa to 10-bits
+ mantissa &= ((1 << 10) - 1);
+ // shift left to generate single-precision mantissa of 23-bits
+ mantissa <<= 13;
+ }
+ } else {
+ // shift left to generate single-precision mantissa of 23-bits
+ mantissa <<= 13;
+ // generate single precision biased exponent value
+ exp = (exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
+ }
+
+ f.i = (sign << 31) | exp | mantissa;
+
+ return f;
+}
+
+
/**
- * Converts from 32-bit float as uint32_t to uint16_t
+ * Convert from 32-bit float as uint32_t to uint16_t.
*
* @param v 32-bit float
+ *
* @return normalized 16-bit unsigned int
*/
static inline uint16_t exr_flt2uint(uint32_t v)
@@ -111,7 +191,7 @@ static inline uint16_t exr_flt2uint(uint32_t v)
unsigned int exp = v >> 23;
// "HACK": negative values result in exp< 0, so clipping them to 0
// is also handled by this condition, avoids explicit check for sign bit.
- if (exp<= 127 + 7 - 24) // we would shift out all bits anyway
+ if (exp <= 127 + 7 - 24) // we would shift out all bits anyway
return 0;
if (exp >= 127)
return 0xffff;
@@ -120,83 +200,32 @@ static inline uint16_t exr_flt2uint(uint32_t v)
}
/**
- * Converts from 16-bit float as uint16_t to uint16_t
+ * Convert from 16-bit float as uint16_t to uint16_t.
*
* @param v 16-bit float
+ *
* @return normalized 16-bit unsigned int
*/
static inline uint16_t exr_halflt2uint(uint16_t v)
{
unsigned exp = 14 - (v >> 10);
if (exp >= 14) {
- if (exp == 14) return (v >> 9) & 1;
- else return (v & 0x8000) ? 0 : 0xffff;
+ if (exp == 14)
+ return (v >> 9) & 1;
+ else
+ return (v & 0x8000) ? 0 : 0xffff;
}
v <<= 6;
return (v + (1 << 16)) >> (exp + 1);
}
-/**
- * Gets the size of the header variable
- *
- * @param **buf the current pointer location in the header where
- * the variable data starts
- * @param *buf_end pointer location of the end of the buffer
- * @return size of variable data
- */
-static unsigned int get_header_variable_length(const uint8_t **buf,
- const uint8_t *buf_end)
-{
- unsigned int variable_buffer_data_size = bytestream_get_le32(buf);
- if (variable_buffer_data_size >= buf_end - *buf)
- return 0;
- return variable_buffer_data_size;
-}
-
-/**
- * Checks if the variable name corresponds with it's data type
- *
- * @param *avctx the AVCodecContext
- * @param **buf the current pointer location in the header where
- * the variable name starts
- * @param *buf_end pointer location of the end of the buffer
- * @param *value_name name of the varible to check
- * @param *value_type type of the varible to check
- * @param minimum_length minimum length of the variable data
- * @param variable_buffer_data_size variable length read from the header
- * after it's checked
- * @return negative if variable is invalid
- */
-static int check_header_variable(AVCodecContext *avctx,
- const uint8_t **buf,
- const uint8_t *buf_end,
- const char *value_name,
- const char *value_type,
- unsigned int minimum_length,
- unsigned int *variable_buffer_data_size)
-{
- if (buf_end - *buf >= minimum_length && !strcmp(*buf, value_name)) {
- *buf += strlen(value_name)+1;
- if (!strcmp(*buf, value_type)) {
- *buf += strlen(value_type)+1;
- *variable_buffer_data_size = get_header_variable_length(buf, buf_end);
- if (!*variable_buffer_data_size)
- av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
- return 1;
- }
- *buf -= strlen(value_name)+1;
- av_log(avctx, AV_LOG_WARNING, "Unknown data type for header variable %s\n", value_name);
- }
- return -1;
-}
-
static void predictor(uint8_t *src, int size)
{
- uint8_t *t = src + 1;
+ uint8_t *t = src + 1;
uint8_t *stop = src + size;
while (t < stop) {
- int d = (int)t[-1] + (int)t[0] - 128;
+ int d = (int) t[-1] + (int) t[0] - 128;
t[0] = d;
++t;
}
@@ -206,8 +235,8 @@ static void reorder_pixels(uint8_t *src, uint8_t *dst, int size)
{
const int8_t *t1 = src;
const int8_t *t2 = src + (size + 1) / 2;
- int8_t *s = dst;
- int8_t *stop = s + size;
+ int8_t *s = dst;
+ int8_t *stop = s + size;
while (1) {
if (s < stop)
@@ -229,7 +258,7 @@ static int zip_uncompress(const uint8_t *src, int compressed_size,
if (uncompress(td->tmp, &dest_len, src, compressed_size) != Z_OK ||
dest_len != uncompressed_size)
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
predictor(td->tmp, uncompressed_size);
reorder_pixels(td->tmp, td->uncompressed_data, uncompressed_size);
@@ -240,11 +269,11 @@ static int zip_uncompress(const uint8_t *src, int compressed_size,
static int rle_uncompress(const uint8_t *src, int compressed_size,
int uncompressed_size, EXRThreadData *td)
{
- int8_t *d = (int8_t *)td->tmp;
- const int8_t *s = (const int8_t *)src;
- int ssize = compressed_size;
- int dsize = uncompressed_size;
- int8_t *dend = d + dsize;
+ uint8_t *d = td->tmp;
+ const int8_t *s = src;
+ int ssize = compressed_size;
+ int dsize = uncompressed_size;
+ uint8_t *dend = d + dsize;
int count;
while (ssize > 0) {
@@ -253,9 +282,9 @@ static int rle_uncompress(const uint8_t *src, int compressed_size,
if (count < 0) {
count = -count;
- if ((dsize -= count ) < 0 ||
+ if ((dsize -= count) < 0 ||
(ssize -= count + 1) < 0)
- return -1;
+ return AVERROR_INVALIDDATA;
while (count--)
*d++ = *s++;
@@ -263,8 +292,8 @@ static int rle_uncompress(const uint8_t *src, int compressed_size,
count++;
if ((dsize -= count) < 0 ||
- (ssize -= 2 ) < 0)
- return -1;
+ (ssize -= 2) < 0)
+ return AVERROR_INVALIDDATA;
while (count--)
*d++ = *s;
@@ -283,16 +312,15 @@ static int rle_uncompress(const uint8_t *src, int compressed_size,
}
#define USHORT_RANGE (1 << 16)
-#define BITMAP_SIZE (1 << 13)
+#define BITMAP_SIZE (1 << 13)
static uint16_t reverse_lut(const uint8_t *bitmap, uint16_t *lut)
{
int i, k = 0;
- for (i = 0; i < USHORT_RANGE; i++) {
+ for (i = 0; i < USHORT_RANGE; i++)
if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))
lut[k++] = i;
- }
i = k - 1;
@@ -313,7 +341,7 @@ static void apply_lut(const uint16_t *lut, uint16_t *dst, int dsize)
#define HUF_DECBITS 14 // decoding bit size (>= 8)
#define HUF_ENCSIZE ((1 << HUF_ENCBITS) + 1) // encoding table size
-#define HUF_DECSIZE (1 << HUF_DECBITS) // decoding table size
+#define HUF_DECSIZE (1 << HUF_DECBITS) // decoding table size
#define HUF_DECMASK (HUF_DECSIZE - 1)
typedef struct HufDec {
@@ -334,7 +362,7 @@ static void huf_canonical_code_table(uint64_t *hcode)
for (i = 58; i > 0; --i) {
uint64_t nc = ((c + n[i]) >> 1);
n[i] = c;
- c = nc;
+ c = nc;
}
for (i = 0; i < HUF_ENCSIZE; ++i) {
@@ -370,7 +398,7 @@ static int huf_unpack_enc_table(GetByteContext *gb,
hcode[im++] = 0;
im--;
- } else if (l >= (uint64_t) SHORT_ZEROCODE_RUN) {
+ } else if (l >= SHORT_ZEROCODE_RUN) {
int zerun = l - SHORT_ZEROCODE_RUN + 2;
if (im + zerun > iM + 1)
@@ -406,7 +434,7 @@ static int huf_build_dec_table(const uint64_t *hcode, int im,
pl->lit++;
- pl->p = av_realloc_f(pl->p, pl->lit, sizeof(int));
+ pl->p = av_realloc(pl->p, pl->lit * sizeof(int));
if (!pl->p)
return AVERROR(ENOMEM);
@@ -426,40 +454,42 @@ static int huf_build_dec_table(const uint64_t *hcode, int im,
return 0;
}
-#define get_char(c, lc, gb) { \
- c = (c << 8) | bytestream2_get_byte(gb); \
- lc += 8; \
+#define get_char(c, lc, gb) \
+{ \
+ c = (c << 8) | bytestream2_get_byte(gb); \
+ lc += 8; \
}
-#define get_code(po, rlc, c, lc, gb, out, oe) { \
- if (po == rlc) { \
- if (lc < 8) \
- get_char(c, lc, gb); \
- lc -= 8; \
- \
- cs = c >> lc; \
- \
- if (out + cs > oe) \
- return AVERROR_INVALIDDATA; \
- \
- s = out[-1]; \
- \
- while (cs-- > 0) \
- *out++ = s; \
- } else if (out < oe) { \
- *out++ = po; \
- } else { \
- return AVERROR_INVALIDDATA; \
- } \
+#define get_code(po, rlc, c, lc, gb, out, oe) \
+{ \
+ if (po == rlc) { \
+ if (lc < 8) \
+ get_char(c, lc, gb); \
+ lc -= 8; \
+ \
+ cs = c >> lc; \
+ \
+ if (out + cs > oe) \
+ return AVERROR_INVALIDDATA; \
+ \
+ s = out[-1]; \
+ \
+ while (cs-- > 0) \
+ *out++ = s; \
+ } else if (out < oe) { \
+ *out++ = po; \
+ } else { \
+ return AVERROR_INVALIDDATA; \
+ } \
}
static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
GetByteContext *gb, int nbits,
int rlc, int no, uint16_t *out)
{
- uint64_t c = 0;
- uint16_t *outb = out;
- uint16_t *oe = out + no;
+ uint64_t c = 0;
+ uint16_t *outb = out;
+ uint16_t *oe = out + no;
const uint8_t *ie = gb->buffer + (nbits + 7) / 8; // input byte size
uint8_t cs, s;
int i, lc = 0;
@@ -468,7 +498,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
get_char(c, lc, gb);
while (lc >= HUF_DECBITS) {
- const HufDec pl = hdecod[(c >> (lc-HUF_DECBITS)) & HUF_DECMASK];
+ const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK];
if (pl.len) {
lc -= pl.len;
@@ -501,7 +531,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,
}
}
- i = (8 - nbits) & 7;
+ i = (8 - nbits) & 7;
c >>= i;
lc -= i;
@@ -531,8 +561,8 @@ static int huf_uncompress(GetByteContext *gb,
int ret, i;
src_size = bytestream2_get_le32(gb);
- im = bytestream2_get_le32(gb);
- iM = bytestream2_get_le32(gb);
+ im = bytestream2_get_le32(gb);
+ iM = bytestream2_get_le32(gb);
bytestream2_skip(gb, 4);
nBits = bytestream2_get_le32(gb);
if (im < 0 || im >= HUF_ENCSIZE ||
@@ -542,8 +572,8 @@ static int huf_uncompress(GetByteContext *gb,
bytestream2_skip(gb, 4);
- freq = av_calloc(HUF_ENCSIZE, sizeof(*freq));
- hdec = av_calloc(HUF_DECSIZE, sizeof(*hdec));
+ freq = av_mallocz_array(HUF_ENCSIZE, sizeof(*freq));
+ hdec = av_mallocz_array(HUF_DECSIZE, sizeof(*hdec));
if (!freq || !hdec) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -562,10 +592,9 @@ static int huf_uncompress(GetByteContext *gb,
ret = huf_decode(freq, hdec, gb, nBits, iM, dst_size, dst);
fail:
- for (i = 0; i < HUF_DECSIZE; i++) {
+ for (i = 0; i < HUF_DECSIZE; i++)
if (hdec)
av_freep(&hdec[i].p);
- }
av_free(freq);
av_free(hdec);
@@ -577,8 +606,8 @@ static inline void wdec14(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
{
int16_t ls = l;
int16_t hs = h;
- int hi = hs;
- int ai = ls + (hi & 1) + (hi >> 1);
+ int hi = hs;
+ int ai = ls + (hi & 1) + (hi >> 1);
int16_t as = ai;
int16_t bs = ai - hi;
@@ -587,13 +616,13 @@ static inline void wdec14(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
}
#define NBITS 16
-#define A_OFFSET (1 << (NBITS - 1))
+#define A_OFFSET (1 << (NBITS - 1))
#define MOD_MASK ((1 << NBITS) - 1)
static inline void wdec16(uint16_t l, uint16_t h, uint16_t *a, uint16_t *b)
{
- int m = l;
- int d = h;
+ int m = l;
+ int d = h;
int bb = (m - (d >> 1)) & MOD_MASK;
int aa = (d + bb - A_OFFSET) & MOD_MASK;
*b = bb;
@@ -604,8 +633,8 @@ static void wav_decode(uint16_t *in, int nx, int ox,
int ny, int oy, uint16_t mx)
{
int w14 = (mx < (1 << 14));
- int n = (nx > ny) ? ny: nx;
- int p = 1;
+ int n = (nx > ny) ? ny : nx;
+ int p = 1;
int p2;
while (p <= n)
@@ -629,19 +658,19 @@ static void wav_decode(uint16_t *in, int nx, int ox,
uint16_t *ex = py + ox * (nx - p2);
for (; px <= ex; px += ox2) {
- uint16_t *p01 = px + ox1;
- uint16_t *p10 = px + oy1;
+ uint16_t *p01 = px + ox1;
+ uint16_t *p10 = px + oy1;
uint16_t *p11 = p10 + ox1;
if (w14) {
- wdec14(*px, *p10, &i00, &i10);
+ wdec14(*px, *p10, &i00, &i10);
wdec14(*p01, *p11, &i01, &i11);
- wdec14(i00, i01, px, p01);
+ wdec14(i00, i01, px, p01);
wdec14(i10, i11, p10, p11);
} else {
- wdec16(*px, *p10, &i00, &i10);
+ wdec16(*px, *p10, &i00, &i10);
wdec16(*p01, *p11, &i01, &i11);
- wdec16(i00, i01, px, p01);
+ wdec16(i00, i01, px, p01);
wdec16(i10, i11, p10, p11);
}
}
@@ -674,25 +703,30 @@ static void wav_decode(uint16_t *in, int nx, int ox,
}
}
- p2 = p;
+ p2 = p;
p >>= 1;
}
}
-static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize, int dsize, EXRThreadData *td)
+static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
+ int dsize, EXRThreadData *td)
{
GetByteContext gb;
uint16_t maxval, min_non_zero, max_non_zero;
- uint16_t *ptr, *tmp = (uint16_t *)td->tmp;
- int8_t *out;
+ uint16_t *ptr;
+ uint16_t *tmp = (uint16_t *)td->tmp;
+ uint8_t *out;
int ret, i, j;
if (!td->bitmap)
td->bitmap = av_malloc(BITMAP_SIZE);
if (!td->lut)
td->lut = av_malloc(1 << 17);
- if (!td->bitmap || !td->lut)
+ if (!td->bitmap || !td->lut) {
+ av_freep(&td->bitmap);
+ av_freep(&td->lut);
return AVERROR(ENOMEM);
+ }
bytestream2_init(&gb, src, ssize);
min_non_zero = bytestream2_get_le16(&gb);
@@ -709,7 +743,7 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize, int dsiz
maxval = reverse_lut(td->bitmap, td->lut);
- ret = huf_uncompress(&gb, tmp, dsize / sizeof(int16_t));
+ ret = huf_uncompress(&gb, tmp, dsize / sizeof(uint16_t));
if (ret)
return ret;
@@ -719,20 +753,20 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize, int dsiz
int size = channel->pixel_type;
for (j = 0; j < size; j++)
- wav_decode(ptr + j, s->xdelta, size, s->ysize, s->xdelta * size, maxval);
+ wav_decode(ptr + j, s->xdelta, size, s->ysize,
+ s->xdelta * size, maxval);
ptr += s->xdelta * s->ysize * size;
}
- apply_lut(td->lut, tmp, dsize / sizeof(int16_t));
+ apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
out = td->uncompressed_data;
- for (i = 0; i < s->ysize; i++) {
+ for (i = 0; i < s->ysize; i++)
for (j = 0; j < s->nb_channels; j++) {
uint16_t *in = tmp + j * s->xdelta * s->ysize + i * s->xdelta;
memcpy(out, in, s->xdelta * 2);
out += s->xdelta * 2;
}
- }
return 0;
}
@@ -748,10 +782,10 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
if (uncompress(td->tmp, &dest_len, src, compressed_size) != Z_OK ||
dest_len != uncompressed_size)
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
out = td->uncompressed_data;
- for (i = 0; i < s->ysize; i++) {
+ for (i = 0; i < s->ysize; i++)
for (c = 0; c < s->nb_channels; c++) {
EXRChannel *channel = &s->channels[c];
const uint8_t *ptr[4];
@@ -762,12 +796,12 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
ptr[0] = in;
ptr[1] = ptr[0] + s->xdelta;
ptr[2] = ptr[1] + s->xdelta;
- in = ptr[2] + s->xdelta;
+ in = ptr[2] + s->xdelta;
for (j = 0; j < s->xdelta; ++j) {
uint32_t diff = (*(ptr[0]++) << 24) |
(*(ptr[1]++) << 16) |
- (*(ptr[2]++) << 8);
+ (*(ptr[2]++) << 8);
pixel += diff;
bytestream_put_le32(&out, pixel);
}
@@ -775,7 +809,7 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
case EXR_HALF:
ptr[0] = in;
ptr[1] = ptr[0] + s->xdelta;
- in = ptr[1] + s->xdelta;
+ in = ptr[1] + s->xdelta;
for (j = 0; j < s->xdelta; j++) {
uint32_t diff = (*(ptr[0]++) << 8) | *(ptr[1]++);
@@ -784,10 +818,9 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
}
break;
default:
- av_assert1(0);
+ return AVERROR_INVALIDDATA;
}
}
- }
return 0;
}
@@ -804,19 +837,20 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
uint32_t xdelta = s->xdelta;
uint16_t *ptr_x;
uint8_t *ptr;
- int32_t data_size, line;
+ uint32_t data_size, line;
const uint8_t *src;
int axmax = (avctx->width - (s->xmax + 1)) * 2 * s->desc->nb_components;
int bxmin = s->xmin * 2 * s->desc->nb_components;
int i, x, buf_size = s->buf_size;
- int av_unused ret;
+ int ret;
+ float one_gamma = 1.0f / s->gamma;
- line_offset = AV_RL64(s->table + jobnr * 8);
+ line_offset = AV_RL64(s->gb.buffer + jobnr * 8);
// Check if the buffer has the required bytes needed from the offset
if (line_offset > buf_size - 8)
return AVERROR_INVALIDDATA;
- src = buf + line_offset + 8;
+ src = buf + line_offset + 8;
line = AV_RL32(src - 8);
if (line < s->ymin || line > s->ymax)
return AVERROR_INVALIDDATA;
@@ -825,22 +859,24 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
if (data_size <= 0 || data_size > buf_size)
return AVERROR_INVALIDDATA;
- s->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1);
+ s->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1);
uncompressed_size = s->scan_line_size * s->ysize;
- if ((s->compr == EXR_RAW && (data_size != uncompressed_size ||
+ if ((s->compression == EXR_RAW && (data_size != uncompressed_size ||
line_offset > buf_size - uncompressed_size)) ||
- (s->compr != EXR_RAW && (data_size > uncompressed_size ||
+ (s->compression != EXR_RAW && (data_size > uncompressed_size ||
line_offset > buf_size - data_size))) {
return AVERROR_INVALIDDATA;
}
if (data_size < uncompressed_size) {
- av_fast_padded_malloc(&td->uncompressed_data, &td->uncompressed_size, uncompressed_size);
+ av_fast_padded_malloc(&td->uncompressed_data,
+ &td->uncompressed_size, uncompressed_size);
av_fast_padded_malloc(&td->tmp, &td->tmp_size, uncompressed_size);
if (!td->uncompressed_data || !td->tmp)
return AVERROR(ENOMEM);
- switch (s->compr) {
+ ret = AVERROR_INVALIDDATA;
+ switch (s->compression) {
case EXR_ZIP1:
case EXR_ZIP16:
ret = zip_uncompress(src, data_size, uncompressed_size, td);
@@ -854,7 +890,10 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
case EXR_RLE:
ret = rle_uncompress(src, data_size, uncompressed_size, td);
}
-
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "decode_block() failed.\n");
+ return ret;
+ }
src = td->uncompressed_data;
}
@@ -865,7 +904,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
channel_buffer[3] = src + xdelta * s->channel_offsets[3];
ptr = p->data[0] + line * p->linesize[0];
- for (i = 0; i < s->scan_lines_per_block && line + i <= s->ymax; i++, ptr += p->linesize[0]) {
+ for (i = 0;
+ i < s->scan_lines_per_block && line + i <= s->ymax;
+ i++, ptr += p->linesize[0]) {
const uint8_t *r, *g, *b, *a;
r = channel_buffer[0];
@@ -874,7 +915,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
if (channel_buffer[3])
a = channel_buffer[3];
- ptr_x = (uint16_t *)ptr;
+ ptr_x = (uint16_t *) ptr;
// Zero out the start if xmin is not 0
memset(ptr_x, 0, bxmin);
@@ -882,18 +923,30 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
if (s->pixel_type == EXR_FLOAT) {
// 32-bit
for (x = 0; x < xdelta; x++) {
- *ptr_x++ = exr_flt2uint(bytestream_get_le32(&r));
- *ptr_x++ = exr_flt2uint(bytestream_get_le32(&g));
- *ptr_x++ = exr_flt2uint(bytestream_get_le32(&b));
+ union av_intfloat32 t;
+ t.i = bytestream_get_le32(&r);
+ if ( t.f > 0.0f ) /* avoid negative values */
+ t.f = powf(t.f, one_gamma);
+ *ptr_x++ = exr_flt2uint(t.i);
+
+ t.i = bytestream_get_le32(&g);
+ if ( t.f > 0.0f )
+ t.f = powf(t.f, one_gamma);
+ *ptr_x++ = exr_flt2uint(t.i);
+
+ t.i = bytestream_get_le32(&b);
+ if ( t.f > 0.0f )
+ t.f = powf(t.f, one_gamma);
+ *ptr_x++ = exr_flt2uint(t.i);
if (channel_buffer[3])
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&a));
}
} else {
// 16-bit
for (x = 0; x < xdelta; x++) {
- *ptr_x++ = exr_halflt2uint(bytestream_get_le16(&r));
- *ptr_x++ = exr_halflt2uint(bytestream_get_le16(&g));
- *ptr_x++ = exr_halflt2uint(bytestream_get_le16(&b));
+ *ptr_x++ = s->gamma_table[bytestream_get_le16(&r)];
+ *ptr_x++ = s->gamma_table[bytestream_get_le16(&g)];
+ *ptr_x++ = s->gamma_table[bytestream_get_le16(&b)];
if (channel_buffer[3])
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&a));
}
@@ -912,244 +965,296 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
return 0;
}
-static int decode_frame(AVCodecContext *avctx,
- void *data,
- int *got_frame,
- AVPacket *avpkt)
+/**
+ * Check if the variable name corresponds to its data type.
+ *
+ * @param s the EXRContext
+ * @param value_name name of the variable to check
+ * @param value_type type of the variable to check
+ * @param minimum_length minimum length of the variable data
+ *
+ * @return bytes to read containing variable data
+ * -1 if variable is not found
+ * 0 if buffer ended prematurely
+ */
+static int check_header_variable(EXRContext *s,
+ const char *value_name,
+ const char *value_type,
+ unsigned int minimum_length)
{
- const uint8_t *buf = avpkt->data;
- unsigned int buf_size = avpkt->size;
- const uint8_t *buf_end = buf + buf_size;
-
- EXRContext *const s = avctx->priv_data;
- ThreadFrame frame = { .f = data };
- AVFrame *picture = data;
- uint8_t *ptr;
-
- int i, y, magic_number, version, flags, ret;
- int w = 0;
- int h = 0;
+ int var_size = -1;
+
+ if (bytestream2_get_bytes_left(&s->gb) >= minimum_length &&
+ !strcmp(s->gb.buffer, value_name)) {
+ // found value_name, jump to value_type (null terminated strings)
+ s->gb.buffer += strlen(value_name) + 1;
+ if (!strcmp(s->gb.buffer, value_type)) {
+ s->gb.buffer += strlen(value_type) + 1;
+ var_size = bytestream2_get_le32(&s->gb);
+ // don't go read past boundaries
+ if (var_size > bytestream2_get_bytes_left(&s->gb))
+ var_size = 0;
+ } else {
+ // value_type not found, reset the buffer
+ s->gb.buffer -= strlen(value_name) + 1;
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Unknown data type %s for header variable %s.\n",
+ value_type, value_name);
+ }
+ }
- int out_line_size;
- int scan_line_blocks;
+ return var_size;
+}
- unsigned int current_channel_offset = 0;
+static int decode_header(EXRContext *s)
+{
+ int current_channel_offset = 0;
+ int magic_number, version, flags, i;
- s->xmin = ~0;
- s->xmax = ~0;
- s->ymin = ~0;
- s->ymax = ~0;
- s->xdelta = ~0;
- s->ydelta = ~0;
- s->channel_offsets[0] = -1;
- s->channel_offsets[1] = -1;
- s->channel_offsets[2] = -1;
- s->channel_offsets[3] = -1;
- s->pixel_type = -1;
- s->nb_channels = 0;
- s->compr = -1;
- s->buf = buf;
- s->buf_size = buf_size;
-
- if (buf_size < 10) {
- av_log(avctx, AV_LOG_ERROR, "Too short header to parse\n");
+ if (bytestream2_get_bytes_left(&s->gb) < 10) {
+ av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
return AVERROR_INVALIDDATA;
}
- magic_number = bytestream_get_le32(&buf);
- if (magic_number != 20000630) { // As per documentation of OpenEXR it's supposed to be int 20000630 little-endian
- av_log(avctx, AV_LOG_ERROR, "Wrong magic number %d\n", magic_number);
+ magic_number = bytestream2_get_le32(&s->gb);
+ if (magic_number != 20000630) {
+ /* As per documentation of OpenEXR, it is supposed to be
+ * int 20000630 little-endian */
+ av_log(s->avctx, AV_LOG_ERROR, "Wrong magic number %d.\n", magic_number);
return AVERROR_INVALIDDATA;
}
- version = bytestream_get_byte(&buf);
+ version = bytestream2_get_byte(&s->gb);
if (version != 2) {
- avpriv_report_missing_feature(avctx, "Version %d", version);
+ avpriv_report_missing_feature(s->avctx, "Version %d", version);
return AVERROR_PATCHWELCOME;
}
- flags = bytestream_get_le24(&buf);
- if (flags & 0x2) {
- avpriv_report_missing_feature(avctx, "Tile support");
+ flags = bytestream2_get_le24(&s->gb);
+ if (flags & 0x02) {
+ avpriv_report_missing_feature(s->avctx, "Tile support");
return AVERROR_PATCHWELCOME;
}
// Parse the header
- while (buf < buf_end && buf[0]) {
- unsigned int variable_buffer_data_size;
- // Process the channel list
- if (check_header_variable(avctx, &buf, buf_end, "channels", "chlist", 38, &variable_buffer_data_size) >= 0) {
- const uint8_t *channel_list_end;
- if (!variable_buffer_data_size)
+ while (bytestream2_get_bytes_left(&s->gb) > 0 && *s->gb.buffer) {
+ int var_size;
+ if ((var_size = check_header_variable(s, "channels",
+ "chlist", 38)) >= 0) {
+ GetByteContext ch_gb;
+ if (!var_size)
return AVERROR_INVALIDDATA;
- channel_list_end = buf + variable_buffer_data_size;
- while (channel_list_end - buf >= 19) {
+ bytestream2_init(&ch_gb, s->gb.buffer, var_size);
+
+ while (bytestream2_get_bytes_left(&ch_gb) >= 19) {
EXRChannel *channel;
enum ExrPixelType current_pixel_type;
int channel_index = -1;
int xsub, ysub;
- if (!strcmp(buf, "R"))
+ if (strcmp(s->layer, "") != 0) {
+ if (strncmp(ch_gb.buffer, s->layer, strlen(s->layer)) == 0) {
+ ch_gb.buffer += strlen(s->layer);
+ if (*ch_gb.buffer == '.')
+ ch_gb.buffer++; /* skip dot if not given */
+ av_log(s->avctx, AV_LOG_INFO,
+ "Layer %s.%s matched.\n", s->layer, ch_gb.buffer);
+ }
+ }
+
+ if (!strcmp(ch_gb.buffer, "R") ||
+ !strcmp(ch_gb.buffer, "X") ||
+ !strcmp(ch_gb.buffer, "U"))
channel_index = 0;
- else if (!strcmp(buf, "G"))
+ else if (!strcmp(ch_gb.buffer, "G") ||
+ !strcmp(ch_gb.buffer, "Y") ||
+ !strcmp(ch_gb.buffer, "V"))
channel_index = 1;
- else if (!strcmp(buf, "B"))
+ else if (!strcmp(ch_gb.buffer, "B") ||
+ !strcmp(ch_gb.buffer, "Z") ||
+ !strcmp(ch_gb.buffer, "W"))
channel_index = 2;
- else if (!strcmp(buf, "A"))
+ else if (!strcmp(ch_gb.buffer, "A"))
channel_index = 3;
else
- av_log(avctx, AV_LOG_WARNING, "Unsupported channel %.256s\n", buf);
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Unsupported channel %.256s.\n", ch_gb.buffer);
- while (bytestream_get_byte(&buf) && buf < channel_list_end)
- continue; /* skip */
+ /* skip until you get a 0 */
+ while (bytestream2_get_bytes_left(&ch_gb) > 0 &&
+ bytestream2_get_byte(&ch_gb))
+ continue;
- if (channel_list_end - * &buf < 4) {
- av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
+ if (bytestream2_get_bytes_left(&ch_gb) < 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "Incomplete header.\n");
return AVERROR_INVALIDDATA;
}
- current_pixel_type = bytestream_get_le32(&buf);
- if (current_pixel_type > 2) {
- av_log(avctx, AV_LOG_ERROR, "Unknown pixel type\n");
- return AVERROR_INVALIDDATA;
+ current_pixel_type = bytestream2_get_le32(&ch_gb);
+ if (current_pixel_type >= EXR_UNKNOWN) {
+ avpriv_report_missing_feature(s->avctx,
+ "Pixel type %d.\n",
+ current_pixel_type);
+ return AVERROR_PATCHWELCOME;
}
- buf += 4;
- xsub = bytestream_get_le32(&buf);
- ysub = bytestream_get_le32(&buf);
+ bytestream2_skip(&ch_gb, 4);
+ xsub = bytestream2_get_le32(&ch_gb);
+ ysub = bytestream2_get_le32(&ch_gb);
if (xsub != 1 || ysub != 1) {
- avpriv_report_missing_feature(avctx, "Subsampling %dx%d", xsub, ysub);
+ avpriv_report_missing_feature(s->avctx,
+ "Subsampling %dx%d",
+ xsub, ysub);
return AVERROR_PATCHWELCOME;
}
if (channel_index >= 0) {
- if (s->pixel_type != -1 && s->pixel_type != current_pixel_type) {
- av_log(avctx, AV_LOG_ERROR, "RGB channels not of the same depth\n");
+ if (s->pixel_type != EXR_UNKNOWN &&
+ s->pixel_type != current_pixel_type) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "RGB channels not of the same depth.\n");
return AVERROR_INVALIDDATA;
}
- s->pixel_type = current_pixel_type;
+ s->pixel_type = current_pixel_type;
s->channel_offsets[channel_index] = current_channel_offset;
}
- s->channels = av_realloc_f(s->channels, ++s->nb_channels, sizeof(EXRChannel));
+ s->channels = av_realloc(s->channels,
+ ++s->nb_channels * sizeof(EXRChannel));
if (!s->channels)
return AVERROR(ENOMEM);
- channel = &s->channels[s->nb_channels - 1];
+ channel = &s->channels[s->nb_channels - 1];
channel->pixel_type = current_pixel_type;
- channel->xsub = xsub;
- channel->ysub = ysub;
+ channel->xsub = xsub;
+ channel->ysub = ysub;
current_channel_offset += 1 << current_pixel_type;
}
/* Check if all channels are set with an offset or if the channels
* are causing an overflow */
-
if (FFMIN3(s->channel_offsets[0],
s->channel_offsets[1],
s->channel_offsets[2]) < 0) {
if (s->channel_offsets[0] < 0)
- av_log(avctx, AV_LOG_ERROR, "Missing red channel\n");
+ av_log(s->avctx, AV_LOG_ERROR, "Missing red channel.\n");
if (s->channel_offsets[1] < 0)
- av_log(avctx, AV_LOG_ERROR, "Missing green channel\n");
+ av_log(s->avctx, AV_LOG_ERROR, "Missing green channel.\n");
if (s->channel_offsets[2] < 0)
- av_log(avctx, AV_LOG_ERROR, "Missing blue channel\n");
+ av_log(s->avctx, AV_LOG_ERROR, "Missing blue channel.\n");
return AVERROR_INVALIDDATA;
}
- buf = channel_list_end;
+ // skip one last byte and update main gb
+ s->gb.buffer = ch_gb.buffer + 1;
continue;
- } else if (check_header_variable(avctx, &buf, buf_end, "dataWindow", "box2i", 31, &variable_buffer_data_size) >= 0) {
- if (!variable_buffer_data_size)
+ } else if ((var_size = check_header_variable(s, "dataWindow", "box2i",
+ 31)) >= 0) {
+ if (!var_size)
return AVERROR_INVALIDDATA;
- s->xmin = AV_RL32(buf);
- s->ymin = AV_RL32(buf + 4);
- s->xmax = AV_RL32(buf + 8);
- s->ymax = AV_RL32(buf + 12);
+ s->xmin = bytestream2_get_le32(&s->gb);
+ s->ymin = bytestream2_get_le32(&s->gb);
+ s->xmax = bytestream2_get_le32(&s->gb);
+ s->ymax = bytestream2_get_le32(&s->gb);
s->xdelta = (s->xmax - s->xmin) + 1;
s->ydelta = (s->ymax - s->ymin) + 1;
- buf += variable_buffer_data_size;
continue;
- } else if (check_header_variable(avctx, &buf, buf_end, "displayWindow", "box2i", 34, &variable_buffer_data_size) >= 0) {
- if (!variable_buffer_data_size)
+ } else if ((var_size = check_header_variable(s, "displayWindow",
+ "box2i", 34)) >= 0) {
+ if (!var_size)
return AVERROR_INVALIDDATA;
- w = AV_RL32(buf + 8) + 1;
- h = AV_RL32(buf + 12) + 1;
+ bytestream2_skip(&s->gb, 8);
+ s->w = bytestream2_get_le32(&s->gb) + 1;
+ s->h = bytestream2_get_le32(&s->gb) + 1;
- buf += variable_buffer_data_size;
continue;
- } else if (check_header_variable(avctx, &buf, buf_end, "lineOrder", "lineOrder", 25, &variable_buffer_data_size) >= 0) {
- if (!variable_buffer_data_size)
+ } else if ((var_size = check_header_variable(s, "lineOrder",
+ "lineOrder", 25)) >= 0) {
+ int line_order;
+ if (!var_size)
return AVERROR_INVALIDDATA;
- av_log(avctx, AV_LOG_DEBUG, "line order : %d\n", *buf);
- if (*buf > 2) {
- av_log(avctx, AV_LOG_ERROR, "Unknown line order\n");
+ line_order = bytestream2_get_byte(&s->gb);
+ av_log(s->avctx, AV_LOG_DEBUG, "line order: %d.\n", line_order);
+ if (line_order > 2) {
+ av_log(s->avctx, AV_LOG_ERROR, "Unknown line order.\n");
return AVERROR_INVALIDDATA;
}
- buf += variable_buffer_data_size;
continue;
- } else if (check_header_variable(avctx, &buf, buf_end, "pixelAspectRatio", "float", 31, &variable_buffer_data_size) >= 0) {
- if (!variable_buffer_data_size)
+ } else if ((var_size = check_header_variable(s, "pixelAspectRatio",
+ "float", 31)) >= 0) {
+ if (!var_size)
return AVERROR_INVALIDDATA;
- avctx->sample_aspect_ratio = av_d2q(av_int2float(AV_RL32(buf)), 255);
+ s->avctx->sample_aspect_ratio =
+ av_d2q(av_int2float(bytestream2_get_le32(&s->gb)), 255);
- buf += variable_buffer_data_size;
continue;
- } else if (check_header_variable(avctx, &buf, buf_end, "compression", "compression", 29, &variable_buffer_data_size) >= 0) {
- if (!variable_buffer_data_size)
+ } else if ((var_size = check_header_variable(s, "compression",
+ "compression", 29)) >= 0) {
+ if (!var_size)
return AVERROR_INVALIDDATA;
- if (s->compr == -1)
- s->compr = *buf;
+ if (s->compression == EXR_UNKN)
+ s->compression = bytestream2_get_byte(&s->gb);
else
- av_log(avctx, AV_LOG_WARNING, "Found more than one compression attribute\n");
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Found more than one compression attribute.\n");
- buf += variable_buffer_data_size;
continue;
}
- // Check if there is enough bytes for a header
- if (buf_end - buf <= 9) {
- av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
+ // Check if there are enough bytes for a header
+ if (bytestream2_get_bytes_left(&s->gb) <= 9) {
+ av_log(s->avctx, AV_LOG_ERROR, "Incomplete header\n");
return AVERROR_INVALIDDATA;
}
// Process unknown variables
- for (i = 0; i < 2; i++) {
- // Skip variable name/type
- while (++buf < buf_end)
- if (buf[0] == 0x0)
- break;
- }
- buf++;
+ for (i = 0; i < 2; i++) // value_name and value_type
+ while (bytestream2_get_byte(&s->gb) != 0);
+
// Skip variable length
- if (buf_end - buf >= 5) {
- variable_buffer_data_size = get_header_variable_length(&buf, buf_end);
- if (!variable_buffer_data_size) {
- av_log(avctx, AV_LOG_ERROR, "Incomplete header\n");
- return AVERROR_INVALIDDATA;
- }
- buf += variable_buffer_data_size;
- }
+ bytestream2_skip(&s->gb, bytestream2_get_le32(&s->gb));
}
- if (s->compr == -1) {
- av_log(avctx, AV_LOG_ERROR, "Missing compression attribute\n");
+ if (s->compression == EXR_UNKN) {
+ av_log(s->avctx, AV_LOG_ERROR, "Missing compression attribute.\n");
return AVERROR_INVALIDDATA;
}
+ s->scan_line_size = s->xdelta * current_channel_offset;
- if (buf >= buf_end) {
- av_log(avctx, AV_LOG_ERROR, "Incomplete frame\n");
+ if (bytestream2_get_bytes_left(&s->gb) <= 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Incomplete frame.\n");
return AVERROR_INVALIDDATA;
}
- buf++;
+
+ // aaand we are done
+ bytestream2_skip(&s->gb, 1);
+ return 0;
+}
+
+static int decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
+{
+ EXRContext *s = avctx->priv_data;
+ ThreadFrame frame = { .f = data };
+ AVFrame *picture = data;
+ uint8_t *ptr;
+
+ int y, ret;
+ int out_line_size;
+ int scan_line_blocks;
+
+ bytestream2_init(&s->gb, avpkt->data, avpkt->size);
+
+ if ((ret = decode_header(s)) < 0)
+ return ret;
switch (s->pixel_type) {
case EXR_FLOAT:
@@ -1163,11 +1268,11 @@ static int decode_frame(AVCodecContext *avctx,
avpriv_request_sample(avctx, "32-bit unsigned int");
return AVERROR_PATCHWELCOME;
default:
- av_log(avctx, AV_LOG_ERROR, "Missing channel list\n");
+ av_log(avctx, AV_LOG_ERROR, "Missing channel list.\n");
return AVERROR_INVALIDDATA;
}
- switch (s->compr) {
+ switch (s->compression) {
case EXR_RAW:
case EXR_RLE:
case EXR_ZIP1:
@@ -1181,49 +1286,41 @@ static int decode_frame(AVCodecContext *avctx,
s->scan_lines_per_block = 32;
break;
default:
- avpriv_report_missing_feature(avctx, "Compression %d", s->compr);
+ avpriv_report_missing_feature(avctx, "Compression %d", s->compression);
return AVERROR_PATCHWELCOME;
}
- // Verify the xmin, xmax, ymin, ymax and xdelta before setting the actual image size
- if (s->xmin > s->xmax ||
- s->ymin > s->ymax ||
+ /* Verify the xmin, xmax, ymin, ymax and xdelta before setting
+ * the actual image size. */
+ if (s->xmin > s->xmax ||
+ s->ymin > s->ymax ||
s->xdelta != s->xmax - s->xmin + 1 ||
- s->xmax >= w || s->ymax >= h) {
- av_log(avctx, AV_LOG_ERROR, "Wrong sizing or missing size information\n");
+ s->xmax >= s->w ||
+ s->ymax >= s->h) {
+ av_log(avctx, AV_LOG_ERROR, "Wrong or missing size information.\n");
return AVERROR_INVALIDDATA;
}
- if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
+ if ((ret = ff_set_dimensions(avctx, s->w, s->h)) < 0)
return ret;
- s->desc = av_pix_fmt_desc_get(avctx->pix_fmt);
- out_line_size = avctx->width * 2 * s->desc->nb_components;
- s->scan_line_size = s->xdelta * current_channel_offset;
- scan_line_blocks = (s->ydelta + s->scan_lines_per_block - 1) / s->scan_lines_per_block;
-
- if (s->compr != EXR_RAW) {
- size_t thread_data_size, prev_size;
- EXRThreadData *m;
-
- prev_size = s->thread_data_size;
- if (av_size_mult(avctx->thread_count, sizeof(EXRThreadData), &thread_data_size))
- return AVERROR(EINVAL);
-
- m = av_fast_realloc(s->thread_data, &s->thread_data_size, thread_data_size);
- if (!m)
- return AVERROR(ENOMEM);
- s->thread_data = m;
- memset(s->thread_data + prev_size, 0, s->thread_data_size - prev_size);
- }
+ s->desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ if (!s->desc)
+ return AVERROR_INVALIDDATA;
+ out_line_size = avctx->width * 2 * s->desc->nb_components;
+ scan_line_blocks = (s->ydelta + s->scan_lines_per_block - 1) /
+ s->scan_lines_per_block;
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
- if (buf_end - buf < scan_line_blocks * 8)
+ if (bytestream2_get_bytes_left(&s->gb) < scan_line_blocks * 8)
return AVERROR_INVALIDDATA;
- s->table = buf;
- ptr = picture->data[0];
+
+ // save pointer we are going to use in decode_block
+ s->buf = avpkt->data;
+ s->buf_size = avpkt->size;
+ ptr = picture->data[0];
// Zero out the start if ymin is not 0
for (y = 0; y < s->ymin; y++) {
@@ -1243,15 +1340,74 @@ static int decode_frame(AVCodecContext *avctx,
picture->pict_type = AV_PICTURE_TYPE_I;
*got_frame = 1;
- return buf_size;
+ return avpkt->size;
+}
+
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+ uint32_t i;
+ union av_intfloat32 t;
+ EXRContext *s = avctx->priv_data;
+ float one_gamma = 1.0f / s->gamma;
+
+ s->avctx = avctx;
+ s->xmin = ~0;
+ s->xmax = ~0;
+ s->ymin = ~0;
+ s->ymax = ~0;
+ s->xdelta = ~0;
+ s->ydelta = ~0;
+ s->channel_offsets[0] = -1;
+ s->channel_offsets[1] = -1;
+ s->channel_offsets[2] = -1;
+ s->channel_offsets[3] = -1;
+ s->pixel_type = EXR_UNKNOWN;
+ s->compression = EXR_UNKN;
+ s->nb_channels = 0;
+ s->w = 0;
+ s->h = 0;
+
+ if ( one_gamma > 0.9999f && one_gamma < 1.0001f ) {
+ for ( i = 0; i < 65536; ++i ) {
+ s->gamma_table[i] = exr_halflt2uint(i);
+ }
+ } else {
+ for ( i = 0; i < 65536; ++i ) {
+ t = exr_half2float(i);
+ /* If negative value we reuse half value */
+ if ( t.f <= 0.0f ) {
+ s->gamma_table[i] = exr_halflt2uint(i);
+ } else {
+ t.f = powf(t.f, one_gamma);
+ s->gamma_table[i] = exr_flt2uint(t.i);
+ }
+ }
+ }
+
+ // allocate thread data, used for non EXR_RAW compreesion types
+ s->thread_data = av_mallocz_array(avctx->thread_count, sizeof(EXRThreadData));
+ if (!s->thread_data)
+ return AVERROR_INVALIDDATA;
+
+ return 0;
+}
+
+static int decode_init_thread_copy(AVCodecContext *avctx)
+{ EXRContext *s = avctx->priv_data;
+
+ // allocate thread data, used for non EXR_RAW compreesion types
+ s->thread_data = av_mallocz_array(avctx->thread_count, sizeof(EXRThreadData));
+ if (!s->thread_data)
+ return AVERROR_INVALIDDATA;
+
+ return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
EXRContext *s = avctx->priv_data;
int i;
-
- for (i = 0; i < s->thread_data_size / sizeof(EXRThreadData); i++) {
+ for (i = 0; i < avctx->thread_count; i++) {
EXRThreadData *td = &s->thread_data[i];
av_freep(&td->uncompressed_data);
av_freep(&td->tmp);
@@ -1260,19 +1416,39 @@ static av_cold int decode_end(AVCodecContext *avctx)
}
av_freep(&s->thread_data);
- s->thread_data_size = 0;
av_freep(&s->channels);
return 0;
}
+#define OFFSET(x) offsetof(EXRContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption options[] = {
+ { "layer", "Set the decoding layer", OFFSET(layer),
+ AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD },
+ { "gamma", "Set the float gamma value when decoding (experimental/unsupported)", OFFSET(gamma),
+ AV_OPT_TYPE_FLOAT, { .dbl = 1.0f }, 0.001, FLT_MAX, VD },
+ { NULL },
+};
+
+static const AVClass exr_class = {
+ .class_name = "EXR",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_exr_decoder = {
- .name = "exr",
- .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_EXR,
- .priv_data_size = sizeof(EXRContext),
- .close = decode_end,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS,
+ .name = "exr",
+ .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_EXR,
+ .priv_data_size = sizeof(EXRContext),
+ .init = decode_init,
+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
+ .close = decode_end,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS |
+ CODEC_CAP_SLICE_THREADS,
+ .priv_class = &exr_class,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/faxcompr.c b/chromium/third_party/ffmpeg/libavcodec/faxcompr.c
index 900851b3f1b..155f78da66b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/faxcompr.c
+++ b/chromium/third_party/ffmpeg/libavcodec/faxcompr.c
@@ -287,8 +287,8 @@ int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize,
int runsize = avctx->width + 2;
int has_eol;
- runs = av_malloc(runsize * sizeof(runs[0]));
- ref = av_malloc(runsize * sizeof(ref[0]));
+ runs = av_malloc_array(runsize, sizeof(runs[0]));
+ ref = av_malloc_array(runsize, sizeof(ref[0]));
if (!runs || !ref) {
ret = AVERROR(ENOMEM);
goto fail;
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft-fixed-test.c b/chromium/third_party/ffmpeg/libavcodec/fft-fixed-test.c
index a1a61604a93..330211ebf64 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft-fixed-test.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft-fixed-test.c
@@ -16,5 +16,5 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
+#define FFT_FLOAT 0
#include "fft-test.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft-fixed32-test.c b/chromium/third_party/ffmpeg/libavcodec/fft-fixed32-test.c
index 89cd47c1dae..4bd11cea61e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft-fixed32-test.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft-fixed32-test.c
@@ -16,6 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
-#define CONFIG_FFT_FIXED_32 1
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 1
#include "fft-test.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft-internal.h b/chromium/third_party/ffmpeg/libavcodec/fft-internal.h
index 065eeccef19..0a8f7d05cf8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft-internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/fft-internal.h
@@ -19,7 +19,7 @@
#ifndef AVCODEC_FFT_INTERNAL_H
#define AVCODEC_FFT_INTERNAL_H
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
#define FIX15(v) (v)
#define sqrthalf (float)M_SQRT1_2
@@ -38,7 +38,7 @@
#define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits)))
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
#define CMUL(dre, dim, are, aim, bre, bim) do { \
int64_t accu; \
@@ -52,7 +52,7 @@
#define FIX15(a) av_clip(SCALE_FLOAT(a, 31), -2147483647, 2147483647)
-#else /* CONFIG_FFT_FIXED_32 */
+#else /* FFT_FIXED_32 */
#include "fft.h"
#include "mathops.h"
@@ -79,9 +79,9 @@ void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input);
#define CMULL(dre, dim, are, aim, bre, bim) \
CMULS(dre, dim, are, aim, bre, bim, 0)
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
-#endif /* CONFIG_FFT_FLOAT */
+#endif /* FFT_FLOAT */
#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c)
#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c)
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft-test.c b/chromium/third_party/ffmpeg/libavcodec/fft-test.c
index d650a10844b..a29896fde78 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft-test.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft-test.c
@@ -29,7 +29,7 @@
#include "libavutil/log.h"
#include "libavutil/time.h"
#include "fft.h"
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
#include "dct.h"
#include "rdft.h"
#endif
@@ -51,11 +51,11 @@
pim += (MUL16(are, bim) + MUL16(bre, aim));\
}
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
# define RANGE 1.0
# define REF_SCALE(x, bits) (x)
# define FMT "%10.6f"
-#elif CONFIG_FFT_FIXED_32
+#elif FFT_FIXED_32
# define RANGE 8388608
# define REF_SCALE(x, bits) (x)
# define FMT "%6d"
@@ -75,7 +75,7 @@ static void fft_ref_init(int nbits, int inverse)
double c1, s1, alpha;
n = 1 << nbits;
- exptab = av_malloc((n / 2) * sizeof(*exptab));
+ exptab = av_malloc_array((n / 2), sizeof(*exptab));
for (i = 0; i < (n/2); i++) {
alpha = 2 * M_PI * (float)i / (float)n;
@@ -152,7 +152,7 @@ static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
}
}
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
static void idct_ref(FFTSample *output, FFTSample *input, int nbits)
{
int n = 1<<nbits;
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
int do_inverse = 0;
FFTContext s1, *s = &s1;
FFTContext m1, *m = &m1;
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
RDFTContext r1, *r = &r1;
DCTContext d1, *d = &d1;
int fft_size_2;
@@ -304,10 +304,10 @@ int main(int argc, char **argv)
}
fft_size = 1 << fft_nbits;
- tab = av_malloc(fft_size * sizeof(FFTComplex));
- tab1 = av_malloc(fft_size * sizeof(FFTComplex));
- tab_ref = av_malloc(fft_size * sizeof(FFTComplex));
- tab2 = av_malloc(fft_size * sizeof(FFTSample));
+ tab = av_malloc_array(fft_size, sizeof(FFTComplex));
+ tab1 = av_malloc_array(fft_size, sizeof(FFTComplex));
+ tab_ref = av_malloc_array(fft_size, sizeof(FFTComplex));
+ tab2 = av_malloc_array(fft_size, sizeof(FFTSample));
switch (transform) {
case TRANSFORM_MDCT:
@@ -326,7 +326,7 @@ int main(int argc, char **argv)
ff_fft_init(s, fft_nbits, do_inverse);
fft_ref_init(fft_nbits, do_inverse);
break;
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
case TRANSFORM_RDFT:
if (do_inverse)
av_log(NULL, AV_LOG_INFO,"IDFT_C2R");
@@ -383,7 +383,7 @@ int main(int argc, char **argv)
fft_ref(tab_ref, tab1, fft_nbits);
err = check_diff((FFTSample *)tab_ref, (FFTSample *)tab, fft_size * 2, 1.0);
break;
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
case TRANSFORM_RDFT:
fft_size_2 = fft_size >> 1;
if (do_inverse) {
@@ -452,7 +452,7 @@ int main(int argc, char **argv)
memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
s->fft_calc(s, tab);
break;
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
case TRANSFORM_RDFT:
memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
r->rdft_calc(r, tab2);
@@ -482,7 +482,7 @@ int main(int argc, char **argv)
case TRANSFORM_FFT:
ff_fft_end(s);
break;
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
case TRANSFORM_RDFT:
ff_rdft_end(r);
break;
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft.h b/chromium/third_party/ffmpeg/libavcodec/fft.h
index 217090cf2ac..2d7e2549850 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft.h
+++ b/chromium/third_party/ffmpeg/libavcodec/fft.h
@@ -22,19 +22,19 @@
#ifndef AVCODEC_FFT_H
#define AVCODEC_FFT_H
-#ifndef CONFIG_FFT_FLOAT
-#define CONFIG_FFT_FLOAT 1
+#ifndef FFT_FLOAT
+#define FFT_FLOAT 1
#endif
-#ifndef CONFIG_FFT_FIXED_32
-#define CONFIG_FFT_FIXED_32 0
+#ifndef FFT_FIXED_32
+#define FFT_FIXED_32 0
#endif
#include <stdint.h>
#include "config.h"
#include "libavutil/mem.h"
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
#include "avfft.h"
@@ -44,20 +44,20 @@ typedef float FFTDouble;
#else
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
#define Q31(x) (int)((x)*2147483648.0 + 0.5)
#define FFT_NAME(x) x ## _fixed_32
typedef int32_t FFTSample;
-#else /* CONFIG_FFT_FIXED_32 */
+#else /* FFT_FIXED_32 */
#define FFT_NAME(x) x ## _fixed
typedef int16_t FFTSample;
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
typedef struct FFTComplex {
FFTSample re, im;
@@ -66,7 +66,7 @@ typedef struct FFTComplex {
typedef int FFTDouble;
typedef struct FFTContext FFTContext;
-#endif /* CONFIG_FFT_FLOAT */
+#endif /* FFT_FLOAT */
typedef struct FFTDComplex {
FFTDouble re, im;
@@ -148,6 +148,7 @@ void ff_init_ff_cos_tabs(int index);
*/
int ff_fft_init(FFTContext *s, int nbits, int inverse);
+void ff_fft_init_aarch64(FFTContext *s);
void ff_fft_init_x86(FFTContext *s);
void ff_fft_init_arm(FFTContext *s);
void ff_fft_init_mips(FFTContext *s);
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft_fixed.c b/chromium/third_party/ffmpeg/libavcodec/fft_fixed.c
index 9e74b8c160a..3d3bd2fca61 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft_fixed.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft_fixed.c
@@ -16,6 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
-#define CONFIG_FFT_FIXED_32 0
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 0
#include "fft_template.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft_fixed_32.c b/chromium/third_party/ffmpeg/libavcodec/fft_fixed_32.c
index 18e6da90976..fbdbf847e23 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft_fixed_32.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft_fixed_32.c
@@ -47,6 +47,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
-#define CONFIG_FFT_FIXED_32 1
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 1
#include "fft_template.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft_float.c b/chromium/third_party/ffmpeg/libavcodec/fft_float.c
index 93d36071a22..73cc98d0d4b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft_float.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft_float.c
@@ -16,6 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 1
-#define CONFIG_FFT_FIXED_32 0
+#define FFT_FLOAT 1
+#define FFT_FIXED_32 0
#include "fft_template.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft_table.h b/chromium/third_party/ffmpeg/libavcodec/fft_table.h
index 687e5b94fd5..7f3142d7a9f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft_table.h
+++ b/chromium/third_party/ffmpeg/libavcodec/fft_table.h
@@ -56,7 +56,7 @@
#include "libavcodec/fft.h"
-#define MAX_LOG2_NFFT 16 //!< Specifies maxiumum allowed fft size
+#define MAX_LOG2_NFFT 16 //!< Specifies maximum allowed fft size
#define MAX_FFT_SIZE (1 << MAX_LOG2_NFFT)
extern int32_t w_tab_sr[];
diff --git a/chromium/third_party/ffmpeg/libavcodec/fft_template.c b/chromium/third_party/ffmpeg/libavcodec/fft_template.c
index e0cf1f29822..b8d6417fd13 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fft_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fft_template.c
@@ -32,9 +32,9 @@
#include "fft.h"
#include "fft-internal.h"
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
#include "fft_table.h"
-#else /* CONFIG_FFT_FIXED_32 */
+#else /* FFT_FIXED_32 */
/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
#if !CONFIG_HARDCODED_TABLES
@@ -69,7 +69,7 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
FFT_NAME(ff_cos_65536),
};
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
static void fft_permute_c(FFTContext *s, FFTComplex *z);
static void fft_calc_c(FFTContext *s, FFTComplex *z);
@@ -87,7 +87,7 @@ static int split_radix_permutation(int i, int n, int inverse)
av_cold void ff_init_ff_cos_tabs(int index)
{
-#if (!CONFIG_HARDCODED_TABLES) && (!CONFIG_FFT_FIXED_32)
+#if (!CONFIG_HARDCODED_TABLES) && (!FFT_FIXED_32)
int i;
int m = 1<<index;
double freq = 2*M_PI/m;
@@ -163,13 +163,14 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
s->mdct_calc = ff_mdct_calc_c;
#endif
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
{
int n=0;
ff_fft_lut_init(fft_offsets_lut, 0, 1 << 16, &n);
}
-#else /* CONFIG_FFT_FIXED_32 */
-#if CONFIG_FFT_FLOAT
+#else /* FFT_FIXED_32 */
+#if FFT_FLOAT
+ if (ARCH_AARCH64) ff_fft_init_aarch64(s);
if (ARCH_ARM) ff_fft_init_arm(s);
if (ARCH_PPC) ff_fft_init_ppc(s);
if (ARCH_X86) ff_fft_init_x86(s);
@@ -182,7 +183,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
for(j=4; j<=nbits; j++) {
ff_init_ff_cos_tabs(j);
}
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
if (s->fft_permutation == FF_FFT_PERM_AVX) {
@@ -219,7 +220,7 @@ av_cold void ff_fft_end(FFTContext *s)
av_freep(&s->tmp_buf);
}
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
static void fft_calc_c(FFTContext *s, FFTComplex *z) {
@@ -380,7 +381,7 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
}
}
-#else /* CONFIG_FFT_FIXED_32 */
+#else /* FFT_FIXED_32 */
#define BUTTERFLIES(a0,a1,a2,a3) {\
BF(t3, t5, t5, t1);\
@@ -527,4 +528,4 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
{
fft_dispatch[s->nbits-2](z);
}
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ffv1.c b/chromium/third_party/ffmpeg/libavcodec/ffv1.c
index f8556b01f17..ab58a6074f7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ffv1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ffv1.c
@@ -54,8 +54,6 @@ av_cold int ffv1_common_init(AVCodecContext *avctx)
if (!s->picture.f || !s->last_picture.f)
return AVERROR(ENOMEM);
- ff_dsputil_init(&s->dsp, avctx);
-
s->width = avctx->width;
s->height = avctx->height;
@@ -77,13 +75,13 @@ av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
if (fs->ac) {
if (!p->state)
- p->state = av_malloc(CONTEXT_SIZE * p->context_count *
+ p->state = av_malloc_array(p->context_count, CONTEXT_SIZE *
sizeof(uint8_t));
if (!p->state)
return AVERROR(ENOMEM);
} else {
if (!p->vlc_state)
- p->vlc_state = av_malloc(p->context_count * sizeof(VlcState));
+ p->vlc_state = av_malloc_array(p->context_count, sizeof(VlcState));
if (!p->vlc_state)
return AVERROR(ENOMEM);
}
@@ -139,7 +137,7 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
fs->slice_x = sxs;
fs->slice_y = sys;
- fs->sample_buffer = av_malloc(3 * MAX_PLANES * (fs->width + 6) *
+ fs->sample_buffer = av_malloc_array((fs->width + 6), 3 * MAX_PLANES *
sizeof(*fs->sample_buffer));
if (!fs->sample_buffer)
return AVERROR(ENOMEM);
@@ -152,7 +150,7 @@ int ffv1_allocate_initial_states(FFV1Context *f)
int i;
for (i = 0; i < f->quant_table_count; i++) {
- f->initial_states[i] = av_malloc(f->context_count[i] *
+ f->initial_states[i] = av_malloc_array(f->context_count[i],
sizeof(*f->initial_states[i]));
if (!f->initial_states[i])
return AVERROR(ENOMEM);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ffv1.h b/chromium/third_party/ffmpeg/libavcodec/ffv1.h
index 2c3e6e4c983..5081397f54b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ffv1.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ffv1.h
@@ -35,7 +35,6 @@
#include "libavutil/pixdesc.h"
#include "libavutil/timer.h"
#include "avcodec.h"
-#include "dsputil.h"
#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
@@ -54,8 +53,6 @@
#define MAX_QUANT_TABLES 8
#define MAX_CONTEXT_INPUTS 5
-extern const uint8_t ff_log2_run[41];
-
typedef struct VlcState {
int16_t drift;
uint16_t error_sum;
@@ -118,8 +115,6 @@ typedef struct FFV1Context {
int gob_count;
int quant_table_count;
- DSPContext dsp;
-
struct FFV1Context *slice_context[MAX_SLICES];
int slice_count;
int num_v_slices;
@@ -130,7 +125,8 @@ typedef struct FFV1Context {
int slice_y;
int slice_reset_contexts;
int slice_coding_mode;
- int slice_rct_y_coef;
+ int slice_rct_by_coef;
+ int slice_rct_ry_coef;
} FFV1Context;
int ffv1_common_init(AVCodecContext *avctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ffv1dec.c b/chromium/third_party/ffmpeg/libavcodec/ffv1dec.c
index 6c01ebf15f9..a0a50abed4d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ffv1dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ffv1dec.c
@@ -260,7 +260,7 @@ static void decode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int
if (s->slice_coding_mode != 1) {
b -= offset;
r -= offset;
- g -= ((b + r) * s->slice_rct_y_coef) >> 2;
+ g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;
b += g;
r += g;
}
@@ -334,8 +334,9 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
fs->slice_reset_contexts = get_rac(c, state);
fs->slice_coding_mode = get_symbol(c, state, 0);
if (fs->slice_coding_mode != 1) {
- fs->slice_rct_y_coef = get_symbol(c, state, 0);
- if (fs->slice_rct_y_coef > 2U) {
+ fs->slice_rct_by_coef = get_symbol(c, state, 0);
+ fs->slice_rct_ry_coef = get_symbol(c, state, 0);
+ if ((uint64_t)fs->slice_rct_by_coef + (uint64_t)fs->slice_rct_ry_coef > 4) {
av_log(f->avctx, AV_LOG_ERROR, "slice_rct_y_coef out of range\n");
return AVERROR_INVALIDDATA;
}
@@ -379,16 +380,17 @@ static int decode_slice(AVCodecContext *c, void *arg)
pdst->vlc_state = NULL;
if (fssrc->ac) {
- pdst->state = av_malloc(CONTEXT_SIZE * psrc->context_count);
+ pdst->state = av_malloc_array(CONTEXT_SIZE, psrc->context_count);
memcpy(pdst->state, psrc->state, CONTEXT_SIZE * psrc->context_count);
} else {
- pdst->vlc_state = av_malloc(sizeof(*pdst->vlc_state) * psrc->context_count);
+ pdst->vlc_state = av_malloc_array(sizeof(*pdst->vlc_state), psrc->context_count);
memcpy(pdst->vlc_state, psrc->vlc_state, sizeof(*pdst->vlc_state) * psrc->context_count);
}
}
}
- fs->slice_rct_y_coef = 1;
+ fs->slice_rct_by_coef = 1;
+ fs->slice_rct_ry_coef = 1;
if (f->version > 2) {
if (ffv1_init_slice_state(f, fs) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/ffv1enc.c b/chromium/third_party/ffmpeg/libavcodec/ffv1enc.c
index 25a69bf8e07..c7479e649ff 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ffv1enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ffv1enc.c
@@ -405,7 +405,7 @@ static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
return 0;
}
-static int encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
+static int encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, const int stride[3])
{
int x, y, p, i;
const int ring_size = s->avctx->context_model ? 3 : 2;
@@ -441,7 +441,7 @@ static int encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int s
if (s->slice_coding_mode != 1) {
b -= g;
r -= g;
- g += ((b + r) * s->slice_rct_y_coef) >> 2;
+ g += (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;
b += offset;
r += offset;
}
@@ -560,7 +560,7 @@ static int write_extradata(FFV1Context *f)
if (f->version == 3) {
f->micro_version = 4;
} else if (f->version == 4)
- f->micro_version = 1;
+ f->micro_version = 2;
put_symbol(c, state, f->micro_version, 0);
}
@@ -674,6 +674,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
if ((avctx->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)) || avctx->slices>1)
s->version = FFMAX(s->version, 2);
+ // Unspecified level & slices, we choose version 1.2+ to ensure multithreaded decodability
+ if (avctx->slices == 0 && avctx->level < 0 && avctx->width * avctx->height > 720*576)
+ s->version = FFMAX(s->version, 2);
+
if (avctx->level <= 0 && s->version == 2) {
s->version = 3;
}
@@ -999,14 +1003,36 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
if (fs->slice_coding_mode == 1)
ffv1_clear_slice_state(f, fs);
put_symbol(c, state, fs->slice_coding_mode, 0);
- if (fs->slice_coding_mode != 1)
- put_symbol(c, state, fs->slice_rct_y_coef, 0);
+ if (fs->slice_coding_mode != 1) {
+ put_symbol(c, state, fs->slice_rct_by_coef, 0);
+ put_symbol(c, state, fs->slice_rct_ry_coef, 0);
+ }
}
}
static void choose_rct_params(FFV1Context *fs, uint8_t *src[3], const int stride[3], int w, int h)
{
- int stat[3] = {0};
+#define NB_Y_COEFF 15
+ static const int rct_y_coeff[15][2] = {
+ {0, 0}, // 4G
+ {1, 1}, // R + 2G + B
+ {2, 2}, // 2R + 2B
+ {0, 2}, // 2G + 2B
+ {2, 0}, // 2R + 2G
+ {4, 0}, // 4R
+ {0, 4}, // 4B
+
+ {0, 3}, // 1G + 3B
+ {3, 0}, // 3R + 1G
+ {3, 1}, // 3R + B
+ {1, 3}, // R + 3B
+ {1, 2}, // R + G + 2B
+ {2, 1}, // 2R + G + B
+ {0, 1}, // 3G + B
+ {1, 0}, // R + 3G
+ };
+
+ int stat[NB_Y_COEFF] = {0};
int x, y, i, p, best;
int16_t *sample[3];
int lbd = fs->bits_per_raw_sample <= 8;
@@ -1018,6 +1044,7 @@ static void choose_rct_params(FFV1Context *fs, uint8_t *src[3], const int stride
for (x = 0; x < w; x++) {
int b, g, r;
+ int ab, ag, ar;
if (lbd) {
unsigned v = *((uint32_t*)(src[0] + x*4 + stride[0]*y));
b = v & 0xFF;
@@ -1029,10 +1056,10 @@ static void choose_rct_params(FFV1Context *fs, uint8_t *src[3], const int stride
r = *((uint16_t*)(src[2] + x*2 + stride[2]*y));
}
+ ar = r - lastr;
+ ag = g - lastg;
+ ab = b - lastb;
if (x && y) {
- int ar = r - lastr;
- int ag = g - lastg;
- int ab = b - lastb;
int bg = ag - sample[0][x];
int bb = ab - sample[1][x];
int br = ar - sample[2][x];
@@ -1040,14 +1067,14 @@ static void choose_rct_params(FFV1Context *fs, uint8_t *src[3], const int stride
br -= bg;
bb -= bg;
- stat[0] += FFABS(bg);
- stat[1] += FFABS(bg + ((br+bb)>>2));
- stat[2] += FFABS(bg + ((br+bb)>>1));
+ for (i = 0; i<NB_Y_COEFF; i++) {
+ stat[i] += FFABS(bg + ((br*rct_y_coeff[i][0] + bb*rct_y_coeff[i][1])>>2));
+ }
- sample[0][x] = ag;
- sample[1][x] = ab;
- sample[2][x] = ar;
}
+ sample[0][x] = ag;
+ sample[1][x] = ab;
+ sample[2][x] = ar;
lastr = r;
lastg = g;
@@ -1056,12 +1083,13 @@ static void choose_rct_params(FFV1Context *fs, uint8_t *src[3], const int stride
}
best = 0;
- for (i=1; i<=2; i++) {
+ for (i=1; i<NB_Y_COEFF; i++) {
if (stat[i] < stat[best])
best = i;
}
- fs->slice_rct_y_coef = best;
+ fs->slice_rct_by_coef = rct_y_coeff[best][1];
+ fs->slice_rct_ry_coef = rct_y_coeff[best][0];
}
static int encode_slice(AVCodecContext *c, void *arg)
@@ -1084,7 +1112,8 @@ static int encode_slice(AVCodecContext *c, void *arg)
if (f->version > 3) {
choose_rct_params(fs, planes, p->linesize, width, height);
} else {
- fs->slice_rct_y_coef = 1;
+ fs->slice_rct_by_coef = 1;
+ fs->slice_rct_ry_coef = 1;
}
retry:
diff --git a/chromium/third_party/ffmpeg/libavcodec/ffwavesynth.c b/chromium/third_party/ffmpeg/libavcodec/ffwavesynth.c
index a62746d61c5..4a5031a8cae 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ffwavesynth.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ffwavesynth.c
@@ -93,7 +93,6 @@ struct wavesynth_context {
int64_t cur_ts;
int64_t next_ts;
int32_t *sin;
- AVFrame frame;
struct ws_interval *inter;
uint32_t dither_state;
uint32_t pink_state;
@@ -341,8 +340,6 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
ws->pink_need += ws->inter[i].type == WS_NOISE;
ws->pink_state = MKTAG('P','I','N','K');
ws->pink_pos = PINK_UNIT;
- avcodec_get_frame_defaults(&ws->frame);
- avc->coded_frame = &ws->frame;
wavesynth_seek(ws, 0);
avc->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
@@ -428,6 +425,7 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
AVPacket *packet)
{
struct wavesynth_context *ws = avc->priv_data;
+ AVFrame *frame = rframe;
int64_t ts;
int duration;
int s, c, r;
@@ -443,11 +441,11 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
duration = AV_RL32(packet->data + 8);
if (duration <= 0)
return AVERROR(EINVAL);
- ws->frame.nb_samples = duration;
- r = ff_get_buffer(avc, &ws->frame, 0);
+ frame->nb_samples = duration;
+ r = ff_get_buffer(avc, frame, 0);
if (r < 0)
return r;
- pcm = (int16_t *)ws->frame.data[0];
+ pcm = (int16_t *)frame->data[0];
for (s = 0; s < duration; s++, ts++) {
memset(channels, 0, avc->channels * sizeof(*channels));
if (ts >= ws->next_ts)
@@ -458,7 +456,6 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
}
ws->cur_ts += duration;
*rgot_frame = 1;
- *(AVFrame *)rframe = ws->frame;
return packet->size;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/fic.c b/chromium/third_party/ffmpeg/libavcodec/fic.c
new file mode 100644
index 00000000000..d08d240efef
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/fic.c
@@ -0,0 +1,459 @@
+/*
+ * Mirillis FIC decoder
+ *
+ * Copyright (c) 2014 Konstantin Shishkov
+ * Copyright (c) 2014 Derek Buitenhuis
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "avcodec.h"
+#include "internal.h"
+#include "get_bits.h"
+#include "golomb.h"
+
+typedef struct FICThreadContext {
+ DECLARE_ALIGNED(16, int16_t, block)[64];
+ uint8_t *src;
+ int slice_h;
+ int src_size;
+ int y_off;
+} FICThreadContext;
+
+typedef struct FICContext {
+ AVCodecContext *avctx;
+ AVFrame *frame;
+ AVFrame *final_frame;
+
+ FICThreadContext *slice_data;
+ int slice_data_size;
+
+ const uint8_t *qmat;
+
+ enum AVPictureType cur_frame_type;
+
+ int aligned_width, aligned_height;
+ int num_slices, slice_h;
+
+ uint8_t cursor_buf[4096];
+} FICContext;
+
+static const uint8_t fic_qmat_hq[64] = {
+ 1, 2, 2, 2, 3, 3, 3, 4,
+ 2, 2, 2, 3, 3, 3, 4, 4,
+ 2, 2, 3, 3, 3, 4, 4, 4,
+ 2, 2, 3, 3, 3, 4, 4, 5,
+ 2, 3, 3, 3, 4, 4, 5, 6,
+ 3, 3, 3, 4, 4, 5, 6, 7,
+ 3, 3, 3, 4, 4, 5, 7, 7,
+ 3, 3, 4, 4, 5, 7, 7, 7,
+};
+
+static const uint8_t fic_qmat_lq[64] = {
+ 1, 5, 6, 7, 8, 9, 9, 11,
+ 5, 5, 7, 8, 9, 9, 11, 12,
+ 6, 7, 8, 9, 9, 11, 11, 12,
+ 7, 7, 8, 9, 9, 11, 12, 13,
+ 7, 8, 9, 9, 10, 11, 13, 16,
+ 8, 9, 9, 10, 11, 13, 16, 19,
+ 8, 9, 9, 11, 12, 15, 18, 23,
+ 9, 9, 11, 12, 15, 18, 23, 27
+};
+
+static const uint8_t fic_header[7] = { 0, 0, 1, 'F', 'I', 'C', 'V' };
+
+#define FIC_HEADER_SIZE 27
+
+static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd)
+{
+ const int t0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];
+ const int t1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];
+ const int t2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];
+ const int t3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];
+ const int t4 = 5793 * (t2 + t0 + 0x800 >> 12);
+ const int t5 = 5793 * (t3 + t1 + 0x800 >> 12);
+ const int t6 = t2 - t0;
+ const int t7 = t3 - t1;
+ const int t8 = 17734 * blk[2 * step] - 42813 * blk[6 * step];
+ const int t9 = 17734 * blk[6 * step] + 42814 * blk[2 * step];
+ const int tA = (blk[0 * step] - blk[4 * step] << 15) + rnd;
+ const int tB = (blk[0 * step] + blk[4 * step] << 15) + rnd;
+ blk[0 * step] = ( t4 + t9 + tB) >> shift;
+ blk[1 * step] = ( t6 + t7 + t8 + tA) >> shift;
+ blk[2 * step] = ( t6 - t7 - t8 + tA) >> shift;
+ blk[3 * step] = ( t5 - t9 + tB) >> shift;
+ blk[4 * step] = ( -t5 - t9 + tB) >> shift;
+ blk[5 * step] = (-(t6 - t7) - t8 + tA) >> shift;
+ blk[6 * step] = (-(t6 + t7) + t8 + tA) >> shift;
+ blk[7 * step] = ( -t4 + t9 + tB) >> shift;
+}
+
+static void fic_idct_put(uint8_t *dst, int stride, int16_t *block)
+{
+ int i, j;
+ int16_t *ptr;
+
+ ptr = block;
+ fic_idct(ptr++, 8, 13, (1 << 12) + (1 << 17));
+ for (i = 1; i < 8; i++) {
+ fic_idct(ptr, 8, 13, 1 << 12);
+ ptr++;
+ }
+
+ ptr = block;
+ for (i = 0; i < 8; i++) {
+ fic_idct(ptr, 1, 20, 0);
+ ptr += 8;
+ }
+
+ ptr = block;
+ for (j = 0; j < 8; j++) {
+ for (i = 0; i < 8; i++)
+ dst[i] = av_clip_uint8(ptr[i]);
+ dst += stride;
+ ptr += 8;
+ }
+}
+static int fic_decode_block(FICContext *ctx, GetBitContext *gb,
+ uint8_t *dst, int stride, int16_t *block)
+{
+ int i, num_coeff;
+
+ /* Is it a skip block? */
+ if (get_bits1(gb)) {
+ /* This is a P-frame. */
+ ctx->frame->key_frame = 0;
+ ctx->frame->pict_type = AV_PICTURE_TYPE_P;
+
+ return 0;
+ }
+
+ memset(block, 0, sizeof(*block) * 64);
+
+ num_coeff = get_bits(gb, 7);
+ if (num_coeff > 64)
+ return AVERROR_INVALIDDATA;
+
+ for (i = 0; i < num_coeff; i++)
+ block[ff_zigzag_direct[i]] = get_se_golomb(gb) *
+ ctx->qmat[ff_zigzag_direct[i]];
+
+ fic_idct_put(dst, stride, block);
+
+ return 0;
+}
+
+static int fic_decode_slice(AVCodecContext *avctx, void *tdata)
+{
+ FICContext *ctx = avctx->priv_data;
+ FICThreadContext *tctx = tdata;
+ GetBitContext gb;
+ uint8_t *src = tctx->src;
+ int slice_h = tctx->slice_h;
+ int src_size = tctx->src_size;
+ int y_off = tctx->y_off;
+ int x, y, p;
+
+ init_get_bits(&gb, src, src_size * 8);
+
+ for (p = 0; p < 3; p++) {
+ int stride = ctx->frame->linesize[p];
+ uint8_t* dst = ctx->frame->data[p] + (y_off >> !!p) * stride;
+
+ for (y = 0; y < (slice_h >> !!p); y += 8) {
+ for (x = 0; x < (ctx->aligned_width >> !!p); x += 8) {
+ int ret;
+
+ if ((ret = fic_decode_block(ctx, &gb, dst + x, stride, tctx->block)) != 0)
+ return ret;
+ }
+
+ dst += 8 * stride;
+ }
+ }
+
+ return 0;
+}
+
+static av_always_inline void fic_alpha_blend(uint8_t *dst, uint8_t *src,
+ int size, uint8_t *alpha)
+{
+ int i;
+
+ for (i = 0; i < size; i++)
+ dst[i] += ((src[i] - dst[i]) * alpha[i]) >> 8;
+}
+
+static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y)
+{
+ FICContext *ctx = avctx->priv_data;
+ uint8_t *ptr = ctx->cursor_buf;
+ uint8_t *dstptr[3];
+ uint8_t planes[4][1024];
+ uint8_t chroma[3][256];
+ int i, j, p;
+
+ /* Convert to YUVA444. */
+ for (i = 0; i < 1024; i++) {
+ planes[0][i] = (( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16;
+ planes[1][i] = ((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128;
+ planes[2][i] = ((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128;
+ planes[3][i] = ptr[3];
+
+ ptr += 4;
+ }
+
+ /* Subsample chroma. */
+ for (i = 0; i < 32; i += 2)
+ for (j = 0; j < 32; j += 2)
+ for (p = 0; p < 3; p++)
+ chroma[p][16 * (i / 2) + j / 2] = (planes[p + 1][32 * i + j ] +
+ planes[p + 1][32 * i + j + 1] +
+ planes[p + 1][32 * (i + 1) + j ] +
+ planes[p + 1][32 * (i + 1) + j + 1]) / 4;
+
+ /* Seek to x/y pos of cursor. */
+ for (i = 0; i < 3; i++)
+ dstptr[i] = ctx->final_frame->data[i] +
+ (ctx->final_frame->linesize[i] * (cur_y >> !!i)) +
+ (cur_x >> !!i) + !!i;
+
+ /* Copy. */
+ for (i = 0; i < FFMIN(32, avctx->height - cur_y) - 1; i += 2) {
+ int lsize = FFMIN(32, avctx->width - cur_x);
+ int csize = lsize / 2;
+
+ fic_alpha_blend(dstptr[0],
+ planes[0] + i * 32, lsize, planes[3] + i * 32);
+ fic_alpha_blend(dstptr[0] + ctx->final_frame->linesize[0],
+ planes[0] + (i + 1) * 32, lsize, planes[3] + (i + 1) * 32);
+ fic_alpha_blend(dstptr[1],
+ chroma[0] + (i / 2) * 16, csize, chroma[2] + (i / 2) * 16);
+ fic_alpha_blend(dstptr[2],
+ chroma[1] + (i / 2) * 16, csize, chroma[2] + (i / 2) * 16);
+
+ dstptr[0] += ctx->final_frame->linesize[0] * 2;
+ dstptr[1] += ctx->final_frame->linesize[1];
+ dstptr[2] += ctx->final_frame->linesize[2];
+ }
+}
+
+static int fic_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
+{
+ FICContext *ctx = avctx->priv_data;
+ uint8_t *src = avpkt->data;
+ int ret;
+ int slice, nslices;
+ int msize;
+ int tsize;
+ int cur_x, cur_y;
+ int skip_cursor = 0;
+ uint8_t *sdata;
+
+ if ((ret = ff_reget_buffer(avctx, ctx->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ return ret;
+ }
+
+ /* Header + at least one slice (4) */
+ if (avpkt->size < FIC_HEADER_SIZE + 4) {
+ av_log(avctx, AV_LOG_ERROR, "Frame data is too small.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ /* Check for header. */
+ if (memcmp(src, fic_header, 7))
+ av_log(avctx, AV_LOG_WARNING, "Invalid FIC Header.\n");
+
+ /* Is it a skip frame? */
+ if (src[17])
+ goto skip;
+
+ nslices = src[13];
+ if (!nslices) {
+ av_log(avctx, AV_LOG_ERROR, "Zero slices found.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ /* High or Low Quality Matrix? */
+ ctx->qmat = src[23] ? fic_qmat_hq : fic_qmat_lq;
+
+ /* Skip cursor data. */
+ tsize = AV_RB24(src + 24);
+ if (tsize > avpkt->size - FIC_HEADER_SIZE) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Packet is too small to contain cursor (%d vs %d bytes).\n",
+ tsize, avpkt->size - FIC_HEADER_SIZE);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (tsize < 32) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Cursor data too small. Skipping cursor.\n");
+ skip_cursor = 1;
+ }
+
+ /* Cursor position. */
+ cur_x = AV_RL16(src + 33);
+ cur_y = AV_RL16(src + 35);
+ if (cur_x > avctx->width || cur_y > avctx->height) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Invalid cursor position: (%d,%d). Skipping cusor.\n",
+ cur_x, cur_y);
+ skip_cursor = 1;
+ }
+
+ if (AV_RL16(src + 37) != 32 || AV_RL16(src + 39) != 32) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Invalid cursor size. Skipping cursor.\n");
+ skip_cursor = 1;
+ }
+
+ /* Slice height for all but the last slice. */
+ ctx->slice_h = 16 * (ctx->aligned_height >> 4) / nslices;
+ if (ctx->slice_h % 16)
+ ctx->slice_h = FFALIGN(ctx->slice_h - 16, 16);
+
+ /* First slice offset and remaining data. */
+ sdata = src + tsize + FIC_HEADER_SIZE + 4 * nslices;
+ msize = avpkt->size - nslices * 4 - tsize - FIC_HEADER_SIZE;
+
+ if (msize <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "Not enough frame data to decode.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ /*
+ * Set the frametype to I initially. It will be set to P if the frame
+ * has any dependencies (skip blocks). There will be a race condition
+ * inside the slice decode function to set these, but we do not care.
+ * since they will only ever be set to 0/P.
+ */
+ ctx->frame->key_frame = 1;
+ ctx->frame->pict_type = AV_PICTURE_TYPE_I;
+
+ /* Allocate slice data. */
+ av_fast_malloc(&ctx->slice_data, &ctx->slice_data_size,
+ nslices * sizeof(ctx->slice_data[0]));
+ if (!ctx->slice_data_size) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate slice data.\n");
+ return AVERROR(ENOMEM);
+ }
+ memset(ctx->slice_data, 0, nslices * sizeof(ctx->slice_data[0]));
+
+ for (slice = 0; slice < nslices; slice++) {
+ unsigned slice_off = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4);
+ unsigned slice_size;
+ int y_off = ctx->slice_h * slice;
+ int slice_h = ctx->slice_h;
+
+ /*
+ * Either read the slice size, or consume all data left.
+ * Also, special case the last slight height.
+ */
+ if (slice == nslices - 1) {
+ slice_size = msize;
+ slice_h = FFALIGN(avctx->height - ctx->slice_h * (nslices - 1), 16);
+ } else {
+ slice_size = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4 + 4);
+ }
+
+ if (slice_size < slice_off || slice_size > msize)
+ continue;
+
+ slice_size -= slice_off;
+
+ ctx->slice_data[slice].src = sdata + slice_off;
+ ctx->slice_data[slice].src_size = slice_size;
+ ctx->slice_data[slice].slice_h = slice_h;
+ ctx->slice_data[slice].y_off = y_off;
+ }
+
+ if ((ret = avctx->execute(avctx, fic_decode_slice, ctx->slice_data,
+ NULL, nslices, sizeof(ctx->slice_data[0]))) < 0)
+ return ret;
+
+ av_frame_free(&ctx->final_frame);
+ ctx->final_frame = av_frame_clone(ctx->frame);
+ if (!ctx->final_frame) {
+ av_log(avctx, AV_LOG_ERROR, "Could not clone frame buffer.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ /* Make sure we use a user-supplied buffer. */
+ if ((ret = ff_reget_buffer(avctx, ctx->final_frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Could not make frame writable.\n");
+ return ret;
+ }
+
+ /* Draw cursor. */
+ if (!skip_cursor) {
+ memcpy(ctx->cursor_buf, src + 59, 32 * 32 * 4);
+ fic_draw_cursor(avctx, cur_x, cur_y);
+ }
+
+skip:
+ *got_frame = 1;
+ if ((ret = av_frame_ref(data, ctx->final_frame)) < 0)
+ return ret;
+
+ return avpkt->size;
+}
+
+static av_cold int fic_decode_close(AVCodecContext *avctx)
+{
+ FICContext *ctx = avctx->priv_data;
+
+ av_freep(&ctx->slice_data);
+ av_frame_free(&ctx->final_frame);
+ av_frame_free(&ctx->frame);
+
+ return 0;
+}
+
+static av_cold int fic_decode_init(AVCodecContext *avctx)
+{
+ FICContext *ctx = avctx->priv_data;
+
+ /* Initialize various context values */
+ ctx->avctx = avctx;
+ ctx->aligned_width = FFALIGN(avctx->width, 16);
+ ctx->aligned_height = FFALIGN(avctx->height, 16);
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ avctx->bits_per_raw_sample = 8;
+
+ ctx->frame = av_frame_alloc();
+ if (!ctx->frame)
+ return AVERROR(ENOMEM);
+
+ return 0;
+}
+
+AVCodec ff_fic_decoder = {
+ .name = "fic",
+ .long_name = NULL_IF_CONFIG_SMALL("Mirillis FIC"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_FIC,
+ .priv_data_size = sizeof(FICContext),
+ .init = fic_decode_init,
+ .decode = fic_decode_frame,
+ .close = fic_decode_close,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/flac_parser.c b/chromium/third_party/ffmpeg/libavcodec/flac_parser.c
index ba1f060fd9e..3178ee5e553 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flac_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flac_parser.c
@@ -489,6 +489,14 @@ static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf,
&fpc->wrap_buf,
&fpc->wrap_buf_allocated_size);
+
+ if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){
+ if (header->fi.is_var_size)
+ fpc->pc->pts = header->fi.frame_or_sample_num;
+ else if (header->best_child)
+ fpc->pc->pts = header->fi.frame_or_sample_num * header->fi.blocksize;
+ }
+
fpc->best_header_valid = 0;
fpc->last_fi_valid = 1;
fpc->last_fi = header->fi;
@@ -516,6 +524,11 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
s->duration = fi.blocksize;
if (!avctx->sample_rate)
avctx->sample_rate = fi.samplerate;
+ if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){
+ fpc->pc->pts = fi.frame_or_sample_num;
+ if (!fi.is_var_size)
+ fpc->pc->pts *= fi.blocksize;
+ }
}
*poutbuf = buf;
*poutbuf_size = buf_size;
@@ -599,7 +612,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
if ( av_fifo_space(fpc->fifo_buf) < read_end - read_start
&& av_fifo_realloc2(fpc->fifo_buf, (read_end - read_start) + 2*av_fifo_size(fpc->fifo_buf)) < 0) {
av_log(avctx, AV_LOG_ERROR,
- "couldn't reallocate buffer of size %td\n",
+ "couldn't reallocate buffer of size %"PTRDIFF_SPECIFIER"\n",
(read_end - read_start) + av_fifo_size(fpc->fifo_buf));
goto handle_error;
}
@@ -711,7 +724,7 @@ static void flac_parse_close(AVCodecParserContext *c)
av_free(curr);
curr = temp;
}
- av_fifo_free(fpc->fifo_buf);
+ av_fifo_freep(&fpc->fifo_buf);
av_free(fpc->wrap_buf);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/flacdec.c b/chromium/third_party/ffmpeg/libavcodec/flacdec.c
index 596b24d76d1..ec3cbffbf42 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flacdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flacdec.c
@@ -221,6 +221,12 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
+ if (samples << rice_order != s->blocksize) {
+ av_log(s->avctx, AV_LOG_ERROR, "invalid rice order: %i blocksize %i\n",
+ rice_order, s->blocksize);
+ return AVERROR_INVALIDDATA;
+ }
+
if (pred_order > samples) {
av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
pred_order, samples);
@@ -506,12 +512,12 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,
}
if (buf_size > 5 && !memcmp(buf, "\177FLAC", 5)) {
- av_log(s->avctx, AV_LOG_DEBUG, "skiping flac header packet 1\n");
+ av_log(s->avctx, AV_LOG_DEBUG, "skipping flac header packet 1\n");
return buf_size;
}
if (buf_size > 0 && (*buf & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
- av_log(s->avctx, AV_LOG_DEBUG, "skiping vorbis comment\n");
+ av_log(s->avctx, AV_LOG_DEBUG, "skipping vorbis comment\n");
return buf_size;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/flacdsp.c b/chromium/third_party/ffmpeg/libavcodec/flacdsp.c
index 02eba3ea8af..b15bc7476b2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flacdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flacdsp.c
@@ -128,4 +128,6 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt,
if (ARCH_ARM)
ff_flacdsp_init_arm(c, fmt, bps);
+ if (ARCH_X86)
+ ff_flacdsp_init_x86(c, fmt, bps);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/flacdsp.h b/chromium/third_party/ffmpeg/libavcodec/flacdsp.h
index 5e66dc2f109..272cf2a6749 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flacdsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/flacdsp.h
@@ -33,5 +33,6 @@ typedef struct FLACDSPContext {
void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
+void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
#endif /* AVCODEC_FLACDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/flacdsp_lpc_template.c b/chromium/third_party/ffmpeg/libavcodec/flacdsp_lpc_template.c
index 0c453aee8e2..acdac042b6e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flacdsp_lpc_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flacdsp_lpc_template.c
@@ -139,3 +139,21 @@ static void FUNC(flac_lpc_encode_c)(int32_t *res, const int32_t *smp, int len,
}
#endif
}
+
+/* Comment for clarity/de-obfuscation.
+ *
+ * for (int i = order; i < len; i++) {
+ * int32_t p = 0;
+ * for (int j = 0; j < order; j++) {
+ * int c = coefs[j];
+ * int s = smp[(i-1)-j];
+ * p += c*s;
+ * }
+ * res[i] = smp[i] - (p >> shift);
+ * }
+ *
+ * The CONFIG_SMALL code above simplifies to this, in the case of SAMPLE_SIZE
+ * not being equal to 32 (at the present time that means for 16-bit audio). The
+ * code above does 2 samples per iteration. Commit bfdd5bc ( made all the way
+ * back in 2007) says that way is faster.
+ */
diff --git a/chromium/third_party/ffmpeg/libavcodec/flacenc.c b/chromium/third_party/ffmpeg/libavcodec/flacenc.c
index 1fc8c4ce6bd..b6ae4af9a73 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flacenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flacenc.c
@@ -649,7 +649,7 @@ static uint64_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
tmp_rc.coding_mode = rc->coding_mode;
- udata = av_malloc(n * sizeof(uint32_t));
+ udata = av_malloc_array(n, sizeof(uint32_t));
for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
diff --git a/chromium/third_party/ffmpeg/libavcodec/flashsv.c b/chromium/third_party/ffmpeg/libavcodec/flashsv.c
index 981d7744075..8791a2d750c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flashsv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flashsv.c
@@ -69,7 +69,7 @@ typedef struct FlashSVContext {
int diff_start, diff_height;
} FlashSVContext;
-static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
+static int decode_hybrid(const uint8_t *sptr, const uint8_t *sptr_end, uint8_t *dptr, int dx, int dy,
int h, int w, int stride, const uint32_t *pal)
{
int x, y;
@@ -78,6 +78,8 @@ static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
for (y = dx + h; y > dx; y--) {
uint8_t *dst = dptr + (y * stride) + dy * 3;
for (x = 0; x < w; x++) {
+ if (sptr >= sptr_end)
+ return AVERROR_INVALIDDATA;
if (*sptr & 0x80) {
/* 15-bit color */
unsigned c = AV_RB16(sptr) & ~0x8000;
@@ -232,10 +234,15 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,
}
} else {
/* hybrid 15-bit/palette mode */
- decode_hybrid(s->tmpblock, s->frame->data[0],
+ ret = decode_hybrid(s->tmpblock, s->zstream.next_out,
+ s->frame->data[0],
s->image_height - (y_pos + 1 + s->diff_height),
x_pos, s->diff_height, width,
s->frame->linesize[0], s->pal);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "decode_hybrid failed\n");
+ return ret;
+ }
}
skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/flashsv2enc.c b/chromium/third_party/ffmpeg/libavcodec/flashsv2enc.c
index 2115a465946..436daa4be23 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flashsv2enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flashsv2enc.c
@@ -87,7 +87,6 @@ typedef struct FlashSV2Context {
AVCodecContext *avctx;
uint8_t *current_frame;
uint8_t *key_frame;
- AVFrame frame;
uint8_t *encbuffer;
uint8_t *keybuffer;
uint8_t *databuffer;
@@ -849,15 +848,12 @@ static int reconfigure_at_keyframe(FlashSV2Context * s, const uint8_t * image,
}
static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
- const AVFrame *pict, int *got_packet)
+ const AVFrame *p, int *got_packet)
{
FlashSV2Context *const s = avctx->priv_data;
- AVFrame *const p = &s->frame;
int res;
int keyframe = 0;
- *p = *pict;
-
if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0)
return res;
@@ -891,18 +887,11 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (keyframe) {
new_key_frame(s);
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
s->last_key_frame = avctx->frame_number;
pkt->flags |= AV_PKT_FLAG_KEY;
av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number);
- } else {
- p->pict_type = AV_PICTURE_TYPE_P;
- p->key_frame = 0;
}
- avctx->coded_frame = p;
-
pkt->size = res;
*got_packet = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/flvdec.c b/chromium/third_party/ffmpeg/libavcodec/flvdec.c
index f425f004243..3b048f666df 100644
--- a/chromium/third_party/ffmpeg/libavcodec/flvdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/flvdec.c
@@ -22,11 +22,12 @@
#include "flv.h"
#include "libavutil/imgutils.h"
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
+void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last)
+{
int is11 = get_bits1(gb);
*last = get_bits1(gb);
- *run = get_bits(gb, 6);
- if(is11){
+ *run = get_bits(gb, 6);
+ if (is11) {
*level = get_sbits(gb, 11);
} else {
*level = get_sbits(gb, 7);
@@ -47,45 +48,45 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
return AVERROR_INVALIDDATA;
}
- s->h263_flv = format+1;
+ s->h263_flv = format + 1;
s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
- format = get_bits(&s->gb, 3);
+ format = get_bits(&s->gb, 3);
switch (format) {
case 0:
- width = get_bits(&s->gb, 8);
+ width = get_bits(&s->gb, 8);
height = get_bits(&s->gb, 8);
break;
case 1:
- width = get_bits(&s->gb, 16);
+ width = get_bits(&s->gb, 16);
height = get_bits(&s->gb, 16);
break;
case 2:
- width = 352;
+ width = 352;
height = 288;
break;
case 3:
- width = 176;
+ width = 176;
height = 144;
break;
case 4:
- width = 128;
+ width = 128;
height = 96;
break;
case 5:
- width = 320;
+ width = 320;
height = 240;
break;
case 6:
- width = 160;
+ width = 160;
height = 120;
break;
default:
width = height = 0;
break;
}
- if(av_image_check_size(width, height, 0, s->avctx))
+ if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR(EINVAL);
- s->width = width;
+ s->width = width;
s->height = height;
s->pict_type = AV_PICTURE_TYPE_I + get_bits(&s->gb, 2);
@@ -94,29 +95,29 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
s->pict_type = AV_PICTURE_TYPE_P;
skip_bits1(&s->gb); /* deblocking flag */
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
+ s->chroma_qscale = s->qscale = get_bits(&s->gb, 5);
s->h263_plus = 0;
- s->unrestricted_mv = 1;
+ s->unrestricted_mv = 1;
s->h263_long_vectors = 0;
/* PEI */
if (skip_1stop_8data_bits(&s->gb) < 0)
return AVERROR_INVALIDDATA;
+
s->f_code = 1;
if (s->ehc_mode)
s->avctx->sample_aspect_ratio= (AVRational){1,2};
- if(s->avctx->debug & FF_DEBUG_PICT_INFO){
+ if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
s->droppable ? 'D' : av_get_picture_type_char(s->pict_type),
s->h263_flv - 1, s->qscale, s->picture_number);
}
- s->y_dc_scale_table=
- s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+ s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
return 0;
}
@@ -132,5 +133,8 @@ AVCodec ff_flv_decoder = {
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/frame_thread_encoder.c b/chromium/third_party/ffmpeg/libavcodec/frame_thread_encoder.c
index b9acefc1101..9ab7c3475e9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/frame_thread_encoder.c
+++ b/chromium/third_party/ffmpeg/libavcodec/frame_thread_encoder.c
@@ -125,6 +125,31 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){
|| !(avctx->codec->capabilities & CODEC_CAP_INTRA_ONLY))
return 0;
+ if( !avctx->thread_count
+ && avctx->codec_id == AV_CODEC_ID_MJPEG
+ && !(avctx->flags & CODEC_FLAG_QSCALE)) {
+ av_log(avctx, AV_LOG_DEBUG,
+ "Forcing thread count to 1 for MJPEG encoding, use -thread_type slice "
+ "or a constant quantizer if you want to use multiple cpu cores\n");
+ avctx->thread_count = 1;
+ }
+ if( avctx->thread_count > 1
+ && avctx->codec_id == AV_CODEC_ID_MJPEG
+ && !(avctx->flags & CODEC_FLAG_QSCALE))
+ av_log(avctx, AV_LOG_WARNING,
+ "MJPEG CBR encoding works badly with frame multi-threading, consider "
+ "using -threads 1, -thread_type slice or a constant quantizer.\n");
+
+ if (avctx->codec_id == AV_CODEC_ID_HUFFYUV ||
+ avctx->codec_id == AV_CODEC_ID_FFVHUFF) {
+ // huffyuv does not support these with multiple frame threads currently
+ if (avctx->context_model > 0 || (avctx->flags & CODEC_FLAG_PASS1)) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Forcing thread count to 1 for huffyuv encoding with first pass or context 1\n");
+ avctx->thread_count = 1;
+ }
+ }
+
if(!avctx->thread_count) {
avctx->thread_count = av_cpu_count();
avctx->thread_count = FFMIN(avctx->thread_count, MAX_THREADS);
@@ -209,7 +234,7 @@ void ff_frame_thread_encoder_free(AVCodecContext *avctx){
pthread_mutex_destroy(&c->buffer_mutex);
pthread_cond_destroy(&c->task_fifo_cond);
pthread_cond_destroy(&c->finished_task_cond);
- av_fifo_free(c->task_fifo); c->task_fifo = NULL;
+ av_fifo_freep(&c->task_fifo);
av_freep(&avctx->internal->frame_thread_encoder);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/fraps.c b/chromium/third_party/ffmpeg/libavcodec/fraps.c
index 225da112994..4f89af1e580 100644
--- a/chromium/third_party/ffmpeg/libavcodec/fraps.c
+++ b/chromium/third_party/ffmpeg/libavcodec/fraps.c
@@ -207,7 +207,8 @@ static int decode_frame(AVCodecContext *avctx,
f->key_frame = 1;
avctx->pix_fmt = version & 1 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUVJ420P;
- avctx->color_range = version & 1 ? AVCOL_RANGE_UNSPECIFIED : AVCOL_RANGE_JPEG;
+ avctx->color_range = version & 1 ? AVCOL_RANGE_UNSPECIFIED
+ : AVCOL_RANGE_JPEG;
avctx->colorspace = version & 1 ? AVCOL_SPC_UNSPECIFIED : AVCOL_SPC_BT709;
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/g2meet.c b/chromium/third_party/ffmpeg/libavcodec/g2meet.c
index 8f8e88047a4..700eb338c41 100644
--- a/chromium/third_party/ffmpeg/libavcodec/g2meet.c
+++ b/chromium/third_party/ffmpeg/libavcodec/g2meet.c
@@ -24,6 +24,7 @@
* Go2Webinar decoder
*/
+#include <inttypes.h>
#include <zlib.h>
#include "libavutil/intreadwrite.h"
@@ -35,7 +36,7 @@
#include "mjpeg.h"
enum ChunkType {
- FRAME_INFO = 0xC8,
+ DISPLAY_INFO = 0xC8,
TILE_DATA,
CURSOR_POS,
CURSOR_SHAPE,
@@ -198,8 +199,8 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
return AVERROR_INVALIDDATA;
if (dc)
dc = get_xbits(gb, dc);
- dc = dc * qmat[0] + c->prev_dc[plane];
- block[0] = dc;
+ dc = dc * qmat[0] + c->prev_dc[plane];
+ block[0] = dc;
c->prev_dc[plane] = dc;
pos = 0;
@@ -214,8 +215,8 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
if (val) {
int nbits = val;
- val = get_xbits(gb, nbits);
- val *= qmat[ff_zigzag_direct[pos]];
+ val = get_xbits(gb, nbits);
+ val *= qmat[ff_zigzag_direct[pos]];
block[c->scantable.permutated[pos]] = val;
}
}
@@ -253,19 +254,25 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
mb_h = (height + 15) >> 4;
if (!num_mbs)
- num_mbs = mb_w * mb_h;
+ num_mbs = mb_w * mb_h * 4;
for (i = 0; i < 3; i++)
c->prev_dc[i] = 1024;
bx = by = 0;
+ c->dsp.clear_blocks(c->block[0]);
for (mb_y = 0; mb_y < mb_h; mb_y++) {
for (mb_x = 0; mb_x < mb_w; mb_x++) {
- if (mask && !mask[mb_x]) {
+ if (mask && !mask[mb_x * 2] && !mask[mb_x * 2 + 1] &&
+ !mask[mb_x * 2 + mask_stride] &&
+ !mask[mb_x * 2 + 1 + mask_stride]) {
bx += 16;
continue;
}
for (j = 0; j < 2; j++) {
for (i = 0; i < 2; i++) {
+ if (mask && !mask[mb_x * 2 + i + j * mask_stride])
+ continue;
+ num_mbs--;
if ((ret = jpg_decode_block(c, &gb, 0,
c->block[i + j * 2])) != 0)
return ret;
@@ -290,14 +297,14 @@ static int jpg_decode_data(JPGContext *c, int width, int height,
}
}
- if (!--num_mbs)
+ if (!num_mbs)
return 0;
bx += 16;
}
bx = 0;
by += 16;
if (mask)
- mask += mask_stride;
+ mask += mask_stride * 2;
}
return 0;
@@ -353,7 +360,7 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width);
height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
- hdr = *src++;
+ hdr = *src++;
sub_type = hdr >> 5;
if (sub_type == 0) {
int j;
@@ -375,19 +382,21 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
npal = *src++ + 1;
if (src_end - src < npal * 3)
return AVERROR_INVALIDDATA;
- memcpy(pal, src, npal * 3); src += npal * 3;
+ memcpy(pal, src, npal * 3);
+ src += npal * 3;
if (sub_type != 2) {
for (i = 0; i < npal; i++) {
if (!memcmp(pal + i * 3, transp, 3)) {
- tidx = i;
- break;
+ tidx = i;
+ break;
}
}
}
if (src_end - src < 2)
return 0;
- zsize = (src[0] << 8) | src[1]; src += 2;
+ zsize = (src[0] << 8) | src[1];
+ src += 2;
if (src_end - src < zsize + (sub_type != 2))
return AVERROR_INVALIDDATA;
@@ -405,7 +414,7 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
nblocks = *src++ + 1;
cblocks = 0;
- bstride = FFALIGN(width, 16) >> 4;
+ bstride = FFALIGN(width, 16) >> 3;
// blocks are coded LSB and we need normal bitreader for JPEG data
bits = 0;
for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
@@ -422,14 +431,17 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
cblocks += coded;
if (cblocks > nblocks)
return AVERROR_INVALIDDATA;
- c->kempf_flags[j + i * bstride] = coded;
+ c->kempf_flags[j * 2 + i * 2 * bstride] =
+ c->kempf_flags[j * 2 + 1 + i * 2 * bstride] =
+ c->kempf_flags[j * 2 + (i * 2 + 1) * bstride] =
+ c->kempf_flags[j * 2 + 1 + (i * 2 + 1) * bstride] = coded;
}
}
memset(c->jpeg_tile, 0, c->tile_stride * height);
jpg_decode_data(&c->jc, width, height, src, src_end - src,
c->jpeg_tile, c->tile_stride,
- c->kempf_flags, bstride, nblocks, 0);
+ c->kempf_flags, bstride, nblocks * 4, 0);
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
c->jpeg_tile, c->tile_stride,
@@ -482,30 +494,30 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
uint32_t cursor_hot_x, cursor_hot_y;
int cursor_fmt, err;
- cur_size = bytestream2_get_be32(gb);
- cursor_w = bytestream2_get_byte(gb);
- cursor_h = bytestream2_get_byte(gb);
- cursor_hot_x = bytestream2_get_byte(gb);
- cursor_hot_y = bytestream2_get_byte(gb);
- cursor_fmt = bytestream2_get_byte(gb);
+ cur_size = bytestream2_get_be32(gb);
+ cursor_w = bytestream2_get_byte(gb);
+ cursor_h = bytestream2_get_byte(gb);
+ cursor_hot_x = bytestream2_get_byte(gb);
+ cursor_hot_y = bytestream2_get_byte(gb);
+ cursor_fmt = bytestream2_get_byte(gb);
cursor_stride = FFALIGN(cursor_w, cursor_fmt==1 ? 32 : 1) * 4;
if (cursor_w < 1 || cursor_w > 256 ||
cursor_h < 1 || cursor_h > 256) {
- av_log(avctx, AV_LOG_ERROR, "Invalid cursor dimensions %dx%d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid cursor dimensions %"PRIu32"x%"PRIu32"\n",
cursor_w, cursor_h);
return AVERROR_INVALIDDATA;
}
if (cursor_hot_x > cursor_w || cursor_hot_y > cursor_h) {
- av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %d,%d\n",
+ av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %"PRIu32",%"PRIu32"\n",
cursor_hot_x, cursor_hot_y);
cursor_hot_x = FFMIN(cursor_hot_x, cursor_w - 1);
cursor_hot_y = FFMIN(cursor_hot_y, cursor_h - 1);
}
if (cur_size - 9 > bytestream2_get_bytes_left(gb) ||
c->cursor_w * c->cursor_h / 4 > cur_size) {
- av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d/%d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %"PRIu32"/%u\n",
cur_size, bytestream2_get_bytes_left(gb));
return AVERROR_INVALIDDATA;
}
@@ -535,7 +547,7 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
bits = bytestream2_get_be32(gb);
for (k = 0; k < 32; k++) {
dst[0] = !!(bits & 0x80000000);
- dst += 4;
+ dst += 4;
bits <<= 1;
}
}
@@ -549,18 +561,24 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
int mask_bit = !!(bits & 0x80000000);
switch (dst[0] * 2 + mask_bit) {
case 0:
- dst[0] = 0xFF; dst[1] = 0x00;
- dst[2] = 0x00; dst[3] = 0x00;
+ dst[0] = 0xFF;
+ dst[1] = 0x00;
+ dst[2] = 0x00;
+ dst[3] = 0x00;
break;
case 1:
- dst[0] = 0xFF; dst[1] = 0xFF;
- dst[2] = 0xFF; dst[3] = 0xFF;
+ dst[0] = 0xFF;
+ dst[1] = 0xFF;
+ dst[2] = 0xFF;
+ dst[3] = 0xFF;
break;
default:
- dst[0] = 0x00; dst[1] = 0x00;
- dst[2] = 0x00; dst[3] = 0x00;
+ dst[0] = 0x00;
+ dst[1] = 0x00;
+ dst[2] = 0x00;
+ dst[3] = 0x00;
}
- dst += 4;
+ dst += 4;
bits <<= 1;
}
}
@@ -645,8 +663,8 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
GetByteContext bc, tbc;
int magic;
int got_header = 0;
- uint32_t chunk_size;
- int chunk_type;
+ uint32_t chunk_size, r_mask, g_mask, b_mask;
+ int chunk_type, chunk_start;
int i;
int ret;
@@ -672,18 +690,20 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
}
while (bytestream2_get_bytes_left(&bc) > 5) {
- chunk_size = bytestream2_get_le32(&bc) - 1;
- chunk_type = bytestream2_get_byte(&bc);
+ chunk_size = bytestream2_get_le32(&bc) - 1;
+ chunk_type = bytestream2_get_byte(&bc);
+ chunk_start = bytestream2_tell(&bc);
if (chunk_size > bytestream2_get_bytes_left(&bc)) {
- av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %d type %02X\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %"PRIu32" type %02X\n",
chunk_size, chunk_type);
break;
}
switch (chunk_type) {
- case FRAME_INFO:
+ case DISPLAY_INFO:
+ got_header =
c->got_header = 0;
if (chunk_size < 21) {
- av_log(avctx, AV_LOG_ERROR, "Invalid frame info size %d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid display info size %"PRIu32"\n",
chunk_size);
break;
}
@@ -697,14 +717,18 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
- if (c->width != avctx->width || c->height != avctx->height)
- ff_set_dimensions(avctx, c->width, c->height);
+ if (c->width != avctx->width || c->height != avctx->height) {
+ ret = ff_set_dimensions(avctx, c->width, c->height);
+ if (ret < 0)
+ goto header_fail;
+ }
c->compression = bytestream2_get_be32(&bc);
if (c->compression != 2 && c->compression != 3) {
av_log(avctx, AV_LOG_ERROR,
"Unknown compression method %d\n",
c->compression);
- return AVERROR_PATCHWELCOME;
+ ret = AVERROR_PATCHWELCOME;
+ goto header_fail;
}
c->tile_width = bytestream2_get_be32(&bc);
c->tile_height = bytestream2_get_be32(&bc);
@@ -718,9 +742,30 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
}
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
- c->bpp = bytestream2_get_byte(&bc);
- chunk_size -= 21;
- bytestream2_skip(&bc, chunk_size);
+ c->bpp = bytestream2_get_byte(&bc);
+ if (c->bpp == 32) {
+ if (bytestream2_get_bytes_left(&bc) < 16 ||
+ (chunk_size - 21) < 16) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Display info: missing bitmasks!\n");
+ ret = AVERROR_INVALIDDATA;
+ goto header_fail;
+ }
+ r_mask = bytestream2_get_be32(&bc);
+ g_mask = bytestream2_get_be32(&bc);
+ b_mask = bytestream2_get_be32(&bc);
+ if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid or unsupported bitmasks: R=%"PRIX32", G=%"PRIX32", B=%"PRIX32"\n",
+ r_mask, g_mask, b_mask);
+ ret = AVERROR_PATCHWELCOME;
+ goto header_fail;
+ }
+ } else {
+ avpriv_request_sample(avctx, "bpp=%d", c->bpp);
+ ret = AVERROR_PATCHWELCOME;
+ goto header_fail;
+ }
if (g2m_init_buffers(c)) {
ret = AVERROR(ENOMEM);
goto header_fail;
@@ -730,12 +775,11 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
case TILE_DATA:
if (!c->tiles_x || !c->tiles_y) {
av_log(avctx, AV_LOG_WARNING,
- "No frame header - skipping tile\n");
- bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc));
+ "No display info - skipping tile\n");
break;
}
if (chunk_size < 2) {
- av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %"PRIu32"\n",
chunk_size);
break;
}
@@ -747,7 +791,6 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
break;
}
- chunk_size -= 2;
ret = 0;
switch (c->compression) {
case COMPR_EPIC_J_B:
@@ -757,44 +800,42 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
case COMPR_KEMPF_J_B:
ret = kempf_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
- chunk_size);
+ chunk_size - 2);
break;
}
if (ret && c->framebuf)
av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
c->tile_x, c->tile_y);
- bytestream2_skip(&bc, chunk_size);
break;
case CURSOR_POS:
if (chunk_size < 5) {
- av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %"PRIu32"\n",
chunk_size);
break;
}
c->cursor_x = bytestream2_get_be16(&bc);
c->cursor_y = bytestream2_get_be16(&bc);
- bytestream2_skip(&bc, chunk_size - 4);
break;
case CURSOR_SHAPE:
if (chunk_size < 8) {
- av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %"PRIu32"\n",
chunk_size);
break;
}
bytestream2_init(&tbc, buf + bytestream2_tell(&bc),
chunk_size - 4);
g2m_load_cursor(avctx, c, &tbc);
- bytestream2_skip(&bc, chunk_size);
break;
case CHUNK_CC:
case CHUNK_CD:
- bytestream2_skip(&bc, chunk_size);
break;
default:
- av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02X\n",
+ av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02d\n",
chunk_type);
- bytestream2_skip(&bc, chunk_size);
}
+
+ /* navigate to next chunk */
+ bytestream2_skip(&bc, chunk_start + chunk_size - bytestream2_tell(&bc));
}
if (got_header)
c->got_header = 1;
@@ -808,7 +849,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
for (i = 0; i < avctx->height; i++)
memcpy(pic->data[0] + i * pic->linesize[0],
- c->framebuf + i * c->framebuf_stride,
+ c->framebuf + i * c->framebuf_stride,
c->width * 3);
g2m_paint_cursor(c, pic->data[0], pic->linesize[0]);
@@ -816,15 +857,18 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
}
return buf_size;
+
header_fail:
- c->width = c->height = 0;
- c->tiles_x = c->tiles_y = 0;
+ c->width =
+ c->height = 0;
+ c->tiles_x =
+ c->tiles_y = 0;
return ret;
}
static av_cold int g2m_decode_init(AVCodecContext *avctx)
{
- G2MContext * const c = avctx->priv_data;
+ G2MContext *const c = avctx->priv_data;
int ret;
if ((ret = jpg_init(avctx, &c->jc)) != 0) {
@@ -840,7 +884,7 @@ static av_cold int g2m_decode_init(AVCodecContext *avctx)
static av_cold int g2m_decode_end(AVCodecContext *avctx)
{
- G2MContext * const c = avctx->priv_data;
+ G2MContext *const c = avctx->priv_data;
jpg_free_context(&c->jc);
diff --git a/chromium/third_party/ffmpeg/libavcodec/g723_1.c b/chromium/third_party/ffmpeg/libavcodec/g723_1.c
index 09da7665b80..e4bde2afd12 100644
--- a/chromium/third_party/ffmpeg/libavcodec/g723_1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/g723_1.c
@@ -2285,7 +2285,8 @@ static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size)
if (p->cur_rate == RATE_6300) {
info_bits = 0;
put_bits(&pb, 2, info_bits);
- }
+ }else
+ av_assert0(0);
put_bits(&pb, 8, p->lsp_index[2]);
put_bits(&pb, 8, p->lsp_index[1]);
diff --git a/chromium/third_party/ffmpeg/libavcodec/g729postfilter.c b/chromium/third_party/ffmpeg/libavcodec/g729postfilter.c
index fc903740edd..bcf509cfcc6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/g729postfilter.c
+++ b/chromium/third_party/ffmpeg/libavcodec/g729postfilter.c
@@ -389,7 +389,7 @@ static int16_t long_term_filter(DSPContext *dsp, int pitch_delay_int,
lt_filt_factor_a = (gain_den << 15) / (gain_den + gain_num);
}
#else
- L64_temp0 = ((int64_t)gain_num) << (sh_gain_num - 1);
+ L64_temp0 = (((int64_t)gain_num) << sh_gain_num) >> 1;
L64_temp1 = ((int64_t)gain_den) << sh_gain_den;
lt_filt_factor_a = FFMAX((L64_temp1 << 15) / (L64_temp1 + L64_temp0), MIN_LT_FILT_FACTOR_A);
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/get_bits.h b/chromium/third_party/ffmpeg/libavcodec/get_bits.h
index 7824e5ab0fd..ddcef50bd03 100644
--- a/chromium/third_party/ffmpeg/libavcodec/get_bits.h
+++ b/chromium/third_party/ffmpeg/libavcodec/get_bits.h
@@ -219,7 +219,7 @@ static inline void skip_bits_long(GetBitContext *s, int n)
}
/**
- * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
+ * read mpeg1 dc style vlc (sign bit + mantissa with no MSB).
* if MSB not set it is negative
* @param n length in bits
*/
@@ -513,7 +513,7 @@ void ff_free_vlc(VLC *vlc);
SKIP_BITS(name, gb, n); \
} while (0)
-#define GET_RL_VLC(level, run, name, gb, table, bits, \
+#define GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits, \
max_depth, need_update) \
do { \
int n, nb_bits; \
@@ -642,6 +642,25 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
return r;
}
+#define GET_RL_VLC(level, run, name, gb, table, bits, \
+ max_depth, need_update) \
+ do { \
+ int show = SHOW_UBITS(name, gb, 24); \
+ int len; \
+ int pos = name ## _index; \
+ \
+ GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits,max_depth, need_update); \
+ \
+ len = name ## _index - pos + 1; \
+ show = show >> (24 - len); \
+ \
+ print_bin(show, len); \
+ \
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d/%-3d rlv @%5d in %s %s:%d\n",\
+ show, len, run-1, level, pos, __FILE__, __PRETTY_FUNCTION__, __LINE__);\
+ } while (0) \
+
+
static inline int get_xbits_trace(GetBitContext *s, int n, const char *file,
const char *func, int line)
{
@@ -666,6 +685,7 @@ static inline int get_xbits_trace(GetBitContext *s, int n, const char *file,
#else //TRACE
#define tprintf(p, ...) { }
+#define GET_RL_VLC GET_RL_VLC_INTERNAL
#endif
#endif /* AVCODEC_GET_BITS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/gifdec.c b/chromium/third_party/ffmpeg/libavcodec/gifdec.c
index c7b9ac87263..78c8900628d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/gifdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/gifdec.c
@@ -237,8 +237,12 @@ static int gif_read_image(GifState *s, AVFrame *frame)
pass = 0;
y1 = 0;
for (y = 0; y < height; y++) {
- if (ff_lzw_decode(s->lzw, s->idx_line, width) == 0)
+ int count = ff_lzw_decode(s->lzw, s->idx_line, width);
+ if (count != width) {
+ if (count)
+ av_log(s->avctx, AV_LOG_ERROR, "LZW decode failed\n");
goto decode_tail;
+ }
pr = ptr + width;
diff --git a/chromium/third_party/ffmpeg/libavcodec/golomb.h b/chromium/third_party/ffmpeg/libavcodec/golomb.h
index 43875dc85c4..1c4e2106ee1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/golomb.h
+++ b/chromium/third_party/ffmpeg/libavcodec/golomb.h
@@ -214,6 +214,18 @@ static inline int get_se_golomb(GetBitContext *gb)
}
}
+static inline int get_se_golomb_long(GetBitContext *gb)
+{
+ unsigned int buf = get_ue_golomb_long(gb);
+
+ if (buf & 1)
+ buf = (buf + 1) >> 1;
+ else
+ buf = -(buf >> 1);
+
+ return buf;
+}
+
static inline int svq3_get_se_golomb(GetBitContext *gb)
{
unsigned int buf;
diff --git a/chromium/third_party/ffmpeg/libavcodec/h261data.c b/chromium/third_party/ffmpeg/libavcodec/h261data.c
index 0d1f305418d..a9891edd0a6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h261data.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h261data.c
@@ -26,6 +26,7 @@
#include <stdint.h>
+#include "mpegutils.h"
#include "rl.h"
#include "h261.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/h261dec.c b/chromium/third_party/ffmpeg/libavcodec/h261dec.c
index 49f1b4a199b..95587f2be0a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h261dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h261dec.c
@@ -27,6 +27,7 @@
#include "libavutil/avassert.h"
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "h261.h"
@@ -431,6 +432,13 @@ static int h261_decode_mb(H261Context *h)
s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation
s->mv[0][0][1] = h->current_mv_y * 2;
+ if (s->current_picture.motion_val[0]) {
+ int b_stride = 2*s->mb_width + 1;
+ int b_xy = 2 * s->mb_x + (2 * s->mb_y) * b_stride;
+ s->current_picture.motion_val[0][b_xy][0] = s->mv[0][0][0];
+ s->current_picture.motion_val[0][b_xy][1] = s->mv[0][0][1];
+ }
+
intra:
/* decode each block */
if (s->mb_intra || HAS_CBP(h->mtype)) {
@@ -609,8 +617,8 @@ retry:
}
// for skipping the frame
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture.f->pict_type = s->pict_type;
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
@@ -633,10 +641,10 @@ retry:
}
ff_MPV_frame_end(s);
- av_assert0(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
- av_assert0(s->current_picture.f.pict_type == s->pict_type);
+ av_assert0(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
+ av_assert0(s->current_picture.f->pict_type == s->pict_type);
- if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h261enc.c b/chromium/third_party/ffmpeg/libavcodec/h261enc.c
index e185f5ec0aa..47696e583f9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h261enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h261enc.c
@@ -28,6 +28,7 @@
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "h261.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/h263.c b/chromium/third_party/ffmpeg/libavcodec/h263.c
index dafc4ecbb51..77d5f75d56d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h263.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h263.c
@@ -34,6 +34,7 @@
#include "h263.h"
#include "h263data.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "unary.h"
#include "flv.h"
#include "mpeg4video.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/h263dec.c b/chromium/third_party/ffmpeg/libavcodec/h263dec.c
index 1fbc08a5068..7db4c0cc941 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h263dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h263dec.c
@@ -58,7 +58,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
if (avctx->codec->id == AV_CODEC_ID_MSS2)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
else
- avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
+ avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
s->unrestricted_mv = 1;
/* select sub codec */
@@ -110,7 +110,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
s->codec_id = avctx->codec->id;
- avctx->hwaccel = ff_find_hwaccel(avctx);
if (avctx->stream_codec_tag == AV_RL32("l263") && avctx->extradata_size == 56 && avctx->extradata[0] == 1)
s->ehc_mode = 1;
@@ -233,6 +232,8 @@ static int decode_slice(MpegEncContext *s)
s->mv_type = MV_TYPE_16X16;
av_dlog(s, "%d %d %06X\n",
ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
+
+ tprintf(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y);
ret = s->decode_mb(s, s->block);
if (s->pict_type != AV_PICTURE_TYPE_B)
@@ -269,6 +270,8 @@ static int decode_slice(MpegEncContext *s)
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
+ if (s->err_recognition & AV_EF_IGNORE_ERR)
+ continue;
return AVERROR_INVALIDDATA;
}
@@ -317,6 +320,17 @@ static int decode_slice(MpegEncContext *s)
}
}
+ if (s->codec_id == AV_CODEC_ID_H263 &&
+ (s->workaround_bugs & FF_BUG_AUTODETECT) &&
+ get_bits_left(&s->gb) >= 8 &&
+ get_bits_left(&s->gb) < 300 &&
+ s->pict_type == AV_PICTURE_TYPE_I &&
+ show_bits(&s->gb, 8) == 0 &&
+ !s->data_partitioning) {
+
+ s->padding_bug_score += 32;
+ }
+
if (s->workaround_bugs & FF_BUG_AUTODETECT) {
if (s->padding_bug_score > -2 && !s->data_partitioning)
s->workaround_bugs |= FF_BUG_NO_PADDING;
@@ -381,7 +395,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) {
- if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr = NULL;
@@ -442,7 +456,7 @@ retry:
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
- if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
+ if (s->current_picture_ptr == NULL || s->current_picture_ptr->f->data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
return i;
@@ -518,8 +532,8 @@ retry:
s->gob_index = ff_h263_get_gob_height(s);
// for skipping the frame
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture.f->pict_type = s->pict_type;
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL &&
@@ -554,7 +568,7 @@ retry:
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
- ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
+ ff_vdpau_mpeg4_decode_picture(avctx->priv_data, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
@@ -627,15 +641,15 @@ frame_end:
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
- av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
- av_assert1(s->current_picture.f.pict_type == s->pict_type);
+ av_assert1(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
+ av_assert1(s->current_picture.f->pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
- if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
@@ -667,10 +681,10 @@ frame_end:
}
const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_VAAPI
+#if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI_VLD,
#endif
-#if CONFIG_VDPAU
+#if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU,
#endif
AV_PIX_FMT_YUV420P,
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264.c b/chromium/third_party/ffmpeg/libavcodec/h264.c
index a6218535af0..82bbb1b18ec 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264.c
@@ -28,19 +28,21 @@
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
+#include "libavutil/stereo3d.h"
+#include "libavutil/timer.h"
#include "internal.h"
#include "cabac.h"
#include "cabac_functions.h"
#include "dsputil.h"
#include "error_resilience.h"
#include "avcodec.h"
-#include "mpegvideo.h"
#include "h264.h"
#include "h264data.h"
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "golomb.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "rectangle.h"
#include "svq3.h"
#include "thread.h"
@@ -48,147 +50,8 @@
#include <assert.h>
-static void flush_change(H264Context *h);
-
const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 };
-static const uint8_t rem6[QP_MAX_NUM + 1] = {
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
- 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
- 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3,
-};
-
-static const uint8_t div6[QP_MAX_NUM + 1] = {
- 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
- 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,
- 10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,13,13,13, 13, 13, 13,
- 14,14,14,14,
-};
-
-static const uint8_t field_scan[16+1] = {
- 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
- 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
- 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
- 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
-};
-
-static const uint8_t field_scan8x8[64+1] = {
- 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
- 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
- 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
- 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
- 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
- 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
- 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
- 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
- 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
- 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
- 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
- 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
- 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
- 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
- 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
- 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
-};
-
-static const uint8_t field_scan8x8_cavlc[64+1] = {
- 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
- 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
- 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
- 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
- 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
- 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
- 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
- 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
- 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
- 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
- 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
- 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
- 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
- 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
- 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
- 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
-};
-
-// zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
-static const uint8_t zigzag_scan8x8_cavlc[64+1] = {
- 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
- 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
- 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
- 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
- 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
- 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
- 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
- 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
- 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
- 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
- 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
- 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
- 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
- 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
- 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
- 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
-};
-
-static const uint8_t dequant4_coeff_init[6][3] = {
- { 10, 13, 16 },
- { 11, 14, 18 },
- { 13, 16, 20 },
- { 14, 18, 23 },
- { 16, 20, 25 },
- { 18, 23, 29 },
-};
-
-static const uint8_t dequant8_coeff_init_scan[16] = {
- 0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1
-};
-
-static const uint8_t dequant8_coeff_init[6][6] = {
- { 20, 18, 32, 19, 25, 24 },
- { 22, 19, 35, 21, 28, 26 },
- { 26, 23, 42, 24, 33, 31 },
- { 28, 25, 45, 26, 35, 33 },
- { 32, 28, 51, 30, 40, 38 },
- { 36, 32, 58, 34, 46, 43 },
-};
-
-static const enum AVPixelFormat h264_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_H264_DXVA2_HWACCEL
- AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_H264_VAAPI_HWACCEL
- AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_H264_VDA_HWACCEL
- AV_PIX_FMT_VDA_VLD,
-#endif
-#if CONFIG_H264_VDPAU_HWACCEL
- AV_PIX_FMT_VDPAU,
-#endif
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE
-};
-
-static const enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[] = {
-#if CONFIG_H264_DXVA2_HWACCEL
- AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_H264_VAAPI_HWACCEL
- AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_H264_VDA_HWACCEL
- AV_PIX_FMT_VDA_VLD,
-#endif
-#if CONFIG_H264_VDPAU_HWACCEL
- AV_PIX_FMT_VDPAU,
-#endif
- AV_PIX_FMT_YUVJ420P,
- AV_PIX_FMT_NONE
-};
-
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
@@ -233,8 +96,8 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
{
AVCodecContext *avctx = h->avctx;
- Picture *cur = &h->cur_pic;
- Picture *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0] : NULL;
+ AVFrame *cur = &h->cur_pic.f;
+ AVFrame *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0].f : NULL;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chroma_h;
const int field_pic = h->picture_structure != PICT_FRAME;
@@ -253,11 +116,11 @@ void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
int offset[AV_NUM_DATA_POINTERS];
int i;
- if (cur->f.pict_type == AV_PICTURE_TYPE_B || h->low_delay ||
+ if (cur->pict_type == AV_PICTURE_TYPE_B || h->low_delay ||
(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
- src = &cur->f;
+ src = cur;
else if (last)
- src = &last->f;
+ src = last;
else
return;
@@ -274,241 +137,6 @@ void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
}
}
-static void unref_picture(H264Context *h, Picture *pic)
-{
- int off = offsetof(Picture, tf) + sizeof(pic->tf);
- int i;
-
- if (!pic->f.buf[0])
- return;
-
- ff_thread_release_buffer(h->avctx, &pic->tf);
- av_buffer_unref(&pic->hwaccel_priv_buf);
-
- av_buffer_unref(&pic->qscale_table_buf);
- av_buffer_unref(&pic->mb_type_buf);
- for (i = 0; i < 2; i++) {
- av_buffer_unref(&pic->motion_val_buf[i]);
- av_buffer_unref(&pic->ref_index_buf[i]);
- }
-
- memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
-}
-
-static void release_unused_pictures(H264Context *h, int remove_current)
-{
- int i;
-
- /* release non reference frames */
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (h->DPB[i].f.buf[0] && !h->DPB[i].reference &&
- (remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
- unref_picture(h, &h->DPB[i]);
- }
- }
-}
-
-static int ref_picture(H264Context *h, Picture *dst, Picture *src)
-{
- int ret, i;
-
- av_assert0(!dst->f.buf[0]);
- av_assert0(src->f.buf[0]);
-
- src->tf.f = &src->f;
- dst->tf.f = &dst->f;
- ret = ff_thread_ref_frame(&dst->tf, &src->tf);
- if (ret < 0)
- goto fail;
-
- dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
- dst->mb_type_buf = av_buffer_ref(src->mb_type_buf);
- if (!dst->qscale_table_buf || !dst->mb_type_buf)
- goto fail;
- dst->qscale_table = src->qscale_table;
- dst->mb_type = src->mb_type;
-
- for (i = 0; i < 2; i++) {
- dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]);
- dst->ref_index_buf[i] = av_buffer_ref(src->ref_index_buf[i]);
- if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i])
- goto fail;
- dst->motion_val[i] = src->motion_val[i];
- dst->ref_index[i] = src->ref_index[i];
- }
-
- if (src->hwaccel_picture_private) {
- dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
- if (!dst->hwaccel_priv_buf)
- goto fail;
- dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
- }
-
- for (i = 0; i < 2; i++)
- dst->field_poc[i] = src->field_poc[i];
-
- memcpy(dst->ref_poc, src->ref_poc, sizeof(src->ref_poc));
- memcpy(dst->ref_count, src->ref_count, sizeof(src->ref_count));
-
- dst->poc = src->poc;
- dst->frame_num = src->frame_num;
- dst->mmco_reset = src->mmco_reset;
- dst->pic_id = src->pic_id;
- dst->long_ref = src->long_ref;
- dst->mbaff = src->mbaff;
- dst->field_picture = src->field_picture;
- dst->needs_realloc = src->needs_realloc;
- dst->reference = src->reference;
- dst->crop = src->crop;
- dst->crop_left = src->crop_left;
- dst->crop_top = src->crop_top;
- dst->recovered = src->recovered;
-
- return 0;
-fail:
- unref_picture(h, dst);
- return ret;
-}
-
-static int alloc_scratch_buffers(H264Context *h, int linesize)
-{
- int alloc_size = FFALIGN(FFABS(linesize) + 32, 32);
-
- if (h->bipred_scratchpad)
- return 0;
-
- h->bipred_scratchpad = av_malloc(16 * 6 * alloc_size);
- // edge emu needs blocksize + filter length - 1
- // (= 21x21 for h264)
- h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 21);
- h->me.scratchpad = av_mallocz(alloc_size * 2 * 16 * 2);
-
- if (!h->bipred_scratchpad || !h->edge_emu_buffer || !h->me.scratchpad) {
- av_freep(&h->bipred_scratchpad);
- av_freep(&h->edge_emu_buffer);
- av_freep(&h->me.scratchpad);
- return AVERROR(ENOMEM);
- }
-
- h->me.temp = h->me.scratchpad;
-
- return 0;
-}
-
-static int init_table_pools(H264Context *h)
-{
- const int big_mb_num = h->mb_stride * (h->mb_height + 1) + 1;
- const int mb_array_size = h->mb_stride * h->mb_height;
- const int b4_stride = h->mb_width * 4 + 1;
- const int b4_array_size = b4_stride * h->mb_height * 4;
-
- h->qscale_table_pool = av_buffer_pool_init(big_mb_num + h->mb_stride,
- av_buffer_allocz);
- h->mb_type_pool = av_buffer_pool_init((big_mb_num + h->mb_stride) *
- sizeof(uint32_t), av_buffer_allocz);
- h->motion_val_pool = av_buffer_pool_init(2 * (b4_array_size + 4) *
- sizeof(int16_t), av_buffer_allocz);
- h->ref_index_pool = av_buffer_pool_init(4 * mb_array_size, av_buffer_allocz);
-
- if (!h->qscale_table_pool || !h->mb_type_pool || !h->motion_val_pool ||
- !h->ref_index_pool) {
- av_buffer_pool_uninit(&h->qscale_table_pool);
- av_buffer_pool_uninit(&h->mb_type_pool);
- av_buffer_pool_uninit(&h->motion_val_pool);
- av_buffer_pool_uninit(&h->ref_index_pool);
- return AVERROR(ENOMEM);
- }
-
- return 0;
-}
-
-static int alloc_picture(H264Context *h, Picture *pic)
-{
- int i, ret = 0;
-
- av_assert0(!pic->f.data[0]);
-
- pic->tf.f = &pic->f;
- ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
- AV_GET_BUFFER_FLAG_REF : 0);
- if (ret < 0)
- goto fail;
-
- h->linesize = pic->f.linesize[0];
- h->uvlinesize = pic->f.linesize[1];
- pic->crop = h->sps.crop;
- pic->crop_top = h->sps.crop_top;
- pic->crop_left= h->sps.crop_left;
-
- if (h->avctx->hwaccel) {
- const AVHWAccel *hwaccel = h->avctx->hwaccel;
- av_assert0(!pic->hwaccel_picture_private);
- if (hwaccel->priv_data_size) {
- pic->hwaccel_priv_buf = av_buffer_allocz(hwaccel->priv_data_size);
- if (!pic->hwaccel_priv_buf)
- return AVERROR(ENOMEM);
- pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
- }
- }
-
- if (!h->qscale_table_pool) {
- ret = init_table_pools(h);
- if (ret < 0)
- goto fail;
- }
-
- pic->qscale_table_buf = av_buffer_pool_get(h->qscale_table_pool);
- pic->mb_type_buf = av_buffer_pool_get(h->mb_type_pool);
- if (!pic->qscale_table_buf || !pic->mb_type_buf)
- goto fail;
-
- pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * h->mb_stride + 1;
- pic->qscale_table = pic->qscale_table_buf->data + 2 * h->mb_stride + 1;
-
- for (i = 0; i < 2; i++) {
- pic->motion_val_buf[i] = av_buffer_pool_get(h->motion_val_pool);
- pic->ref_index_buf[i] = av_buffer_pool_get(h->ref_index_pool);
- if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
- goto fail;
-
- pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
- pic->ref_index[i] = pic->ref_index_buf[i]->data;
- }
-
- return 0;
-fail:
- unref_picture(h, pic);
- return (ret < 0) ? ret : AVERROR(ENOMEM);
-}
-
-static inline int pic_is_unused(H264Context *h, Picture *pic)
-{
- if (!pic->f.buf[0])
- return 1;
- if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
- return 1;
- return 0;
-}
-
-static int find_unused_picture(H264Context *h)
-{
- int i;
-
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (pic_is_unused(h, &h->DPB[i]))
- break;
- }
- if (i == MAX_PICTURE_COUNT)
- return AVERROR_INVALIDDATA;
-
- if (h->DPB[i].needs_realloc) {
- h->DPB[i].needs_realloc = 0;
- unref_picture(h, &h->DPB[i]);
- }
-
- return i;
-}
-
/**
* Check if the top & left blocks are available if needed and
* change the dc mode so it only uses the available blocks.
@@ -563,7 +191,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h)
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
{
static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 };
- static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
+ static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
if (mode > 3U) {
av_log(h->avctx, AV_LOG_ERROR,
@@ -734,464 +362,7 @@ static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
return 0;
}
-static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n,
- int height, int y_offset, int list)
-{
- int raw_my = h->mv_cache[list][scan8[n]][1];
- int filter_height_down = (raw_my & 3) ? 3 : 0;
- int full_my = (raw_my >> 2) + y_offset;
- int bottom = full_my + filter_height_down + height;
-
- av_assert2(height >= 0);
-
- return FFMAX(0, bottom);
-}
-
-static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n,
- int height, int y_offset, int list0,
- int list1, int *nrefs)
-{
- int my;
-
- y_offset += 16 * (h->mb_y >> MB_FIELD(h));
-
- if (list0) {
- int ref_n = h->ref_cache[0][scan8[n]];
- Picture *ref = &h->ref_list[0][ref_n];
-
- // Error resilience puts the current picture in the ref list.
- // Don't try to wait on these as it will cause a deadlock.
- // Fields can wait on each other, though.
- if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
- (ref->reference & 3) != h->picture_structure) {
- my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0);
- if (refs[0][ref_n] < 0)
- nrefs[0] += 1;
- refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
- }
- }
-
- if (list1) {
- int ref_n = h->ref_cache[1][scan8[n]];
- Picture *ref = &h->ref_list[1][ref_n];
-
- if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
- (ref->reference & 3) != h->picture_structure) {
- my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1);
- if (refs[1][ref_n] < 0)
- nrefs[1] += 1;
- refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
- }
- }
-}
-
-/**
- * Wait until all reference frames are available for MC operations.
- *
- * @param h the H264 context
- */
-static void await_references(H264Context *h)
-{
- const int mb_xy = h->mb_xy;
- const int mb_type = h->cur_pic.mb_type[mb_xy];
- int refs[2][48];
- int nrefs[2] = { 0 };
- int ref, list;
-
- memset(refs, -1, sizeof(refs));
-
- if (IS_16X16(mb_type)) {
- get_lowest_part_y(h, refs, 0, 16, 0,
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
- } else if (IS_16X8(mb_type)) {
- get_lowest_part_y(h, refs, 0, 8, 0,
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
- get_lowest_part_y(h, refs, 8, 8, 8,
- IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
- } else if (IS_8X16(mb_type)) {
- get_lowest_part_y(h, refs, 0, 16, 0,
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
- get_lowest_part_y(h, refs, 4, 16, 0,
- IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
- } else {
- int i;
-
- av_assert2(IS_8X8(mb_type));
-
- for (i = 0; i < 4; i++) {
- const int sub_mb_type = h->sub_mb_type[i];
- const int n = 4 * i;
- int y_offset = (i & 2) << 2;
-
- if (IS_SUB_8X8(sub_mb_type)) {
- get_lowest_part_y(h, refs, n, 8, y_offset,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- } else if (IS_SUB_8X4(sub_mb_type)) {
- get_lowest_part_y(h, refs, n, 4, y_offset,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- get_lowest_part_y(h, refs, n + 2, 4, y_offset + 4,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- } else if (IS_SUB_4X8(sub_mb_type)) {
- get_lowest_part_y(h, refs, n, 8, y_offset,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- get_lowest_part_y(h, refs, n + 1, 8, y_offset,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- } else {
- int j;
- av_assert2(IS_SUB_4X4(sub_mb_type));
- for (j = 0; j < 4; j++) {
- int sub_y_offset = y_offset + 2 * (j & 2);
- get_lowest_part_y(h, refs, n + j, 4, sub_y_offset,
- IS_DIR(sub_mb_type, 0, 0),
- IS_DIR(sub_mb_type, 0, 1),
- nrefs);
- }
- }
- }
- }
-
- for (list = h->list_count - 1; list >= 0; list--)
- for (ref = 0; ref < 48 && nrefs[list]; ref++) {
- int row = refs[list][ref];
- if (row >= 0) {
- Picture *ref_pic = &h->ref_list[list][ref];
- int ref_field = ref_pic->reference - 1;
- int ref_field_picture = ref_pic->field_picture;
- int pic_height = 16 * h->mb_height >> ref_field_picture;
-
- row <<= MB_MBAFF(h);
- nrefs[list]--;
-
- if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields
- ff_thread_await_progress(&ref_pic->tf,
- FFMIN((row >> 1) - !(row & 1),
- pic_height - 1),
- 1);
- ff_thread_await_progress(&ref_pic->tf,
- FFMIN((row >> 1), pic_height - 1),
- 0);
- } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame
- ff_thread_await_progress(&ref_pic->tf,
- FFMIN(row * 2 + ref_field,
- pic_height - 1),
- 0);
- } else if (FIELD_PICTURE(h)) {
- ff_thread_await_progress(&ref_pic->tf,
- FFMIN(row, pic_height - 1),
- ref_field);
- } else {
- ff_thread_await_progress(&ref_pic->tf,
- FFMIN(row, pic_height - 1),
- 0);
- }
- }
- }
-}
-
-static av_always_inline void mc_dir_part(H264Context *h, Picture *pic,
- int n, int square, int height,
- int delta, int list,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr,
- int src_x_offset, int src_y_offset,
- qpel_mc_func *qpix_op,
- h264_chroma_mc_func chroma_op,
- int pixel_shift, int chroma_idc)
-{
- const int mx = h->mv_cache[list][scan8[n]][0] + src_x_offset * 8;
- int my = h->mv_cache[list][scan8[n]][1] + src_y_offset * 8;
- const int luma_xy = (mx & 3) + ((my & 3) << 2);
- ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->mb_linesize;
- uint8_t *src_y = pic->f.data[0] + offset;
- uint8_t *src_cb, *src_cr;
- int extra_width = 0;
- int extra_height = 0;
- int emu = 0;
- const int full_mx = mx >> 2;
- const int full_my = my >> 2;
- const int pic_width = 16 * h->mb_width;
- const int pic_height = 16 * h->mb_height >> MB_FIELD(h);
- int ysh;
-
- if (mx & 7)
- extra_width -= 3;
- if (my & 7)
- extra_height -= 3;
-
- if (full_mx < 0 - extra_width ||
- full_my < 0 - extra_height ||
- full_mx + 16 /*FIXME*/ > pic_width + extra_width ||
- full_my + 16 /*FIXME*/ > pic_height + extra_height) {
- h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
- src_y - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize, h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2,
- full_my - 2, pic_width, pic_height);
- src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
- emu = 1;
- }
-
- qpix_op[luma_xy](dest_y, src_y, h->mb_linesize); // FIXME try variable height perhaps?
- if (!square)
- qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize);
-
- if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY)
- return;
-
- if (chroma_idc == 3 /* yuv444 */) {
- src_cb = pic->f.data[1] + offset;
- if (emu) {
- h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
- src_cb - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize, h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/,
- full_mx - 2, full_my - 2,
- pic_width, pic_height);
- src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
- }
- qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); // FIXME try variable height perhaps?
- if (!square)
- qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize);
-
- src_cr = pic->f.data[2] + offset;
- if (emu) {
- h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
- src_cr - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize, h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/,
- full_mx - 2, full_my - 2,
- pic_width, pic_height);
- src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
- }
- qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); // FIXME try variable height perhaps?
- if (!square)
- qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize);
- return;
- }
-
- ysh = 3 - (chroma_idc == 2 /* yuv422 */);
- if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) {
- // chroma offset when predicting from a field of opposite parity
- my += 2 * ((h->mb_y & 1) - (pic->reference - 1));
- emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
- }
-
- src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) +
- (my >> ysh) * h->mb_uvlinesize;
- src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) +
- (my >> ysh) * h->mb_uvlinesize;
-
- if (emu) {
- h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb,
- h->mb_uvlinesize, h->mb_uvlinesize,
- 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
- pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
- src_cb = h->edge_emu_buffer;
- }
- chroma_op(dest_cb, src_cb, h->mb_uvlinesize,
- height >> (chroma_idc == 1 /* yuv420 */),
- mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7);
-
- if (emu) {
- h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr,
- h->mb_uvlinesize, h->mb_uvlinesize,
- 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
- pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
- src_cr = h->edge_emu_buffer;
- }
- chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */),
- mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7);
-}
-
-static av_always_inline void mc_part_std(H264Context *h, int n, int square,
- int height, int delta,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr,
- int x_offset, int y_offset,
- qpel_mc_func *qpix_put,
- h264_chroma_mc_func chroma_put,
- qpel_mc_func *qpix_avg,
- h264_chroma_mc_func chroma_avg,
- int list0, int list1,
- int pixel_shift, int chroma_idc)
-{
- qpel_mc_func *qpix_op = qpix_put;
- h264_chroma_mc_func chroma_op = chroma_put;
-
- dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- if (chroma_idc == 3 /* yuv444 */) {
- dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- } else if (chroma_idc == 2 /* yuv422 */) {
- dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
- dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
- } else { /* yuv420 */
- dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
- dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
- }
- x_offset += 8 * h->mb_x;
- y_offset += 8 * (h->mb_y >> MB_FIELD(h));
-
- if (list0) {
- Picture *ref = &h->ref_list[0][h->ref_cache[0][scan8[n]]];
- mc_dir_part(h, ref, n, square, height, delta, 0,
- dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_op, chroma_op, pixel_shift, chroma_idc);
-
- qpix_op = qpix_avg;
- chroma_op = chroma_avg;
- }
-
- if (list1) {
- Picture *ref = &h->ref_list[1][h->ref_cache[1][scan8[n]]];
- mc_dir_part(h, ref, n, square, height, delta, 1,
- dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_op, chroma_op, pixel_shift, chroma_idc);
- }
-}
-
-static av_always_inline void mc_part_weighted(H264Context *h, int n, int square,
- int height, int delta,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr,
- int x_offset, int y_offset,
- qpel_mc_func *qpix_put,
- h264_chroma_mc_func chroma_put,
- h264_weight_func luma_weight_op,
- h264_weight_func chroma_weight_op,
- h264_biweight_func luma_weight_avg,
- h264_biweight_func chroma_weight_avg,
- int list0, int list1,
- int pixel_shift, int chroma_idc)
-{
- int chroma_height;
-
- dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- if (chroma_idc == 3 /* yuv444 */) {
- chroma_height = height;
- chroma_weight_avg = luma_weight_avg;
- chroma_weight_op = luma_weight_op;
- dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
- } else if (chroma_idc == 2 /* yuv422 */) {
- chroma_height = height;
- dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
- dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
- } else { /* yuv420 */
- chroma_height = height >> 1;
- dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
- dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
- }
- x_offset += 8 * h->mb_x;
- y_offset += 8 * (h->mb_y >> MB_FIELD(h));
-
- if (list0 && list1) {
- /* don't optimize for luma-only case, since B-frames usually
- * use implicit weights => chroma too. */
- uint8_t *tmp_cb = h->bipred_scratchpad;
- uint8_t *tmp_cr = h->bipred_scratchpad + (16 << pixel_shift);
- uint8_t *tmp_y = h->bipred_scratchpad + 16 * h->mb_uvlinesize;
- int refn0 = h->ref_cache[0][scan8[n]];
- int refn1 = h->ref_cache[1][scan8[n]];
-
- mc_dir_part(h, &h->ref_list[0][refn0], n, square, height, delta, 0,
- dest_y, dest_cb, dest_cr,
- x_offset, y_offset, qpix_put, chroma_put,
- pixel_shift, chroma_idc);
- mc_dir_part(h, &h->ref_list[1][refn1], n, square, height, delta, 1,
- tmp_y, tmp_cb, tmp_cr,
- x_offset, y_offset, qpix_put, chroma_put,
- pixel_shift, chroma_idc);
-
- if (h->use_weight == 2) {
- int weight0 = h->implicit_weight[refn0][refn1][h->mb_y & 1];
- int weight1 = 64 - weight0;
- luma_weight_avg(dest_y, tmp_y, h->mb_linesize,
- height, 5, weight0, weight1, 0);
- chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize,
- chroma_height, 5, weight0, weight1, 0);
- chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize,
- chroma_height, 5, weight0, weight1, 0);
- } else {
- luma_weight_avg(dest_y, tmp_y, h->mb_linesize, height,
- h->luma_log2_weight_denom,
- h->luma_weight[refn0][0][0],
- h->luma_weight[refn1][1][0],
- h->luma_weight[refn0][0][1] +
- h->luma_weight[refn1][1][1]);
- chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, chroma_height,
- h->chroma_log2_weight_denom,
- h->chroma_weight[refn0][0][0][0],
- h->chroma_weight[refn1][1][0][0],
- h->chroma_weight[refn0][0][0][1] +
- h->chroma_weight[refn1][1][0][1]);
- chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, chroma_height,
- h->chroma_log2_weight_denom,
- h->chroma_weight[refn0][0][1][0],
- h->chroma_weight[refn1][1][1][0],
- h->chroma_weight[refn0][0][1][1] +
- h->chroma_weight[refn1][1][1][1]);
- }
- } else {
- int list = list1 ? 1 : 0;
- int refn = h->ref_cache[list][scan8[n]];
- Picture *ref = &h->ref_list[list][refn];
- mc_dir_part(h, ref, n, square, height, delta, list,
- dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_put, chroma_put, pixel_shift, chroma_idc);
-
- luma_weight_op(dest_y, h->mb_linesize, height,
- h->luma_log2_weight_denom,
- h->luma_weight[refn][list][0],
- h->luma_weight[refn][list][1]);
- if (h->use_weight_chroma) {
- chroma_weight_op(dest_cb, h->mb_uvlinesize, chroma_height,
- h->chroma_log2_weight_denom,
- h->chroma_weight[refn][list][0][0],
- h->chroma_weight[refn][list][0][1]);
- chroma_weight_op(dest_cr, h->mb_uvlinesize, chroma_height,
- h->chroma_log2_weight_denom,
- h->chroma_weight[refn][list][1][0],
- h->chroma_weight[refn][list][1][1]);
- }
- }
-}
-
-static av_always_inline void prefetch_motion(H264Context *h, int list,
- int pixel_shift, int chroma_idc)
-{
- /* fetch pixels for estimated mv 4 macroblocks ahead
- * optimized for 64byte cache lines */
- const int refn = h->ref_cache[list][scan8[0]];
- if (refn >= 0) {
- const int mx = (h->mv_cache[list][scan8[0]][0] >> 2) + 16 * h->mb_x + 8;
- const int my = (h->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y;
- uint8_t **src = h->ref_list[list][refn].f.data;
- int off = (mx << pixel_shift) +
- (my + (h->mb_x & 3) * 4) * h->mb_linesize +
- (64 << pixel_shift);
- h->vdsp.prefetch(src[0] + off, h->linesize, 4);
- if (chroma_idc == 3 /* yuv444 */) {
- h->vdsp.prefetch(src[1] + off, h->linesize, 4);
- h->vdsp.prefetch(src[2] + off, h->linesize, 4);
- } else {
- off= (((mx>>1)+64)<<pixel_shift) + ((my>>1) + (h->mb_x&7))*h->uvlinesize;
- h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
- }
- }
-}
-
-static void free_tables(H264Context *h, int free_rbsp)
+void ff_h264_free_tables(H264Context *h, int free_rbsp)
{
int i;
H264Context *hx;
@@ -1210,26 +381,23 @@ static void free_tables(H264Context *h, int free_rbsp)
av_freep(&h->mb2b_xy);
av_freep(&h->mb2br_xy);
- for (i = 0; i < 3; i++)
- av_freep(&h->visualization_buffer[i]);
-
av_buffer_pool_uninit(&h->qscale_table_pool);
av_buffer_pool_uninit(&h->mb_type_pool);
av_buffer_pool_uninit(&h->motion_val_pool);
av_buffer_pool_uninit(&h->ref_index_pool);
if (free_rbsp && h->DPB) {
- for (i = 0; i < MAX_PICTURE_COUNT; i++)
- unref_picture(h, &h->DPB[i]);
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+ ff_h264_unref_picture(h, &h->DPB[i]);
av_freep(&h->DPB);
} else if (h->DPB) {
- for (i = 0; i < MAX_PICTURE_COUNT; i++)
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
h->DPB[i].needs_realloc = 1;
}
h->cur_pic_ptr = NULL;
- for (i = 0; i < MAX_THREADS; i++) {
+ for (i = 0; i < H264_MAX_THREADS; i++) {
hx = h->thread_context[i];
if (!hx)
continue;
@@ -1238,7 +406,6 @@ static void free_tables(H264Context *h, int free_rbsp)
av_freep(&hx->bipred_scratchpad);
av_freep(&hx->edge_emu_buffer);
av_freep(&hx->dc_val_base);
- av_freep(&hx->me.scratchpad);
av_freep(&hx->er.mb_index2xy);
av_freep(&hx->er.error_status_table);
av_freep(&hx->er.er_temp_buffer);
@@ -1256,76 +423,6 @@ static void free_tables(H264Context *h, int free_rbsp)
}
}
-static void init_dequant8_coeff_table(H264Context *h)
-{
- int i, j, q, x;
- const int max_qp = 51 + 6 * (h->sps.bit_depth_luma - 8);
-
- for (i = 0; i < 6; i++) {
- h->dequant8_coeff[i] = h->dequant8_buffer[i];
- for (j = 0; j < i; j++)
- if (!memcmp(h->pps.scaling_matrix8[j], h->pps.scaling_matrix8[i],
- 64 * sizeof(uint8_t))) {
- h->dequant8_coeff[i] = h->dequant8_buffer[j];
- break;
- }
- if (j < i)
- continue;
-
- for (q = 0; q < max_qp + 1; q++) {
- int shift = div6[q];
- int idx = rem6[q];
- for (x = 0; x < 64; x++)
- h->dequant8_coeff[i][q][(x >> 3) | ((x & 7) << 3)] =
- ((uint32_t)dequant8_coeff_init[idx][dequant8_coeff_init_scan[((x >> 1) & 12) | (x & 3)]] *
- h->pps.scaling_matrix8[i][x]) << shift;
- }
- }
-}
-
-static void init_dequant4_coeff_table(H264Context *h)
-{
- int i, j, q, x;
- const int max_qp = 51 + 6 * (h->sps.bit_depth_luma - 8);
- for (i = 0; i < 6; i++) {
- h->dequant4_coeff[i] = h->dequant4_buffer[i];
- for (j = 0; j < i; j++)
- if (!memcmp(h->pps.scaling_matrix4[j], h->pps.scaling_matrix4[i],
- 16 * sizeof(uint8_t))) {
- h->dequant4_coeff[i] = h->dequant4_buffer[j];
- break;
- }
- if (j < i)
- continue;
-
- for (q = 0; q < max_qp + 1; q++) {
- int shift = div6[q] + 2;
- int idx = rem6[q];
- for (x = 0; x < 16; x++)
- h->dequant4_coeff[i][q][(x >> 2) | ((x << 2) & 0xF)] =
- ((uint32_t)dequant4_coeff_init[idx][(x & 1) + ((x >> 2) & 1)] *
- h->pps.scaling_matrix4[i][x]) << shift;
- }
- }
-}
-
-static void init_dequant_tables(H264Context *h)
-{
- int i, x;
- init_dequant4_coeff_table(h);
- if (h->pps.transform_8x8_mode)
- init_dequant8_coeff_table(h);
- if (h->sps.transform_bypass) {
- for (i = 0; i < 6; i++)
- for (x = 0; x < 16; x++)
- h->dequant4_coeff[i][0][x] = 1 << 6;
- if (h->pps.transform_8x8_mode)
- for (i = 0; i < 6; i++)
- for (x = 0; x < 64; x++)
- h->dequant8_coeff[i][0][x] = 1 << 6;
- }
-}
-
int ff_h264_alloc_tables(H264Context *h)
{
const int big_mb_num = h->mb_stride * (h->mb_height + 1);
@@ -1369,55 +466,29 @@ int ff_h264_alloc_tables(H264Context *h)
}
if (!h->dequant4_coeff[0])
- init_dequant_tables(h);
+ h264_init_dequant_tables(h);
if (!h->DPB) {
- h->DPB = av_mallocz_array(MAX_PICTURE_COUNT, sizeof(*h->DPB));
+ h->DPB = av_mallocz_array(H264_MAX_PICTURE_COUNT, sizeof(*h->DPB));
if (!h->DPB)
return AVERROR(ENOMEM);
- for (i = 0; i < MAX_PICTURE_COUNT; i++)
- avcodec_get_frame_defaults(&h->DPB[i].f);
- avcodec_get_frame_defaults(&h->cur_pic.f);
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+ av_frame_unref(&h->DPB[i].f);
+ av_frame_unref(&h->cur_pic.f);
}
return 0;
fail:
- free_tables(h, 1);
+ ff_h264_free_tables(h, 1);
return AVERROR(ENOMEM);
}
/**
- * Mimic alloc_tables(), but for every context thread.
- */
-static void clone_tables(H264Context *dst, H264Context *src, int i)
-{
- dst->intra4x4_pred_mode = src->intra4x4_pred_mode + i * 8 * 2 * src->mb_stride;
- dst->non_zero_count = src->non_zero_count;
- dst->slice_table = src->slice_table;
- dst->cbp_table = src->cbp_table;
- dst->mb2b_xy = src->mb2b_xy;
- dst->mb2br_xy = src->mb2br_xy;
- dst->chroma_pred_mode_table = src->chroma_pred_mode_table;
- dst->mvd_table[0] = src->mvd_table[0] + i * 8 * 2 * src->mb_stride;
- dst->mvd_table[1] = src->mvd_table[1] + i * 8 * 2 * src->mb_stride;
- dst->direct_table = src->direct_table;
- dst->list_counts = src->list_counts;
- dst->DPB = src->DPB;
- dst->cur_pic_ptr = src->cur_pic_ptr;
- dst->cur_pic = src->cur_pic;
- dst->bipred_scratchpad = NULL;
- dst->edge_emu_buffer = NULL;
- dst->me.scratchpad = NULL;
- ff_h264_pred_init(&dst->hpc, src->avctx->codec_id, src->sps.bit_depth_luma,
- src->sps.chroma_format_idc);
-}
-
-/**
* Init context
* Allocate buffers which are not shared amongst multiple threads.
*/
-static int context_init(H264Context *h)
+int ff_h264_context_init(H264Context *h)
{
ERContext *er = &h->er;
int mb_array_size = h->mb_height * h->mb_stride;
@@ -1483,7 +554,7 @@ static int context_init(H264Context *h)
return 0;
fail:
- return AVERROR(ENOMEM); // free_tables will clean up for us
+ return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
}
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
@@ -1504,7 +575,8 @@ int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
h->is_avc = 1;
if (size < 7) {
- av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "avcC %d too short\n", size);
return AVERROR_INVALIDDATA;
}
/* sps and pps in the avcC always have length coded with 2 bytes,
@@ -1635,49 +707,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
avctx->internal->allocate_progress = 1;
- flush_change(h);
-
- return 0;
-}
-
-#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b) + (size))))
-#undef REBASE_PICTURE
-#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
- ((pic && pic >= old_ctx->DPB && \
- pic < old_ctx->DPB + MAX_PICTURE_COUNT) ? \
- &new_ctx->DPB[pic - old_ctx->DPB] : NULL)
-
-static void copy_picture_range(Picture **to, Picture **from, int count,
- H264Context *new_base,
- H264Context *old_base)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- assert((IN_RANGE(from[i], old_base, sizeof(*old_base)) ||
- IN_RANGE(from[i], old_base->DPB,
- sizeof(Picture) * MAX_PICTURE_COUNT) ||
- !from[i]));
- to[i] = REBASE_PICTURE(from[i], new_base, old_base);
- }
-}
-
-static int copy_parameter_set(void **to, void **from, int count, int size)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- if (to[i] && !from[i]) {
- av_freep(&to[i]);
- } else if (from[i] && !to[i]) {
- to[i] = av_malloc(size);
- if (!to[i])
- return AVERROR(ENOMEM);
- }
-
- if (from[i])
- memcpy(to[i], from[i], size);
- }
+ ff_h264_flush_change(h);
return 0;
}
@@ -1700,318 +730,6 @@ static int decode_init_thread_copy(AVCodecContext *avctx)
return 0;
}
-#define copy_fields(to, from, start_field, end_field) \
- memcpy(&to->start_field, &from->start_field, \
- (char *)&to->end_field - (char *)&to->start_field)
-
-static int h264_slice_header_init(H264Context *, int);
-
-static int h264_set_parameter_from_sps(H264Context *h);
-
-static int decode_update_thread_context(AVCodecContext *dst,
- const AVCodecContext *src)
-{
- H264Context *h = dst->priv_data, *h1 = src->priv_data;
- int inited = h->context_initialized, err = 0;
- int context_reinitialized = 0;
- int i, ret;
-
- if (dst == src)
- return 0;
-
- if (inited &&
- (h->width != h1->width ||
- h->height != h1->height ||
- h->mb_width != h1->mb_width ||
- h->mb_height != h1->mb_height ||
- h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
- h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
- h->sps.colorspace != h1->sps.colorspace)) {
-
- /* set bits_per_raw_sample to the previous value. the check for changed
- * bit depth in h264_set_parameter_from_sps() uses it and sets it to
- * the current value */
- h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
-
- av_freep(&h->bipred_scratchpad);
-
- h->width = h1->width;
- h->height = h1->height;
- h->mb_height = h1->mb_height;
- h->mb_width = h1->mb_width;
- h->mb_num = h1->mb_num;
- h->mb_stride = h1->mb_stride;
- h->b_stride = h1->b_stride;
- // SPS/PPS
- if ((ret = copy_parameter_set((void **)h->sps_buffers,
- (void **)h1->sps_buffers,
- MAX_SPS_COUNT, sizeof(SPS))) < 0)
- return ret;
- h->sps = h1->sps;
- if ((ret = copy_parameter_set((void **)h->pps_buffers,
- (void **)h1->pps_buffers,
- MAX_PPS_COUNT, sizeof(PPS))) < 0)
- return ret;
- h->pps = h1->pps;
-
- if ((err = h264_slice_header_init(h, 1)) < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
- return err;
- }
- context_reinitialized = 1;
-
-#if 0
- h264_set_parameter_from_sps(h);
- //Note we set context_reinitialized which will cause h264_set_parameter_from_sps to be reexecuted
- h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
-#endif
- }
- /* update linesize on resize for h264. The h264 decoder doesn't
- * necessarily call ff_MPV_frame_start in the new thread */
- h->linesize = h1->linesize;
- h->uvlinesize = h1->uvlinesize;
-
- /* copy block_offset since frame_start may not be called */
- memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
-
- if (!inited) {
- for (i = 0; i < MAX_SPS_COUNT; i++)
- av_freep(h->sps_buffers + i);
-
- for (i = 0; i < MAX_PPS_COUNT; i++)
- av_freep(h->pps_buffers + i);
-
- av_freep(&h->rbsp_buffer[0]);
- av_freep(&h->rbsp_buffer[1]);
- memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));
- memcpy(&h->cabac, &h1->cabac,
- sizeof(H264Context) - offsetof(H264Context, cabac));
- av_assert0((void*)&h->cabac == &h->mb_padding + 1);
-
- memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
- memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
-
- memset(&h->er, 0, sizeof(h->er));
- memset(&h->me, 0, sizeof(h->me));
- memset(&h->mb, 0, sizeof(h->mb));
- memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
- memset(&h->mb_padding, 0, sizeof(h->mb_padding));
-
- h->avctx = dst;
- h->DPB = NULL;
- h->qscale_table_pool = NULL;
- h->mb_type_pool = NULL;
- h->ref_index_pool = NULL;
- h->motion_val_pool = NULL;
- for (i = 0; i < 2; i++) {
- h->rbsp_buffer[i] = NULL;
- h->rbsp_buffer_size[i] = 0;
- }
-
- if (h1->context_initialized) {
- h->context_initialized = 0;
-
- memset(&h->cur_pic, 0, sizeof(h->cur_pic));
- avcodec_get_frame_defaults(&h->cur_pic.f);
- h->cur_pic.tf.f = &h->cur_pic.f;
-
- ret = ff_h264_alloc_tables(h);
- if (ret < 0) {
- av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
- return ret;
- }
- ret = context_init(h);
- if (ret < 0) {
- av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
- return ret;
- }
- }
-
- h->bipred_scratchpad = NULL;
- h->edge_emu_buffer = NULL;
-
- h->thread_context[0] = h;
- h->context_initialized = h1->context_initialized;
- }
-
- h->avctx->coded_height = h1->avctx->coded_height;
- h->avctx->coded_width = h1->avctx->coded_width;
- h->avctx->width = h1->avctx->width;
- h->avctx->height = h1->avctx->height;
- h->coded_picture_number = h1->coded_picture_number;
- h->first_field = h1->first_field;
- h->picture_structure = h1->picture_structure;
- h->qscale = h1->qscale;
- h->droppable = h1->droppable;
- h->data_partitioning = h1->data_partitioning;
- h->low_delay = h1->low_delay;
-
- for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
- unref_picture(h, &h->DPB[i]);
- if (h1->DPB[i].f.buf[0] &&
- (ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
- return ret;
- }
-
- h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
- unref_picture(h, &h->cur_pic);
- if (h1->cur_pic.f.buf[0] && (ret = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
- return ret;
-
- h->workaround_bugs = h1->workaround_bugs;
- h->low_delay = h1->low_delay;
- h->droppable = h1->droppable;
-
- // extradata/NAL handling
- h->is_avc = h1->is_avc;
-
- // SPS/PPS
- if ((ret = copy_parameter_set((void **)h->sps_buffers,
- (void **)h1->sps_buffers,
- MAX_SPS_COUNT, sizeof(SPS))) < 0)
- return ret;
- h->sps = h1->sps;
- if ((ret = copy_parameter_set((void **)h->pps_buffers,
- (void **)h1->pps_buffers,
- MAX_PPS_COUNT, sizeof(PPS))) < 0)
- return ret;
- h->pps = h1->pps;
-
- // Dequantization matrices
- // FIXME these are big - can they be only copied when PPS changes?
- copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
-
- for (i = 0; i < 6; i++)
- h->dequant4_coeff[i] = h->dequant4_buffer[0] +
- (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
-
- for (i = 0; i < 6; i++)
- h->dequant8_coeff[i] = h->dequant8_buffer[0] +
- (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
-
- h->dequant_coeff_pps = h1->dequant_coeff_pps;
-
- // POC timing
- copy_fields(h, h1, poc_lsb, redundant_pic_count);
-
- // reference lists
- copy_fields(h, h1, short_ref, cabac_init_idc);
-
- copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
- copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
- copy_picture_range(h->delayed_pic, h1->delayed_pic,
- MAX_DELAYED_PIC_COUNT + 2, h, h1);
-
- h->frame_recovered = h1->frame_recovered;
-
- if (context_reinitialized)
- h264_set_parameter_from_sps(h);
-
- if (!h->cur_pic_ptr)
- return 0;
-
- if (!h->droppable) {
- err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
- h->prev_poc_msb = h->poc_msb;
- h->prev_poc_lsb = h->poc_lsb;
- }
- h->prev_frame_num_offset = h->frame_num_offset;
- h->prev_frame_num = h->frame_num;
- h->outputed_poc = h->next_outputed_poc;
-
- h->recovery_frame = h1->recovery_frame;
-
- return err;
-}
-
-static int h264_frame_start(H264Context *h)
-{
- Picture *pic;
- int i, ret;
- const int pixel_shift = h->pixel_shift;
- int c[4] = {
- 1<<(h->sps.bit_depth_luma-1),
- 1<<(h->sps.bit_depth_chroma-1),
- 1<<(h->sps.bit_depth_chroma-1),
- -1
- };
-
- if (!ff_thread_can_start_frame(h->avctx)) {
- av_log(h->avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
- return -1;
- }
-
- release_unused_pictures(h, 1);
- h->cur_pic_ptr = NULL;
-
- i = find_unused_picture(h);
- if (i < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- pic = &h->DPB[i];
-
- pic->reference = h->droppable ? 0 : h->picture_structure;
- pic->f.coded_picture_number = h->coded_picture_number++;
- pic->field_picture = h->picture_structure != PICT_FRAME;
-
- /*
- * Zero key_frame here; IDR markings per slice in frame or fields are ORed
- * in later.
- * See decode_nal_units().
- */
- pic->f.key_frame = 0;
- pic->mmco_reset = 0;
- pic->recovered = 0;
-
- if ((ret = alloc_picture(h, pic)) < 0)
- return ret;
- if(!h->frame_recovered && !h->avctx->hwaccel &&
- !(h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU))
- avpriv_color_frame(&pic->f, c);
-
- h->cur_pic_ptr = pic;
- unref_picture(h, &h->cur_pic);
- if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
- return ret;
-
- if (CONFIG_ERROR_RESILIENCE) {
- ff_er_frame_start(&h->er);
- h->er.last_pic =
- h->er.next_pic = NULL;
- }
-
- assert(h->linesize && h->uvlinesize);
-
- for (i = 0; i < 16; i++) {
- h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
- h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
- }
- for (i = 0; i < 16; i++) {
- h->block_offset[16 + i] =
- h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
- h->block_offset[48 + 16 + i] =
- h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
- }
-
- // s->decode = (h->flags & CODEC_FLAG_PSNR) || !s->encoding ||
- // h->cur_pic.reference /* || h->contains_intra */ || 1;
-
- /* We mark the current picture as non-reference after allocating it, so
- * that if we break out due to an error it can be released automatically
- * in the next ff_MPV_frame_start().
- */
- h->cur_pic_ptr->reference = 0;
-
- h->cur_pic_ptr->field_poc[0] = h->cur_pic_ptr->field_poc[1] = INT_MAX;
-
- h->next_output_pic = NULL;
-
- assert(h->cur_pic_ptr->long_ref == 0);
-
- return 0;
-}
-
/**
* Run setup operations that must be run after slice header decoding.
* This includes finding the next displayed frame.
@@ -2022,8 +740,8 @@ static int h264_frame_start(H264Context *h)
*/
static void decode_postinit(H264Context *h, int setup_finished)
{
- Picture *out = h->cur_pic_ptr;
- Picture *cur = h->cur_pic_ptr;
+ H264Picture *out = h->cur_pic_ptr;
+ H264Picture *cur = h->cur_pic_ptr;
int i, pics, out_of_order, out_idx;
h->cur_pic_ptr->f.pict_type = h->pict_type;
@@ -2106,8 +824,49 @@ static void decode_postinit(H264Context *h, int setup_finished)
}
}
+ if (h->sei_frame_packing_present &&
+ h->frame_packing_arrangement_type >= 0 &&
+ h->frame_packing_arrangement_type <= 6 &&
+ h->content_interpretation_type > 0 &&
+ h->content_interpretation_type < 3) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(&cur->f);
+ if (!stereo)
+ return;
+
+ switch (h->frame_packing_arrangement_type) {
+ case 0:
+ stereo->type = AV_STEREO3D_CHECKERBOARD;
+ break;
+ case 1:
+ stereo->type = AV_STEREO3D_LINES;
+ break;
+ case 2:
+ stereo->type = AV_STEREO3D_COLUMNS;
+ break;
+ case 3:
+ if (h->quincunx_subsampling)
+ stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ else
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 4:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case 5:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+ case 6:
+ stereo->type = AV_STEREO3D_2D;
+ break;
+ }
+
+ if (h->content_interpretation_type == 2)
+ stereo->flags = AV_STEREO3D_FLAG_INVERT;
+ }
+
cur->mmco_reset = h->mmco_reset;
h->mmco_reset = 0;
+
// FIXME do something with unavailable reference frames
/* Sort B-frames into display order */
@@ -2204,424 +963,6 @@ static void decode_postinit(H264Context *h, int setup_finished)
ff_thread_finish_setup(h->avctx);
}
-static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y,
- uint8_t *src_cb, uint8_t *src_cr,
- int linesize, int uvlinesize,
- int simple)
-{
- uint8_t *top_border;
- int top_idx = 1;
- const int pixel_shift = h->pixel_shift;
- int chroma444 = CHROMA444(h);
- int chroma422 = CHROMA422(h);
-
- src_y -= linesize;
- src_cb -= uvlinesize;
- src_cr -= uvlinesize;
-
- if (!simple && FRAME_MBAFF(h)) {
- if (h->mb_y & 1) {
- if (!MB_MBAFF(h)) {
- top_border = h->top_borders[0][h->mb_x];
- AV_COPY128(top_border, src_y + 15 * linesize);
- if (pixel_shift)
- AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
- if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
- if (chroma444) {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
- AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
- AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
- AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
- } else {
- AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
- AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
- }
- } else if (chroma422) {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
- AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
- } else {
- AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
- AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
- }
- } else {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
- AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
- } else {
- AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
- AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
- }
- }
- }
- }
- } else if (MB_MBAFF(h)) {
- top_idx = 0;
- } else
- return;
- }
-
- top_border = h->top_borders[top_idx][h->mb_x];
- /* There are two lines saved, the line above the top macroblock
- * of a pair, and the line above the bottom macroblock. */
- AV_COPY128(top_border, src_y + 16 * linesize);
- if (pixel_shift)
- AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
-
- if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
- if (chroma444) {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 16 * linesize);
- AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
- AV_COPY128(top_border + 64, src_cr + 16 * linesize);
- AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
- } else {
- AV_COPY128(top_border + 16, src_cb + 16 * linesize);
- AV_COPY128(top_border + 32, src_cr + 16 * linesize);
- }
- } else if (chroma422) {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
- AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
- } else {
- AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
- AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
- }
- } else {
- if (pixel_shift) {
- AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
- AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
- } else {
- AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
- AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
- }
- }
- }
-}
-
-static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
- uint8_t *src_cb, uint8_t *src_cr,
- int linesize, int uvlinesize,
- int xchg, int chroma444,
- int simple, int pixel_shift)
-{
- int deblock_topleft;
- int deblock_top;
- int top_idx = 1;
- uint8_t *top_border_m1;
- uint8_t *top_border;
-
- if (!simple && FRAME_MBAFF(h)) {
- if (h->mb_y & 1) {
- if (!MB_MBAFF(h))
- return;
- } else {
- top_idx = MB_MBAFF(h) ? 0 : 1;
- }
- }
-
- if (h->deblocking_filter == 2) {
- deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == h->slice_num;
- deblock_top = h->top_type;
- } else {
- deblock_topleft = (h->mb_x > 0);
- deblock_top = (h->mb_y > !!MB_FIELD(h));
- }
-
- src_y -= linesize + 1 + pixel_shift;
- src_cb -= uvlinesize + 1 + pixel_shift;
- src_cr -= uvlinesize + 1 + pixel_shift;
-
- top_border_m1 = h->top_borders[top_idx][h->mb_x - 1];
- top_border = h->top_borders[top_idx][h->mb_x];
-
-#define XCHG(a, b, xchg) \
- if (pixel_shift) { \
- if (xchg) { \
- AV_SWAP64(b + 0, a + 0); \
- AV_SWAP64(b + 8, a + 8); \
- } else { \
- AV_COPY128(b, a); \
- } \
- } else if (xchg) \
- AV_SWAP64(b, a); \
- else \
- AV_COPY64(b, a);
-
- if (deblock_top) {
- if (deblock_topleft) {
- XCHG(top_border_m1 + (8 << pixel_shift),
- src_y - (7 << pixel_shift), 1);
- }
- XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
- XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
- if (h->mb_x + 1 < h->mb_width) {
- XCHG(h->top_borders[top_idx][h->mb_x + 1],
- src_y + (17 << pixel_shift), 1);
- }
- if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
- if (chroma444) {
- if (deblock_topleft) {
- XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
- XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
- }
- XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
- XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
- XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
- XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
- if (h->mb_x + 1 < h->mb_width) {
- XCHG(h->top_borders[top_idx][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
- XCHG(h->top_borders[top_idx][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
- }
- } else {
- if (deblock_topleft) {
- XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
- XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
- }
- XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
- XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
- }
- }
- }
-}
-
-static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth,
- int index)
-{
- if (high_bit_depth) {
- return AV_RN32A(((int32_t *)mb) + index);
- } else
- return AV_RN16A(mb + index);
-}
-
-static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth,
- int index, int value)
-{
- if (high_bit_depth) {
- AV_WN32A(((int32_t *)mb) + index, value);
- } else
- AV_WN16A(mb + index, value);
-}
-
-static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
- int mb_type, int is_h264,
- int simple,
- int transform_bypass,
- int pixel_shift,
- int *block_offset,
- int linesize,
- uint8_t *dest_y, int p)
-{
- void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
- void (*idct_dc_add)(uint8_t *dst, int16_t *block, int stride);
- int i;
- int qscale = p == 0 ? h->qscale : h->chroma_qp[p - 1];
- block_offset += 16 * p;
- if (IS_INTRA4x4(mb_type)) {
- if (IS_8x8DCT(mb_type)) {
- if (transform_bypass) {
- idct_dc_add =
- idct_add = h->h264dsp.h264_add_pixels8_clear;
- } else {
- idct_dc_add = h->h264dsp.h264_idct8_dc_add;
- idct_add = h->h264dsp.h264_idct8_add;
- }
- for (i = 0; i < 16; i += 4) {
- uint8_t *const ptr = dest_y + block_offset[i];
- const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
- if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
- h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- } else {
- const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
- h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
- (h->topright_samples_available << i) & 0x4000, linesize);
- if (nnz) {
- if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
- idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- else
- idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- }
- }
- }
- } else {
- if (transform_bypass) {
- idct_dc_add =
- idct_add = h->h264dsp.h264_add_pixels4_clear;
- } else {
- idct_dc_add = h->h264dsp.h264_idct_dc_add;
- idct_add = h->h264dsp.h264_idct_add;
- }
- for (i = 0; i < 16; i++) {
- uint8_t *const ptr = dest_y + block_offset[i];
- const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
-
- if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
- h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- } else {
- uint8_t *topright;
- int nnz, tr;
- uint64_t tr_high;
- if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
- const int topright_avail = (h->topright_samples_available << i) & 0x8000;
- av_assert2(h->mb_y || linesize <= block_offset[i]);
- if (!topright_avail) {
- if (pixel_shift) {
- tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
- topright = (uint8_t *)&tr_high;
- } else {
- tr = ptr[3 - linesize] * 0x01010101u;
- topright = (uint8_t *)&tr;
- }
- } else
- topright = ptr + (4 << pixel_shift) - linesize;
- } else
- topright = NULL;
-
- h->hpc.pred4x4[dir](ptr, topright, linesize);
- nnz = h->non_zero_count_cache[scan8[i + p * 16]];
- if (nnz) {
- if (is_h264) {
- if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
- idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- else
- idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- } else if (CONFIG_SVQ3_DECODER)
- ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0);
- }
- }
- }
- }
- } else {
- h->hpc.pred16x16[h->intra16x16_pred_mode](dest_y, linesize);
- if (is_h264) {
- if (h->non_zero_count_cache[scan8[LUMA_DC_BLOCK_INDEX + p]]) {
- if (!transform_bypass)
- h->h264dsp.h264_luma_dc_dequant_idct(h->mb + (p * 256 << pixel_shift),
- h->mb_luma_dc[p],
- h->dequant4_coeff[p][qscale][0]);
- else {
- static const uint8_t dc_mapping[16] = {
- 0 * 16, 1 * 16, 4 * 16, 5 * 16,
- 2 * 16, 3 * 16, 6 * 16, 7 * 16,
- 8 * 16, 9 * 16, 12 * 16, 13 * 16,
- 10 * 16, 11 * 16, 14 * 16, 15 * 16
- };
- for (i = 0; i < 16; i++)
- dctcoef_set(h->mb + (p * 256 << pixel_shift),
- pixel_shift, dc_mapping[i],
- dctcoef_get(h->mb_luma_dc[p],
- pixel_shift, i));
- }
- }
- } else if (CONFIG_SVQ3_DECODER)
- ff_svq3_luma_dc_dequant_idct_c(h->mb + p * 256,
- h->mb_luma_dc[p], qscale);
- }
-}
-
-static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type,
- int is_h264, int simple,
- int transform_bypass,
- int pixel_shift,
- int *block_offset,
- int linesize,
- uint8_t *dest_y, int p)
-{
- void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
- int i;
- block_offset += 16 * p;
- if (!IS_INTRA4x4(mb_type)) {
- if (is_h264) {
- if (IS_INTRA16x16(mb_type)) {
- if (transform_bypass) {
- if (h->sps.profile_idc == 244 &&
- (h->intra16x16_pred_mode == VERT_PRED8x8 ||
- h->intra16x16_pred_mode == HOR_PRED8x8)) {
- h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset,
- h->mb + (p * 256 << pixel_shift),
- linesize);
- } else {
- for (i = 0; i < 16; i++)
- if (h->non_zero_count_cache[scan8[i + p * 16]] ||
- dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
- h->h264dsp.h264_add_pixels4_clear(dest_y + block_offset[i],
- h->mb + (i * 16 + p * 256 << pixel_shift),
- linesize);
- }
- } else {
- h->h264dsp.h264_idct_add16intra(dest_y, block_offset,
- h->mb + (p * 256 << pixel_shift),
- linesize,
- h->non_zero_count_cache + p * 5 * 8);
- }
- } else if (h->cbp & 15) {
- if (transform_bypass) {
- const int di = IS_8x8DCT(mb_type) ? 4 : 1;
- idct_add = IS_8x8DCT(mb_type) ? h->h264dsp.h264_add_pixels8_clear
- : h->h264dsp.h264_add_pixels4_clear;
- for (i = 0; i < 16; i += di)
- if (h->non_zero_count_cache[scan8[i + p * 16]])
- idct_add(dest_y + block_offset[i],
- h->mb + (i * 16 + p * 256 << pixel_shift),
- linesize);
- } else {
- if (IS_8x8DCT(mb_type))
- h->h264dsp.h264_idct8_add4(dest_y, block_offset,
- h->mb + (p * 256 << pixel_shift),
- linesize,
- h->non_zero_count_cache + p * 5 * 8);
- else
- h->h264dsp.h264_idct_add16(dest_y, block_offset,
- h->mb + (p * 256 << pixel_shift),
- linesize,
- h->non_zero_count_cache + p * 5 * 8);
- }
- }
- } else if (CONFIG_SVQ3_DECODER) {
- for (i = 0; i < 16; i++)
- if (h->non_zero_count_cache[scan8[i + p * 16]] || h->mb[i * 16 + p * 256]) {
- // FIXME benchmark weird rule, & below
- uint8_t *const ptr = dest_y + block_offset[i];
- ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize,
- h->qscale, IS_INTRA(mb_type) ? 1 : 0);
- }
- }
- }
-}
-
-#define BITS 8
-#define SIMPLE 1
-#include "h264_mb_template.c"
-
-#undef BITS
-#define BITS 16
-#include "h264_mb_template.c"
-
-#undef SIMPLE
-#define SIMPLE 0
-#include "h264_mb_template.c"
-
-void ff_h264_hl_decode_mb(H264Context *h)
-{
- const int mb_xy = h->mb_xy;
- const int mb_type = h->cur_pic.mb_type[mb_xy];
- int is_complex = CONFIG_SMALL || h->is_complex ||
- IS_INTRA_PCM(mb_type) || h->qscale == 0;
-
- if (CHROMA444(h)) {
- if (is_complex || h->pixel_shift)
- hl_decode_mb_444_complex(h);
- else
- hl_decode_mb_444_simple_8(h);
- } else if (is_complex) {
- hl_decode_mb_complex(h);
- } else if (h->pixel_shift) {
- hl_decode_mb_simple_16(h);
- } else
- hl_decode_mb_simple_8(h);
-}
-
int ff_pred_weight_table(H264Context *h)
{
int list, i;
@@ -2685,72 +1026,6 @@ int ff_pred_weight_table(H264Context *h)
}
/**
- * Initialize implicit_weight table.
- * @param field 0/1 initialize the weight for interlaced MBAFF
- * -1 initializes the rest
- */
-static void implicit_weight_table(H264Context *h, int field)
-{
- int ref0, ref1, i, cur_poc, ref_start, ref_count0, ref_count1;
-
- for (i = 0; i < 2; i++) {
- h->luma_weight_flag[i] = 0;
- h->chroma_weight_flag[i] = 0;
- }
-
- if (field < 0) {
- if (h->picture_structure == PICT_FRAME) {
- cur_poc = h->cur_pic_ptr->poc;
- } else {
- cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
- }
- if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
- h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc) {
- h->use_weight = 0;
- h->use_weight_chroma = 0;
- return;
- }
- ref_start = 0;
- ref_count0 = h->ref_count[0];
- ref_count1 = h->ref_count[1];
- } else {
- cur_poc = h->cur_pic_ptr->field_poc[field];
- ref_start = 16;
- ref_count0 = 16 + 2 * h->ref_count[0];
- ref_count1 = 16 + 2 * h->ref_count[1];
- }
-
- h->use_weight = 2;
- h->use_weight_chroma = 2;
- h->luma_log2_weight_denom = 5;
- h->chroma_log2_weight_denom = 5;
-
- for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
- int poc0 = h->ref_list[0][ref0].poc;
- for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
- int w = 32;
- if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) {
- int poc1 = h->ref_list[1][ref1].poc;
- int td = av_clip(poc1 - poc0, -128, 127);
- if (td) {
- int tb = av_clip(cur_poc - poc0, -128, 127);
- int tx = (16384 + (FFABS(td) >> 1)) / td;
- int dist_scale_factor = (tb * tx + 32) >> 8;
- if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
- w = 64 - dist_scale_factor;
- }
- }
- if (field < 0) {
- h->implicit_weight[ref0][ref1][0] =
- h->implicit_weight[ref0][ref1][1] = w;
- } else {
- h->implicit_weight[ref0][ref1][field] = w;
- }
- }
- }
-}
-
-/**
* instantaneous decoder refresh.
*/
static void idr(H264Context *h)
@@ -2766,7 +1041,7 @@ static void idr(H264Context *h)
}
/* forget old pics after a seek */
-static void flush_change(H264Context *h)
+void ff_h264_flush_change(H264Context *h)
{
int i, j;
@@ -2807,13 +1082,13 @@ static void flush_dpb(AVCodecContext *avctx)
h->delayed_pic[i] = NULL;
}
- flush_change(h);
+ ff_h264_flush_change(h);
if (h->DPB)
- for (i = 0; i < MAX_PICTURE_COUNT; i++)
- unref_picture(h, &h->DPB[i]);
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+ ff_h264_unref_picture(h, &h->DPB[i]);
h->cur_pic_ptr = NULL;
- unref_picture(h, &h->cur_pic);
+ ff_h264_unref_picture(h, &h->cur_pic);
h->mb_x = h->mb_y = 0;
@@ -2824,7 +1099,7 @@ static void flush_dpb(AVCodecContext *avctx)
h->parse_context.index = 0;
h->parse_context.last_index = 0;
- free_tables(h, 1);
+ ff_h264_free_tables(h, 1);
h->context_initialized = 0;
}
@@ -2907,128 +1182,6 @@ int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
}
/**
- * initialize scan tables
- */
-static void init_scan_tables(H264Context *h)
-{
- int i;
- for (i = 0; i < 16; i++) {
-#define T(x) (x >> 2) | ((x << 2) & 0xF)
- h->zigzag_scan[i] = T(zigzag_scan[i]);
- h->field_scan[i] = T(field_scan[i]);
-#undef T
- }
- for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
- h->zigzag_scan8x8[i] = T(ff_zigzag_direct[i]);
- h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
- h->field_scan8x8[i] = T(field_scan8x8[i]);
- h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]);
-#undef T
- }
- if (h->sps.transform_bypass) { // FIXME same ugly
- memcpy(h->zigzag_scan_q0 , zigzag_scan , sizeof(h->zigzag_scan_q0 ));
- memcpy(h->zigzag_scan8x8_q0 , ff_zigzag_direct , sizeof(h->zigzag_scan8x8_q0 ));
- memcpy(h->zigzag_scan8x8_cavlc_q0 , zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
- memcpy(h->field_scan_q0 , field_scan , sizeof(h->field_scan_q0 ));
- memcpy(h->field_scan8x8_q0 , field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
- memcpy(h->field_scan8x8_cavlc_q0 , field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
- } else {
- memcpy(h->zigzag_scan_q0 , h->zigzag_scan , sizeof(h->zigzag_scan_q0 ));
- memcpy(h->zigzag_scan8x8_q0 , h->zigzag_scan8x8 , sizeof(h->zigzag_scan8x8_q0 ));
- memcpy(h->zigzag_scan8x8_cavlc_q0 , h->zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
- memcpy(h->field_scan_q0 , h->field_scan , sizeof(h->field_scan_q0 ));
- memcpy(h->field_scan8x8_q0 , h->field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
- memcpy(h->field_scan8x8_cavlc_q0 , h->field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
- }
-}
-
-static int field_end(H264Context *h, int in_setup)
-{
- AVCodecContext *const avctx = h->avctx;
- int err = 0;
- h->mb_y = 0;
-
- if (CONFIG_H264_VDPAU_DECODER &&
- h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_h264_set_reference_frames(h);
-
- if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
- if (!h->droppable) {
- err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
- h->prev_poc_msb = h->poc_msb;
- h->prev_poc_lsb = h->poc_lsb;
- }
- h->prev_frame_num_offset = h->frame_num_offset;
- h->prev_frame_num = h->frame_num;
- h->outputed_poc = h->next_outputed_poc;
- }
-
- if (avctx->hwaccel) {
- if (avctx->hwaccel->end_frame(avctx) < 0)
- av_log(avctx, AV_LOG_ERROR,
- "hardware accelerator failed to decode picture\n");
- }
-
- if (CONFIG_H264_VDPAU_DECODER &&
- h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_h264_picture_complete(h);
-
- /*
- * FIXME: Error handling code does not seem to support interlaced
- * when slices span multiple rows
- * The ff_er_add_slice calls don't work right for bottom
- * fields; they cause massive erroneous error concealing
- * Error marking covers both fields (top and bottom).
- * This causes a mismatched s->error_count
- * and a bad error table. Further, the error count goes to
- * INT_MAX when called for bottom field, because mb_y is
- * past end by one (callers fault) and resync_mb_y != 0
- * causes problems for the first MB line, too.
- */
- if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
- h->er.cur_pic = h->cur_pic_ptr;
- ff_er_frame_end(&h->er);
- }
- if (!in_setup && !h->droppable)
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
- h->picture_structure == PICT_BOTTOM_FIELD);
- emms_c();
-
- h->current_slice = 0;
-
- return err;
-}
-
-/**
- * Replicate H264 "master" context to thread contexts.
- */
-static int clone_slice(H264Context *dst, H264Context *src)
-{
- memcpy(dst->block_offset, src->block_offset, sizeof(dst->block_offset));
- dst->cur_pic_ptr = src->cur_pic_ptr;
- dst->cur_pic = src->cur_pic;
- dst->linesize = src->linesize;
- dst->uvlinesize = src->uvlinesize;
- dst->first_field = src->first_field;
-
- dst->prev_poc_msb = src->prev_poc_msb;
- dst->prev_poc_lsb = src->prev_poc_lsb;
- dst->prev_frame_num_offset = src->prev_frame_num_offset;
- dst->prev_frame_num = src->prev_frame_num;
- dst->short_ref_count = src->short_ref_count;
-
- memcpy(dst->short_ref, src->short_ref, sizeof(dst->short_ref));
- memcpy(dst->long_ref, src->long_ref, sizeof(dst->long_ref));
- memcpy(dst->default_ref_list, src->default_ref_list, sizeof(dst->default_ref_list));
-
- memcpy(dst->dequant4_coeff, src->dequant4_coeff, sizeof(src->dequant4_coeff));
- memcpy(dst->dequant8_coeff, src->dequant8_coeff, sizeof(src->dequant8_coeff));
-
- return 0;
-}
-
-/**
* Compute profile from profile_idc and constraint_set?_flags.
*
* @param sps SPS
@@ -3055,7 +1208,7 @@ int ff_h264_get_profile(SPS *sps)
return profile;
}
-static int h264_set_parameter_from_sps(H264Context *h)
+int ff_h264_set_parameter_from_sps(H264Context *h)
{
if (h->flags & CODEC_FLAG_LOW_DELAY ||
(h->sps.bitstream_restriction_flag &&
@@ -3070,12 +1223,6 @@ static int h264_set_parameter_from_sps(H264Context *h)
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
- if (h->sps.bit_depth_luma != h->sps.bit_depth_chroma) {
- avpriv_request_sample(h->avctx,
- "Different chroma and luma bit depth");
- return AVERROR_PATCHWELCOME;
- }
-
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->avctx->codec &&
@@ -3102,7 +1249,7 @@ static int h264_set_parameter_from_sps(H264Context *h)
ff_dsputil_init(&h->dsp, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else {
- av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
+ av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
@@ -3110,238 +1257,14 @@ static int h264_set_parameter_from_sps(H264Context *h)
return 0;
}
-static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
-{
- switch (h->sps.bit_depth_luma) {
- case 9:
- if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP9;
- } else
- return AV_PIX_FMT_YUV444P9;
- } else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P9;
- else
- return AV_PIX_FMT_YUV420P9;
- break;
- case 10:
- if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP10;
- } else
- return AV_PIX_FMT_YUV444P10;
- } else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P10;
- else
- return AV_PIX_FMT_YUV420P10;
- break;
- case 12:
- if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP12;
- } else
- return AV_PIX_FMT_YUV444P12;
- } else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P12;
- else
- return AV_PIX_FMT_YUV420P12;
- break;
- case 14:
- if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP14;
- } else
- return AV_PIX_FMT_YUV444P14;
- } else if (CHROMA422(h))
- return AV_PIX_FMT_YUV422P14;
- else
- return AV_PIX_FMT_YUV420P14;
- break;
- case 8:
- if (CHROMA444(h)) {
- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
- av_log(h->avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n");
- return AV_PIX_FMT_GBR24P;
- } else if (h->avctx->colorspace == AVCOL_SPC_YCGCO) {
- av_log(h->avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
- }
- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
- : AV_PIX_FMT_YUV444P;
- } else if (CHROMA422(h)) {
- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
- : AV_PIX_FMT_YUV422P;
- } else {
- int i;
- const enum AVPixelFormat * fmt = h->avctx->codec->pix_fmts ?
- h->avctx->codec->pix_fmts :
- h->avctx->color_range == AVCOL_RANGE_JPEG ?
- h264_hwaccel_pixfmt_list_jpeg_420 :
- h264_hwaccel_pixfmt_list_420;
-
- for (i=0; fmt[i] != AV_PIX_FMT_NONE; i++)
- if (fmt[i] == h->avctx->pix_fmt && !force_callback)
- return fmt[i];
- return ff_thread_get_format(h->avctx, fmt);
- }
- break;
- default:
- av_log(h->avctx, AV_LOG_ERROR,
- "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
- return AVERROR_INVALIDDATA;
- }
-}
-
-/* export coded and cropped frame dimensions to AVCodecContext */
-static int init_dimensions(H264Context *h)
-{
- int width = h->width - (h->sps.crop_right + h->sps.crop_left);
- int height = h->height - (h->sps.crop_top + h->sps.crop_bottom);
- av_assert0(h->sps.crop_right + h->sps.crop_left < (unsigned)h->width);
- av_assert0(h->sps.crop_top + h->sps.crop_bottom < (unsigned)h->height);
-
- /* handle container cropping */
- if (!h->sps.crop &&
- FFALIGN(h->avctx->width, 16) == h->width &&
- FFALIGN(h->avctx->height, 16) == h->height) {
- width = h->avctx->width;
- height = h->avctx->height;
- }
-
- if (width <= 0 || height <= 0) {
- av_log(h->avctx, AV_LOG_ERROR, "Invalid cropped dimensions: %dx%d.\n",
- width, height);
- if (h->avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
-
- av_log(h->avctx, AV_LOG_WARNING, "Ignoring cropping information.\n");
- h->sps.crop_bottom = h->sps.crop_top = h->sps.crop_right = h->sps.crop_left = 0;
- h->sps.crop = 0;
-
- width = h->width;
- height = h->height;
- }
-
- h->avctx->coded_width = h->width;
- h->avctx->coded_height = h->height;
- h->avctx->width = width;
- h->avctx->height = height;
-
- return 0;
-}
-
-static int h264_slice_header_init(H264Context *h, int reinit)
-{
- int nb_slices = (HAVE_THREADS &&
- h->avctx->active_thread_type & FF_THREAD_SLICE) ?
- h->avctx->thread_count : 1;
- int i, ret;
-
- h->avctx->sample_aspect_ratio = h->sps.sar;
- av_assert0(h->avctx->sample_aspect_ratio.den);
- av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
- &h->chroma_x_shift, &h->chroma_y_shift);
-
- if (h->sps.timing_info_present_flag) {
- int64_t den = h->sps.time_scale;
- if (h->x264_build < 44U)
- den *= 2;
- av_reduce(&h->avctx->time_base.num, &h->avctx->time_base.den,
- h->sps.num_units_in_tick, den, 1 << 30);
- }
-
- h->avctx->hwaccel = ff_find_hwaccel(h->avctx);
-
- if (reinit)
- free_tables(h, 0);
- h->first_field = 0;
- h->prev_interlaced_frame = 1;
-
- init_scan_tables(h);
- ret = ff_h264_alloc_tables(h);
- if (ret < 0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Could not allocate memory for h264\n");
- return ret;
- }
-
- if (nb_slices > MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
- int max_slices;
- if (h->mb_height)
- max_slices = FFMIN(MAX_THREADS, h->mb_height);
- else
- max_slices = MAX_THREADS;
- av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices (%d),"
- " reducing to %d\n", nb_slices, max_slices);
- nb_slices = max_slices;
- }
- h->slice_context_count = nb_slices;
-
- if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
- ret = context_init(h);
- if (ret < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
- return ret;
- }
- } else {
- for (i = 1; i < h->slice_context_count; i++) {
- H264Context *c;
- c = h->thread_context[i] = av_mallocz(sizeof(H264Context));
- if (!c)
- return AVERROR(ENOMEM);
- c->avctx = h->avctx;
- if (CONFIG_ERROR_RESILIENCE) {
- c->dsp = h->dsp;
- }
- c->vdsp = h->vdsp;
- c->h264dsp = h->h264dsp;
- c->h264qpel = h->h264qpel;
- c->h264chroma = h->h264chroma;
- c->sps = h->sps;
- c->pps = h->pps;
- c->pixel_shift = h->pixel_shift;
- c->cur_chroma_format_idc = h->cur_chroma_format_idc;
- c->width = h->width;
- c->height = h->height;
- c->linesize = h->linesize;
- c->uvlinesize = h->uvlinesize;
- c->chroma_x_shift = h->chroma_x_shift;
- c->chroma_y_shift = h->chroma_y_shift;
- c->qscale = h->qscale;
- c->droppable = h->droppable;
- c->data_partitioning = h->data_partitioning;
- c->low_delay = h->low_delay;
- c->mb_width = h->mb_width;
- c->mb_height = h->mb_height;
- c->mb_stride = h->mb_stride;
- c->mb_num = h->mb_num;
- c->flags = h->flags;
- c->workaround_bugs = h->workaround_bugs;
- c->pict_type = h->pict_type;
-
- init_scan_tables(c);
- clone_tables(c, h, i);
- c->context_initialized = 1;
- }
-
- for (i = 0; i < h->slice_context_count; i++)
- if ((ret = context_init(h->thread_context[i])) < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
- return ret;
- }
- }
-
- h->context_initialized = 1;
-
- return 0;
-}
-
int ff_set_ref_count(H264Context *h)
{
+ int ref_count[2], list_count;
int num_ref_idx_active_override_flag;
// set defaults, might be overridden a few lines later
- h->ref_count[0] = h->pps.ref_count[0];
- h->ref_count[1] = h->pps.ref_count[1];
+ ref_count[0] = h->pps.ref_count[0];
+ ref_count[1] = h->pps.ref_count[1];
if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
unsigned max[2];
@@ -3352,1327 +1275,174 @@ int ff_set_ref_count(H264Context *h)
num_ref_idx_active_override_flag = get_bits1(&h->gb);
if (num_ref_idx_active_override_flag) {
- h->ref_count[0] = get_ue_golomb(&h->gb) + 1;
+ ref_count[0] = get_ue_golomb(&h->gb) + 1;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- h->ref_count[1] = get_ue_golomb(&h->gb) + 1;
+ ref_count[1] = get_ue_golomb(&h->gb) + 1;
} else
// full range is spec-ok in this case, even for frames
- h->ref_count[1] = 1;
+ ref_count[1] = 1;
}
- if (h->ref_count[0]-1 > max[0] || h->ref_count[1]-1 > max[1]){
- av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", h->ref_count[0]-1, max[0], h->ref_count[1]-1, max[1]);
+ if (ref_count[0]-1 > max[0] || ref_count[1]-1 > max[1]){
+ av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", ref_count[0]-1, max[0], ref_count[1]-1, max[1]);
h->ref_count[0] = h->ref_count[1] = 0;
+ h->list_count = 0;
return AVERROR_INVALIDDATA;
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->list_count = 2;
+ list_count = 2;
else
- h->list_count = 1;
+ list_count = 1;
} else {
- h->list_count = 0;
- h->ref_count[0] = h->ref_count[1] = 0;
- }
-
- return 0;
-}
-
-/**
- * Decode a slice header.
- * This will also call ff_MPV_common_init() and frame_start() as needed.
- *
- * @param h h264context
- * @param h0 h264 master context (differs from 'h' when doing sliced based
- * parallel decoding)
- *
- * @return 0 if okay, <0 if an error occurred, 1 if decoding must not be multithreaded
- */
-static int decode_slice_header(H264Context *h, H264Context *h0)
-{
- unsigned int first_mb_in_slice;
- unsigned int pps_id;
- int ret;
- unsigned int slice_type, tmp, i, j;
- int last_pic_structure, last_pic_droppable;
- int must_reinit;
- int needs_reinit = 0;
- int field_pic_flag, bottom_field_flag;
-
- h->me.qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
- h->me.qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
-
- first_mb_in_slice = get_ue_golomb_long(&h->gb);
-
- if (first_mb_in_slice == 0) { // FIXME better field boundary detection
- if (h0->current_slice && FIELD_PICTURE(h)) {
- field_end(h, 1);
- }
-
- h0->current_slice = 0;
- if (!h0->first_field) {
- if (h->cur_pic_ptr && !h->droppable) {
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
- h->picture_structure == PICT_BOTTOM_FIELD);
- }
- h->cur_pic_ptr = NULL;
- }
+ list_count = 0;
+ ref_count[0] = ref_count[1] = 0;
}
- slice_type = get_ue_golomb_31(&h->gb);
- if (slice_type > 9) {
- av_log(h->avctx, AV_LOG_ERROR,
- "slice type too large (%d) at %d %d\n",
- slice_type, h->mb_x, h->mb_y);
- return AVERROR_INVALIDDATA;
- }
- if (slice_type > 4) {
- slice_type -= 5;
- h->slice_type_fixed = 1;
- } else
- h->slice_type_fixed = 0;
-
- slice_type = golomb_to_pict_type[slice_type];
- h->slice_type = slice_type;
- h->slice_type_nos = slice_type & 3;
-
- // to make a few old functions happy, it's wrong though
- h->pict_type = h->slice_type;
-
- pps_id = get_ue_golomb(&h->gb);
- if (pps_id >= MAX_PPS_COUNT) {
- av_log(h->avctx, AV_LOG_ERROR, "pps_id %d out of range\n", pps_id);
- return AVERROR_INVALIDDATA;
- }
- if (!h0->pps_buffers[pps_id]) {
- av_log(h->avctx, AV_LOG_ERROR,
- "non-existing PPS %u referenced\n",
- pps_id);
- return AVERROR_INVALIDDATA;
- }
- h->pps = *h0->pps_buffers[pps_id];
-
- if (!h0->sps_buffers[h->pps.sps_id]) {
- av_log(h->avctx, AV_LOG_ERROR,
- "non-existing SPS %u referenced\n",
- h->pps.sps_id);
- return AVERROR_INVALIDDATA;
- }
-
- if (h->pps.sps_id != h->current_sps_id ||
- h0->sps_buffers[h->pps.sps_id]->new) {
- h0->sps_buffers[h->pps.sps_id]->new = 0;
-
- h->current_sps_id = h->pps.sps_id;
- h->sps = *h0->sps_buffers[h->pps.sps_id];
-
- if (h->mb_width != h->sps.mb_width ||
- h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) ||
- h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
- h->cur_chroma_format_idc != h->sps.chroma_format_idc
- )
- needs_reinit = 1;
-
- if (h->bit_depth_luma != h->sps.bit_depth_luma ||
- h->chroma_format_idc != h->sps.chroma_format_idc) {
- h->bit_depth_luma = h->sps.bit_depth_luma;
- h->chroma_format_idc = h->sps.chroma_format_idc;
- needs_reinit = 1;
- }
- if ((ret = h264_set_parameter_from_sps(h)) < 0)
- return ret;
- }
-
- h->avctx->profile = ff_h264_get_profile(&h->sps);
- h->avctx->level = h->sps.level_idc;
- h->avctx->refs = h->sps.ref_frame_count;
-
- must_reinit = (h->context_initialized &&
- ( 16*h->sps.mb_width != h->avctx->coded_width
- || 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
- || h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma
- || h->cur_chroma_format_idc != h->sps.chroma_format_idc
- || av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio)
- || h->mb_width != h->sps.mb_width
- || h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
- ));
- if (h0->avctx->pix_fmt != get_pixel_format(h0, 0))
- must_reinit = 1;
-
- h->mb_width = h->sps.mb_width;
- h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
- h->mb_num = h->mb_width * h->mb_height;
- h->mb_stride = h->mb_width + 1;
-
- h->b_stride = h->mb_width * 4;
-
- h->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
-
- h->width = 16 * h->mb_width;
- h->height = 16 * h->mb_height;
-
- ret = init_dimensions(h);
- if (ret < 0)
- return ret;
-
- if (h->sps.video_signal_type_present_flag) {
- h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
- : AVCOL_RANGE_MPEG;
- if (h->sps.colour_description_present_flag) {
- if (h->avctx->colorspace != h->sps.colorspace)
- needs_reinit = 1;
- h->avctx->color_primaries = h->sps.color_primaries;
- h->avctx->color_trc = h->sps.color_trc;
- h->avctx->colorspace = h->sps.colorspace;
- }
- }
-
- if (h->context_initialized &&
- (h->width != h->avctx->coded_width ||
- h->height != h->avctx->coded_height ||
- must_reinit ||
- needs_reinit)) {
- if (h != h0) {
- av_log(h->avctx, AV_LOG_ERROR, "changing width/height on "
- "slice %d\n", h0->current_slice + 1);
- return AVERROR_INVALIDDATA;
- }
-
- flush_change(h);
-
- if ((ret = get_pixel_format(h, 1)) < 0)
- return ret;
- h->avctx->pix_fmt = ret;
-
- av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
- "pix_fmt: %s\n", h->width, h->height, av_get_pix_fmt_name(h->avctx->pix_fmt));
-
- if ((ret = h264_slice_header_init(h, 1)) < 0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "h264_slice_header_init() failed\n");
- return ret;
- }
- }
- if (!h->context_initialized) {
- if (h != h0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Cannot (re-)initialize context during parallel decoding.\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if ((ret = get_pixel_format(h, 1)) < 0)
- return ret;
- h->avctx->pix_fmt = ret;
-
- if ((ret = h264_slice_header_init(h, 0)) < 0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "h264_slice_header_init() failed\n");
- return ret;
- }
- }
-
- if (h == h0 && h->dequant_coeff_pps != pps_id) {
- h->dequant_coeff_pps = pps_id;
- init_dequant_tables(h);
- }
-
- h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
-
- h->mb_mbaff = 0;
- h->mb_aff_frame = 0;
- last_pic_structure = h0->picture_structure;
- last_pic_droppable = h0->droppable;
- h->droppable = h->nal_ref_idc == 0;
- if (h->sps.frame_mbs_only_flag) {
- h->picture_structure = PICT_FRAME;
- } else {
- if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
- av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
- return -1;
- }
- field_pic_flag = get_bits1(&h->gb);
- if (field_pic_flag) {
- bottom_field_flag = get_bits1(&h->gb);
- h->picture_structure = PICT_TOP_FIELD + bottom_field_flag;
- } else {
- h->picture_structure = PICT_FRAME;
- h->mb_aff_frame = h->sps.mb_aff;
- }
- }
- h->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
-
- if (h0->current_slice != 0) {
- if (last_pic_structure != h->picture_structure ||
- last_pic_droppable != h->droppable) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Changing field mode (%d -> %d) between slices is not allowed\n",
- last_pic_structure, h->picture_structure);
- h->picture_structure = last_pic_structure;
- h->droppable = last_pic_droppable;
- return AVERROR_INVALIDDATA;
- } else if (!h0->cur_pic_ptr) {
- av_log(h->avctx, AV_LOG_ERROR,
- "unset cur_pic_ptr on %d. slice\n",
- h0->current_slice + 1);
- return AVERROR_INVALIDDATA;
- }
- } else {
- /* Shorten frame num gaps so we don't have to allocate reference
- * frames just to throw them away */
- if (h->frame_num != h->prev_frame_num) {
- int unwrap_prev_frame_num = h->prev_frame_num;
- int max_frame_num = 1 << h->sps.log2_max_frame_num;
-
- if (unwrap_prev_frame_num > h->frame_num)
- unwrap_prev_frame_num -= max_frame_num;
-
- if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
- unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
- if (unwrap_prev_frame_num < 0)
- unwrap_prev_frame_num += max_frame_num;
-
- h->prev_frame_num = unwrap_prev_frame_num;
- }
- }
-
- /* See if we have a decoded first field looking for a pair...
- * Here, we're using that to see if we should mark previously
- * decode frames as "finished".
- * We have to do that before the "dummy" in-between frame allocation,
- * since that can modify h->cur_pic_ptr. */
- if (h0->first_field) {
- assert(h0->cur_pic_ptr);
- assert(h0->cur_pic_ptr->f.buf[0]);
- assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
-
- /* Mark old field/frame as completed */
- if (h0->cur_pic_ptr->tf.owner == h0->avctx) {
- ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
- last_pic_structure == PICT_BOTTOM_FIELD);
- }
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
- /* Previous field is unmatched. Don't display it, but let it
- * remain for reference if marked as such. */
- if (last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- if (h0->cur_pic_ptr->frame_num != h->frame_num) {
- /* This and previous field were reference, but had
- * different frame_nums. Consider this field first in
- * pair. Throw away previous field except for reference
- * purposes. */
- if (last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- /* Second field in complementary pair */
- if (!((last_pic_structure == PICT_TOP_FIELD &&
- h->picture_structure == PICT_BOTTOM_FIELD) ||
- (last_pic_structure == PICT_BOTTOM_FIELD &&
- h->picture_structure == PICT_TOP_FIELD))) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Invalid field mode combination %d/%d\n",
- last_pic_structure, h->picture_structure);
- h->picture_structure = last_pic_structure;
- h->droppable = last_pic_droppable;
- return AVERROR_INVALIDDATA;
- } else if (last_pic_droppable != h->droppable) {
- avpriv_request_sample(h->avctx,
- "Found reference and non-reference fields in the same frame, which");
- h->picture_structure = last_pic_structure;
- h->droppable = last_pic_droppable;
- return AVERROR_PATCHWELCOME;
- }
- }
- }
- }
-
- while (h->frame_num != h->prev_frame_num && !h0->first_field &&
- h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
- Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
- av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
- h->frame_num, h->prev_frame_num);
- if (!h->sps.gaps_in_frame_num_allowed_flag)
- for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
- h->last_pocs[i] = INT_MIN;
- ret = h264_frame_start(h);
- if (ret < 0)
- return ret;
- h->prev_frame_num++;
- h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
- h->cur_pic_ptr->frame_num = h->prev_frame_num;
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
- ret = ff_generate_sliding_window_mmcos(h, 1);
- if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
- return ret;
- ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
- if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
- return ret;
- /* Error concealment: If a ref is missing, copy the previous ref
- * in its place.
- * FIXME: Avoiding a memcpy would be nice, but ref handling makes
- * many assumptions about there being no actual duplicates.
- * FIXME: This does not copy padding for out-of-frame motion
- * vectors. Given we are concealing a lost frame, this probably
- * is not noticeable by comparison, but it should be fixed. */
- if (h->short_ref_count) {
- if (prev) {
- av_image_copy(h->short_ref[0]->f.data,
- h->short_ref[0]->f.linesize,
- (const uint8_t **)prev->f.data,
- prev->f.linesize,
- h->avctx->pix_fmt,
- h->mb_width * 16,
- h->mb_height * 16);
- h->short_ref[0]->poc = prev->poc + 2;
- }
- h->short_ref[0]->frame_num = h->prev_frame_num;
- }
- }
-
- /* See if we have a decoded first field looking for a pair...
- * We're using that to see whether to continue decoding in that
- * frame, or to allocate a new one. */
- if (h0->first_field) {
- assert(h0->cur_pic_ptr);
- assert(h0->cur_pic_ptr->f.buf[0]);
- assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
- /* Previous field is unmatched. Don't display it, but let it
- * remain for reference if marked as such. */
- h0->cur_pic_ptr = NULL;
- h0->first_field = FIELD_PICTURE(h);
- } else {
- if (h0->cur_pic_ptr->frame_num != h->frame_num) {
- ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
- h0->picture_structure==PICT_BOTTOM_FIELD);
- /* This and the previous field had different frame_nums.
- * Consider this field first in pair. Throw away previous
- * one except for reference purposes. */
- h0->first_field = 1;
- h0->cur_pic_ptr = NULL;
- } else {
- /* Second field in complementary pair */
- h0->first_field = 0;
- }
- }
- } else {
- /* Frame or first field in a potentially complementary pair */
- h0->first_field = FIELD_PICTURE(h);
- }
-
- if (!FIELD_PICTURE(h) || h0->first_field) {
- if (h264_frame_start(h) < 0) {
- h0->first_field = 0;
- return AVERROR_INVALIDDATA;
- }
- } else {
- release_unused_pictures(h, 0);
- }
- /* Some macroblocks can be accessed before they're available in case
- * of lost slices, MBAFF or threading. */
- if (FIELD_PICTURE(h)) {
- for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
- memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
- } else {
- memset(h->slice_table, -1,
- (h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
- }
- h0->last_slice_type = -1;
- }
- if (h != h0 && (ret = clone_slice(h, h0)) < 0)
- return ret;
-
- /* can't be in alloc_tables because linesize isn't known there.
- * FIXME: redo bipred weight to not require extra buffer? */
- for (i = 0; i < h->slice_context_count; i++)
- if (h->thread_context[i]) {
- ret = alloc_scratch_buffers(h->thread_context[i], h->linesize);
- if (ret < 0)
- return ret;
- }
-
- h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
-
- av_assert1(h->mb_num == h->mb_width * h->mb_height);
- if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
- first_mb_in_slice >= h->mb_num) {
- av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
- return AVERROR_INVALIDDATA;
- }
- h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
- h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) <<
- FIELD_OR_MBAFF_PICTURE(h);
- if (h->picture_structure == PICT_BOTTOM_FIELD)
- h->resync_mb_y = h->mb_y = h->mb_y + 1;
- av_assert1(h->mb_y < h->mb_height);
-
- if (h->picture_structure == PICT_FRAME) {
- h->curr_pic_num = h->frame_num;
- h->max_pic_num = 1 << h->sps.log2_max_frame_num;
- } else {
- h->curr_pic_num = 2 * h->frame_num + 1;
- h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
- }
-
- if (h->nal_unit_type == NAL_IDR_SLICE)
- get_ue_golomb(&h->gb); /* idr_pic_id */
-
- if (h->sps.poc_type == 0) {
- h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
-
- if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
- h->delta_poc_bottom = get_se_golomb(&h->gb);
- }
-
- if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
- h->delta_poc[0] = get_se_golomb(&h->gb);
-
- if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
- h->delta_poc[1] = get_se_golomb(&h->gb);
- }
-
- ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
-
- if (h->pps.redundant_pic_cnt_present)
- h->redundant_pic_count = get_ue_golomb(&h->gb);
-
- ret = ff_set_ref_count(h);
- if (ret < 0)
- return ret;
-
- if (slice_type != AV_PICTURE_TYPE_I &&
- (h0->current_slice == 0 ||
- slice_type != h0->last_slice_type ||
- memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
-
- ff_h264_fill_default_ref_list(h);
- }
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
- ret = ff_h264_decode_ref_pic_list_reordering(h);
- if (ret < 0) {
- h->ref_count[1] = h->ref_count[0] = 0;
- return ret;
- }
- }
-
- if ((h->pps.weighted_pred && h->slice_type_nos == AV_PICTURE_TYPE_P) ||
- (h->pps.weighted_bipred_idc == 1 &&
- h->slice_type_nos == AV_PICTURE_TYPE_B))
- ff_pred_weight_table(h);
- else if (h->pps.weighted_bipred_idc == 2 &&
- h->slice_type_nos == AV_PICTURE_TYPE_B) {
- implicit_weight_table(h, -1);
- } else {
- h->use_weight = 0;
- for (i = 0; i < 2; i++) {
- h->luma_weight_flag[i] = 0;
- h->chroma_weight_flag[i] = 0;
- }
- }
-
- // If frame-mt is enabled, only update mmco tables for the first slice
- // in a field. Subsequent slices can temporarily clobber h->mmco_index
- // or h->mmco, which will cause ref list mix-ups and decoding errors
- // further down the line. This may break decoding if the first slice is
- // corrupt, thus we only do this if frame-mt is enabled.
- if (h->nal_ref_idc) {
- ret = ff_h264_decode_ref_pic_marking(h0, &h->gb,
- !(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
- h0->current_slice == 0);
- if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
- }
-
- if (FRAME_MBAFF(h)) {
- ff_h264_fill_mbaff_ref_list(h);
-
- if (h->pps.weighted_bipred_idc == 2 && h->slice_type_nos == AV_PICTURE_TYPE_B) {
- implicit_weight_table(h, 0);
- implicit_weight_table(h, 1);
- }
- }
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B && !h->direct_spatial_mv_pred)
- ff_h264_direct_dist_scale_factor(h);
- ff_h264_direct_ref_list_init(h);
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
- tmp = get_ue_golomb_31(&h->gb);
- if (tmp > 2) {
- av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
- return AVERROR_INVALIDDATA;
- }
- h->cabac_init_idc = tmp;
- }
-
- h->last_qscale_diff = 0;
- tmp = h->pps.init_qp + get_se_golomb(&h->gb);
- if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
- av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
- return AVERROR_INVALIDDATA;
- }
- h->qscale = tmp;
- h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale);
- // FIXME qscale / qp ... stuff
- if (h->slice_type == AV_PICTURE_TYPE_SP)
- get_bits1(&h->gb); /* sp_for_switch_flag */
- if (h->slice_type == AV_PICTURE_TYPE_SP ||
- h->slice_type == AV_PICTURE_TYPE_SI)
- get_se_golomb(&h->gb); /* slice_qs_delta */
-
- h->deblocking_filter = 1;
- h->slice_alpha_c0_offset = 52;
- h->slice_beta_offset = 52;
- if (h->pps.deblocking_filter_parameters_present) {
- tmp = get_ue_golomb_31(&h->gb);
- if (tmp > 2) {
- av_log(h->avctx, AV_LOG_ERROR,
- "deblocking_filter_idc %u out of range\n", tmp);
- return AVERROR_INVALIDDATA;
- }
- h->deblocking_filter = tmp;
- if (h->deblocking_filter < 2)
- h->deblocking_filter ^= 1; // 1<->0
-
- if (h->deblocking_filter) {
- h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1;
- h->slice_beta_offset += get_se_golomb(&h->gb) << 1;
- if (h->slice_alpha_c0_offset > 104U ||
- h->slice_beta_offset > 104U) {
- av_log(h->avctx, AV_LOG_ERROR,
- "deblocking filter parameters %d %d out of range\n",
- h->slice_alpha_c0_offset, h->slice_beta_offset);
- return AVERROR_INVALIDDATA;
- }
- }
- }
-
- if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
- (h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
- h->slice_type_nos != AV_PICTURE_TYPE_I) ||
- (h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
- h->slice_type_nos == AV_PICTURE_TYPE_B) ||
- (h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
- h->nal_ref_idc == 0))
- h->deblocking_filter = 0;
-
- if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
- if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
- /* Cheat slightly for speed:
- * Do not bother to deblock across slices. */
- h->deblocking_filter = 2;
- } else {
- h0->max_contexts = 1;
- if (!h0->single_decode_warning) {
- av_log(h->avctx, AV_LOG_INFO,
- "Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
- h0->single_decode_warning = 1;
- }
- if (h != h0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Deblocking switched inside frame.\n");
- return 1;
- }
- }
- }
- h->qp_thresh = 15 + 52 -
- FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
- FFMAX3(0,
- h->pps.chroma_qp_index_offset[0],
- h->pps.chroma_qp_index_offset[1]) +
- 6 * (h->sps.bit_depth_luma - 8);
-
- h0->last_slice_type = slice_type;
- memcpy(h0->last_ref_count, h0->ref_count, sizeof(h0->last_ref_count));
- h->slice_num = ++h0->current_slice;
-
- if (h->slice_num)
- h0->slice_row[(h->slice_num-1)&(MAX_SLICES-1)]= h->resync_mb_y;
- if ( h0->slice_row[h->slice_num&(MAX_SLICES-1)] + 3 >= h->resync_mb_y
- && h0->slice_row[h->slice_num&(MAX_SLICES-1)] <= h->resync_mb_y
- && h->slice_num >= MAX_SLICES) {
- //in case of ASO this check needs to be updated depending on how we decide to assign slice numbers in this case
- av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", h->slice_num, MAX_SLICES);
- }
-
- for (j = 0; j < 2; j++) {
- int id_list[16];
- int *ref2frm = h->ref2frm[h->slice_num & (MAX_SLICES - 1)][j];
- for (i = 0; i < 16; i++) {
- id_list[i] = 60;
- if (j < h->list_count && i < h->ref_count[j] &&
- h->ref_list[j][i].f.buf[0]) {
- int k;
- AVBuffer *buf = h->ref_list[j][i].f.buf[0]->buffer;
- for (k = 0; k < h->short_ref_count; k++)
- if (h->short_ref[k]->f.buf[0]->buffer == buf) {
- id_list[i] = k;
- break;
- }
- for (k = 0; k < h->long_ref_count; k++)
- if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
- id_list[i] = h->short_ref_count + k;
- break;
- }
- }
- }
-
- ref2frm[0] =
- ref2frm[1] = -1;
- for (i = 0; i < 16; i++)
- ref2frm[i + 2] = 4 * id_list[i] + (h->ref_list[j][i].reference & 3);
- ref2frm[18 + 0] =
- ref2frm[18 + 1] = -1;
- for (i = 16; i < 48; i++)
- ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
- (h->ref_list[j][i].reference & 3);
- }
-
- if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
- if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
- h->er.ref_count = h->ref_count[0];
-
- if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(h->avctx, AV_LOG_DEBUG,
- "slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
- h->slice_num,
- (h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
- first_mb_in_slice,
- av_get_picture_type_char(h->slice_type),
- h->slice_type_fixed ? " fix" : "",
- h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
- pps_id, h->frame_num,
- h->cur_pic_ptr->field_poc[0],
- h->cur_pic_ptr->field_poc[1],
- h->ref_count[0], h->ref_count[1],
- h->qscale,
- h->deblocking_filter,
- h->slice_alpha_c0_offset / 2 - 26, h->slice_beta_offset / 2 - 26,
- h->use_weight,
- h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
- h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
+ if (list_count != h->list_count ||
+ ref_count[0] != h->ref_count[0] ||
+ ref_count[1] != h->ref_count[1]) {
+ h->ref_count[0] = ref_count[0];
+ h->ref_count[1] = ref_count[1];
+ h->list_count = list_count;
+ return 1;
}
return 0;
}
-int ff_h264_get_slice_type(const H264Context *h)
-{
- switch (h->slice_type) {
- case AV_PICTURE_TYPE_P:
- return 0;
- case AV_PICTURE_TYPE_B:
- return 1;
- case AV_PICTURE_TYPE_I:
- return 2;
- case AV_PICTURE_TYPE_SP:
- return 3;
- case AV_PICTURE_TYPE_SI:
- return 4;
- default:
- return AVERROR_INVALIDDATA;
- }
-}
+static const uint8_t start_code[] = { 0x00, 0x00, 0x01 };
-static av_always_inline void fill_filter_caches_inter(H264Context *h,
- int mb_type, int top_xy,
- int left_xy[LEFT_MBS],
- int top_type,
- int left_type[LEFT_MBS],
- int mb_xy, int list)
+static int find_start_code(const uint8_t *buf, int buf_size,
+ int buf_index, int next_avc)
{
- int b_stride = h->b_stride;
- int16_t(*mv_dst)[2] = &h->mv_cache[list][scan8[0]];
- int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
- if (IS_INTER(mb_type) || IS_DIRECT(mb_type)) {
- if (USES_LIST(top_type, list)) {
- const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
- const int b8_xy = 4 * top_xy + 2;
- int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
- AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]);
- ref_cache[0 - 1 * 8] =
- ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]];
- ref_cache[2 - 1 * 8] =
- ref_cache[3 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 1]];
- } else {
- AV_ZERO128(mv_dst - 1 * 8);
- AV_WN32A(&ref_cache[0 - 1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
- }
+ // start code prefix search
+ for (; buf_index + 3 < next_avc; buf_index++)
+ // This should always succeed in the first iteration.
+ if (buf[buf_index] == 0 &&
+ buf[buf_index + 1] == 0 &&
+ buf[buf_index + 2] == 1)
+ break;
- if (!IS_INTERLACED(mb_type ^ left_type[LTOP])) {
- if (USES_LIST(left_type[LTOP], list)) {
- const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
- const int b8_xy = 4 * left_xy[LTOP] + 1;
- int (*ref2frm)[64] =(void*)( h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
- AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]);
- AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]);
- AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]);
- AV_COPY32(mv_dst - 1 + 24, h->cur_pic.motion_val[list][b_xy + b_stride * 3]);
- ref_cache[-1 + 0] =
- ref_cache[-1 + 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 0]];
- ref_cache[-1 + 16] =
- ref_cache[-1 + 24] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 1]];
- } else {
- AV_ZERO32(mv_dst - 1 + 0);
- AV_ZERO32(mv_dst - 1 + 8);
- AV_ZERO32(mv_dst - 1 + 16);
- AV_ZERO32(mv_dst - 1 + 24);
- ref_cache[-1 + 0] =
- ref_cache[-1 + 8] =
- ref_cache[-1 + 16] =
- ref_cache[-1 + 24] = LIST_NOT_USED;
- }
- }
- }
+ buf_index += 3;
- if (!USES_LIST(mb_type, list)) {
- fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0, 0), 4);
- AV_WN32A(&ref_cache[0 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
- AV_WN32A(&ref_cache[1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
- AV_WN32A(&ref_cache[2 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
- AV_WN32A(&ref_cache[3 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
- return;
- }
+ if (buf_index >= buf_size)
+ return buf_size;
- {
- int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
- int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
- uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101;
- uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101;
- AV_WN32A(&ref_cache[0 * 8], ref01);
- AV_WN32A(&ref_cache[1 * 8], ref01);
- AV_WN32A(&ref_cache[2 * 8], ref23);
- AV_WN32A(&ref_cache[3 * 8], ref23);
- }
-
- {
- int16_t(*mv_src)[2] = &h->cur_pic.motion_val[list][4 * h->mb_x + 4 * h->mb_y * b_stride];
- AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
- AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
- AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
- AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
- }
+ return buf_index;
}
-/**
- *
- * @return non zero if the loop filter can be skipped
- */
-static int fill_filter_caches(H264Context *h, int mb_type)
+static int get_avc_nalsize(H264Context *h, const uint8_t *buf,
+ int buf_size, int *buf_index)
{
- const int mb_xy = h->mb_xy;
- int top_xy, left_xy[LEFT_MBS];
- int top_type, left_type[LEFT_MBS];
- uint8_t *nnz;
- uint8_t *nnz_cache;
-
- top_xy = mb_xy - (h->mb_stride << MB_FIELD(h));
-
- /* Wow, what a mess, why didn't they simplify the interlacing & intra
- * stuff, I can't imagine that these complex rules are worth it. */
-
- left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1;
- if (FRAME_MBAFF(h)) {
- const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]);
- const int curr_mb_field_flag = IS_INTERLACED(mb_type);
- if (h->mb_y & 1) {
- if (left_mb_field_flag != curr_mb_field_flag)
- left_xy[LTOP] -= h->mb_stride;
- } else {
- if (curr_mb_field_flag)
- top_xy += h->mb_stride &
- (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
- if (left_mb_field_flag != curr_mb_field_flag)
- left_xy[LBOT] += h->mb_stride;
- }
- }
-
- h->top_mb_xy = top_xy;
- h->left_mb_xy[LTOP] = left_xy[LTOP];
- h->left_mb_xy[LBOT] = left_xy[LBOT];
- {
- /* For sufficiently low qp, filtering wouldn't do anything.
- * This is a conservative estimate: could also check beta_offset
- * and more accurate chroma_qp. */
- int qp_thresh = h->qp_thresh; // FIXME strictly we should store qp_thresh for each mb of a slice
- int qp = h->cur_pic.qscale_table[mb_xy];
- if (qp <= qp_thresh &&
- (left_xy[LTOP] < 0 ||
- ((qp + h->cur_pic.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) &&
- (top_xy < 0 ||
- ((qp + h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
- if (!FRAME_MBAFF(h))
- return 1;
- if ((left_xy[LTOP] < 0 ||
- ((qp + h->cur_pic.qscale_table[left_xy[LBOT]] + 1) >> 1) <= qp_thresh) &&
- (top_xy < h->mb_stride ||
- ((qp + h->cur_pic.qscale_table[top_xy - h->mb_stride] + 1) >> 1) <= qp_thresh))
- return 1;
- }
- }
-
- top_type = h->cur_pic.mb_type[top_xy];
- left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]];
- left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]];
- if (h->deblocking_filter == 2) {
- if (h->slice_table[top_xy] != h->slice_num)
- top_type = 0;
- if (h->slice_table[left_xy[LBOT]] != h->slice_num)
- left_type[LTOP] = left_type[LBOT] = 0;
- } else {
- if (h->slice_table[top_xy] == 0xFFFF)
- top_type = 0;
- if (h->slice_table[left_xy[LBOT]] == 0xFFFF)
- left_type[LTOP] = left_type[LBOT] = 0;
- }
- h->top_type = top_type;
- h->left_type[LTOP] = left_type[LTOP];
- h->left_type[LBOT] = left_type[LBOT];
-
- if (IS_INTRA(mb_type))
- return 0;
-
- fill_filter_caches_inter(h, mb_type, top_xy, left_xy,
- top_type, left_type, mb_xy, 0);
- if (h->list_count == 2)
- fill_filter_caches_inter(h, mb_type, top_xy, left_xy,
- top_type, left_type, mb_xy, 1);
-
- nnz = h->non_zero_count[mb_xy];
- nnz_cache = h->non_zero_count_cache;
- AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
- AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
- AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
- AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
- h->cbp = h->cbp_table[mb_xy];
-
- if (top_type) {
- nnz = h->non_zero_count[top_xy];
- AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
- }
+ int i, nalsize = 0;
- if (left_type[LTOP]) {
- nnz = h->non_zero_count[left_xy[LTOP]];
- nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
- nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
- nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
- nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
- }
-
- /* CAVLC 8x8dct requires NNZ values for residual decoding that differ
- * from what the loop filter needs */
- if (!CABAC(h) && h->pps.transform_8x8_mode) {
- if (IS_8x8DCT(top_type)) {
- nnz_cache[4 + 8 * 0] =
- nnz_cache[5 + 8 * 0] = (h->cbp_table[top_xy] & 0x4000) >> 12;
- nnz_cache[6 + 8 * 0] =
- nnz_cache[7 + 8 * 0] = (h->cbp_table[top_xy] & 0x8000) >> 12;
- }
- if (IS_8x8DCT(left_type[LTOP])) {
- nnz_cache[3 + 8 * 1] =
- nnz_cache[3 + 8 * 2] = (h->cbp_table[left_xy[LTOP]] & 0x2000) >> 12; // FIXME check MBAFF
- }
- if (IS_8x8DCT(left_type[LBOT])) {
- nnz_cache[3 + 8 * 3] =
- nnz_cache[3 + 8 * 4] = (h->cbp_table[left_xy[LBOT]] & 0x8000) >> 12; // FIXME check MBAFF
- }
-
- if (IS_8x8DCT(mb_type)) {
- nnz_cache[scan8[0]] =
- nnz_cache[scan8[1]] =
- nnz_cache[scan8[2]] =
- nnz_cache[scan8[3]] = (h->cbp & 0x1000) >> 12;
-
- nnz_cache[scan8[0 + 4]] =
- nnz_cache[scan8[1 + 4]] =
- nnz_cache[scan8[2 + 4]] =
- nnz_cache[scan8[3 + 4]] = (h->cbp & 0x2000) >> 12;
-
- nnz_cache[scan8[0 + 8]] =
- nnz_cache[scan8[1 + 8]] =
- nnz_cache[scan8[2 + 8]] =
- nnz_cache[scan8[3 + 8]] = (h->cbp & 0x4000) >> 12;
-
- nnz_cache[scan8[0 + 12]] =
- nnz_cache[scan8[1 + 12]] =
- nnz_cache[scan8[2 + 12]] =
- nnz_cache[scan8[3 + 12]] = (h->cbp & 0x8000) >> 12;
- }
- }
-
- return 0;
-}
-
-static void loop_filter(H264Context *h, int start_x, int end_x)
-{
- uint8_t *dest_y, *dest_cb, *dest_cr;
- int linesize, uvlinesize, mb_x, mb_y;
- const int end_mb_y = h->mb_y + FRAME_MBAFF(h);
- const int old_slice_type = h->slice_type;
- const int pixel_shift = h->pixel_shift;
- const int block_h = 16 >> h->chroma_y_shift;
-
- if (h->deblocking_filter) {
- for (mb_x = start_x; mb_x < end_x; mb_x++)
- for (mb_y = end_mb_y - FRAME_MBAFF(h); mb_y <= end_mb_y; mb_y++) {
- int mb_xy, mb_type;
- mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride;
- h->slice_num = h->slice_table[mb_xy];
- mb_type = h->cur_pic.mb_type[mb_xy];
- h->list_count = h->list_counts[mb_xy];
-
- if (FRAME_MBAFF(h))
- h->mb_mbaff =
- h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type);
-
- h->mb_x = mb_x;
- h->mb_y = mb_y;
- dest_y = h->cur_pic.f.data[0] +
- ((mb_x << pixel_shift) + mb_y * h->linesize) * 16;
- dest_cb = h->cur_pic.f.data[1] +
- (mb_x << pixel_shift) * (8 << CHROMA444(h)) +
- mb_y * h->uvlinesize * block_h;
- dest_cr = h->cur_pic.f.data[2] +
- (mb_x << pixel_shift) * (8 << CHROMA444(h)) +
- mb_y * h->uvlinesize * block_h;
- // FIXME simplify above
-
- if (MB_FIELD(h)) {
- linesize = h->mb_linesize = h->linesize * 2;
- uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2;
- if (mb_y & 1) { // FIXME move out of this function?
- dest_y -= h->linesize * 15;
- dest_cb -= h->uvlinesize * (block_h - 1);
- dest_cr -= h->uvlinesize * (block_h - 1);
- }
- } else {
- linesize = h->mb_linesize = h->linesize;
- uvlinesize = h->mb_uvlinesize = h->uvlinesize;
- }
- backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize,
- uvlinesize, 0);
- if (fill_filter_caches(h, mb_type))
- continue;
- h->chroma_qp[0] = get_chroma_qp(h, 0, h->cur_pic.qscale_table[mb_xy]);
- h->chroma_qp[1] = get_chroma_qp(h, 1, h->cur_pic.qscale_table[mb_xy]);
+ if (*buf_index >= buf_size - h->nal_length_size)
+ return -1;
- if (FRAME_MBAFF(h)) {
- ff_h264_filter_mb(h, mb_x, mb_y, dest_y, dest_cb, dest_cr,
- linesize, uvlinesize);
- } else {
- ff_h264_filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb,
- dest_cr, linesize, uvlinesize);
- }
- }
+ for (i = 0; i < h->nal_length_size; i++)
+ nalsize = (nalsize << 8) | buf[(*buf_index)++];
+ if (nalsize <= 0 || nalsize > buf_size - *buf_index) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "AVC: nal size %d\n", nalsize);
+ return -1;
}
- h->slice_type = old_slice_type;
- h->mb_x = end_x;
- h->mb_y = end_mb_y - FRAME_MBAFF(h);
- h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale);
+ return nalsize;
}
-static void predict_field_decoding_flag(H264Context *h)
-{
- const int mb_xy = h->mb_x + h->mb_y * h->mb_stride;
- int mb_type = (h->slice_table[mb_xy - 1] == h->slice_num) ?
- h->cur_pic.mb_type[mb_xy - 1] :
- (h->slice_table[mb_xy - h->mb_stride] == h->slice_num) ?
- h->cur_pic.mb_type[mb_xy - h->mb_stride] : 0;
- h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0;
-}
-
-/**
- * Draw edges and report progress for the last MB row.
- */
-static void decode_finish_row(H264Context *h)
+static int get_bit_length(H264Context *h, const uint8_t *buf,
+ const uint8_t *ptr, int dst_length,
+ int i, int next_avc)
{
- int top = 16 * (h->mb_y >> FIELD_PICTURE(h));
- int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h);
- int height = 16 << FRAME_MBAFF(h);
- int deblock_border = (16 + 4) << FRAME_MBAFF(h);
-
- if (h->deblocking_filter) {
- if ((top + height) >= pic_height)
- height += deblock_border;
- top -= deblock_border;
- }
-
- if (top >= pic_height || (top + height) < 0)
- return;
-
- height = FFMIN(height, pic_height - top);
- if (top < 0) {
- height = top + height;
- top = 0;
- }
-
- ff_h264_draw_horiz_band(h, top, height);
+ if ((h->workaround_bugs & FF_BUG_AUTODETECT) && i + 3 < next_avc &&
+ buf[i] == 0x00 && buf[i + 1] == 0x00 &&
+ buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
+ h->workaround_bugs |= FF_BUG_TRUNCATED;
- if (h->droppable || h->er.error_occurred)
- return;
+ if (!(h->workaround_bugs & FF_BUG_TRUNCATED))
+ while (dst_length > 0 && ptr[dst_length - 1] == 0)
+ dst_length--;
- ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1,
- h->picture_structure == PICT_BOTTOM_FIELD);
-}
-
-static void er_add_slice(H264Context *h, int startx, int starty,
- int endx, int endy, int status)
-{
- if (CONFIG_ERROR_RESILIENCE) {
- ERContext *er = &h->er;
+ if (!dst_length)
+ return 0;
- ff_er_add_slice(er, startx, starty, endx, endy, status);
- }
+ return 8 * dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1);
}
-static int decode_slice(struct AVCodecContext *avctx, void *arg)
+static int get_last_needed_nal(H264Context *h, const uint8_t *buf, int buf_size)
{
- H264Context *h = *(void **)arg;
- int lf_x_start = h->mb_x;
-
- h->mb_skip_run = -1;
-
- av_assert0(h->block_offset[15] == (4 * ((scan8[15] - scan8[0]) & 7) << h->pixel_shift) + 4 * h->linesize * ((scan8[15] - scan8[0]) >> 3));
-
- h->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
- avctx->codec_id != AV_CODEC_ID_H264 ||
- (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY));
-
- if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->er.error_status_table) {
- const int start_i = av_clip(h->resync_mb_x + h->resync_mb_y * h->mb_width, 0, h->mb_num - 1);
- if (start_i) {
- int prev_status = h->er.error_status_table[h->er.mb_index2xy[start_i - 1]];
- prev_status &= ~ VP_START;
- if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
- h->er.error_occurred = 1;
- }
- }
-
- if (h->pps.cabac) {
- /* realign */
- align_get_bits(&h->gb);
-
- /* init cabac */
- ff_init_cabac_decoder(&h->cabac,
- h->gb.buffer + get_bits_count(&h->gb) / 8,
- (get_bits_left(&h->gb) + 7) / 8);
-
- ff_h264_init_cabac_states(h);
-
- for (;;) {
- // START_TIMER
- int ret = ff_h264_decode_mb_cabac(h);
- int eos;
- // STOP_TIMER("decode_mb_cabac")
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
-
- // FIXME optimal? or let mb_decode decode 16x32 ?
- if (ret >= 0 && FRAME_MBAFF(h)) {
- h->mb_y++;
-
- ret = ff_h264_decode_mb_cabac(h);
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
- h->mb_y--;
- }
- eos = get_cabac_terminate(&h->cabac);
-
- if ((h->workaround_bugs & FF_BUG_TRUNCATED) &&
- h->cabac.bytestream > h->cabac.bytestream_end + 2) {
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
- h->mb_y, ER_MB_END);
- if (h->mb_x >= lf_x_start)
- loop_filter(h, lf_x_start, h->mb_x + 1);
- return 0;
- }
- if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
- av_log(h->avctx, AV_LOG_DEBUG, "bytestream overread %td\n", h->cabac.bytestream_end - h->cabac.bytestream);
- if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 4) {
- av_log(h->avctx, AV_LOG_ERROR,
- "error while decoding MB %d %d, bytestream (%td)\n",
- h->mb_x, h->mb_y,
- h->cabac.bytestream_end - h->cabac.bytestream);
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
- h->mb_y, ER_MB_ERROR);
- return AVERROR_INVALIDDATA;
- }
+ int next_avc = h->is_avc ? 0 : buf_size;
+ int nal_index = 0;
+ int buf_index = 0;
+ int nals_needed = 0;
+ int first_slice = 0;
- if (++h->mb_x >= h->mb_width) {
- loop_filter(h, lf_x_start, h->mb_x);
- h->mb_x = lf_x_start = 0;
- decode_finish_row(h);
- ++h->mb_y;
- if (FIELD_OR_MBAFF_PICTURE(h)) {
- ++h->mb_y;
- if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
- predict_field_decoding_flag(h);
- }
- }
+ while(1) {
+ int nalsize = 0;
+ int dst_length, bit_length, consumed;
+ const uint8_t *ptr;
- if (eos || h->mb_y >= h->mb_height) {
- tprintf(h->avctx, "slice end %d %d\n",
- get_bits_count(&h->gb), h->gb.size_in_bits);
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
- h->mb_y, ER_MB_END);
- if (h->mb_x > lf_x_start)
- loop_filter(h, lf_x_start, h->mb_x);
- return 0;
- }
+ if (buf_index >= next_avc) {
+ nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
+ if (nalsize < 0)
+ break;
+ next_avc = buf_index + nalsize;
+ } else {
+ buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
+ if (buf_index >= buf_size)
+ break;
+ if (buf_index >= next_avc)
+ continue;
}
- } else {
- for (;;) {
- int ret = ff_h264_decode_mb_cavlc(h);
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
-
- // FIXME optimal? or let mb_decode decode 16x32 ?
- if (ret >= 0 && FRAME_MBAFF(h)) {
- h->mb_y++;
- ret = ff_h264_decode_mb_cavlc(h);
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
- h->mb_y--;
- }
-
- if (ret < 0) {
- av_log(h->avctx, AV_LOG_ERROR,
- "error while decoding MB %d %d\n", h->mb_x, h->mb_y);
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
- h->mb_y, ER_MB_ERROR);
- return ret;
- }
-
- if (++h->mb_x >= h->mb_width) {
- loop_filter(h, lf_x_start, h->mb_x);
- h->mb_x = lf_x_start = 0;
- decode_finish_row(h);
- ++h->mb_y;
- if (FIELD_OR_MBAFF_PICTURE(h)) {
- ++h->mb_y;
- if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
- predict_field_decoding_flag(h);
- }
- if (h->mb_y >= h->mb_height) {
- tprintf(h->avctx, "slice end %d %d\n",
- get_bits_count(&h->gb), h->gb.size_in_bits);
-
- if ( get_bits_left(&h->gb) == 0
- || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
- h->mb_x - 1, h->mb_y,
- ER_MB_END);
-
- return 0;
- } else {
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
- h->mb_x, h->mb_y,
- ER_MB_END);
-
- return AVERROR_INVALIDDATA;
- }
- }
- }
-
- if (get_bits_left(&h->gb) <= 0 && h->mb_skip_run <= 0) {
- tprintf(h->avctx, "slice end %d %d\n",
- get_bits_count(&h->gb), h->gb.size_in_bits);
- if (get_bits_left(&h->gb) == 0) {
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
- h->mb_x - 1, h->mb_y,
- ER_MB_END);
- if (h->mb_x > lf_x_start)
- loop_filter(h, lf_x_start, h->mb_x);
+ ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length, &consumed,
+ next_avc - buf_index);
- return 0;
- } else {
- er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
- h->mb_y, ER_MB_ERROR);
+ if (ptr == NULL || dst_length < 0)
+ return AVERROR_INVALIDDATA;
- return AVERROR_INVALIDDATA;
- }
- }
- }
- }
-}
+ buf_index += consumed;
-/**
- * Call decode_slice() for each context.
- *
- * @param h h264 master context
- * @param context_count number of contexts to execute
- */
-static int execute_decode_slices(H264Context *h, int context_count)
-{
- AVCodecContext *const avctx = h->avctx;
- H264Context *hx;
- int i;
+ bit_length = get_bit_length(h, buf, ptr, dst_length,
+ buf_index, next_avc);
+ nal_index++;
- if (h->avctx->hwaccel ||
- h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- return 0;
- if (context_count == 1) {
- return decode_slice(avctx, &h);
- } else {
- av_assert0(context_count > 0);
- for (i = 1; i < context_count; i++) {
- hx = h->thread_context[i];
- if (CONFIG_ERROR_RESILIENCE) {
- hx->er.error_count = 0;
- }
- hx->x264_build = h->x264_build;
- }
-
- avctx->execute(avctx, decode_slice, h->thread_context,
- NULL, context_count, sizeof(void *));
-
- /* pull back stuff from slices to master context */
- hx = h->thread_context[context_count - 1];
- h->mb_x = hx->mb_x;
- h->mb_y = hx->mb_y;
- h->droppable = hx->droppable;
- h->picture_structure = hx->picture_structure;
- if (CONFIG_ERROR_RESILIENCE) {
- for (i = 1; i < context_count; i++)
- h->er.error_count += h->thread_context[i]->er.error_count;
+ /* packets can sometimes contain multiple PPS/SPS,
+ * e.g. two PAFF field pictures in one packet, or a demuxer
+ * which splits NALs strangely if so, when frame threading we
+ * can't start the next thread until we've read all of them */
+ switch (h->nal_unit_type) {
+ case NAL_SPS:
+ case NAL_PPS:
+ nals_needed = nal_index;
+ break;
+ case NAL_DPA:
+ case NAL_IDR_SLICE:
+ case NAL_SLICE:
+ init_get_bits(&h->gb, ptr, bit_length);
+ if (!get_ue_golomb(&h->gb) ||
+ !first_slice ||
+ first_slice != h->nal_unit_type)
+ nals_needed = nal_index;
+ if (!first_slice)
+ first_slice = h->nal_unit_type;
}
}
- return 0;
+ return nals_needed;
}
-static const uint8_t start_code[] = { 0x00, 0x00, 0x01 };
-
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
int parse_extradata)
{
AVCodecContext *const avctx = h->avctx;
H264Context *hx; ///< thread context
int buf_index;
- int context_count;
+ unsigned context_count;
int next_avc;
- int pass = !(avctx->active_thread_type & FF_THREAD_FRAME);
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
int nal_index;
int idr_cleared=0;
- int first_slice = 0;
int ret = 0;
h->nal_unit_type= 0;
@@ -4694,7 +1464,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
h->is_avc = 1;
}
- for (; pass <= 1; pass++) {
+ if (avctx->active_thread_type & FF_THREAD_FRAME)
+ nals_needed = get_last_needed_nal(h, buf, buf_size);
+
+ {
buf_index = 0;
context_count = 0;
next_avc = h->is_avc ? 0 : buf_size;
@@ -4704,36 +1477,18 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
int dst_length;
int bit_length;
const uint8_t *ptr;
- int i, nalsize = 0;
+ int nalsize = 0;
int err;
if (buf_index >= next_avc) {
- if (buf_index >= buf_size - h->nal_length_size)
+ nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
+ if (nalsize < 0)
break;
- nalsize = 0;
- for (i = 0; i < h->nal_length_size; i++)
- nalsize = (nalsize << 8) | buf[buf_index++];
- if (nalsize <= 0 || nalsize > buf_size - buf_index) {
- av_log(h->avctx, AV_LOG_ERROR,
- "AVC: nal size %d\n", nalsize);
- break;
- }
next_avc = buf_index + nalsize;
} else {
- // start code prefix search
- for (; buf_index + 3 < next_avc; buf_index++)
- // This should always succeed in the first iteration.
- if (buf[buf_index] == 0 &&
- buf[buf_index + 1] == 0 &&
- buf[buf_index + 2] == 1)
- break;
-
- if (buf_index + 3 >= buf_size) {
- buf_index = buf_size;
+ buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
+ if (buf_index >= buf_size)
break;
- }
-
- buf_index += 3;
if (buf_index >= next_avc)
continue;
}
@@ -4746,23 +1501,14 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
ret = -1;
goto end;
}
- i = buf_index + consumed;
- if ((h->workaround_bugs & FF_BUG_AUTODETECT) && i + 3 < next_avc &&
- buf[i] == 0x00 && buf[i + 1] == 0x00 &&
- buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
- h->workaround_bugs |= FF_BUG_TRUNCATED;
-
- if (!(h->workaround_bugs & FF_BUG_TRUNCATED))
- while (dst_length > 0 && ptr[dst_length - 1] == 0)
- dst_length--;
- bit_length = !dst_length ? 0
- : (8 * dst_length -
- decode_rbsp_trailing(h, ptr + dst_length - 1));
+
+ bit_length = get_bit_length(h, buf, ptr, dst_length,
+ buf_index + consumed, next_avc);
if (h->avctx->debug & FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG,
- "NAL %d/%d at %d/%d length %d pass %d\n",
- hx->nal_unit_type, hx->nal_ref_idc, buf_index, buf_size, dst_length, pass);
+ "NAL %d/%d at %d/%d length %d\n",
+ hx->nal_unit_type, hx->nal_ref_idc, buf_index, buf_size, dst_length);
if (h->is_avc && (nalsize != consumed) && nalsize)
av_log(h->avctx, AV_LOG_DEBUG,
@@ -4772,42 +1518,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
buf_index += consumed;
nal_index++;
- if (pass == 0) {
- /* packets can sometimes contain multiple PPS/SPS,
- * e.g. two PAFF field pictures in one packet, or a demuxer
- * which splits NALs strangely if so, when frame threading we
- * can't start the next thread until we've read all of them */
- switch (hx->nal_unit_type) {
- case NAL_SPS:
- case NAL_PPS:
- nals_needed = nal_index;
- break;
- case NAL_DPA:
- case NAL_IDR_SLICE:
- case NAL_SLICE:
- init_get_bits(&hx->gb, ptr, bit_length);
- if (!get_ue_golomb(&hx->gb) || !first_slice)
- nals_needed = nal_index;
- if (!first_slice)
- first_slice = hx->nal_unit_type;
- }
- continue;
- }
-
- if (!first_slice)
- switch (hx->nal_unit_type) {
- case NAL_DPA:
- case NAL_IDR_SLICE:
- case NAL_SLICE:
- first_slice = hx->nal_unit_type;
- }
-
if (avctx->skip_frame >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0 &&
h->nal_unit_type != NAL_SEI)
continue;
again:
+ if ( !(avctx->active_thread_type & FF_THREAD_FRAME)
+ || nals_needed >= nal_index)
+ h->au_pps_id = -1;
/* Ignore per frame NAL unit type during extradata
* parsing. Decoding slices is not possible in codec init
* with frame-mt */
@@ -4831,7 +1550,7 @@ again:
switch (hx->nal_unit_type) {
case NAL_IDR_SLICE:
- if (first_slice != NAL_IDR_SLICE) {
+ if (h->nal_unit_type != NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
@@ -4846,7 +1565,7 @@ again:
hx->inter_gb_ptr = &hx->gb;
hx->data_partitioning = 0;
- if ((err = decode_slice_header(hx, h)))
+ if ((err = ff_h264_decode_slice_header(hx, h)))
break;
if (h->sei_recovery_frame_cnt >= 0) {
@@ -4922,12 +1641,24 @@ again:
}
break;
case NAL_DPA:
+ if (h->avctx->flags & CODEC_FLAG2_CHUNKS) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Decoding in chunks is not supported for "
+ "partitioned slices.\n");
+ return AVERROR(ENOSYS);
+ }
+
init_get_bits(&hx->gb, ptr, bit_length);
hx->intra_gb_ptr =
hx->inter_gb_ptr = NULL;
- if ((err = decode_slice_header(hx, h)) < 0)
+ if ((err = ff_h264_decode_slice_header(hx, h)) < 0) {
+ /* make sure data_partitioning is cleared if it was set
+ * before, so we don't try decoding a slice without a valid
+ * slice header later */
+ h->data_partitioning = 0;
break;
+ }
hx->data_partitioning = 1;
break;
@@ -4992,13 +1723,14 @@ again:
}
if (context_count == h->max_contexts) {
- execute_decode_slices(h, context_count);
+ ff_h264_execute_decode_slices(h, context_count);
context_count = 0;
}
- if (err < 0)
+ if (err < 0) {
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
- else if (err == 1) {
+ h->ref_count[0] = h->ref_count[1] = h->list_count = 0;
+ } else if (err == 1) {
/* Slice could not be decoded in parallel mode, copy down
* NAL unit stuff to context 0 and restart. Note that
* rbsp_buffer is not transferred, but since we no longer
@@ -5011,7 +1743,7 @@ again:
}
}
if (context_count)
- execute_decode_slices(h, context_count);
+ ff_h264_execute_decode_slices(h, context_count);
end:
/* clean up */
@@ -5036,9 +1768,10 @@ static int get_consumed_bytes(int pos, int buf_size)
return pos;
}
-static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
+static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
{
AVFrame *src = &srcp->f;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format);
int i;
int ret = av_frame_ref(dst, src);
if (ret < 0)
@@ -5046,12 +1779,14 @@ static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0);
+ if (srcp->sei_recovery_frame_cnt == 0)
+ dst->key_frame = 1;
if (!srcp->crop)
return 0;
- for (i = 0; i < 3; i++) {
- int hshift = (i > 0) ? h->chroma_x_shift : 0;
- int vshift = (i > 0) ? h->chroma_y_shift : 0;
+ for (i = 0; i < desc->nb_components; i++) {
+ int hshift = (i > 0) ? desc->log2_chroma_w : 0;
+ int vshift = (i > 0) ? desc->log2_chroma_h : 0;
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
(srcp->crop_top >> vshift) * dst->linesize[i];
dst->data[i] += off;
@@ -5059,19 +1794,22 @@ static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
return 0;
}
-static int decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *avpkt)
+static int h264_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
- Picture *out;
+ H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
+ /* reset data partitioning here, to ensure GetBitContexts from previous
+ * packets do not get used. */
+ h->data_partitioning = 0;
/* end of stream, output what is still in the buffers */
if (buf_size == 0) {
@@ -5151,7 +1889,7 @@ not_extra:
if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
- field_end(h, 0);
+ ff_h264_field_end(h, 0);
/* Wait for second field. */
*got_frame = 0;
@@ -5165,7 +1903,10 @@ not_extra:
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
- ff_print_debug_info2(h->avctx, h->next_output_pic, pict, h->er.mbskip_table,
+ ff_print_debug_info2(h->avctx, pict, h->er.mbskip_table,
+ h->next_output_pic->mb_type,
+ h->next_output_pic->qscale_table,
+ h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
@@ -5181,7 +1922,7 @@ av_cold void ff_h264_free_context(H264Context *h)
{
int i;
- free_tables(h, 1); // FIXME cleanup init stuff perhaps
+ ff_h264_free_tables(h, 1); // FIXME cleanup init stuff perhaps
for (i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
@@ -5197,7 +1938,7 @@ static av_cold int h264_decode_end(AVCodecContext *avctx)
ff_h264_remove_all_refs(h);
ff_h264_free_context(h);
- unref_picture(h, &h->cur_pic);
+ ff_h264_unref_picture(h, &h->cur_pic);
return 0;
}
@@ -5247,13 +1988,13 @@ AVCodec ff_h264_decoder = {
.priv_data_size = sizeof(H264Context),
.init = ff_h264_decode_init,
.close = h264_decode_end,
- .decode = decode_frame,
+ .decode = h264_decode_frame,
.capabilities = /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 |
CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS |
CODEC_CAP_FRAME_THREADS,
.flush = flush_dpb,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(decode_update_thread_context),
+ .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
.profiles = NULL_IF_CONFIG_SMALL(profiles),
.priv_class = &h264_class,
};
@@ -5267,7 +2008,7 @@ AVCodec ff_h264_vdpau_decoder = {
.priv_data_size = sizeof(H264Context),
.init = ff_h264_decode_init,
.close = h264_decode_end,
- .decode = decode_frame,
+ .decode = h264_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
.flush = flush_dpb,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VDPAU_H264,
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264.h b/chromium/third_party/ffmpeg/libavcodec/h264.h
index b7e1214a762..76f111ba789 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264.h
@@ -30,14 +30,20 @@
#include "libavutil/intreadwrite.h"
#include "cabac.h"
+#include "dsputil.h"
#include "error_resilience.h"
#include "get_bits.h"
-#include "mpegvideo.h"
#include "h264chroma.h"
#include "h264dsp.h"
#include "h264pred.h"
#include "h264qpel.h"
+#include "mpegutils.h"
+#include "parser.h"
#include "rectangle.h"
+#include "videodsp.h"
+
+#define H264_MAX_PICTURE_COUNT 36
+#define H264_MAX_THREADS 32
#define MAX_SPS_COUNT 32
#define MAX_PPS_COUNT 256
@@ -102,19 +108,19 @@
/* NAL unit types */
enum {
- NAL_SLICE = 1,
- NAL_DPA,
- NAL_DPB,
- NAL_DPC,
- NAL_IDR_SLICE,
- NAL_SEI,
- NAL_SPS,
- NAL_PPS,
- NAL_AUD,
- NAL_END_SEQUENCE,
- NAL_END_STREAM,
- NAL_FILLER_DATA,
- NAL_SPS_EXT,
+ NAL_SLICE = 1,
+ NAL_DPA = 2,
+ NAL_DPB = 3,
+ NAL_DPC = 4,
+ NAL_IDR_SLICE = 5,
+ NAL_SEI = 6,
+ NAL_SPS = 7,
+ NAL_PPS = 8,
+ NAL_AUD = 9,
+ NAL_END_SEQUENCE = 10,
+ NAL_END_STREAM = 11,
+ NAL_FILLER_DATA = 12,
+ NAL_SPS_EXT = 13,
NAL_AUXILIARY_SLICE = 19,
NAL_FF_IGNORE = 0xff0f001,
};
@@ -123,7 +129,7 @@ enum {
* SEI message types
*/
typedef enum {
- SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
+ SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
SEI_TYPE_PIC_TIMING = 1, ///< picture timing
SEI_TYPE_USER_DATA_ITU_T_T35 = 4, ///< user data registered by ITU-T Recommendation T.35
SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
@@ -163,6 +169,7 @@ typedef enum {
* Sequence parameter set
*/
typedef struct SPS {
+ unsigned int sps_id;
int profile_idc;
int level_idc;
int chroma_format_idc;
@@ -280,6 +287,50 @@ typedef struct MMCO {
int long_arg; ///< index, pic_num, or num long refs depending on opcode
} MMCO;
+typedef struct H264Picture {
+ struct AVFrame f;
+ uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
+ ThreadFrame tf;
+
+ AVBufferRef *qscale_table_buf;
+ int8_t *qscale_table;
+
+ AVBufferRef *motion_val_buf[2];
+ int16_t (*motion_val[2])[2];
+
+ AVBufferRef *mb_type_buf;
+ uint32_t *mb_type;
+
+ AVBufferRef *hwaccel_priv_buf;
+ void *hwaccel_picture_private; ///< hardware accelerator private data
+
+ AVBufferRef *ref_index_buf[2];
+ int8_t *ref_index[2];
+
+ int field_poc[2]; ///< top/bottom POC
+ int poc; ///< frame POC
+ int frame_num; ///< frame_num (raw frame_num from slice header)
+ int mmco_reset; /**< MMCO_RESET set this 1. Reordering code must
+ not mix pictures before and after MMCO_RESET. */
+ int pic_id; /**< pic_num (short -> no wrap version of pic_num,
+ pic_num & max_pic_num; long -> long_pic_num) */
+ int long_ref; ///< 1->long term reference 0->short term reference
+ int ref_poc[2][2][32]; ///< POCs of the frames/fields used as reference (FIXME need per slice)
+ int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice)
+ int mbaff; ///< 1 -> MBAFF frame 0-> not MBAFF
+ int field_picture; ///< whether or not picture was encoded in separate fields
+
+ int needs_realloc; ///< picture needs to be reallocated (eg due to a frame size change)
+ int reference;
+ int recovered; ///< picture at IDR or recovery point + recovery count
+ int invalid_gap;
+ int sei_recovery_frame_cnt;
+
+ int crop;
+ int crop_left;
+ int crop_top;
+} H264Picture;
+
/**
* H264Context
*/
@@ -289,15 +340,14 @@ typedef struct H264Context {
H264DSPContext h264dsp;
H264ChromaContext h264chroma;
H264QpelContext h264qpel;
- MotionEstContext me;
ParseContext parse_context;
GetBitContext gb;
DSPContext dsp;
ERContext er;
- Picture *DPB;
- Picture *cur_pic_ptr;
- Picture cur_pic;
+ H264Picture *DPB;
+ H264Picture *cur_pic_ptr;
+ H264Picture cur_pic;
int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
int chroma_qp[2]; // QPc
@@ -384,11 +434,9 @@ typedef struct H264Context {
unsigned current_sps_id; ///< id of the current SPS
SPS sps; ///< current sps
+ PPS pps; ///< current pps
- /**
- * current pps
- */
- PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
+ int au_pps_id; ///< pps_id of current access unit
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down?
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
@@ -434,7 +482,7 @@ typedef struct H264Context {
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type
- Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
+ H264Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
@@ -549,12 +597,12 @@ typedef struct H264Context {
int redundant_pic_count;
- Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture
- Picture *short_ref[32];
- Picture *long_ref[32];
- Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size?
+ H264Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture
+ H264Picture *short_ref[32];
+ H264Picture *long_ref[32];
+ H264Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size?
int last_pocs[MAX_DELAYED_PIC_COUNT];
- Picture *next_output_pic;
+ H264Picture *next_output_pic;
int outputed_poc;
int next_outputed_poc;
@@ -574,7 +622,7 @@ typedef struct H264Context {
* @name Members for slice based multithreading
* @{
*/
- struct H264Context *thread_context[MAX_THREADS];
+ struct H264Context *thread_context[H264_MAX_THREADS];
/**
* current slice number, used to initialize slice_num of each thread/context
@@ -617,6 +665,14 @@ typedef struct H264Context {
int prev_interlaced_frame;
/**
+ * frame_packing_arrangment SEI message
+ */
+ int sei_frame_packing_present;
+ int frame_packing_arrangement_type;
+ int content_interpretation_type;
+ int quincunx_subsampling;
+
+ /**
* Bit set of clock types for fields/frames in picture timing SEI message.
* For each found ct_type, appropriate bit is set (e.g., bit 1 for
* interlaced).
@@ -688,12 +744,14 @@ typedef struct H264Context {
uint8_t *edge_emu_buffer;
int16_t *dc_val_base;
- uint8_t *visualization_buffer[3]; ///< temporary buffer vor MV visualization
-
AVBufferPool *qscale_table_pool;
AVBufferPool *mb_type_pool;
AVBufferPool *motion_val_pool;
AVBufferPool *ref_index_pool;
+
+ /* Motion Estimation */
+ qpel_mc_func (*qpel_put)[16];
+ qpel_mc_func (*qpel_avg)[16];
} H264Context;
extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14).
@@ -797,6 +855,8 @@ int ff_h264_decode_mb_cabac(H264Context *h);
void ff_h264_init_cabac_states(H264Context *h);
+void h264_init_dequant_tables(H264Context *h);
+
void ff_h264_direct_dist_scale_factor(H264Context *const h);
void ff_h264_direct_ref_list_init(H264Context *const h);
void ff_h264_pred_direct_motion(H264Context *const h, int *mb_type);
@@ -1021,9 +1081,28 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h)
0x0001000100010001ULL));
}
+int ff_h264_field_end(H264Context *h, int in_setup);
+
+int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
+void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
+
+int ff_h264_context_init(H264Context *h);
+int ff_h264_set_parameter_from_sps(H264Context *h);
+
void ff_h264_draw_horiz_band(H264Context *h, int y, int height);
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc);
int ff_pred_weight_table(H264Context *h);
int ff_set_ref_count(H264Context *h);
+int ff_h264_decode_slice_header(H264Context *h, H264Context *h0);
+int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count);
+int ff_h264_update_thread_context(AVCodecContext *dst,
+ const AVCodecContext *src);
+
+void ff_h264_flush_change(H264Context *h);
+
+void ff_h264_free_tables(H264Context *h, int free_rbsp);
+
+void ff_h264_set_erpic(ERPicture *dst, H264Picture *src);
+
#endif /* AVCODEC_H264_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_cabac.c b/chromium/third_party/ffmpeg/libavcodec/h264_cabac.c
index d092ba69617..938b94770bd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_cabac.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_cabac.c
@@ -28,6 +28,8 @@
#define CABAC(h) 1
#include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
+#include "libavutil/timer.h"
#include "config.h"
#include "cabac.h"
#include "cabac_functions.h"
@@ -37,7 +39,7 @@
#include "h264data.h"
#include "h264_mvpred.h"
#include "golomb.h"
-#include "libavutil/avassert.h"
+#include "mpegutils.h"
#if ARCH_X86
#include "x86/h264_i386.h"
@@ -1618,6 +1620,9 @@ decode_cabac_residual_internal(H264Context *h, int16_t *block,
cc.range = h->cabac.range;
cc.low = h->cabac.low;
cc.bytestream= h->cabac.bytestream;
+#if !UNCHECKED_BITSTREAM_READER || ARCH_AARCH64
+ cc.bytestream_end = h->cabac.bytestream_end;
+#endif
#else
#define CC &h->cabac
#endif
@@ -2188,7 +2193,7 @@ decode_intra_mb:
}
}else
ref=0;
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
+ fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}
}
for(list=0; list<h->list_count; list++){
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_cavlc.c b/chromium/third_party/ffmpeg/libavcodec/h264_cavlc.c
index 87ae17c69d4..bc502484732 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_cavlc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_cavlc.c
@@ -29,11 +29,11 @@
#include "internal.h"
#include "avcodec.h"
-#include "mpegvideo.h"
#include "h264.h"
#include "h264data.h" // FIXME FIXME FIXME
#include "h264_mvpred.h"
#include "golomb.h"
+#include "mpegutils.h"
#include "libavutil/avassert.h"
@@ -615,17 +615,17 @@ static int decode_residual(H264Context *h, GetBitContext *gb, int16_t *block, in
} \
}
- if(zeros_left<0){
- av_log(h->avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", h->mb_x, h->mb_y);
- return -1;
- }
-
if (h->pixel_shift) {
STORE_BLOCK(int32_t)
} else {
STORE_BLOCK(int16_t)
}
+ if(zeros_left<0){
+ av_log(h->avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", h->mb_x, h->mb_y);
+ return -1;
+ }
+
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_direct.c b/chromium/third_party/ffmpeg/libavcodec/h264_direct.c
index 477359c8fff..3cc5f857151 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_direct.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_direct.c
@@ -27,8 +27,8 @@
#include "internal.h"
#include "avcodec.h"
-#include "mpegvideo.h"
#include "h264.h"
+#include "mpegutils.h"
#include "rectangle.h"
#include "thread.h"
@@ -67,7 +67,7 @@ void ff_h264_direct_dist_scale_factor(H264Context * const h){
}
static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){
- Picture * const ref1 = &h->ref_list[1][0];
+ H264Picture * const ref1 = &h->ref_list[1][0];
int j, old_ref, rfield;
int start= mbafi ? 16 : 0;
int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0];
@@ -100,8 +100,8 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field,
}
void ff_h264_direct_ref_list_init(H264Context * const h){
- Picture * const ref1 = &h->ref_list[1][0];
- Picture * const cur = h->cur_pic_ptr;
+ H264Picture * const ref1 = &h->ref_list[1][0];
+ H264Picture * const cur = h->cur_pic_ptr;
int list, j, field;
int sidx= (h->picture_structure&1)^1;
int ref1sidx = (ref1->reference&1)^1;
@@ -140,7 +140,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){
}
}
-static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y)
+static void await_reference_mb_row(H264Context * const h, H264Picture *ref, int mb_y)
{
int ref_field = ref->reference - 1;
int ref_field_picture = ref->field_picture;
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_loopfilter.c b/chromium/third_party/ffmpeg/libavcodec/h264_loopfilter.c
index 475070ae1b3..8c052c3e210 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_loopfilter.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_loopfilter.c
@@ -29,9 +29,9 @@
#include "libavutil/intreadwrite.h"
#include "internal.h"
#include "avcodec.h"
-#include "mpegvideo.h"
#include "h264.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "rectangle.h"
/* Deblocking filter (p153) */
@@ -250,8 +250,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int top_type= h->top_type;
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
- int a = h->slice_alpha_c0_offset - qp_bd_offset;
- int b = h->slice_beta_offset - qp_bd_offset;
+ int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
+ int b = 52 + h->slice_beta_offset - qp_bd_offset;
int mb_type = h->cur_pic.mb_type[mb_xy];
int qp = h->cur_pic.qscale_table[mb_xy];
@@ -709,8 +709,8 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
av_unused int dir;
int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
- int a = h->slice_alpha_c0_offset - qp_bd_offset;
- int b = h->slice_beta_offset - qp_bd_offset;
+ int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
+ int b = 52 + h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_mb.c b/chromium/third_party/ffmpeg/libavcodec/h264_mb.c
new file mode 100644
index 00000000000..ff902beef46
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_mb.c
@@ -0,0 +1,820 @@
+/*
+ * H.26L/H.264/AVC/JVT/14496-10/... decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * H.264 / AVC / MPEG4 part10 macroblock decoding
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "h264.h"
+#include "svq3.h"
+#include "thread.h"
+
+static inline int get_lowest_part_list_y(H264Context *h, H264Picture *pic, int n,
+ int height, int y_offset, int list)
+{
+ int raw_my = h->mv_cache[list][scan8[n]][1];
+ int filter_height_down = (raw_my & 3) ? 3 : 0;
+ int full_my = (raw_my >> 2) + y_offset;
+ int bottom = full_my + filter_height_down + height;
+
+ av_assert2(height >= 0);
+
+ return FFMAX(0, bottom);
+}
+
+static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n,
+ int height, int y_offset, int list0,
+ int list1, int *nrefs)
+{
+ int my;
+
+ y_offset += 16 * (h->mb_y >> MB_FIELD(h));
+
+ if (list0) {
+ int ref_n = h->ref_cache[0][scan8[n]];
+ H264Picture *ref = &h->ref_list[0][ref_n];
+
+ // Error resilience puts the current picture in the ref list.
+ // Don't try to wait on these as it will cause a deadlock.
+ // Fields can wait on each other, though.
+ if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
+ (ref->reference & 3) != h->picture_structure) {
+ my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0);
+ if (refs[0][ref_n] < 0)
+ nrefs[0] += 1;
+ refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
+ }
+ }
+
+ if (list1) {
+ int ref_n = h->ref_cache[1][scan8[n]];
+ H264Picture *ref = &h->ref_list[1][ref_n];
+
+ if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
+ (ref->reference & 3) != h->picture_structure) {
+ my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1);
+ if (refs[1][ref_n] < 0)
+ nrefs[1] += 1;
+ refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
+ }
+ }
+}
+
+/**
+ * Wait until all reference frames are available for MC operations.
+ *
+ * @param h the H264 context
+ */
+static void await_references(H264Context *h)
+{
+ const int mb_xy = h->mb_xy;
+ const int mb_type = h->cur_pic.mb_type[mb_xy];
+ int refs[2][48];
+ int nrefs[2] = { 0 };
+ int ref, list;
+
+ memset(refs, -1, sizeof(refs));
+
+ if (IS_16X16(mb_type)) {
+ get_lowest_part_y(h, refs, 0, 16, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ } else if (IS_16X8(mb_type)) {
+ get_lowest_part_y(h, refs, 0, 8, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, 8, 8, 8,
+ IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
+ } else if (IS_8X16(mb_type)) {
+ get_lowest_part_y(h, refs, 0, 16, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, 4, 16, 0,
+ IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
+ } else {
+ int i;
+
+ av_assert2(IS_8X8(mb_type));
+
+ for (i = 0; i < 4; i++) {
+ const int sub_mb_type = h->sub_mb_type[i];
+ const int n = 4 * i;
+ int y_offset = (i & 2) << 2;
+
+ if (IS_SUB_8X8(sub_mb_type)) {
+ get_lowest_part_y(h, refs, n, 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ } else if (IS_SUB_8X4(sub_mb_type)) {
+ get_lowest_part_y(h, refs, n, 4, y_offset,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ get_lowest_part_y(h, refs, n + 2, 4, y_offset + 4,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ } else if (IS_SUB_4X8(sub_mb_type)) {
+ get_lowest_part_y(h, refs, n, 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ get_lowest_part_y(h, refs, n + 1, 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ } else {
+ int j;
+ av_assert2(IS_SUB_4X4(sub_mb_type));
+ for (j = 0; j < 4; j++) {
+ int sub_y_offset = y_offset + 2 * (j & 2);
+ get_lowest_part_y(h, refs, n + j, 4, sub_y_offset,
+ IS_DIR(sub_mb_type, 0, 0),
+ IS_DIR(sub_mb_type, 0, 1),
+ nrefs);
+ }
+ }
+ }
+ }
+
+ for (list = h->list_count - 1; list >= 0; list--)
+ for (ref = 0; ref < 48 && nrefs[list]; ref++) {
+ int row = refs[list][ref];
+ if (row >= 0) {
+ H264Picture *ref_pic = &h->ref_list[list][ref];
+ int ref_field = ref_pic->reference - 1;
+ int ref_field_picture = ref_pic->field_picture;
+ int pic_height = 16 * h->mb_height >> ref_field_picture;
+
+ row <<= MB_MBAFF(h);
+ nrefs[list]--;
+
+ if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields
+ ff_thread_await_progress(&ref_pic->tf,
+ FFMIN((row >> 1) - !(row & 1),
+ pic_height - 1),
+ 1);
+ ff_thread_await_progress(&ref_pic->tf,
+ FFMIN((row >> 1), pic_height - 1),
+ 0);
+ } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame
+ ff_thread_await_progress(&ref_pic->tf,
+ FFMIN(row * 2 + ref_field,
+ pic_height - 1),
+ 0);
+ } else if (FIELD_PICTURE(h)) {
+ ff_thread_await_progress(&ref_pic->tf,
+ FFMIN(row, pic_height - 1),
+ ref_field);
+ } else {
+ ff_thread_await_progress(&ref_pic->tf,
+ FFMIN(row, pic_height - 1),
+ 0);
+ }
+ }
+ }
+}
+
+static av_always_inline void mc_dir_part(H264Context *h, H264Picture *pic,
+ int n, int square, int height,
+ int delta, int list,
+ uint8_t *dest_y, uint8_t *dest_cb,
+ uint8_t *dest_cr,
+ int src_x_offset, int src_y_offset,
+ qpel_mc_func *qpix_op,
+ h264_chroma_mc_func chroma_op,
+ int pixel_shift, int chroma_idc)
+{
+ const int mx = h->mv_cache[list][scan8[n]][0] + src_x_offset * 8;
+ int my = h->mv_cache[list][scan8[n]][1] + src_y_offset * 8;
+ const int luma_xy = (mx & 3) + ((my & 3) << 2);
+ ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->mb_linesize;
+ uint8_t *src_y = pic->f.data[0] + offset;
+ uint8_t *src_cb, *src_cr;
+ int extra_width = 0;
+ int extra_height = 0;
+ int emu = 0;
+ const int full_mx = mx >> 2;
+ const int full_my = my >> 2;
+ const int pic_width = 16 * h->mb_width;
+ const int pic_height = 16 * h->mb_height >> MB_FIELD(h);
+ int ysh;
+
+ if (mx & 7)
+ extra_width -= 3;
+ if (my & 7)
+ extra_height -= 3;
+
+ if (full_mx < 0 - extra_width ||
+ full_my < 0 - extra_height ||
+ full_mx + 16 /*FIXME*/ > pic_width + extra_width ||
+ full_my + 16 /*FIXME*/ > pic_height + extra_height) {
+ h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
+ src_y - (2 << pixel_shift) - 2 * h->mb_linesize,
+ h->mb_linesize, h->mb_linesize,
+ 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2,
+ full_my - 2, pic_width, pic_height);
+ src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
+ emu = 1;
+ }
+
+ qpix_op[luma_xy](dest_y, src_y, h->mb_linesize); // FIXME try variable height perhaps?
+ if (!square)
+ qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize);
+
+ if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY)
+ return;
+
+ if (chroma_idc == 3 /* yuv444 */) {
+ src_cb = pic->f.data[1] + offset;
+ if (emu) {
+ h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
+ src_cb - (2 << pixel_shift) - 2 * h->mb_linesize,
+ h->mb_linesize, h->mb_linesize,
+ 16 + 5, 16 + 5 /*FIXME*/,
+ full_mx - 2, full_my - 2,
+ pic_width, pic_height);
+ src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
+ }
+ qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); // FIXME try variable height perhaps?
+ if (!square)
+ qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize);
+
+ src_cr = pic->f.data[2] + offset;
+ if (emu) {
+ h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
+ src_cr - (2 << pixel_shift) - 2 * h->mb_linesize,
+ h->mb_linesize, h->mb_linesize,
+ 16 + 5, 16 + 5 /*FIXME*/,
+ full_mx - 2, full_my - 2,
+ pic_width, pic_height);
+ src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize;
+ }
+ qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); // FIXME try variable height perhaps?
+ if (!square)
+ qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize);
+ return;
+ }
+
+ ysh = 3 - (chroma_idc == 2 /* yuv422 */);
+ if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) {
+ // chroma offset when predicting from a field of opposite parity
+ my += 2 * ((h->mb_y & 1) - (pic->reference - 1));
+ emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
+ }
+
+ src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) +
+ (my >> ysh) * h->mb_uvlinesize;
+ src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) +
+ (my >> ysh) * h->mb_uvlinesize;
+
+ if (emu) {
+ h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb,
+ h->mb_uvlinesize, h->mb_uvlinesize,
+ 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
+ pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
+ src_cb = h->edge_emu_buffer;
+ }
+ chroma_op(dest_cb, src_cb, h->mb_uvlinesize,
+ height >> (chroma_idc == 1 /* yuv420 */),
+ mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7);
+
+ if (emu) {
+ h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr,
+ h->mb_uvlinesize, h->mb_uvlinesize,
+ 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
+ pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
+ src_cr = h->edge_emu_buffer;
+ }
+ chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */),
+ mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7);
+}
+
+static av_always_inline void mc_part_std(H264Context *h, int n, int square,
+ int height, int delta,
+ uint8_t *dest_y, uint8_t *dest_cb,
+ uint8_t *dest_cr,
+ int x_offset, int y_offset,
+ qpel_mc_func *qpix_put,
+ h264_chroma_mc_func chroma_put,
+ qpel_mc_func *qpix_avg,
+ h264_chroma_mc_func chroma_avg,
+ int list0, int list1,
+ int pixel_shift, int chroma_idc)
+{
+ qpel_mc_func *qpix_op = qpix_put;
+ h264_chroma_mc_func chroma_op = chroma_put;
+
+ dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ if (chroma_idc == 3 /* yuv444 */) {
+ dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ } else if (chroma_idc == 2 /* yuv422 */) {
+ dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
+ dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
+ } else { /* yuv420 */
+ dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
+ dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
+ }
+ x_offset += 8 * h->mb_x;
+ y_offset += 8 * (h->mb_y >> MB_FIELD(h));
+
+ if (list0) {
+ H264Picture *ref = &h->ref_list[0][h->ref_cache[0][scan8[n]]];
+ mc_dir_part(h, ref, n, square, height, delta, 0,
+ dest_y, dest_cb, dest_cr, x_offset, y_offset,
+ qpix_op, chroma_op, pixel_shift, chroma_idc);
+
+ qpix_op = qpix_avg;
+ chroma_op = chroma_avg;
+ }
+
+ if (list1) {
+ H264Picture *ref = &h->ref_list[1][h->ref_cache[1][scan8[n]]];
+ mc_dir_part(h, ref, n, square, height, delta, 1,
+ dest_y, dest_cb, dest_cr, x_offset, y_offset,
+ qpix_op, chroma_op, pixel_shift, chroma_idc);
+ }
+}
+
+static av_always_inline void mc_part_weighted(H264Context *h, int n, int square,
+ int height, int delta,
+ uint8_t *dest_y, uint8_t *dest_cb,
+ uint8_t *dest_cr,
+ int x_offset, int y_offset,
+ qpel_mc_func *qpix_put,
+ h264_chroma_mc_func chroma_put,
+ h264_weight_func luma_weight_op,
+ h264_weight_func chroma_weight_op,
+ h264_biweight_func luma_weight_avg,
+ h264_biweight_func chroma_weight_avg,
+ int list0, int list1,
+ int pixel_shift, int chroma_idc)
+{
+ int chroma_height;
+
+ dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ if (chroma_idc == 3 /* yuv444 */) {
+ chroma_height = height;
+ chroma_weight_avg = luma_weight_avg;
+ chroma_weight_op = luma_weight_op;
+ dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->mb_linesize;
+ } else if (chroma_idc == 2 /* yuv422 */) {
+ chroma_height = height;
+ dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
+ dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->mb_uvlinesize;
+ } else { /* yuv420 */
+ chroma_height = height >> 1;
+ dest_cb += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
+ dest_cr += (x_offset << pixel_shift) + y_offset * h->mb_uvlinesize;
+ }
+ x_offset += 8 * h->mb_x;
+ y_offset += 8 * (h->mb_y >> MB_FIELD(h));
+
+ if (list0 && list1) {
+ /* don't optimize for luma-only case, since B-frames usually
+ * use implicit weights => chroma too. */
+ uint8_t *tmp_cb = h->bipred_scratchpad;
+ uint8_t *tmp_cr = h->bipred_scratchpad + (16 << pixel_shift);
+ uint8_t *tmp_y = h->bipred_scratchpad + 16 * h->mb_uvlinesize;
+ int refn0 = h->ref_cache[0][scan8[n]];
+ int refn1 = h->ref_cache[1][scan8[n]];
+
+ mc_dir_part(h, &h->ref_list[0][refn0], n, square, height, delta, 0,
+ dest_y, dest_cb, dest_cr,
+ x_offset, y_offset, qpix_put, chroma_put,
+ pixel_shift, chroma_idc);
+ mc_dir_part(h, &h->ref_list[1][refn1], n, square, height, delta, 1,
+ tmp_y, tmp_cb, tmp_cr,
+ x_offset, y_offset, qpix_put, chroma_put,
+ pixel_shift, chroma_idc);
+
+ if (h->use_weight == 2) {
+ int weight0 = h->implicit_weight[refn0][refn1][h->mb_y & 1];
+ int weight1 = 64 - weight0;
+ luma_weight_avg(dest_y, tmp_y, h->mb_linesize,
+ height, 5, weight0, weight1, 0);
+ chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize,
+ chroma_height, 5, weight0, weight1, 0);
+ chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize,
+ chroma_height, 5, weight0, weight1, 0);
+ } else {
+ luma_weight_avg(dest_y, tmp_y, h->mb_linesize, height,
+ h->luma_log2_weight_denom,
+ h->luma_weight[refn0][0][0],
+ h->luma_weight[refn1][1][0],
+ h->luma_weight[refn0][0][1] +
+ h->luma_weight[refn1][1][1]);
+ chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, chroma_height,
+ h->chroma_log2_weight_denom,
+ h->chroma_weight[refn0][0][0][0],
+ h->chroma_weight[refn1][1][0][0],
+ h->chroma_weight[refn0][0][0][1] +
+ h->chroma_weight[refn1][1][0][1]);
+ chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, chroma_height,
+ h->chroma_log2_weight_denom,
+ h->chroma_weight[refn0][0][1][0],
+ h->chroma_weight[refn1][1][1][0],
+ h->chroma_weight[refn0][0][1][1] +
+ h->chroma_weight[refn1][1][1][1]);
+ }
+ } else {
+ int list = list1 ? 1 : 0;
+ int refn = h->ref_cache[list][scan8[n]];
+ H264Picture *ref = &h->ref_list[list][refn];
+ mc_dir_part(h, ref, n, square, height, delta, list,
+ dest_y, dest_cb, dest_cr, x_offset, y_offset,
+ qpix_put, chroma_put, pixel_shift, chroma_idc);
+
+ luma_weight_op(dest_y, h->mb_linesize, height,
+ h->luma_log2_weight_denom,
+ h->luma_weight[refn][list][0],
+ h->luma_weight[refn][list][1]);
+ if (h->use_weight_chroma) {
+ chroma_weight_op(dest_cb, h->mb_uvlinesize, chroma_height,
+ h->chroma_log2_weight_denom,
+ h->chroma_weight[refn][list][0][0],
+ h->chroma_weight[refn][list][0][1]);
+ chroma_weight_op(dest_cr, h->mb_uvlinesize, chroma_height,
+ h->chroma_log2_weight_denom,
+ h->chroma_weight[refn][list][1][0],
+ h->chroma_weight[refn][list][1][1]);
+ }
+ }
+}
+
+static av_always_inline void prefetch_motion(H264Context *h, int list,
+ int pixel_shift, int chroma_idc)
+{
+ /* fetch pixels for estimated mv 4 macroblocks ahead
+ * optimized for 64byte cache lines */
+ const int refn = h->ref_cache[list][scan8[0]];
+ if (refn >= 0) {
+ const int mx = (h->mv_cache[list][scan8[0]][0] >> 2) + 16 * h->mb_x + 8;
+ const int my = (h->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y;
+ uint8_t **src = h->ref_list[list][refn].f.data;
+ int off = (mx << pixel_shift) +
+ (my + (h->mb_x & 3) * 4) * h->mb_linesize +
+ (64 << pixel_shift);
+ h->vdsp.prefetch(src[0] + off, h->linesize, 4);
+ if (chroma_idc == 3 /* yuv444 */) {
+ h->vdsp.prefetch(src[1] + off, h->linesize, 4);
+ h->vdsp.prefetch(src[2] + off, h->linesize, 4);
+ } else {
+ off= (((mx>>1)+64)<<pixel_shift) + ((my>>1) + (h->mb_x&7))*h->uvlinesize;
+ h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
+ }
+ }
+}
+
+static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
+ uint8_t *src_cb, uint8_t *src_cr,
+ int linesize, int uvlinesize,
+ int xchg, int chroma444,
+ int simple, int pixel_shift)
+{
+ int deblock_topleft;
+ int deblock_top;
+ int top_idx = 1;
+ uint8_t *top_border_m1;
+ uint8_t *top_border;
+
+ if (!simple && FRAME_MBAFF(h)) {
+ if (h->mb_y & 1) {
+ if (!MB_MBAFF(h))
+ return;
+ } else {
+ top_idx = MB_MBAFF(h) ? 0 : 1;
+ }
+ }
+
+ if (h->deblocking_filter == 2) {
+ deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == h->slice_num;
+ deblock_top = h->top_type;
+ } else {
+ deblock_topleft = (h->mb_x > 0);
+ deblock_top = (h->mb_y > !!MB_FIELD(h));
+ }
+
+ src_y -= linesize + 1 + pixel_shift;
+ src_cb -= uvlinesize + 1 + pixel_shift;
+ src_cr -= uvlinesize + 1 + pixel_shift;
+
+ top_border_m1 = h->top_borders[top_idx][h->mb_x - 1];
+ top_border = h->top_borders[top_idx][h->mb_x];
+
+#define XCHG(a, b, xchg) \
+ if (pixel_shift) { \
+ if (xchg) { \
+ AV_SWAP64(b + 0, a + 0); \
+ AV_SWAP64(b + 8, a + 8); \
+ } else { \
+ AV_COPY128(b, a); \
+ } \
+ } else if (xchg) \
+ AV_SWAP64(b, a); \
+ else \
+ AV_COPY64(b, a);
+
+ if (deblock_top) {
+ if (deblock_topleft) {
+ XCHG(top_border_m1 + (8 << pixel_shift),
+ src_y - (7 << pixel_shift), 1);
+ }
+ XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
+ XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
+ if (h->mb_x + 1 < h->mb_width) {
+ XCHG(h->top_borders[top_idx][h->mb_x + 1],
+ src_y + (17 << pixel_shift), 1);
+ }
+ if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
+ if (chroma444) {
+ if (deblock_topleft) {
+ XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
+ XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
+ }
+ XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
+ XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
+ XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
+ XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
+ if (h->mb_x + 1 < h->mb_width) {
+ XCHG(h->top_borders[top_idx][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
+ XCHG(h->top_borders[top_idx][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
+ }
+ } else {
+ if (deblock_topleft) {
+ XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
+ XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
+ }
+ XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
+ XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
+ }
+ }
+ }
+}
+
+static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth,
+ int index)
+{
+ if (high_bit_depth) {
+ return AV_RN32A(((int32_t *)mb) + index);
+ } else
+ return AV_RN16A(mb + index);
+}
+
+static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth,
+ int index, int value)
+{
+ if (high_bit_depth) {
+ AV_WN32A(((int32_t *)mb) + index, value);
+ } else
+ AV_WN16A(mb + index, value);
+}
+
+static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
+ int mb_type, int is_h264,
+ int simple,
+ int transform_bypass,
+ int pixel_shift,
+ int *block_offset,
+ int linesize,
+ uint8_t *dest_y, int p)
+{
+ void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
+ void (*idct_dc_add)(uint8_t *dst, int16_t *block, int stride);
+ int i;
+ int qscale = p == 0 ? h->qscale : h->chroma_qp[p - 1];
+ block_offset += 16 * p;
+ if (IS_INTRA4x4(mb_type)) {
+ if (IS_8x8DCT(mb_type)) {
+ if (transform_bypass) {
+ idct_dc_add =
+ idct_add = h->h264dsp.h264_add_pixels8_clear;
+ } else {
+ idct_dc_add = h->h264dsp.h264_idct8_dc_add;
+ idct_add = h->h264dsp.h264_idct8_add;
+ }
+ for (i = 0; i < 16; i += 4) {
+ uint8_t *const ptr = dest_y + block_offset[i];
+ const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
+ if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
+ if (h->x264_build != -1) {
+ h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ } else
+ h->hpc.pred8x8l_filter_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift),
+ (h-> topleft_samples_available << i) & 0x8000,
+ (h->topright_samples_available << i) & 0x4000, linesize);
+ } else {
+ const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
+ h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
+ (h->topright_samples_available << i) & 0x4000, linesize);
+ if (nnz) {
+ if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
+ idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ else
+ idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ }
+ }
+ }
+ } else {
+ if (transform_bypass) {
+ idct_dc_add =
+ idct_add = h->h264dsp.h264_add_pixels4_clear;
+ } else {
+ idct_dc_add = h->h264dsp.h264_idct_dc_add;
+ idct_add = h->h264dsp.h264_idct_add;
+ }
+ for (i = 0; i < 16; i++) {
+ uint8_t *const ptr = dest_y + block_offset[i];
+ const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
+
+ if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
+ h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ } else {
+ uint8_t *topright;
+ int nnz, tr;
+ uint64_t tr_high;
+ if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
+ const int topright_avail = (h->topright_samples_available << i) & 0x8000;
+ av_assert2(h->mb_y || linesize <= block_offset[i]);
+ if (!topright_avail) {
+ if (pixel_shift) {
+ tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
+ topright = (uint8_t *)&tr_high;
+ } else {
+ tr = ptr[3 - linesize] * 0x01010101u;
+ topright = (uint8_t *)&tr;
+ }
+ } else
+ topright = ptr + (4 << pixel_shift) - linesize;
+ } else
+ topright = NULL;
+
+ h->hpc.pred4x4[dir](ptr, topright, linesize);
+ nnz = h->non_zero_count_cache[scan8[i + p * 16]];
+ if (nnz) {
+ if (is_h264) {
+ if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
+ idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ else
+ idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
+ } else if (CONFIG_SVQ3_DECODER)
+ ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0);
+ }
+ }
+ }
+ }
+ } else {
+ h->hpc.pred16x16[h->intra16x16_pred_mode](dest_y, linesize);
+ if (is_h264) {
+ if (h->non_zero_count_cache[scan8[LUMA_DC_BLOCK_INDEX + p]]) {
+ if (!transform_bypass)
+ h->h264dsp.h264_luma_dc_dequant_idct(h->mb + (p * 256 << pixel_shift),
+ h->mb_luma_dc[p],
+ h->dequant4_coeff[p][qscale][0]);
+ else {
+ static const uint8_t dc_mapping[16] = {
+ 0 * 16, 1 * 16, 4 * 16, 5 * 16,
+ 2 * 16, 3 * 16, 6 * 16, 7 * 16,
+ 8 * 16, 9 * 16, 12 * 16, 13 * 16,
+ 10 * 16, 11 * 16, 14 * 16, 15 * 16
+ };
+ for (i = 0; i < 16; i++)
+ dctcoef_set(h->mb + (p * 256 << pixel_shift),
+ pixel_shift, dc_mapping[i],
+ dctcoef_get(h->mb_luma_dc[p],
+ pixel_shift, i));
+ }
+ }
+ } else if (CONFIG_SVQ3_DECODER)
+ ff_svq3_luma_dc_dequant_idct_c(h->mb + p * 256,
+ h->mb_luma_dc[p], qscale);
+ }
+}
+
+static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type,
+ int is_h264, int simple,
+ int transform_bypass,
+ int pixel_shift,
+ int *block_offset,
+ int linesize,
+ uint8_t *dest_y, int p)
+{
+ void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
+ int i;
+ block_offset += 16 * p;
+ if (!IS_INTRA4x4(mb_type)) {
+ if (is_h264) {
+ if (IS_INTRA16x16(mb_type)) {
+ if (transform_bypass) {
+ if (h->sps.profile_idc == 244 &&
+ (h->intra16x16_pred_mode == VERT_PRED8x8 ||
+ h->intra16x16_pred_mode == HOR_PRED8x8)) {
+ h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset,
+ h->mb + (p * 256 << pixel_shift),
+ linesize);
+ } else {
+ for (i = 0; i < 16; i++)
+ if (h->non_zero_count_cache[scan8[i + p * 16]] ||
+ dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
+ h->h264dsp.h264_add_pixels4_clear(dest_y + block_offset[i],
+ h->mb + (i * 16 + p * 256 << pixel_shift),
+ linesize);
+ }
+ } else {
+ h->h264dsp.h264_idct_add16intra(dest_y, block_offset,
+ h->mb + (p * 256 << pixel_shift),
+ linesize,
+ h->non_zero_count_cache + p * 5 * 8);
+ }
+ } else if (h->cbp & 15) {
+ if (transform_bypass) {
+ const int di = IS_8x8DCT(mb_type) ? 4 : 1;
+ idct_add = IS_8x8DCT(mb_type) ? h->h264dsp.h264_add_pixels8_clear
+ : h->h264dsp.h264_add_pixels4_clear;
+ for (i = 0; i < 16; i += di)
+ if (h->non_zero_count_cache[scan8[i + p * 16]])
+ idct_add(dest_y + block_offset[i],
+ h->mb + (i * 16 + p * 256 << pixel_shift),
+ linesize);
+ } else {
+ if (IS_8x8DCT(mb_type))
+ h->h264dsp.h264_idct8_add4(dest_y, block_offset,
+ h->mb + (p * 256 << pixel_shift),
+ linesize,
+ h->non_zero_count_cache + p * 5 * 8);
+ else
+ h->h264dsp.h264_idct_add16(dest_y, block_offset,
+ h->mb + (p * 256 << pixel_shift),
+ linesize,
+ h->non_zero_count_cache + p * 5 * 8);
+ }
+ }
+ } else if (CONFIG_SVQ3_DECODER) {
+ for (i = 0; i < 16; i++)
+ if (h->non_zero_count_cache[scan8[i + p * 16]] || h->mb[i * 16 + p * 256]) {
+ // FIXME benchmark weird rule, & below
+ uint8_t *const ptr = dest_y + block_offset[i];
+ ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize,
+ h->qscale, IS_INTRA(mb_type) ? 1 : 0);
+ }
+ }
+ }
+}
+
+#define BITS 8
+#define SIMPLE 1
+#include "h264_mb_template.c"
+
+#undef BITS
+#define BITS 16
+#include "h264_mb_template.c"
+
+#undef SIMPLE
+#define SIMPLE 0
+#include "h264_mb_template.c"
+
+void ff_h264_hl_decode_mb(H264Context *h)
+{
+ const int mb_xy = h->mb_xy;
+ const int mb_type = h->cur_pic.mb_type[mb_xy];
+ int is_complex = CONFIG_SMALL || h->is_complex ||
+ IS_INTRA_PCM(mb_type) || h->qscale == 0;
+
+ if (CHROMA444(h)) {
+ if (is_complex || h->pixel_shift)
+ hl_decode_mb_444_complex(h);
+ else
+ hl_decode_mb_444_simple_8(h);
+ } else if (is_complex) {
+ hl_decode_mb_complex(h);
+ } else if (h->pixel_shift) {
+ hl_decode_mb_simple_16(h);
+ } else
+ hl_decode_mb_simple_8(h);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_mb_template.c b/chromium/third_party/ffmpeg/libavcodec/h264_mb_template.c
index da3a9263de6..7c9d72b35a7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_mb_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_mb_template.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "svq3.h"
+
#undef FUNC
#undef PIXEL_SHIFT
@@ -172,14 +174,14 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h)
} else if (is_h264) {
if (chroma422) {
FUNC(hl_motion_422)(h, dest_y, dest_cb, dest_cr,
- h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
+ h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
+ h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
} else {
FUNC(hl_motion_420)(h, dest_y, dest_cb, dest_cr,
- h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
+ h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
+ h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
@@ -351,8 +353,8 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h)
linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
FUNC(hl_motion_444)(h, dest[0], dest[1], dest[2],
- h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
+ h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
+ h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_mc_template.c b/chromium/third_party/ffmpeg/libavcodec/h264_mc_template.c
index 7aec43ba90c..0e4e47713dd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_mc_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_mc_template.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "h264.h"
+
#undef MCFUNC
#if CHROMA_IDC == 1
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c b/chromium/third_party/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
index 8c0fbb3df2f..0f142bb2adb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
@@ -175,7 +175,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
goto fail;
/* prepend only to the first type 5 NAL unit of an IDR picture */
- if (ctx->first_idr && unit_type == 5) {
+ if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
avctx->extradata, avctx->extradata_size,
buf, nal_size)) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_mvpred.h b/chromium/third_party/ffmpeg/libavcodec/h264_mvpred.h
index afe327c57ff..5f1e9a1ee50 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_mvpred.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_mvpred.h
@@ -31,6 +31,7 @@
#include "internal.h"
#include "avcodec.h"
#include "h264.h"
+#include "mpegutils.h"
#include "libavutil/avassert.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_parser.c b/chromium/third_party/ffmpeg/libavcodec/h264_parser.c
index e718a3bc9ae..52ab67b0f4a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_parser.c
@@ -30,6 +30,7 @@
#include "h264data.h"
#include "golomb.h"
#include "internal.h"
+#include "mpegutils.h"
static int h264_find_frame_end(H264Context *h, const uint8_t *buf,
@@ -74,13 +75,15 @@ static int h264_find_frame_end(H264Context *h, const uint8_t *buf,
else
state >>= 1; // 2->1, 1->0, 0->0
} else if (state <= 5) {
- int v = buf[i] & 0x1F;
- if (v == 6 || v == 7 || v == 8 || v == 9) {
+ int nalu_type = buf[i] & 0x1F;
+ if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
+ nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
if (pc->frame_start_found) {
i++;
goto found;
}
- } else if (v == 1 || v == 2 || v == 5) {
+ } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
+ nalu_type == NAL_IDR_SLICE) {
state += 8;
continue;
}
@@ -149,7 +152,8 @@ static int scan_mmco_reset(AVCodecParserContext *s)
break;
if (index >= h->ref_count[list]) {
- av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
+ av_log(h->avctx, AV_LOG_ERROR,
+ "reference count %d overflow\n", index);
return AVERROR_INVALIDDATA;
}
}
@@ -290,18 +294,18 @@ static inline int parse_nal_units(AVCodecParserContext *s,
pps_id = get_ue_golomb(&h->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR,
- "pps_id out of range\n");
+ "pps_id %u out of range\n", pps_id);
return -1;
}
if (!h->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
- "non-existing PPS referenced\n");
+ "non-existing PPS %u referenced\n", pps_id);
return -1;
}
h->pps = *h->pps_buffers[pps_id];
if (!h->sps_buffers[h->pps.sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
- "non-existing SPS referenced\n");
+ "non-existing SPS %u referenced\n", h->pps.sps_id);
return -1;
}
h->sps = *h->sps_buffers[h->pps.sps_id];
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_picture.c b/chromium/third_party/ffmpeg/libavcodec/h264_picture.c
new file mode 100644
index 00000000000..61ff862a7aa
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_picture.c
@@ -0,0 +1,211 @@
+/*
+ * H.26L/H.264/AVC/JVT/14496-10/... decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * H.264 / AVC / MPEG4 part10 codec.
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/timer.h"
+#include "internal.h"
+#include "cabac.h"
+#include "cabac_functions.h"
+#include "dsputil.h"
+#include "error_resilience.h"
+#include "avcodec.h"
+#include "h264.h"
+#include "h264data.h"
+#include "h264chroma.h"
+#include "h264_mvpred.h"
+#include "golomb.h"
+#include "mathops.h"
+#include "mpegutils.h"
+#include "rectangle.h"
+#include "thread.h"
+#include "vdpau_internal.h"
+
+void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
+{
+ int off = offsetof(H264Picture, tf) + sizeof(pic->tf);
+ int i;
+
+ if (!pic->f.buf[0])
+ return;
+
+ ff_thread_release_buffer(h->avctx, &pic->tf);
+ av_buffer_unref(&pic->hwaccel_priv_buf);
+
+ av_buffer_unref(&pic->qscale_table_buf);
+ av_buffer_unref(&pic->mb_type_buf);
+ for (i = 0; i < 2; i++) {
+ av_buffer_unref(&pic->motion_val_buf[i]);
+ av_buffer_unref(&pic->ref_index_buf[i]);
+ }
+
+ memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
+}
+
+int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
+{
+ int ret, i;
+
+ av_assert0(!dst->f.buf[0]);
+ av_assert0(src->f.buf[0]);
+
+ src->tf.f = &src->f;
+ dst->tf.f = &dst->f;
+ ret = ff_thread_ref_frame(&dst->tf, &src->tf);
+ if (ret < 0)
+ goto fail;
+
+ dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
+ dst->mb_type_buf = av_buffer_ref(src->mb_type_buf);
+ if (!dst->qscale_table_buf || !dst->mb_type_buf)
+ goto fail;
+ dst->qscale_table = src->qscale_table;
+ dst->mb_type = src->mb_type;
+
+ for (i = 0; i < 2; i++) {
+ dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]);
+ dst->ref_index_buf[i] = av_buffer_ref(src->ref_index_buf[i]);
+ if (!dst->motion_val_buf[i] || !dst->ref_index_buf[i])
+ goto fail;
+ dst->motion_val[i] = src->motion_val[i];
+ dst->ref_index[i] = src->ref_index[i];
+ }
+
+ if (src->hwaccel_picture_private) {
+ dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
+ if (!dst->hwaccel_priv_buf)
+ goto fail;
+ dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
+ }
+
+ for (i = 0; i < 2; i++)
+ dst->field_poc[i] = src->field_poc[i];
+
+ memcpy(dst->ref_poc, src->ref_poc, sizeof(src->ref_poc));
+ memcpy(dst->ref_count, src->ref_count, sizeof(src->ref_count));
+
+ dst->poc = src->poc;
+ dst->frame_num = src->frame_num;
+ dst->mmco_reset = src->mmco_reset;
+ dst->pic_id = src->pic_id;
+ dst->long_ref = src->long_ref;
+ dst->mbaff = src->mbaff;
+ dst->field_picture = src->field_picture;
+ dst->needs_realloc = src->needs_realloc;
+ dst->reference = src->reference;
+ dst->crop = src->crop;
+ dst->crop_left = src->crop_left;
+ dst->crop_top = src->crop_top;
+ dst->recovered = src->recovered;
+ dst->invalid_gap = src->invalid_gap;
+ dst->sei_recovery_frame_cnt = src->sei_recovery_frame_cnt;
+
+ return 0;
+fail:
+ ff_h264_unref_picture(h, dst);
+ return ret;
+}
+
+#if CONFIG_ERROR_RESILIENCE
+void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
+{
+ int i;
+
+ memset(dst, 0, sizeof(*dst));
+
+ if (!src)
+ return;
+
+ dst->f = &src->f;
+ dst->tf = &src->tf;
+
+ for (i = 0; i < 2; i++) {
+ dst->motion_val[i] = src->motion_val[i];
+ dst->ref_index[i] = src->ref_index[i];
+ }
+
+ dst->mb_type = src->mb_type;
+ dst->field_picture = src->field_picture;
+}
+#endif /* CONFIG_ERROR_RESILIENCE */
+
+int ff_h264_field_end(H264Context *h, int in_setup)
+{
+ AVCodecContext *const avctx = h->avctx;
+ int err = 0;
+ h->mb_y = 0;
+
+ if (CONFIG_H264_VDPAU_DECODER &&
+ h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
+ ff_vdpau_h264_set_reference_frames(h);
+
+ if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
+ if (!h->droppable) {
+ err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
+ h->prev_poc_msb = h->poc_msb;
+ h->prev_poc_lsb = h->poc_lsb;
+ }
+ h->prev_frame_num_offset = h->frame_num_offset;
+ h->prev_frame_num = h->frame_num;
+ h->outputed_poc = h->next_outputed_poc;
+ }
+
+ if (avctx->hwaccel) {
+ if (avctx->hwaccel->end_frame(avctx) < 0)
+ av_log(avctx, AV_LOG_ERROR,
+ "hardware accelerator failed to decode picture\n");
+ }
+
+ if (CONFIG_H264_VDPAU_DECODER &&
+ h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
+ ff_vdpau_h264_picture_complete(h);
+
+ /*
+ * FIXME: Error handling code does not seem to support interlaced
+ * when slices span multiple rows
+ * The ff_er_add_slice calls don't work right for bottom
+ * fields; they cause massive erroneous error concealing
+ * Error marking covers both fields (top and bottom).
+ * This causes a mismatched s->error_count
+ * and a bad error table. Further, the error count goes to
+ * INT_MAX when called for bottom field, because mb_y is
+ * past end by one (callers fault) and resync_mb_y != 0
+ * causes problems for the first MB line, too.
+ */
+ if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
+ ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
+ ff_er_frame_end(&h->er);
+ }
+ if (!in_setup && !h->droppable)
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
+ h->picture_structure == PICT_BOTTOM_FIELD);
+ emms_c();
+
+ h->current_slice = 0;
+
+ return err;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_ps.c b/chromium/third_party/ffmpeg/libavcodec/h264_ps.c
index a06e3dd65b5..97073328920 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_ps.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_ps.c
@@ -25,6 +25,8 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
+#include <inttypes.h>
+
#include "libavutil/imgutils.h"
#include "internal.h"
#include "avcodec.h"
@@ -213,7 +215,7 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps)
sps->time_scale = get_bits_long(&h->gb, 32);
if (!sps->num_units_in_tick || !sps->time_scale) {
av_log(h->avctx, AV_LOG_ERROR,
- "time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n",
+ "time_scale/num_units_in_tick invalid or unsupported (%"PRIu32"/%"PRIu32")\n",
sps->time_scale, sps->num_units_in_tick);
return AVERROR_INVALIDDATA;
}
@@ -252,7 +254,9 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps)
if (sps->num_reorder_frames > 16U
/* max_dec_frame_buffering || max_dec_frame_buffering > 16 */) {
av_log(h->avctx, AV_LOG_ERROR,
- "illegal num_reorder_frames %d\n", sps->num_reorder_frames);
+ "Clipping illegal num_reorder_frames %d\n",
+ sps->num_reorder_frames);
+ sps->num_reorder_frames = 16;
return AVERROR_INVALIDDATA;
}
}
@@ -333,18 +337,19 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
constraint_set_flags |= get_bits1(&h->gb) << 3; // constraint_set3_flag
constraint_set_flags |= get_bits1(&h->gb) << 4; // constraint_set4_flag
constraint_set_flags |= get_bits1(&h->gb) << 5; // constraint_set5_flag
- get_bits(&h->gb, 2); // reserved
+ skip_bits(&h->gb, 2); // reserved_zero_2bits
level_idc = get_bits(&h->gb, 8);
sps_id = get_ue_golomb_31(&h->gb);
if (sps_id >= MAX_SPS_COUNT) {
- av_log(h->avctx, AV_LOG_ERROR, "sps_id (%d) out of range\n", sps_id);
+ av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
return AVERROR_INVALIDDATA;
}
sps = av_mallocz(sizeof(SPS));
if (!sps)
return AVERROR(ENOMEM);
+ sps->sps_id = sps_id;
sps->time_offset_length = 24;
sps->profile_idc = profile_idc;
sps->constraint_set_flags = constraint_set_flags;
@@ -356,16 +361,21 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
sps->scaling_matrix_present = 0;
sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED
- if (sps->profile_idc == 100 || sps->profile_idc == 110 ||
- sps->profile_idc == 122 || sps->profile_idc == 244 ||
- sps->profile_idc == 44 || sps->profile_idc == 83 ||
- sps->profile_idc == 86 || sps->profile_idc == 118 ||
- sps->profile_idc == 128 || sps->profile_idc == 144) {
+ if (sps->profile_idc == 100 || // High profile
+ sps->profile_idc == 110 || // High10 profile
+ sps->profile_idc == 122 || // High422 profile
+ sps->profile_idc == 244 || // High444 Predictive profile
+ sps->profile_idc == 44 || // Cavlc444 profile
+ sps->profile_idc == 83 || // Scalable Constrained High profile (SVC)
+ sps->profile_idc == 86 || // Scalable High Intra profile (SVC)
+ sps->profile_idc == 118 || // Stereo High profile (MVC)
+ sps->profile_idc == 128 || // Multiview High profile (MVC)
+ sps->profile_idc == 138 || // Multiview Depth High profile (MVCD)
+ sps->profile_idc == 144) { // old High444 profile
sps->chroma_format_idc = get_ue_golomb_31(&h->gb);
if (sps->chroma_format_idc > 3U) {
- av_log(h->avctx, AV_LOG_ERROR,
- "chroma_format_idc %d is illegal\n",
- sps->chroma_format_idc);
+ avpriv_request_sample(h->avctx, "chroma_format_idc %u",
+ sps->chroma_format_idc);
goto fail;
} else if (sps->chroma_format_idc == 3) {
sps->residual_color_transform_flag = get_bits1(&h->gb);
@@ -376,7 +386,12 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
}
sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
- if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U || sps->bit_depth_luma != sps->bit_depth_chroma) {
+ if (sps->bit_depth_chroma != sps->bit_depth_luma) {
+ avpriv_request_sample(h->avctx,
+ "Different chroma and luma bit depth");
+ goto fail;
+ }
+ if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U) {
av_log(h->avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
sps->bit_depth_luma, sps->bit_depth_chroma);
goto fail;
@@ -418,7 +433,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
if ((unsigned)sps->poc_cycle_length >=
FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
av_log(h->avctx, AV_LOG_ERROR,
- "poc_cycle_length overflow %u\n", sps->poc_cycle_length);
+ "poc_cycle_length overflow %d\n", sps->poc_cycle_length);
goto fail;
}
@@ -432,9 +447,10 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
sps->ref_frame_count = get_ue_golomb_31(&h->gb);
if (h->avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
- if (sps->ref_frame_count > MAX_PICTURE_COUNT - 2 ||
+ if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 ||
sps->ref_frame_count > 16U) {
- av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\n");
+ av_log(h->avctx, AV_LOG_ERROR,
+ "too many reference frames %d\n", sps->ref_frame_count);
goto fail;
}
sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);
@@ -472,7 +488,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) {
av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
- "values are l:%u r:%u t:%u b:%u\n",
+ "values are l:%d r:%d t:%d b:%d\n",
crop_left, crop_right, crop_top, crop_bottom);
sps->crop_left =
@@ -532,7 +548,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" };
av_log(h->avctx, AV_LOG_DEBUG,
- "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d b%d reo:%d\n",
+ "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
@@ -546,7 +562,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
sps->timing_info_present_flag ? sps->time_scale : 0,
sps->bit_depth_luma,
- h->sps.bitstream_restriction_flag ? sps->num_reorder_frames : -1
+ sps->bitstream_restriction_flag ? sps->num_reorder_frames : -1
);
}
sps->new = 1;
@@ -594,7 +610,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
int bits_left;
if (pps_id >= MAX_PPS_COUNT) {
- av_log(h->avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
+ av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
@@ -604,7 +620,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
pps->sps_id = get_ue_golomb_31(&h->gb);
if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
h->sps_buffers[pps->sps_id] == NULL) {
- av_log(h->avctx, AV_LOG_ERROR, "sps_id out of range\n");
+ av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id);
goto fail;
}
sps = h->sps_buffers[pps->sps_id];
@@ -701,7 +717,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
- "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n",
+ "pps:%u sps:%u %s slice_groups:%d ref:%u/%u %s qp:%d/%d/%d/%d %s %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_refs.c b/chromium/third_party/ffmpeg/libavcodec/h264_refs.c
index 7eb1f9e2d49..9bb065d24d9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_refs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_refs.c
@@ -25,11 +25,14 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
+#include <inttypes.h>
+
#include "libavutil/avassert.h"
#include "internal.h"
#include "avcodec.h"
#include "h264.h"
#include "golomb.h"
+#include "mpegutils.h"
#include <assert.h>
@@ -41,7 +44,7 @@ do {\
} while (0)
-static void pic_as_field(Picture *pic, const int parity){
+static void pic_as_field(H264Picture *pic, const int parity){
int i;
for (i = 0; i < 4; ++i) {
if (parity == PICT_BOTTOM_FIELD)
@@ -52,7 +55,7 @@ static void pic_as_field(Picture *pic, const int parity){
pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
}
-static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add)
+static int split_field_copy(H264Picture *dest, H264Picture *src, int parity, int id_add)
{
int match = !!(src->reference & parity);
@@ -68,8 +71,8 @@ static int split_field_copy(Picture *dest, Picture *src, int parity, int id_add)
return match;
}
-static int build_def_list(Picture *def, int def_len,
- Picture **in, int len, int is_long, int sel)
+static int build_def_list(H264Picture *def, int def_len,
+ H264Picture **in, int len, int is_long, int sel)
{
int i[2] = { 0 };
int index = 0;
@@ -94,7 +97,7 @@ static int build_def_list(Picture *def, int def_len,
return index;
}
-static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir)
+static int add_sorted(H264Picture **sorted, H264Picture **src, int len, int limit, int dir)
{
int i, best_poc;
int out_i = 0;
@@ -121,7 +124,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
int i, len;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- Picture *sorted[32];
+ H264Picture *sorted[32];
int cur_poc, list;
int lens[2];
@@ -143,7 +146,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
av_assert0(len <= 32);
if (len < h->ref_count[list])
- memset(&h->default_ref_list[list][len], 0, sizeof(Picture) * (h->ref_count[list] - len));
+ memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (h->ref_count[list] - len));
lens[list] = len;
}
@@ -152,7 +155,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
h->default_ref_list[0][i].f.buf[0]->buffer ==
h->default_ref_list[1][i].f.buf[0]->buffer; i++);
if (i == lens[0]) {
- Picture tmp;
+ H264Picture tmp;
COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
COPY_PICTURE(&h->default_ref_list[1][0], &h->default_ref_list[1][1]);
COPY_PICTURE(&h->default_ref_list[1][1], &tmp);
@@ -167,7 +170,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
av_assert0(len <= 32);
if (len < h->ref_count[0])
- memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
+ memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (h->ref_count[0] - len));
}
#ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) {
@@ -225,16 +228,16 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
for (i = 0; i < h->ref_count[list]; i++)
COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]);
- if (get_bits1(&h->gb)) {
+ if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num;
for (index = 0; ; index++) {
- unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
+ unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
unsigned int pic_id;
int i;
- Picture *ref = NULL;
+ H264Picture *ref = NULL;
- if (reordering_of_pic_nums_idc == 3)
+ if (modification_of_pic_nums_idc == 3)
break;
if (index >= h->ref_count[list]) {
@@ -242,75 +245,84 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
return -1;
}
- if (reordering_of_pic_nums_idc < 3) {
- if (reordering_of_pic_nums_idc < 2) {
- const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1;
- int frame_num;
+ switch (modification_of_pic_nums_idc) {
+ case 0:
+ case 1: {
+ const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1;
+ int frame_num;
- if (abs_diff_pic_num > h->max_pic_num) {
- av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
- return -1;
- }
+ if (abs_diff_pic_num > h->max_pic_num) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "abs_diff_pic_num overflow\n");
+ return AVERROR_INVALIDDATA;
+ }
- if (reordering_of_pic_nums_idc == 0)
- pred -= abs_diff_pic_num;
- else
- pred += abs_diff_pic_num;
- pred &= h->max_pic_num - 1;
-
- frame_num = pic_num_extract(h, pred, &pic_structure);
-
- for (i = h->short_ref_count - 1; i >= 0; i--) {
- ref = h->short_ref[i];
- assert(ref->reference);
- assert(!ref->long_ref);
- if (ref->frame_num == frame_num &&
- (ref->reference & pic_structure))
- break;
- }
- if (i >= 0)
- ref->pic_id = pred;
- } else {
- int long_idx;
- pic_id = get_ue_golomb(&h->gb); //long_term_pic_idx
+ if (modification_of_pic_nums_idc == 0)
+ pred -= abs_diff_pic_num;
+ else
+ pred += abs_diff_pic_num;
+ pred &= h->max_pic_num - 1;
+
+ frame_num = pic_num_extract(h, pred, &pic_structure);
+
+ for (i = h->short_ref_count - 1; i >= 0; i--) {
+ ref = h->short_ref[i];
+ assert(ref->reference);
+ assert(!ref->long_ref);
+ if (ref->frame_num == frame_num &&
+ (ref->reference & pic_structure))
+ break;
+ }
+ if (i >= 0)
+ ref->pic_id = pred;
+ break;
+ }
+ case 2: {
+ int long_idx;
+ pic_id = get_ue_golomb(&h->gb); // long_term_pic_idx
- long_idx = pic_num_extract(h, pic_id, &pic_structure);
+ long_idx = pic_num_extract(h, pic_id, &pic_structure);
- if (long_idx > 31) {
- av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
- return -1;
- }
- ref = h->long_ref[long_idx];
- assert(!(ref && !ref->reference));
- if (ref && (ref->reference & pic_structure)) {
- ref->pic_id = pic_id;
- assert(ref->long_ref);
- i = 0;
- } else {
- i = -1;
- }
+ if (long_idx > 31) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "long_term_pic_idx overflow\n");
+ return AVERROR_INVALIDDATA;
}
-
- if (i < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
- memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
+ ref = h->long_ref[long_idx];
+ assert(!(ref && !ref->reference));
+ if (ref && (ref->reference & pic_structure)) {
+ ref->pic_id = pic_id;
+ assert(ref->long_ref);
+ i = 0;
} else {
- for (i = index; i + 1 < h->ref_count[list]; i++) {
- if (ref->long_ref == h->ref_list[list][i].long_ref &&
- ref->pic_id == h->ref_list[list][i].pic_id)
- break;
- }
- for (; i > index; i--) {
- COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
- }
- COPY_PICTURE(&h->ref_list[list][index], ref);
- if (FIELD_PICTURE(h)) {
- pic_as_field(&h->ref_list[list][index], pic_structure);
- }
+ i = -1;
}
+ break;
+ }
+ default:
+ av_log(h->avctx, AV_LOG_ERROR,
+ "illegal modification_of_pic_nums_idc %u\n",
+ modification_of_pic_nums_idc);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (i < 0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "reference picture missing during reorder\n");
+ memset(&h->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME
} else {
- av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
- return -1;
+ for (i = index; i + 1 < h->ref_count[list]; i++) {
+ if (ref->long_ref == h->ref_list[list][i].long_ref &&
+ ref->pic_id == h->ref_list[list][i].pic_id)
+ break;
+ }
+ for (; i > index; i--) {
+ COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
+ }
+ COPY_PICTURE(&h->ref_list[list][index], ref);
+ if (FIELD_PICTURE(h)) {
+ pic_as_field(&h->ref_list[list][index], pic_structure);
+ }
}
}
}
@@ -341,8 +353,8 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h)
int list, i, j;
for (list = 0; list < h->list_count; list++) {
for (i = 0; i < h->ref_count[list]; i++) {
- Picture *frame = &h->ref_list[list][i];
- Picture *field = &h->ref_list[list][16 + 2 * i];
+ H264Picture *frame = &h->ref_list[list][i];
+ H264Picture *field = &h->ref_list[list][16 + 2 * i];
COPY_PICTURE(field, frame);
for (j = 0; j < 3; j++)
field[0].f.linesize[j] <<= 1;
@@ -375,7 +387,7 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h)
* for display purposes) zero if one of the fields remains in
* reference
*/
-static inline int unreference_pic(H264Context *h, Picture *pic, int refmask)
+static inline int unreference_pic(H264Context *h, H264Picture *pic, int refmask)
{
int i;
if (pic->reference &= refmask) {
@@ -391,19 +403,19 @@ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask)
}
/**
- * Find a Picture in the short term reference list by frame number.
+ * Find a H264Picture in the short term reference list by frame number.
* @param frame_num frame number to search for
* @param idx the index into h->short_ref where returned picture is found
* undefined if no picture found.
* @return pointer to the found picture, or NULL if no pic with the provided
* frame number is found
*/
-static Picture *find_short(H264Context *h, int frame_num, int *idx)
+static H264Picture *find_short(H264Context *h, int frame_num, int *idx)
{
int i;
for (i = 0; i < h->short_ref_count; i++) {
- Picture *pic = h->short_ref[i];
+ H264Picture *pic = h->short_ref[i];
if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
if (pic->frame_num == frame_num) {
@@ -426,16 +438,16 @@ static void remove_short_at_index(H264Context *h, int i)
h->short_ref[i] = NULL;
if (--h->short_ref_count)
memmove(&h->short_ref[i], &h->short_ref[i + 1],
- (h->short_ref_count - i) * sizeof(Picture*));
+ (h->short_ref_count - i) * sizeof(H264Picture*));
}
/**
*
* @return the removed picture or NULL if an error occurs
*/
-static Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
+static H264Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
{
- Picture *pic;
+ H264Picture *pic;
int i;
if (h->avctx->debug & FF_DEBUG_MMCO)
@@ -455,9 +467,9 @@ static Picture *remove_short(H264Context *h, int frame_num, int ref_mask)
* that list.
* @return the removed picture or NULL if an error occurs
*/
-static Picture *remove_long(H264Context *h, int i, int ref_mask)
+static H264Picture *remove_long(H264Context *h, int i, int ref_mask)
{
- Picture *pic;
+ H264Picture *pic;
pic = h->long_ref[i];
if (pic) {
@@ -500,8 +512,8 @@ static void print_short_term(H264Context *h)
if (h->avctx->debug & FF_DEBUG_MMCO) {
av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n");
for (i = 0; i < h->short_ref_count; i++) {
- Picture *pic = h->short_ref[i];
- av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
+ H264Picture *pic = h->short_ref[i];
+ av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
i, pic->frame_num, pic->poc, pic->f.data[0]);
}
}
@@ -516,9 +528,9 @@ static void print_long_term(H264Context *h)
if (h->avctx->debug & FF_DEBUG_MMCO) {
av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n");
for (i = 0; i < 16; i++) {
- Picture *pic = h->long_ref[i];
+ H264Picture *pic = h->long_ref[i];
if (pic) {
- av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
+ av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
i, pic->frame_num, pic->poc, pic->f.data[0]);
}
}
@@ -543,7 +555,7 @@ static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
- int mmco_index = 0, i;
+ int mmco_index = 0, i = 0;
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count &&
@@ -577,7 +589,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
int i, av_uninit(j);
int pps_count;
int current_ref_assigned = 0, err = 0;
- Picture *av_uninit(pic);
+ H264Picture *av_uninit(pic);
if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0)
av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
@@ -637,6 +649,10 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
* Report the problem and keep the pair where it is,
* and mark this field valid.
*/
+ if (h->short_ref[0] == h->cur_pic_ptr) {
+ av_log(h->avctx, AV_LOG_ERROR, "mmco: cannot assign current picture to short and long at the same time\n");
+ remove_short_at_index(h, 0);
+ }
if (h->long_ref[mmco[i].long_arg] != h->cur_pic_ptr) {
if (h->cur_pic_ptr->long_ref) {
@@ -649,9 +665,6 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
}
av_assert0(!h->cur_pic_ptr->long_ref);
remove_long(h, mmco[i].long_arg, 0);
- if (remove_short(h, h->cur_pic_ptr->frame_num, 0)) {
- av_log(h->avctx, AV_LOG_ERROR, "mmco: cannot assign current picture to short and long at the same time\n");
- }
h->long_ref[mmco[i].long_arg] = h->cur_pic_ptr;
h->long_ref[mmco[i].long_arg]->long_ref = 1;
@@ -710,7 +723,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
if (h->short_ref_count)
memmove(&h->short_ref[1], &h->short_ref[0],
- h->short_ref_count * sizeof(Picture*));
+ h->short_ref_count * sizeof(H264Picture*));
h->short_ref[0] = h->cur_pic_ptr;
h->short_ref_count++;
@@ -743,6 +756,15 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
}
}
+ for (i = 0; i<h->short_ref_count; i++) {
+ pic = h->short_ref[i];
+ if (pic->invalid_gap) {
+ int d = (h->cur_pic_ptr->frame_num - pic->frame_num) & ((1 << h->sps.log2_max_frame_num)-1);
+ if (d > h->sps.ref_frame_count)
+ remove_short(h, pic->frame_num, 0);
+ }
+ }
+
print_short_term(h);
print_long_term(h);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_sei.c b/chromium/third_party/ffmpeg/libavcodec/h264_sei.c
index 7d5558acb37..4e2f981181f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264_sei.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_sei.c
@@ -25,12 +25,10 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
-#include "internal.h"
#include "avcodec.h"
-#include "h264.h"
#include "golomb.h"
-
-#include <assert.h>
+#include "h264.h"
+#include "internal.h"
static const uint8_t sei_num_clock_ts_table[9] = {
1, 1, 1, 2, 2, 3, 3, 2, 3
@@ -42,6 +40,7 @@ void ff_h264_reset_sei(H264Context *h)
h->sei_dpb_output_delay = 0;
h->sei_cpb_removal_delay = -1;
h->sei_buffering_period_present = 0;
+ h->sei_frame_packing_present = 0;
}
static int decode_picture_timing(H264Context *h)
@@ -223,31 +222,31 @@ static int decode_buffering_period(H264Context *h)
return 0;
}
-static int decode_frame_packing(H264Context *h, int size) {
- int bits = get_bits_left(&h->gb);
-
+static int decode_frame_packing_arrangement(H264Context *h)
+{
h->sei_fpa.frame_packing_arrangement_id = get_ue_golomb(&h->gb);
- h->sei_fpa.frame_packing_arrangement_cancel_flag = get_bits(&h->gb, 1);
- if (!h->sei_fpa.frame_packing_arrangement_cancel_flag) {
- h->sei_fpa.frame_packing_arrangement_type = get_bits(&h->gb, 7);
- h->sei_fpa.quincunx_sampling_flag = get_bits(&h->gb, 1);
- h->sei_fpa.content_interpretation_type = get_bits(&h->gb, 6);
- skip_bits(&h->gb, 1); /* spatial_flipping_flag */
- skip_bits(&h->gb, 1); /* frame0_flipped_flag */
- skip_bits(&h->gb, 1); /* field_views_flag */
- skip_bits(&h->gb, 1); /* current_frame_is_frame0_flag */
- skip_bits(&h->gb, 1); /* frame0_self_contained_flag */
- skip_bits(&h->gb, 1); /* frame1_self_contained_flag */
- if (!h->sei_fpa.quincunx_sampling_flag && h->sei_fpa.frame_packing_arrangement_type != 5) {
- skip_bits(&h->gb, 4); /* frame0_grid_position_x */
- skip_bits(&h->gb, 4); /* frame0_grid_position_y */
- skip_bits(&h->gb, 4); /* frame1_grid_position_x */
- skip_bits(&h->gb, 4); /* frame1_grid_position_y */
- }
- skip_bits(&h->gb, 8); /* frame_packing_arrangement_reserved_byte */
+ h->sei_fpa.frame_packing_arrangement_cancel_flag = get_bits1(&h->gb);
+ h->sei_frame_packing_present = !h->sei_fpa.frame_packing_arrangement_cancel_flag;
+
+ if (h->sei_frame_packing_present) {
+ h->sei_fpa.frame_packing_arrangement_type =
+ h->frame_packing_arrangement_type = get_bits(&h->gb, 7);
+ h->sei_fpa.quincunx_sampling_flag =
+ h->quincunx_subsampling = get_bits1(&h->gb);
+ h->sei_fpa.content_interpretation_type =
+ h->content_interpretation_type = get_bits(&h->gb, 6);
+
+ // the following skips: spatial_flipping_flag, frame0_flipped_flag,
+ // field_views_flag, current_frame_is_frame0_flag,
+ // frame0_self_contained_flag, frame1_self_contained_flag
+ skip_bits(&h->gb, 6);
+
+ if (!h->quincunx_subsampling && h->frame_packing_arrangement_type != 5)
+ skip_bits(&h->gb, 16); // frame[01]_grid_position_[xy]
+ skip_bits(&h->gb, 8); // frame_packing_arrangement_reserved_byte
h->sei_fpa.frame_packing_arrangement_repetition_period = get_ue_golomb(&h->gb) /* frame_packing_arrangement_repetition_period */;
}
- skip_bits(&h->gb, 1); /* frame_packing_arrangement_extension_flag */
+ skip_bits1(&h->gb); // frame_packing_arrangement_extension_flag
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(h->avctx, AV_LOG_DEBUG, "SEI FPA %d %d %d %d %d %d\n",
@@ -257,7 +256,7 @@ static int decode_frame_packing(H264Context *h, int size) {
h->sei_fpa.quincunx_sampling_flag,
h->sei_fpa.content_interpretation_type,
h->sei_fpa.frame_packing_arrangement_repetition_period);
- skip_bits_long(&h->gb, 8 * size - (bits - get_bits_left(&h->gb)));
+
return 0;
}
@@ -311,14 +310,15 @@ int ff_h264_decode_sei(H264Context *h)
if (ret < 0)
return ret;
break;
- case SEI_BUFFERING_PERIOD:
+ case SEI_TYPE_BUFFERING_PERIOD:
ret = decode_buffering_period(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_FRAME_PACKING:
- if (decode_frame_packing(h, size) < 0)
- return -1;
+ ret = decode_frame_packing_arrangement(h);
+ if (ret < 0)
+ return ret;
break;
default:
av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264_slice.c b/chromium/third_party/ffmpeg/libavcodec/h264_slice.c
new file mode 100644
index 00000000000..a9500432d95
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/h264_slice.c
@@ -0,0 +1,2565 @@
+/*
+ * H.26L/H.264/AVC/JVT/14496-10/... decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * H.264 / AVC / MPEG4 part10 codec.
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/timer.h"
+#include "internal.h"
+#include "cabac.h"
+#include "cabac_functions.h"
+#include "dsputil.h"
+#include "error_resilience.h"
+#include "avcodec.h"
+#include "h264.h"
+#include "h264data.h"
+#include "h264chroma.h"
+#include "h264_mvpred.h"
+#include "golomb.h"
+#include "mathops.h"
+#include "mpegutils.h"
+#include "rectangle.h"
+#include "thread.h"
+
+
+static const uint8_t rem6[QP_MAX_NUM + 1] = {
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
+ 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
+ 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3,
+};
+
+static const uint8_t div6[QP_MAX_NUM + 1] = {
+ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
+ 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,
+ 10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,13,13,13, 13, 13, 13,
+ 14,14,14,14,
+};
+
+static const uint8_t field_scan[16+1] = {
+ 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
+ 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
+ 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
+ 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
+};
+
+static const uint8_t field_scan8x8[64+1] = {
+ 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
+ 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
+ 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
+ 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
+ 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
+ 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
+ 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
+ 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
+ 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
+ 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
+ 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
+ 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
+ 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
+ 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
+ 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
+ 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
+};
+
+static const uint8_t field_scan8x8_cavlc[64+1] = {
+ 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
+ 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
+ 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
+ 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
+ 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
+ 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
+ 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
+ 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
+ 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
+ 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
+ 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
+ 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
+ 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
+ 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
+ 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
+ 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
+};
+
+// zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
+static const uint8_t zigzag_scan8x8_cavlc[64+1] = {
+ 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
+ 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
+ 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
+ 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
+ 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
+ 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
+ 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
+ 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
+ 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
+ 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
+ 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
+ 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
+ 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
+ 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
+ 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
+ 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
+};
+
+static const uint8_t dequant4_coeff_init[6][3] = {
+ { 10, 13, 16 },
+ { 11, 14, 18 },
+ { 13, 16, 20 },
+ { 14, 18, 23 },
+ { 16, 20, 25 },
+ { 18, 23, 29 },
+};
+
+static const uint8_t dequant8_coeff_init_scan[16] = {
+ 0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1
+};
+
+static const uint8_t dequant8_coeff_init[6][6] = {
+ { 20, 18, 32, 19, 25, 24 },
+ { 22, 19, 35, 21, 28, 26 },
+ { 26, 23, 42, 24, 33, 31 },
+ { 28, 25, 45, 26, 35, 33 },
+ { 32, 28, 51, 30, 40, 38 },
+ { 36, 32, 58, 34, 46, 43 },
+};
+
+static const enum AVPixelFormat h264_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_H264_DXVA2_HWACCEL
+ AV_PIX_FMT_DXVA2_VLD,
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+ AV_PIX_FMT_VAAPI_VLD,
+#endif
+#if CONFIG_H264_VDA_HWACCEL
+ AV_PIX_FMT_VDA_VLD,
+ AV_PIX_FMT_VDA,
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+ AV_PIX_FMT_VDPAU,
+#endif
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+};
+
+static const enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[] = {
+#if CONFIG_H264_DXVA2_HWACCEL
+ AV_PIX_FMT_DXVA2_VLD,
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+ AV_PIX_FMT_VAAPI_VLD,
+#endif
+#if CONFIG_H264_VDA_HWACCEL
+ AV_PIX_FMT_VDA_VLD,
+ AV_PIX_FMT_VDA,
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+ AV_PIX_FMT_VDPAU,
+#endif
+ AV_PIX_FMT_YUVJ420P,
+ AV_PIX_FMT_NONE
+};
+
+
+static void release_unused_pictures(H264Context *h, int remove_current)
+{
+ int i;
+
+ /* release non reference frames */
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
+ if (h->DPB[i].f.buf[0] && !h->DPB[i].reference &&
+ (remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
+ ff_h264_unref_picture(h, &h->DPB[i]);
+ }
+ }
+}
+
+static int alloc_scratch_buffers(H264Context *h, int linesize)
+{
+ int alloc_size = FFALIGN(FFABS(linesize) + 32, 32);
+
+ if (h->bipred_scratchpad)
+ return 0;
+
+ h->bipred_scratchpad = av_malloc(16 * 6 * alloc_size);
+ // edge emu needs blocksize + filter length - 1
+ // (= 21x21 for h264)
+ h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 21);
+
+ if (!h->bipred_scratchpad || !h->edge_emu_buffer) {
+ av_freep(&h->bipred_scratchpad);
+ av_freep(&h->edge_emu_buffer);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+
+static int init_table_pools(H264Context *h)
+{
+ const int big_mb_num = h->mb_stride * (h->mb_height + 1) + 1;
+ const int mb_array_size = h->mb_stride * h->mb_height;
+ const int b4_stride = h->mb_width * 4 + 1;
+ const int b4_array_size = b4_stride * h->mb_height * 4;
+
+ h->qscale_table_pool = av_buffer_pool_init(big_mb_num + h->mb_stride,
+ av_buffer_allocz);
+ h->mb_type_pool = av_buffer_pool_init((big_mb_num + h->mb_stride) *
+ sizeof(uint32_t), av_buffer_allocz);
+ h->motion_val_pool = av_buffer_pool_init(2 * (b4_array_size + 4) *
+ sizeof(int16_t), av_buffer_allocz);
+ h->ref_index_pool = av_buffer_pool_init(4 * mb_array_size, av_buffer_allocz);
+
+ if (!h->qscale_table_pool || !h->mb_type_pool || !h->motion_val_pool ||
+ !h->ref_index_pool) {
+ av_buffer_pool_uninit(&h->qscale_table_pool);
+ av_buffer_pool_uninit(&h->mb_type_pool);
+ av_buffer_pool_uninit(&h->motion_val_pool);
+ av_buffer_pool_uninit(&h->ref_index_pool);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+
+static int alloc_picture(H264Context *h, H264Picture *pic)
+{
+ int i, ret = 0;
+
+ av_assert0(!pic->f.data[0]);
+
+ pic->tf.f = &pic->f;
+ ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
+ AV_GET_BUFFER_FLAG_REF : 0);
+ if (ret < 0)
+ goto fail;
+
+ h->linesize = pic->f.linesize[0];
+ h->uvlinesize = pic->f.linesize[1];
+ pic->crop = h->sps.crop;
+ pic->crop_top = h->sps.crop_top;
+ pic->crop_left= h->sps.crop_left;
+
+ if (h->avctx->hwaccel) {
+ const AVHWAccel *hwaccel = h->avctx->hwaccel;
+ av_assert0(!pic->hwaccel_picture_private);
+ if (hwaccel->frame_priv_data_size) {
+ pic->hwaccel_priv_buf = av_buffer_allocz(hwaccel->frame_priv_data_size);
+ if (!pic->hwaccel_priv_buf)
+ return AVERROR(ENOMEM);
+ pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
+ }
+ }
+ if (!h->avctx->hwaccel && CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY && pic->f.data[2]) {
+ int h_chroma_shift, v_chroma_shift;
+ av_pix_fmt_get_chroma_sub_sample(pic->f.format,
+ &h_chroma_shift, &v_chroma_shift);
+
+ for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
+ memset(pic->f.data[1] + pic->f.linesize[1]*i,
+ 0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
+ memset(pic->f.data[2] + pic->f.linesize[2]*i,
+ 0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
+ }
+ }
+
+ if (!h->qscale_table_pool) {
+ ret = init_table_pools(h);
+ if (ret < 0)
+ goto fail;
+ }
+
+ pic->qscale_table_buf = av_buffer_pool_get(h->qscale_table_pool);
+ pic->mb_type_buf = av_buffer_pool_get(h->mb_type_pool);
+ if (!pic->qscale_table_buf || !pic->mb_type_buf)
+ goto fail;
+
+ pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * h->mb_stride + 1;
+ pic->qscale_table = pic->qscale_table_buf->data + 2 * h->mb_stride + 1;
+
+ for (i = 0; i < 2; i++) {
+ pic->motion_val_buf[i] = av_buffer_pool_get(h->motion_val_pool);
+ pic->ref_index_buf[i] = av_buffer_pool_get(h->ref_index_pool);
+ if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
+ goto fail;
+
+ pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
+ pic->ref_index[i] = pic->ref_index_buf[i]->data;
+ }
+
+ return 0;
+fail:
+ ff_h264_unref_picture(h, pic);
+ return (ret < 0) ? ret : AVERROR(ENOMEM);
+}
+
+static inline int pic_is_unused(H264Context *h, H264Picture *pic)
+{
+ if (!pic->f.buf[0])
+ return 1;
+ if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
+ return 1;
+ return 0;
+}
+
+static int find_unused_picture(H264Context *h)
+{
+ int i;
+
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
+ if (pic_is_unused(h, &h->DPB[i]))
+ break;
+ }
+ if (i == H264_MAX_PICTURE_COUNT)
+ return AVERROR_INVALIDDATA;
+
+ if (h->DPB[i].needs_realloc) {
+ h->DPB[i].needs_realloc = 0;
+ ff_h264_unref_picture(h, &h->DPB[i]);
+ }
+
+ return i;
+}
+
+
+static void init_dequant8_coeff_table(H264Context *h)
+{
+ int i, j, q, x;
+ const int max_qp = 51 + 6 * (h->sps.bit_depth_luma - 8);
+
+ for (i = 0; i < 6; i++) {
+ h->dequant8_coeff[i] = h->dequant8_buffer[i];
+ for (j = 0; j < i; j++)
+ if (!memcmp(h->pps.scaling_matrix8[j], h->pps.scaling_matrix8[i],
+ 64 * sizeof(uint8_t))) {
+ h->dequant8_coeff[i] = h->dequant8_buffer[j];
+ break;
+ }
+ if (j < i)
+ continue;
+
+ for (q = 0; q < max_qp + 1; q++) {
+ int shift = div6[q];
+ int idx = rem6[q];
+ for (x = 0; x < 64; x++)
+ h->dequant8_coeff[i][q][(x >> 3) | ((x & 7) << 3)] =
+ ((uint32_t)dequant8_coeff_init[idx][dequant8_coeff_init_scan[((x >> 1) & 12) | (x & 3)]] *
+ h->pps.scaling_matrix8[i][x]) << shift;
+ }
+ }
+}
+
+static void init_dequant4_coeff_table(H264Context *h)
+{
+ int i, j, q, x;
+ const int max_qp = 51 + 6 * (h->sps.bit_depth_luma - 8);
+ for (i = 0; i < 6; i++) {
+ h->dequant4_coeff[i] = h->dequant4_buffer[i];
+ for (j = 0; j < i; j++)
+ if (!memcmp(h->pps.scaling_matrix4[j], h->pps.scaling_matrix4[i],
+ 16 * sizeof(uint8_t))) {
+ h->dequant4_coeff[i] = h->dequant4_buffer[j];
+ break;
+ }
+ if (j < i)
+ continue;
+
+ for (q = 0; q < max_qp + 1; q++) {
+ int shift = div6[q] + 2;
+ int idx = rem6[q];
+ for (x = 0; x < 16; x++)
+ h->dequant4_coeff[i][q][(x >> 2) | ((x << 2) & 0xF)] =
+ ((uint32_t)dequant4_coeff_init[idx][(x & 1) + ((x >> 2) & 1)] *
+ h->pps.scaling_matrix4[i][x]) << shift;
+ }
+ }
+}
+
+void h264_init_dequant_tables(H264Context *h)
+{
+ int i, x;
+ init_dequant4_coeff_table(h);
+ memset(h->dequant8_coeff, 0, sizeof(h->dequant8_coeff));
+
+ if (h->pps.transform_8x8_mode)
+ init_dequant8_coeff_table(h);
+ if (h->sps.transform_bypass) {
+ for (i = 0; i < 6; i++)
+ for (x = 0; x < 16; x++)
+ h->dequant4_coeff[i][0][x] = 1 << 6;
+ if (h->pps.transform_8x8_mode)
+ for (i = 0; i < 6; i++)
+ for (x = 0; x < 64; x++)
+ h->dequant8_coeff[i][0][x] = 1 << 6;
+ }
+}
+
+/**
+ * Mimic alloc_tables(), but for every context thread.
+ */
+static void clone_tables(H264Context *dst, H264Context *src, int i)
+{
+ dst->intra4x4_pred_mode = src->intra4x4_pred_mode + i * 8 * 2 * src->mb_stride;
+ dst->non_zero_count = src->non_zero_count;
+ dst->slice_table = src->slice_table;
+ dst->cbp_table = src->cbp_table;
+ dst->mb2b_xy = src->mb2b_xy;
+ dst->mb2br_xy = src->mb2br_xy;
+ dst->chroma_pred_mode_table = src->chroma_pred_mode_table;
+ dst->mvd_table[0] = src->mvd_table[0] + i * 8 * 2 * src->mb_stride;
+ dst->mvd_table[1] = src->mvd_table[1] + i * 8 * 2 * src->mb_stride;
+ dst->direct_table = src->direct_table;
+ dst->list_counts = src->list_counts;
+ dst->DPB = src->DPB;
+ dst->cur_pic_ptr = src->cur_pic_ptr;
+ dst->cur_pic = src->cur_pic;
+ dst->bipred_scratchpad = NULL;
+ dst->edge_emu_buffer = NULL;
+ ff_h264_pred_init(&dst->hpc, src->avctx->codec_id, src->sps.bit_depth_luma,
+ src->sps.chroma_format_idc);
+}
+
+#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b) + (size))))
+#undef REBASE_PICTURE
+#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
+ ((pic && pic >= old_ctx->DPB && \
+ pic < old_ctx->DPB + H264_MAX_PICTURE_COUNT) ? \
+ &new_ctx->DPB[pic - old_ctx->DPB] : NULL)
+
+static void copy_picture_range(H264Picture **to, H264Picture **from, int count,
+ H264Context *new_base,
+ H264Context *old_base)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ assert((IN_RANGE(from[i], old_base, sizeof(*old_base)) ||
+ IN_RANGE(from[i], old_base->DPB,
+ sizeof(H264Picture) * H264_MAX_PICTURE_COUNT) ||
+ !from[i]));
+ to[i] = REBASE_PICTURE(from[i], new_base, old_base);
+ }
+}
+
+static int copy_parameter_set(void **to, void **from, int count, int size)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (to[i] && !from[i]) {
+ av_freep(&to[i]);
+ } else if (from[i] && !to[i]) {
+ to[i] = av_malloc(size);
+ if (!to[i])
+ return AVERROR(ENOMEM);
+ }
+
+ if (from[i])
+ memcpy(to[i], from[i], size);
+ }
+
+ return 0;
+}
+
+#define copy_fields(to, from, start_field, end_field) \
+ memcpy(&to->start_field, &from->start_field, \
+ (char *)&to->end_field - (char *)&to->start_field)
+
+static int h264_slice_header_init(H264Context *h, int reinit);
+
+int ff_h264_update_thread_context(AVCodecContext *dst,
+ const AVCodecContext *src)
+{
+ H264Context *h = dst->priv_data, *h1 = src->priv_data;
+ int inited = h->context_initialized, err = 0;
+ int context_reinitialized = 0;
+ int i, ret;
+
+ if (dst == src)
+ return 0;
+
+ if (inited &&
+ (h->width != h1->width ||
+ h->height != h1->height ||
+ h->mb_width != h1->mb_width ||
+ h->mb_height != h1->mb_height ||
+ h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
+ h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
+ h->sps.colorspace != h1->sps.colorspace)) {
+
+ /* set bits_per_raw_sample to the previous value. the check for changed
+ * bit depth in h264_set_parameter_from_sps() uses it and sets it to
+ * the current value */
+ h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+
+ av_freep(&h->bipred_scratchpad);
+
+ h->width = h1->width;
+ h->height = h1->height;
+ h->mb_height = h1->mb_height;
+ h->mb_width = h1->mb_width;
+ h->mb_num = h1->mb_num;
+ h->mb_stride = h1->mb_stride;
+ h->b_stride = h1->b_stride;
+ // SPS/PPS
+ if ((ret = copy_parameter_set((void **)h->sps_buffers,
+ (void **)h1->sps_buffers,
+ MAX_SPS_COUNT, sizeof(SPS))) < 0)
+ return ret;
+ h->sps = h1->sps;
+ if ((ret = copy_parameter_set((void **)h->pps_buffers,
+ (void **)h1->pps_buffers,
+ MAX_PPS_COUNT, sizeof(PPS))) < 0)
+ return ret;
+ h->pps = h1->pps;
+
+ if ((err = h264_slice_header_init(h, 1)) < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
+ return err;
+ }
+ context_reinitialized = 1;
+
+#if 0
+ h264_set_parameter_from_sps(h);
+ //Note we set context_reinitialized which will cause h264_set_parameter_from_sps to be reexecuted
+ h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
+#endif
+ }
+ /* update linesize on resize for h264. The h264 decoder doesn't
+ * necessarily call ff_MPV_frame_start in the new thread */
+ h->linesize = h1->linesize;
+ h->uvlinesize = h1->uvlinesize;
+
+ /* copy block_offset since frame_start may not be called */
+ memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
+
+ if (!inited) {
+ for (i = 0; i < MAX_SPS_COUNT; i++)
+ av_freep(h->sps_buffers + i);
+
+ for (i = 0; i < MAX_PPS_COUNT; i++)
+ av_freep(h->pps_buffers + i);
+
+ av_freep(&h->rbsp_buffer[0]);
+ av_freep(&h->rbsp_buffer[1]);
+ memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));
+ memcpy(&h->cabac, &h1->cabac,
+ sizeof(H264Context) - offsetof(H264Context, cabac));
+ av_assert0((void*)&h->cabac == &h->mb_padding + 1);
+
+ memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
+ memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
+
+ memset(&h->er, 0, sizeof(h->er));
+ memset(&h->mb, 0, sizeof(h->mb));
+ memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
+ memset(&h->mb_padding, 0, sizeof(h->mb_padding));
+ memset(&h->cur_pic, 0, sizeof(h->cur_pic));
+
+ h->avctx = dst;
+ h->DPB = NULL;
+ h->qscale_table_pool = NULL;
+ h->mb_type_pool = NULL;
+ h->ref_index_pool = NULL;
+ h->motion_val_pool = NULL;
+ for (i = 0; i < 2; i++) {
+ h->rbsp_buffer[i] = NULL;
+ h->rbsp_buffer_size[i] = 0;
+ }
+
+ if (h1->context_initialized) {
+ h->context_initialized = 0;
+
+ memset(&h->cur_pic, 0, sizeof(h->cur_pic));
+ av_frame_unref(&h->cur_pic.f);
+ h->cur_pic.tf.f = &h->cur_pic.f;
+
+ ret = ff_h264_alloc_tables(h);
+ if (ret < 0) {
+ av_log(dst, AV_LOG_ERROR, "Could not allocate memory\n");
+ return ret;
+ }
+ ret = ff_h264_context_init(h);
+ if (ret < 0) {
+ av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
+ return ret;
+ }
+ }
+
+ h->bipred_scratchpad = NULL;
+ h->edge_emu_buffer = NULL;
+
+ h->thread_context[0] = h;
+ h->context_initialized = h1->context_initialized;
+ }
+
+ h->avctx->coded_height = h1->avctx->coded_height;
+ h->avctx->coded_width = h1->avctx->coded_width;
+ h->avctx->width = h1->avctx->width;
+ h->avctx->height = h1->avctx->height;
+ h->coded_picture_number = h1->coded_picture_number;
+ h->first_field = h1->first_field;
+ h->picture_structure = h1->picture_structure;
+ h->qscale = h1->qscale;
+ h->droppable = h1->droppable;
+ h->low_delay = h1->low_delay;
+
+ for (i = 0; h->DPB && i < H264_MAX_PICTURE_COUNT; i++) {
+ ff_h264_unref_picture(h, &h->DPB[i]);
+ if (h1->DPB && h1->DPB[i].f.buf[0] &&
+ (ret = ff_h264_ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
+ return ret;
+ }
+
+ h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
+ ff_h264_unref_picture(h, &h->cur_pic);
+ if (h1->cur_pic.f.buf[0] && (ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
+ return ret;
+
+ h->workaround_bugs = h1->workaround_bugs;
+ h->low_delay = h1->low_delay;
+ h->droppable = h1->droppable;
+
+ // extradata/NAL handling
+ h->is_avc = h1->is_avc;
+
+ // SPS/PPS
+ if ((ret = copy_parameter_set((void **)h->sps_buffers,
+ (void **)h1->sps_buffers,
+ MAX_SPS_COUNT, sizeof(SPS))) < 0)
+ return ret;
+ h->sps = h1->sps;
+ if ((ret = copy_parameter_set((void **)h->pps_buffers,
+ (void **)h1->pps_buffers,
+ MAX_PPS_COUNT, sizeof(PPS))) < 0)
+ return ret;
+ h->pps = h1->pps;
+
+ // Dequantization matrices
+ // FIXME these are big - can they be only copied when PPS changes?
+ copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
+
+ for (i = 0; i < 6; i++)
+ h->dequant4_coeff[i] = h->dequant4_buffer[0] +
+ (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
+
+ for (i = 0; i < 6; i++)
+ h->dequant8_coeff[i] = h->dequant8_buffer[0] +
+ (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
+
+ h->dequant_coeff_pps = h1->dequant_coeff_pps;
+
+ // POC timing
+ copy_fields(h, h1, poc_lsb, redundant_pic_count);
+
+ // reference lists
+ copy_fields(h, h1, short_ref, cabac_init_idc);
+
+ copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
+ copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
+ copy_picture_range(h->delayed_pic, h1->delayed_pic,
+ MAX_DELAYED_PIC_COUNT + 2, h, h1);
+
+ h->frame_recovered = h1->frame_recovered;
+
+ if (context_reinitialized)
+ ff_h264_set_parameter_from_sps(h);
+
+ if (!h->cur_pic_ptr)
+ return 0;
+
+ if (!h->droppable) {
+ err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
+ h->prev_poc_msb = h->poc_msb;
+ h->prev_poc_lsb = h->poc_lsb;
+ }
+ h->prev_frame_num_offset = h->frame_num_offset;
+ h->prev_frame_num = h->frame_num;
+ h->outputed_poc = h->next_outputed_poc;
+
+ h->recovery_frame = h1->recovery_frame;
+
+ return err;
+}
+
+static int h264_frame_start(H264Context *h)
+{
+ H264Picture *pic;
+ int i, ret;
+ const int pixel_shift = h->pixel_shift;
+ int c[4] = {
+ 1<<(h->sps.bit_depth_luma-1),
+ 1<<(h->sps.bit_depth_chroma-1),
+ 1<<(h->sps.bit_depth_chroma-1),
+ -1
+ };
+
+ if (!ff_thread_can_start_frame(h->avctx)) {
+ av_log(h->avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
+ return -1;
+ }
+
+ release_unused_pictures(h, 1);
+ h->cur_pic_ptr = NULL;
+
+ i = find_unused_picture(h);
+ if (i < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "no frame buffer available\n");
+ return i;
+ }
+ pic = &h->DPB[i];
+
+ pic->reference = h->droppable ? 0 : h->picture_structure;
+ pic->f.coded_picture_number = h->coded_picture_number++;
+ pic->field_picture = h->picture_structure != PICT_FRAME;
+
+ /*
+ * Zero key_frame here; IDR markings per slice in frame or fields are ORed
+ * in later.
+ * See decode_nal_units().
+ */
+ pic->f.key_frame = 0;
+ pic->mmco_reset = 0;
+ pic->recovered = 0;
+ pic->invalid_gap = 0;
+ pic->sei_recovery_frame_cnt = h->sei_recovery_frame_cnt;
+
+ if ((ret = alloc_picture(h, pic)) < 0)
+ return ret;
+ if(!h->frame_recovered && !h->avctx->hwaccel &&
+ !(h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU))
+ avpriv_color_frame(&pic->f, c);
+
+ h->cur_pic_ptr = pic;
+ ff_h264_unref_picture(h, &h->cur_pic);
+ if (CONFIG_ERROR_RESILIENCE) {
+ ff_h264_set_erpic(&h->er.cur_pic, NULL);
+ }
+
+ if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
+ return ret;
+
+ if (CONFIG_ERROR_RESILIENCE) {
+ ff_er_frame_start(&h->er);
+ ff_h264_set_erpic(&h->er.last_pic, NULL);
+ ff_h264_set_erpic(&h->er.next_pic, NULL);
+ }
+
+ assert(h->linesize && h->uvlinesize);
+
+ for (i = 0; i < 16; i++) {
+ h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
+ }
+ for (i = 0; i < 16; i++) {
+ h->block_offset[16 + i] =
+ h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
+ h->block_offset[48 + 16 + i] =
+ h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
+ }
+
+ /* We mark the current picture as non-reference after allocating it, so
+ * that if we break out due to an error it can be released automatically
+ * in the next ff_MPV_frame_start().
+ */
+ h->cur_pic_ptr->reference = 0;
+
+ h->cur_pic_ptr->field_poc[0] = h->cur_pic_ptr->field_poc[1] = INT_MAX;
+
+ h->next_output_pic = NULL;
+
+ assert(h->cur_pic_ptr->long_ref == 0);
+
+ return 0;
+}
+
+static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y,
+ uint8_t *src_cb, uint8_t *src_cr,
+ int linesize, int uvlinesize,
+ int simple)
+{
+ uint8_t *top_border;
+ int top_idx = 1;
+ const int pixel_shift = h->pixel_shift;
+ int chroma444 = CHROMA444(h);
+ int chroma422 = CHROMA422(h);
+
+ src_y -= linesize;
+ src_cb -= uvlinesize;
+ src_cr -= uvlinesize;
+
+ if (!simple && FRAME_MBAFF(h)) {
+ if (h->mb_y & 1) {
+ if (!MB_MBAFF(h)) {
+ top_border = h->top_borders[0][h->mb_x];
+ AV_COPY128(top_border, src_y + 15 * linesize);
+ if (pixel_shift)
+ AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
+ if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
+ if (chroma444) {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
+ AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
+ AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
+ AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
+ } else {
+ AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
+ AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
+ }
+ } else if (chroma422) {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
+ AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
+ } else {
+ AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
+ AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
+ }
+ } else {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
+ AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
+ } else {
+ AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
+ AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
+ }
+ }
+ }
+ }
+ } else if (MB_MBAFF(h)) {
+ top_idx = 0;
+ } else
+ return;
+ }
+
+ top_border = h->top_borders[top_idx][h->mb_x];
+ /* There are two lines saved, the line above the top macroblock
+ * of a pair, and the line above the bottom macroblock. */
+ AV_COPY128(top_border, src_y + 16 * linesize);
+ if (pixel_shift)
+ AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
+
+ if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
+ if (chroma444) {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 16 * linesize);
+ AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
+ AV_COPY128(top_border + 64, src_cr + 16 * linesize);
+ AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
+ } else {
+ AV_COPY128(top_border + 16, src_cb + 16 * linesize);
+ AV_COPY128(top_border + 32, src_cr + 16 * linesize);
+ }
+ } else if (chroma422) {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
+ AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
+ } else {
+ AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
+ AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
+ }
+ } else {
+ if (pixel_shift) {
+ AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
+ AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
+ } else {
+ AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
+ AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
+ }
+ }
+ }
+}
+
+/**
+ * Initialize implicit_weight table.
+ * @param field 0/1 initialize the weight for interlaced MBAFF
+ * -1 initializes the rest
+ */
+static void implicit_weight_table(H264Context *h, int field)
+{
+ int ref0, ref1, i, cur_poc, ref_start, ref_count0, ref_count1;
+
+ for (i = 0; i < 2; i++) {
+ h->luma_weight_flag[i] = 0;
+ h->chroma_weight_flag[i] = 0;
+ }
+
+ if (field < 0) {
+ if (h->picture_structure == PICT_FRAME) {
+ cur_poc = h->cur_pic_ptr->poc;
+ } else {
+ cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
+ }
+ if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
+ h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc) {
+ h->use_weight = 0;
+ h->use_weight_chroma = 0;
+ return;
+ }
+ ref_start = 0;
+ ref_count0 = h->ref_count[0];
+ ref_count1 = h->ref_count[1];
+ } else {
+ cur_poc = h->cur_pic_ptr->field_poc[field];
+ ref_start = 16;
+ ref_count0 = 16 + 2 * h->ref_count[0];
+ ref_count1 = 16 + 2 * h->ref_count[1];
+ }
+
+ h->use_weight = 2;
+ h->use_weight_chroma = 2;
+ h->luma_log2_weight_denom = 5;
+ h->chroma_log2_weight_denom = 5;
+
+ for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
+ int poc0 = h->ref_list[0][ref0].poc;
+ for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
+ int w = 32;
+ if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) {
+ int poc1 = h->ref_list[1][ref1].poc;
+ int td = av_clip(poc1 - poc0, -128, 127);
+ if (td) {
+ int tb = av_clip(cur_poc - poc0, -128, 127);
+ int tx = (16384 + (FFABS(td) >> 1)) / td;
+ int dist_scale_factor = (tb * tx + 32) >> 8;
+ if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
+ w = 64 - dist_scale_factor;
+ }
+ }
+ if (field < 0) {
+ h->implicit_weight[ref0][ref1][0] =
+ h->implicit_weight[ref0][ref1][1] = w;
+ } else {
+ h->implicit_weight[ref0][ref1][field] = w;
+ }
+ }
+ }
+}
+
+/**
+ * initialize scan tables
+ */
+static void init_scan_tables(H264Context *h)
+{
+ int i;
+ for (i = 0; i < 16; i++) {
+#define TRANSPOSE(x) (x >> 2) | ((x << 2) & 0xF)
+ h->zigzag_scan[i] = TRANSPOSE(zigzag_scan[i]);
+ h->field_scan[i] = TRANSPOSE(field_scan[i]);
+#undef TRANSPOSE
+ }
+ for (i = 0; i < 64; i++) {
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+ h->zigzag_scan8x8[i] = TRANSPOSE(ff_zigzag_direct[i]);
+ h->zigzag_scan8x8_cavlc[i] = TRANSPOSE(zigzag_scan8x8_cavlc[i]);
+ h->field_scan8x8[i] = TRANSPOSE(field_scan8x8[i]);
+ h->field_scan8x8_cavlc[i] = TRANSPOSE(field_scan8x8_cavlc[i]);
+#undef TRANSPOSE
+ }
+ if (h->sps.transform_bypass) { // FIXME same ugly
+ memcpy(h->zigzag_scan_q0 , zigzag_scan , sizeof(h->zigzag_scan_q0 ));
+ memcpy(h->zigzag_scan8x8_q0 , ff_zigzag_direct , sizeof(h->zigzag_scan8x8_q0 ));
+ memcpy(h->zigzag_scan8x8_cavlc_q0 , zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
+ memcpy(h->field_scan_q0 , field_scan , sizeof(h->field_scan_q0 ));
+ memcpy(h->field_scan8x8_q0 , field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
+ memcpy(h->field_scan8x8_cavlc_q0 , field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
+ } else {
+ memcpy(h->zigzag_scan_q0 , h->zigzag_scan , sizeof(h->zigzag_scan_q0 ));
+ memcpy(h->zigzag_scan8x8_q0 , h->zigzag_scan8x8 , sizeof(h->zigzag_scan8x8_q0 ));
+ memcpy(h->zigzag_scan8x8_cavlc_q0 , h->zigzag_scan8x8_cavlc , sizeof(h->zigzag_scan8x8_cavlc_q0));
+ memcpy(h->field_scan_q0 , h->field_scan , sizeof(h->field_scan_q0 ));
+ memcpy(h->field_scan8x8_q0 , h->field_scan8x8 , sizeof(h->field_scan8x8_q0 ));
+ memcpy(h->field_scan8x8_cavlc_q0 , h->field_scan8x8_cavlc , sizeof(h->field_scan8x8_cavlc_q0 ));
+ }
+}
+
+/**
+ * Replicate H264 "master" context to thread contexts.
+ */
+static int clone_slice(H264Context *dst, H264Context *src)
+{
+ memcpy(dst->block_offset, src->block_offset, sizeof(dst->block_offset));
+ dst->cur_pic_ptr = src->cur_pic_ptr;
+ dst->cur_pic = src->cur_pic;
+ dst->linesize = src->linesize;
+ dst->uvlinesize = src->uvlinesize;
+ dst->first_field = src->first_field;
+
+ dst->prev_poc_msb = src->prev_poc_msb;
+ dst->prev_poc_lsb = src->prev_poc_lsb;
+ dst->prev_frame_num_offset = src->prev_frame_num_offset;
+ dst->prev_frame_num = src->prev_frame_num;
+ dst->short_ref_count = src->short_ref_count;
+
+ memcpy(dst->short_ref, src->short_ref, sizeof(dst->short_ref));
+ memcpy(dst->long_ref, src->long_ref, sizeof(dst->long_ref));
+ memcpy(dst->default_ref_list, src->default_ref_list, sizeof(dst->default_ref_list));
+
+ memcpy(dst->dequant4_coeff, src->dequant4_coeff, sizeof(src->dequant4_coeff));
+ memcpy(dst->dequant8_coeff, src->dequant8_coeff, sizeof(src->dequant8_coeff));
+
+ return 0;
+}
+
+static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
+{
+ switch (h->sps.bit_depth_luma) {
+ case 9:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+ return AV_PIX_FMT_GBRP9;
+ } else
+ return AV_PIX_FMT_YUV444P9;
+ } else if (CHROMA422(h))
+ return AV_PIX_FMT_YUV422P9;
+ else
+ return AV_PIX_FMT_YUV420P9;
+ break;
+ case 10:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+ return AV_PIX_FMT_GBRP10;
+ } else
+ return AV_PIX_FMT_YUV444P10;
+ } else if (CHROMA422(h))
+ return AV_PIX_FMT_YUV422P10;
+ else
+ return AV_PIX_FMT_YUV420P10;
+ break;
+ case 12:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+ return AV_PIX_FMT_GBRP12;
+ } else
+ return AV_PIX_FMT_YUV444P12;
+ } else if (CHROMA422(h))
+ return AV_PIX_FMT_YUV422P12;
+ else
+ return AV_PIX_FMT_YUV420P12;
+ break;
+ case 14:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+ return AV_PIX_FMT_GBRP14;
+ } else
+ return AV_PIX_FMT_YUV444P14;
+ } else if (CHROMA422(h))
+ return AV_PIX_FMT_YUV422P14;
+ else
+ return AV_PIX_FMT_YUV420P14;
+ break;
+ case 8:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+ av_log(h->avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n");
+ return AV_PIX_FMT_GBR24P;
+ } else if (h->avctx->colorspace == AVCOL_SPC_YCGCO) {
+ av_log(h->avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
+ }
+ return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
+ : AV_PIX_FMT_YUV444P;
+ } else if (CHROMA422(h)) {
+ return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
+ : AV_PIX_FMT_YUV422P;
+ } else {
+ int i;
+ const enum AVPixelFormat * fmt = h->avctx->codec->pix_fmts ?
+ h->avctx->codec->pix_fmts :
+ h->avctx->color_range == AVCOL_RANGE_JPEG ?
+ h264_hwaccel_pixfmt_list_jpeg_420 :
+ h264_hwaccel_pixfmt_list_420;
+
+ for (i=0; fmt[i] != AV_PIX_FMT_NONE; i++)
+ if (fmt[i] == h->avctx->pix_fmt && !force_callback)
+ return fmt[i];
+ return ff_thread_get_format(h->avctx, fmt);
+ }
+ break;
+ default:
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Unsupported bit depth %d\n", h->sps.bit_depth_luma);
+ return AVERROR_INVALIDDATA;
+ }
+}
+
+/* export coded and cropped frame dimensions to AVCodecContext */
+static int init_dimensions(H264Context *h)
+{
+ int width = h->width - (h->sps.crop_right + h->sps.crop_left);
+ int height = h->height - (h->sps.crop_top + h->sps.crop_bottom);
+ av_assert0(h->sps.crop_right + h->sps.crop_left < (unsigned)h->width);
+ av_assert0(h->sps.crop_top + h->sps.crop_bottom < (unsigned)h->height);
+
+ /* handle container cropping */
+ if (!h->sps.crop &&
+ FFALIGN(h->avctx->width, 16) == h->width &&
+ FFALIGN(h->avctx->height, 16) == h->height) {
+ width = h->avctx->width;
+ height = h->avctx->height;
+ }
+
+ if (width <= 0 || height <= 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid cropped dimensions: %dx%d.\n",
+ width, height);
+ if (h->avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR_INVALIDDATA;
+
+ av_log(h->avctx, AV_LOG_WARNING, "Ignoring cropping information.\n");
+ h->sps.crop_bottom = h->sps.crop_top = h->sps.crop_right = h->sps.crop_left = 0;
+ h->sps.crop = 0;
+
+ width = h->width;
+ height = h->height;
+ }
+
+ h->avctx->coded_width = h->width;
+ h->avctx->coded_height = h->height;
+ h->avctx->width = width;
+ h->avctx->height = height;
+
+ return 0;
+}
+
+static int h264_slice_header_init(H264Context *h, int reinit)
+{
+ int nb_slices = (HAVE_THREADS &&
+ h->avctx->active_thread_type & FF_THREAD_SLICE) ?
+ h->avctx->thread_count : 1;
+ int i, ret;
+
+ h->avctx->sample_aspect_ratio = h->sps.sar;
+ av_assert0(h->avctx->sample_aspect_ratio.den);
+ av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
+ &h->chroma_x_shift, &h->chroma_y_shift);
+
+ if (h->sps.timing_info_present_flag) {
+ int64_t den = h->sps.time_scale;
+ if (h->x264_build < 44U)
+ den *= 2;
+ av_reduce(&h->avctx->time_base.num, &h->avctx->time_base.den,
+ h->sps.num_units_in_tick, den, 1 << 30);
+ }
+
+ if (reinit)
+ ff_h264_free_tables(h, 0);
+ h->first_field = 0;
+ h->prev_interlaced_frame = 1;
+
+ init_scan_tables(h);
+ ret = ff_h264_alloc_tables(h);
+ if (ret < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n");
+ return ret;
+ }
+
+ if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
+ int max_slices;
+ if (h->mb_height)
+ max_slices = FFMIN(H264_MAX_THREADS, h->mb_height);
+ else
+ max_slices = H264_MAX_THREADS;
+ av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
+ " reducing to %d\n", nb_slices, max_slices);
+ nb_slices = max_slices;
+ }
+ h->slice_context_count = nb_slices;
+
+ if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
+ ret = ff_h264_context_init(h);
+ if (ret < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
+ return ret;
+ }
+ } else {
+ for (i = 1; i < h->slice_context_count; i++) {
+ H264Context *c;
+ c = h->thread_context[i] = av_mallocz(sizeof(H264Context));
+ if (!c)
+ return AVERROR(ENOMEM);
+ c->avctx = h->avctx;
+ if (CONFIG_ERROR_RESILIENCE) {
+ c->dsp = h->dsp;
+ }
+ c->vdsp = h->vdsp;
+ c->h264dsp = h->h264dsp;
+ c->h264qpel = h->h264qpel;
+ c->h264chroma = h->h264chroma;
+ c->sps = h->sps;
+ c->pps = h->pps;
+ c->pixel_shift = h->pixel_shift;
+ c->cur_chroma_format_idc = h->cur_chroma_format_idc;
+ c->width = h->width;
+ c->height = h->height;
+ c->linesize = h->linesize;
+ c->uvlinesize = h->uvlinesize;
+ c->chroma_x_shift = h->chroma_x_shift;
+ c->chroma_y_shift = h->chroma_y_shift;
+ c->qscale = h->qscale;
+ c->droppable = h->droppable;
+ c->data_partitioning = h->data_partitioning;
+ c->low_delay = h->low_delay;
+ c->mb_width = h->mb_width;
+ c->mb_height = h->mb_height;
+ c->mb_stride = h->mb_stride;
+ c->mb_num = h->mb_num;
+ c->flags = h->flags;
+ c->workaround_bugs = h->workaround_bugs;
+ c->pict_type = h->pict_type;
+
+ init_scan_tables(c);
+ clone_tables(c, h, i);
+ c->context_initialized = 1;
+ }
+
+ for (i = 0; i < h->slice_context_count; i++)
+ if ((ret = ff_h264_context_init(h->thread_context[i])) < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
+ return ret;
+ }
+ }
+
+ h->context_initialized = 1;
+
+ return 0;
+}
+
+static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
+{
+ switch (a) {
+ case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
+ case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
+ case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
+ default:
+ return a;
+ }
+}
+
+/**
+ * Decode a slice header.
+ * This will (re)intialize the decoder and call h264_frame_start() as needed.
+ *
+ * @param h h264context
+ * @param h0 h264 master context (differs from 'h' when doing sliced based
+ * parallel decoding)
+ *
+ * @return 0 if okay, <0 if an error occurred, 1 if decoding must not be multithreaded
+ */
+int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
+{
+ unsigned int first_mb_in_slice;
+ unsigned int pps_id;
+ int ret;
+ unsigned int slice_type, tmp, i, j;
+ int last_pic_structure, last_pic_droppable;
+ int must_reinit;
+ int needs_reinit = 0;
+ int field_pic_flag, bottom_field_flag;
+
+ h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
+ h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
+
+ first_mb_in_slice = get_ue_golomb_long(&h->gb);
+
+ if (first_mb_in_slice == 0) { // FIXME better field boundary detection
+ if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
+ ff_h264_field_end(h, 1);
+ }
+
+ h0->current_slice = 0;
+ if (!h0->first_field) {
+ if (h->cur_pic_ptr && !h->droppable) {
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
+ h->picture_structure == PICT_BOTTOM_FIELD);
+ }
+ h->cur_pic_ptr = NULL;
+ }
+ }
+
+ slice_type = get_ue_golomb_31(&h->gb);
+ if (slice_type > 9) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "slice type %d too large at %d %d\n",
+ slice_type, h->mb_x, h->mb_y);
+ return AVERROR_INVALIDDATA;
+ }
+ if (slice_type > 4) {
+ slice_type -= 5;
+ h->slice_type_fixed = 1;
+ } else
+ h->slice_type_fixed = 0;
+
+ slice_type = golomb_to_pict_type[slice_type];
+ h->slice_type = slice_type;
+ h->slice_type_nos = slice_type & 3;
+
+ if (h->nal_unit_type == NAL_IDR_SLICE &&
+ h->slice_type_nos != AV_PICTURE_TYPE_I) {
+ av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ // to make a few old functions happy, it's wrong though
+ h->pict_type = h->slice_type;
+
+ pps_id = get_ue_golomb(&h->gb);
+ if (pps_id >= MAX_PPS_COUNT) {
+ av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
+ return AVERROR_INVALIDDATA;
+ }
+ if (!h0->pps_buffers[pps_id]) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "non-existing PPS %u referenced\n",
+ pps_id);
+ return AVERROR_INVALIDDATA;
+ }
+ if (h0->au_pps_id >= 0 && pps_id != h0->au_pps_id) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "PPS change from %d to %d forbidden\n",
+ h0->au_pps_id, pps_id);
+ return AVERROR_INVALIDDATA;
+ }
+ h->pps = *h0->pps_buffers[pps_id];
+
+ if (!h0->sps_buffers[h->pps.sps_id]) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "non-existing SPS %u referenced\n",
+ h->pps.sps_id);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (h->pps.sps_id != h->sps.sps_id ||
+ h->pps.sps_id != h->current_sps_id ||
+ h0->sps_buffers[h->pps.sps_id]->new) {
+
+ h->sps = *h0->sps_buffers[h->pps.sps_id];
+
+ if (h->mb_width != h->sps.mb_width ||
+ h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) ||
+ h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
+ h->cur_chroma_format_idc != h->sps.chroma_format_idc
+ )
+ needs_reinit = 1;
+
+ if (h->bit_depth_luma != h->sps.bit_depth_luma ||
+ h->chroma_format_idc != h->sps.chroma_format_idc) {
+ h->bit_depth_luma = h->sps.bit_depth_luma;
+ h->chroma_format_idc = h->sps.chroma_format_idc;
+ needs_reinit = 1;
+ }
+ if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
+ return ret;
+ }
+
+ h->avctx->profile = ff_h264_get_profile(&h->sps);
+ h->avctx->level = h->sps.level_idc;
+ h->avctx->refs = h->sps.ref_frame_count;
+
+ must_reinit = (h->context_initialized &&
+ ( 16*h->sps.mb_width != h->avctx->coded_width
+ || 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
+ || h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma
+ || h->cur_chroma_format_idc != h->sps.chroma_format_idc
+ || av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio)
+ || h->mb_width != h->sps.mb_width
+ || h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
+ ));
+ if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
+ must_reinit = 1;
+
+ h->mb_width = h->sps.mb_width;
+ h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
+ h->mb_num = h->mb_width * h->mb_height;
+ h->mb_stride = h->mb_width + 1;
+
+ h->b_stride = h->mb_width * 4;
+
+ h->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
+
+ h->width = 16 * h->mb_width;
+ h->height = 16 * h->mb_height;
+
+ ret = init_dimensions(h);
+ if (ret < 0)
+ return ret;
+
+ if (h->sps.video_signal_type_present_flag) {
+ h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
+ : AVCOL_RANGE_MPEG;
+ if (h->sps.colour_description_present_flag) {
+ if (h->avctx->colorspace != h->sps.colorspace)
+ needs_reinit = 1;
+ h->avctx->color_primaries = h->sps.color_primaries;
+ h->avctx->color_trc = h->sps.color_trc;
+ h->avctx->colorspace = h->sps.colorspace;
+ }
+ }
+
+ if (h->context_initialized &&
+ (must_reinit || needs_reinit)) {
+ if (h != h0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "changing width %d -> %d / height %d -> %d on "
+ "slice %d\n",
+ h->width, h->avctx->coded_width,
+ h->height, h->avctx->coded_height,
+ h0->current_slice + 1);
+ return AVERROR_INVALIDDATA;
+ }
+
+ ff_h264_flush_change(h);
+
+ if ((ret = get_pixel_format(h, 1)) < 0)
+ return ret;
+ h->avctx->pix_fmt = ret;
+
+ av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
+ "pix_fmt: %s\n", h->width, h->height, av_get_pix_fmt_name(h->avctx->pix_fmt));
+
+ if ((ret = h264_slice_header_init(h, 1)) < 0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "h264_slice_header_init() failed\n");
+ return ret;
+ }
+ }
+ if (!h->context_initialized) {
+ if (h != h0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Cannot (re-)initialize context during parallel decoding.\n");
+ return AVERROR_PATCHWELCOME;
+ }
+
+ if ((ret = get_pixel_format(h, 1)) < 0)
+ return ret;
+ h->avctx->pix_fmt = ret;
+
+ if ((ret = h264_slice_header_init(h, 0)) < 0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "h264_slice_header_init() failed\n");
+ return ret;
+ }
+ }
+
+ if (h == h0 && h->dequant_coeff_pps != pps_id) {
+ h->dequant_coeff_pps = pps_id;
+ h264_init_dequant_tables(h);
+ }
+
+ h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
+
+ h->mb_mbaff = 0;
+ h->mb_aff_frame = 0;
+ last_pic_structure = h0->picture_structure;
+ last_pic_droppable = h0->droppable;
+ h->droppable = h->nal_ref_idc == 0;
+ if (h->sps.frame_mbs_only_flag) {
+ h->picture_structure = PICT_FRAME;
+ } else {
+ if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
+ av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
+ return -1;
+ }
+ field_pic_flag = get_bits1(&h->gb);
+ if (field_pic_flag) {
+ bottom_field_flag = get_bits1(&h->gb);
+ h->picture_structure = PICT_TOP_FIELD + bottom_field_flag;
+ } else {
+ h->picture_structure = PICT_FRAME;
+ h->mb_aff_frame = h->sps.mb_aff;
+ }
+ }
+ h->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
+
+ if (h0->current_slice != 0) {
+ if (last_pic_structure != h->picture_structure ||
+ last_pic_droppable != h->droppable) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Changing field mode (%d -> %d) between slices is not allowed\n",
+ last_pic_structure, h->picture_structure);
+ h->picture_structure = last_pic_structure;
+ h->droppable = last_pic_droppable;
+ return AVERROR_INVALIDDATA;
+ } else if (!h0->cur_pic_ptr) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "unset cur_pic_ptr on slice %d\n",
+ h0->current_slice + 1);
+ return AVERROR_INVALIDDATA;
+ }
+ } else {
+ /* Shorten frame num gaps so we don't have to allocate reference
+ * frames just to throw them away */
+ if (h->frame_num != h->prev_frame_num) {
+ int unwrap_prev_frame_num = h->prev_frame_num;
+ int max_frame_num = 1 << h->sps.log2_max_frame_num;
+
+ if (unwrap_prev_frame_num > h->frame_num)
+ unwrap_prev_frame_num -= max_frame_num;
+
+ if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
+ unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
+ if (unwrap_prev_frame_num < 0)
+ unwrap_prev_frame_num += max_frame_num;
+
+ h->prev_frame_num = unwrap_prev_frame_num;
+ }
+ }
+
+ /* See if we have a decoded first field looking for a pair...
+ * Here, we're using that to see if we should mark previously
+ * decode frames as "finished".
+ * We have to do that before the "dummy" in-between frame allocation,
+ * since that can modify h->cur_pic_ptr. */
+ if (h0->first_field) {
+ assert(h0->cur_pic_ptr);
+ assert(h0->cur_pic_ptr->f.buf[0]);
+ assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
+
+ /* Mark old field/frame as completed */
+ if (h0->cur_pic_ptr->tf.owner == h0->avctx) {
+ ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
+ last_pic_structure == PICT_BOTTOM_FIELD);
+ }
+
+ /* figure out if we have a complementary field pair */
+ if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
+ /* Previous field is unmatched. Don't display it, but let it
+ * remain for reference if marked as such. */
+ if (last_pic_structure != PICT_FRAME) {
+ ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
+ last_pic_structure == PICT_TOP_FIELD);
+ }
+ } else {
+ if (h0->cur_pic_ptr->frame_num != h->frame_num) {
+ /* This and previous field were reference, but had
+ * different frame_nums. Consider this field first in
+ * pair. Throw away previous field except for reference
+ * purposes. */
+ if (last_pic_structure != PICT_FRAME) {
+ ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
+ last_pic_structure == PICT_TOP_FIELD);
+ }
+ } else {
+ /* Second field in complementary pair */
+ if (!((last_pic_structure == PICT_TOP_FIELD &&
+ h->picture_structure == PICT_BOTTOM_FIELD) ||
+ (last_pic_structure == PICT_BOTTOM_FIELD &&
+ h->picture_structure == PICT_TOP_FIELD))) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Invalid field mode combination %d/%d\n",
+ last_pic_structure, h->picture_structure);
+ h->picture_structure = last_pic_structure;
+ h->droppable = last_pic_droppable;
+ return AVERROR_INVALIDDATA;
+ } else if (last_pic_droppable != h->droppable) {
+ avpriv_request_sample(h->avctx,
+ "Found reference and non-reference fields in the same frame, which");
+ h->picture_structure = last_pic_structure;
+ h->droppable = last_pic_droppable;
+ return AVERROR_PATCHWELCOME;
+ }
+ }
+ }
+ }
+
+ while (h->frame_num != h->prev_frame_num && !h0->first_field &&
+ h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
+ H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
+ av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
+ h->frame_num, h->prev_frame_num);
+ if (!h->sps.gaps_in_frame_num_allowed_flag)
+ for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
+ h->last_pocs[i] = INT_MIN;
+ ret = h264_frame_start(h);
+ if (ret < 0) {
+ h0->first_field = 0;
+ return ret;
+ }
+
+ h->prev_frame_num++;
+ h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
+ h->cur_pic_ptr->frame_num = h->prev_frame_num;
+ h->cur_pic_ptr->invalid_gap = !h->sps.gaps_in_frame_num_allowed_flag;
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
+ ret = ff_generate_sliding_window_mmcos(h, 1);
+ if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
+ return ret;
+ ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
+ if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
+ return ret;
+ /* Error concealment: If a ref is missing, copy the previous ref
+ * in its place.
+ * FIXME: Avoiding a memcpy would be nice, but ref handling makes
+ * many assumptions about there being no actual duplicates.
+ * FIXME: This does not copy padding for out-of-frame motion
+ * vectors. Given we are concealing a lost frame, this probably
+ * is not noticeable by comparison, but it should be fixed. */
+ if (h->short_ref_count) {
+ if (prev) {
+ av_image_copy(h->short_ref[0]->f.data,
+ h->short_ref[0]->f.linesize,
+ (const uint8_t **)prev->f.data,
+ prev->f.linesize,
+ h->avctx->pix_fmt,
+ h->mb_width * 16,
+ h->mb_height * 16);
+ h->short_ref[0]->poc = prev->poc + 2;
+ }
+ h->short_ref[0]->frame_num = h->prev_frame_num;
+ }
+ }
+
+ /* See if we have a decoded first field looking for a pair...
+ * We're using that to see whether to continue decoding in that
+ * frame, or to allocate a new one. */
+ if (h0->first_field) {
+ assert(h0->cur_pic_ptr);
+ assert(h0->cur_pic_ptr->f.buf[0]);
+ assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
+
+ /* figure out if we have a complementary field pair */
+ if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
+ /* Previous field is unmatched. Don't display it, but let it
+ * remain for reference if marked as such. */
+ h0->cur_pic_ptr = NULL;
+ h0->first_field = FIELD_PICTURE(h);
+ } else {
+ if (h0->cur_pic_ptr->frame_num != h->frame_num) {
+ ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
+ h0->picture_structure==PICT_BOTTOM_FIELD);
+ /* This and the previous field had different frame_nums.
+ * Consider this field first in pair. Throw away previous
+ * one except for reference purposes. */
+ h0->first_field = 1;
+ h0->cur_pic_ptr = NULL;
+ } else {
+ /* Second field in complementary pair */
+ h0->first_field = 0;
+ }
+ }
+ } else {
+ /* Frame or first field in a potentially complementary pair */
+ h0->first_field = FIELD_PICTURE(h);
+ }
+
+ if (!FIELD_PICTURE(h) || h0->first_field) {
+ if (h264_frame_start(h) < 0) {
+ h0->first_field = 0;
+ return AVERROR_INVALIDDATA;
+ }
+ } else {
+ release_unused_pictures(h, 0);
+ }
+ /* Some macroblocks can be accessed before they're available in case
+ * of lost slices, MBAFF or threading. */
+ if (FIELD_PICTURE(h)) {
+ for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
+ memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
+ } else {
+ memset(h->slice_table, -1,
+ (h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
+ }
+ h0->last_slice_type = -1;
+ }
+ if (h != h0 && (ret = clone_slice(h, h0)) < 0)
+ return ret;
+
+ /* can't be in alloc_tables because linesize isn't known there.
+ * FIXME: redo bipred weight to not require extra buffer? */
+ for (i = 0; i < h->slice_context_count; i++)
+ if (h->thread_context[i]) {
+ ret = alloc_scratch_buffers(h->thread_context[i], h->linesize);
+ if (ret < 0)
+ return ret;
+ }
+
+ h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
+
+ av_assert1(h->mb_num == h->mb_width * h->mb_height);
+ if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
+ first_mb_in_slice >= h->mb_num) {
+ av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
+ return AVERROR_INVALIDDATA;
+ }
+ h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
+ h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) <<
+ FIELD_OR_MBAFF_PICTURE(h);
+ if (h->picture_structure == PICT_BOTTOM_FIELD)
+ h->resync_mb_y = h->mb_y = h->mb_y + 1;
+ av_assert1(h->mb_y < h->mb_height);
+
+ if (h->picture_structure == PICT_FRAME) {
+ h->curr_pic_num = h->frame_num;
+ h->max_pic_num = 1 << h->sps.log2_max_frame_num;
+ } else {
+ h->curr_pic_num = 2 * h->frame_num + 1;
+ h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
+ }
+
+ if (h->nal_unit_type == NAL_IDR_SLICE)
+ get_ue_golomb(&h->gb); /* idr_pic_id */
+
+ if (h->sps.poc_type == 0) {
+ h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
+
+ if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
+ h->delta_poc_bottom = get_se_golomb(&h->gb);
+ }
+
+ if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
+ h->delta_poc[0] = get_se_golomb(&h->gb);
+
+ if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
+ h->delta_poc[1] = get_se_golomb(&h->gb);
+ }
+
+ ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
+
+ if (h->pps.redundant_pic_cnt_present)
+ h->redundant_pic_count = get_ue_golomb(&h->gb);
+
+ ret = ff_set_ref_count(h);
+ if (ret < 0)
+ return ret;
+
+ if (slice_type != AV_PICTURE_TYPE_I &&
+ (h0->current_slice == 0 ||
+ slice_type != h0->last_slice_type ||
+ memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
+
+ ff_h264_fill_default_ref_list(h);
+ }
+
+ if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
+ ret = ff_h264_decode_ref_pic_list_reordering(h);
+ if (ret < 0) {
+ h->ref_count[1] = h->ref_count[0] = 0;
+ return ret;
+ }
+ }
+
+ if ((h->pps.weighted_pred && h->slice_type_nos == AV_PICTURE_TYPE_P) ||
+ (h->pps.weighted_bipred_idc == 1 &&
+ h->slice_type_nos == AV_PICTURE_TYPE_B))
+ ff_pred_weight_table(h);
+ else if (h->pps.weighted_bipred_idc == 2 &&
+ h->slice_type_nos == AV_PICTURE_TYPE_B) {
+ implicit_weight_table(h, -1);
+ } else {
+ h->use_weight = 0;
+ for (i = 0; i < 2; i++) {
+ h->luma_weight_flag[i] = 0;
+ h->chroma_weight_flag[i] = 0;
+ }
+ }
+
+ // If frame-mt is enabled, only update mmco tables for the first slice
+ // in a field. Subsequent slices can temporarily clobber h->mmco_index
+ // or h->mmco, which will cause ref list mix-ups and decoding errors
+ // further down the line. This may break decoding if the first slice is
+ // corrupt, thus we only do this if frame-mt is enabled.
+ if (h->nal_ref_idc) {
+ ret = ff_h264_decode_ref_pic_marking(h0, &h->gb,
+ !(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
+ h0->current_slice == 0);
+ if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (FRAME_MBAFF(h)) {
+ ff_h264_fill_mbaff_ref_list(h);
+
+ if (h->pps.weighted_bipred_idc == 2 && h->slice_type_nos == AV_PICTURE_TYPE_B) {
+ implicit_weight_table(h, 0);
+ implicit_weight_table(h, 1);
+ }
+ }
+
+ if (h->slice_type_nos == AV_PICTURE_TYPE_B && !h->direct_spatial_mv_pred)
+ ff_h264_direct_dist_scale_factor(h);
+ ff_h264_direct_ref_list_init(h);
+
+ if (h->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
+ tmp = get_ue_golomb_31(&h->gb);
+ if (tmp > 2) {
+ av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
+ return AVERROR_INVALIDDATA;
+ }
+ h->cabac_init_idc = tmp;
+ }
+
+ h->last_qscale_diff = 0;
+ tmp = h->pps.init_qp + get_se_golomb(&h->gb);
+ if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
+ av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
+ return AVERROR_INVALIDDATA;
+ }
+ h->qscale = tmp;
+ h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale);
+ h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale);
+ // FIXME qscale / qp ... stuff
+ if (h->slice_type == AV_PICTURE_TYPE_SP)
+ get_bits1(&h->gb); /* sp_for_switch_flag */
+ if (h->slice_type == AV_PICTURE_TYPE_SP ||
+ h->slice_type == AV_PICTURE_TYPE_SI)
+ get_se_golomb(&h->gb); /* slice_qs_delta */
+
+ h->deblocking_filter = 1;
+ h->slice_alpha_c0_offset = 0;
+ h->slice_beta_offset = 0;
+ if (h->pps.deblocking_filter_parameters_present) {
+ tmp = get_ue_golomb_31(&h->gb);
+ if (tmp > 2) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "deblocking_filter_idc %u out of range\n", tmp);
+ return AVERROR_INVALIDDATA;
+ }
+ h->deblocking_filter = tmp;
+ if (h->deblocking_filter < 2)
+ h->deblocking_filter ^= 1; // 1<->0
+
+ if (h->deblocking_filter) {
+ h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
+ h->slice_beta_offset = get_se_golomb(&h->gb) * 2;
+ if (h->slice_alpha_c0_offset > 12 ||
+ h->slice_alpha_c0_offset < -12 ||
+ h->slice_beta_offset > 12 ||
+ h->slice_beta_offset < -12) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "deblocking filter parameters %d %d out of range\n",
+ h->slice_alpha_c0_offset, h->slice_beta_offset);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ }
+
+ if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
+ (h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
+ h->slice_type_nos != AV_PICTURE_TYPE_I) ||
+ (h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
+ h->slice_type_nos == AV_PICTURE_TYPE_B) ||
+ (h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
+ h->nal_ref_idc == 0))
+ h->deblocking_filter = 0;
+
+ if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
+ if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
+ /* Cheat slightly for speed:
+ * Do not bother to deblock across slices. */
+ h->deblocking_filter = 2;
+ } else {
+ h0->max_contexts = 1;
+ if (!h0->single_decode_warning) {
+ av_log(h->avctx, AV_LOG_INFO,
+ "Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
+ h0->single_decode_warning = 1;
+ }
+ if (h != h0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Deblocking switched inside frame.\n");
+ return 1;
+ }
+ }
+ }
+ h->qp_thresh = 15 -
+ FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
+ FFMAX3(0,
+ h->pps.chroma_qp_index_offset[0],
+ h->pps.chroma_qp_index_offset[1]) +
+ 6 * (h->sps.bit_depth_luma - 8);
+
+ h0->last_slice_type = slice_type;
+ memcpy(h0->last_ref_count, h0->ref_count, sizeof(h0->last_ref_count));
+ h->slice_num = ++h0->current_slice;
+
+ if (h->slice_num)
+ h0->slice_row[(h->slice_num-1)&(MAX_SLICES-1)]= h->resync_mb_y;
+ if ( h0->slice_row[h->slice_num&(MAX_SLICES-1)] + 3 >= h->resync_mb_y
+ && h0->slice_row[h->slice_num&(MAX_SLICES-1)] <= h->resync_mb_y
+ && h->slice_num >= MAX_SLICES) {
+ //in case of ASO this check needs to be updated depending on how we decide to assign slice numbers in this case
+ av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", h->slice_num, MAX_SLICES);
+ }
+
+ for (j = 0; j < 2; j++) {
+ int id_list[16];
+ int *ref2frm = h->ref2frm[h->slice_num & (MAX_SLICES - 1)][j];
+ for (i = 0; i < 16; i++) {
+ id_list[i] = 60;
+ if (j < h->list_count && i < h->ref_count[j] &&
+ h->ref_list[j][i].f.buf[0]) {
+ int k;
+ AVBuffer *buf = h->ref_list[j][i].f.buf[0]->buffer;
+ for (k = 0; k < h->short_ref_count; k++)
+ if (h->short_ref[k]->f.buf[0]->buffer == buf) {
+ id_list[i] = k;
+ break;
+ }
+ for (k = 0; k < h->long_ref_count; k++)
+ if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
+ id_list[i] = h->short_ref_count + k;
+ break;
+ }
+ }
+ }
+
+ ref2frm[0] =
+ ref2frm[1] = -1;
+ for (i = 0; i < 16; i++)
+ ref2frm[i + 2] = 4 * id_list[i] + (h->ref_list[j][i].reference & 3);
+ ref2frm[18 + 0] =
+ ref2frm[18 + 1] = -1;
+ for (i = 16; i < 48; i++)
+ ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
+ (h->ref_list[j][i].reference & 3);
+ }
+
+#if CONFIG_ERROR_RESILIENCE
+ if (h->ref_count[0]) ff_h264_set_erpic(&h->er.last_pic, &h->ref_list[0][0]);
+ if (h->ref_count[1]) ff_h264_set_erpic(&h->er.next_pic, &h->ref_list[1][0]);
+#endif
+
+ h->er.ref_count = h->ref_count[0];
+ h0->au_pps_id = pps_id;
+ h->sps.new =
+ h0->sps_buffers[h->pps.sps_id]->new = 0;
+ h->current_sps_id = h->pps.sps_id;
+
+ if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
+ av_log(h->avctx, AV_LOG_DEBUG,
+ "slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
+ h->slice_num,
+ (h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
+ first_mb_in_slice,
+ av_get_picture_type_char(h->slice_type),
+ h->slice_type_fixed ? " fix" : "",
+ h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
+ pps_id, h->frame_num,
+ h->cur_pic_ptr->field_poc[0],
+ h->cur_pic_ptr->field_poc[1],
+ h->ref_count[0], h->ref_count[1],
+ h->qscale,
+ h->deblocking_filter,
+ h->slice_alpha_c0_offset, h->slice_beta_offset,
+ h->use_weight,
+ h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
+ h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
+ }
+
+ return 0;
+}
+
+int ff_h264_get_slice_type(const H264Context *h)
+{
+ switch (h->slice_type) {
+ case AV_PICTURE_TYPE_P:
+ return 0;
+ case AV_PICTURE_TYPE_B:
+ return 1;
+ case AV_PICTURE_TYPE_I:
+ return 2;
+ case AV_PICTURE_TYPE_SP:
+ return 3;
+ case AV_PICTURE_TYPE_SI:
+ return 4;
+ default:
+ return AVERROR_INVALIDDATA;
+ }
+}
+
+static av_always_inline void fill_filter_caches_inter(H264Context *h,
+ int mb_type, int top_xy,
+ int left_xy[LEFT_MBS],
+ int top_type,
+ int left_type[LEFT_MBS],
+ int mb_xy, int list)
+{
+ int b_stride = h->b_stride;
+ int16_t(*mv_dst)[2] = &h->mv_cache[list][scan8[0]];
+ int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
+ if (IS_INTER(mb_type) || IS_DIRECT(mb_type)) {
+ if (USES_LIST(top_type, list)) {
+ const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
+ const int b8_xy = 4 * top_xy + 2;
+ int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
+ AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]);
+ ref_cache[0 - 1 * 8] =
+ ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]];
+ ref_cache[2 - 1 * 8] =
+ ref_cache[3 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 1]];
+ } else {
+ AV_ZERO128(mv_dst - 1 * 8);
+ AV_WN32A(&ref_cache[0 - 1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
+ }
+
+ if (!IS_INTERLACED(mb_type ^ left_type[LTOP])) {
+ if (USES_LIST(left_type[LTOP], list)) {
+ const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
+ const int b8_xy = 4 * left_xy[LTOP] + 1;
+ int (*ref2frm)[64] =(void*)( h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
+ AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]);
+ AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]);
+ AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]);
+ AV_COPY32(mv_dst - 1 + 24, h->cur_pic.motion_val[list][b_xy + b_stride * 3]);
+ ref_cache[-1 + 0] =
+ ref_cache[-1 + 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 0]];
+ ref_cache[-1 + 16] =
+ ref_cache[-1 + 24] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 1]];
+ } else {
+ AV_ZERO32(mv_dst - 1 + 0);
+ AV_ZERO32(mv_dst - 1 + 8);
+ AV_ZERO32(mv_dst - 1 + 16);
+ AV_ZERO32(mv_dst - 1 + 24);
+ ref_cache[-1 + 0] =
+ ref_cache[-1 + 8] =
+ ref_cache[-1 + 16] =
+ ref_cache[-1 + 24] = LIST_NOT_USED;
+ }
+ }
+ }
+
+ if (!USES_LIST(mb_type, list)) {
+ fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0, 0), 4);
+ AV_WN32A(&ref_cache[0 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
+ AV_WN32A(&ref_cache[1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
+ AV_WN32A(&ref_cache[2 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
+ AV_WN32A(&ref_cache[3 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
+ return;
+ }
+
+ {
+ int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
+ int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
+ uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101;
+ uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101;
+ AV_WN32A(&ref_cache[0 * 8], ref01);
+ AV_WN32A(&ref_cache[1 * 8], ref01);
+ AV_WN32A(&ref_cache[2 * 8], ref23);
+ AV_WN32A(&ref_cache[3 * 8], ref23);
+ }
+
+ {
+ int16_t(*mv_src)[2] = &h->cur_pic.motion_val[list][4 * h->mb_x + 4 * h->mb_y * b_stride];
+ AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
+ AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
+ AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
+ AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
+ }
+}
+
+/**
+ *
+ * @return non zero if the loop filter can be skipped
+ */
+static int fill_filter_caches(H264Context *h, int mb_type)
+{
+ const int mb_xy = h->mb_xy;
+ int top_xy, left_xy[LEFT_MBS];
+ int top_type, left_type[LEFT_MBS];
+ uint8_t *nnz;
+ uint8_t *nnz_cache;
+
+ top_xy = mb_xy - (h->mb_stride << MB_FIELD(h));
+
+ /* Wow, what a mess, why didn't they simplify the interlacing & intra
+ * stuff, I can't imagine that these complex rules are worth it. */
+
+ left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1;
+ if (FRAME_MBAFF(h)) {
+ const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]);
+ const int curr_mb_field_flag = IS_INTERLACED(mb_type);
+ if (h->mb_y & 1) {
+ if (left_mb_field_flag != curr_mb_field_flag)
+ left_xy[LTOP] -= h->mb_stride;
+ } else {
+ if (curr_mb_field_flag)
+ top_xy += h->mb_stride &
+ (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
+ if (left_mb_field_flag != curr_mb_field_flag)
+ left_xy[LBOT] += h->mb_stride;
+ }
+ }
+
+ h->top_mb_xy = top_xy;
+ h->left_mb_xy[LTOP] = left_xy[LTOP];
+ h->left_mb_xy[LBOT] = left_xy[LBOT];
+ {
+ /* For sufficiently low qp, filtering wouldn't do anything.
+ * This is a conservative estimate: could also check beta_offset
+ * and more accurate chroma_qp. */
+ int qp_thresh = h->qp_thresh; // FIXME strictly we should store qp_thresh for each mb of a slice
+ int qp = h->cur_pic.qscale_table[mb_xy];
+ if (qp <= qp_thresh &&
+ (left_xy[LTOP] < 0 ||
+ ((qp + h->cur_pic.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) &&
+ (top_xy < 0 ||
+ ((qp + h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
+ if (!FRAME_MBAFF(h))
+ return 1;
+ if ((left_xy[LTOP] < 0 ||
+ ((qp + h->cur_pic.qscale_table[left_xy[LBOT]] + 1) >> 1) <= qp_thresh) &&
+ (top_xy < h->mb_stride ||
+ ((qp + h->cur_pic.qscale_table[top_xy - h->mb_stride] + 1) >> 1) <= qp_thresh))
+ return 1;
+ }
+ }
+
+ top_type = h->cur_pic.mb_type[top_xy];
+ left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]];
+ left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]];
+ if (h->deblocking_filter == 2) {
+ if (h->slice_table[top_xy] != h->slice_num)
+ top_type = 0;
+ if (h->slice_table[left_xy[LBOT]] != h->slice_num)
+ left_type[LTOP] = left_type[LBOT] = 0;
+ } else {
+ if (h->slice_table[top_xy] == 0xFFFF)
+ top_type = 0;
+ if (h->slice_table[left_xy[LBOT]] == 0xFFFF)
+ left_type[LTOP] = left_type[LBOT] = 0;
+ }
+ h->top_type = top_type;
+ h->left_type[LTOP] = left_type[LTOP];
+ h->left_type[LBOT] = left_type[LBOT];
+
+ if (IS_INTRA(mb_type))
+ return 0;
+
+ fill_filter_caches_inter(h, mb_type, top_xy, left_xy,
+ top_type, left_type, mb_xy, 0);
+ if (h->list_count == 2)
+ fill_filter_caches_inter(h, mb_type, top_xy, left_xy,
+ top_type, left_type, mb_xy, 1);
+
+ nnz = h->non_zero_count[mb_xy];
+ nnz_cache = h->non_zero_count_cache;
+ AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
+ AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
+ AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
+ AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
+ h->cbp = h->cbp_table[mb_xy];
+
+ if (top_type) {
+ nnz = h->non_zero_count[top_xy];
+ AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
+ }
+
+ if (left_type[LTOP]) {
+ nnz = h->non_zero_count[left_xy[LTOP]];
+ nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
+ nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
+ nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
+ nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
+ }
+
+ /* CAVLC 8x8dct requires NNZ values for residual decoding that differ
+ * from what the loop filter needs */
+ if (!CABAC(h) && h->pps.transform_8x8_mode) {
+ if (IS_8x8DCT(top_type)) {
+ nnz_cache[4 + 8 * 0] =
+ nnz_cache[5 + 8 * 0] = (h->cbp_table[top_xy] & 0x4000) >> 12;
+ nnz_cache[6 + 8 * 0] =
+ nnz_cache[7 + 8 * 0] = (h->cbp_table[top_xy] & 0x8000) >> 12;
+ }
+ if (IS_8x8DCT(left_type[LTOP])) {
+ nnz_cache[3 + 8 * 1] =
+ nnz_cache[3 + 8 * 2] = (h->cbp_table[left_xy[LTOP]] & 0x2000) >> 12; // FIXME check MBAFF
+ }
+ if (IS_8x8DCT(left_type[LBOT])) {
+ nnz_cache[3 + 8 * 3] =
+ nnz_cache[3 + 8 * 4] = (h->cbp_table[left_xy[LBOT]] & 0x8000) >> 12; // FIXME check MBAFF
+ }
+
+ if (IS_8x8DCT(mb_type)) {
+ nnz_cache[scan8[0]] =
+ nnz_cache[scan8[1]] =
+ nnz_cache[scan8[2]] =
+ nnz_cache[scan8[3]] = (h->cbp & 0x1000) >> 12;
+
+ nnz_cache[scan8[0 + 4]] =
+ nnz_cache[scan8[1 + 4]] =
+ nnz_cache[scan8[2 + 4]] =
+ nnz_cache[scan8[3 + 4]] = (h->cbp & 0x2000) >> 12;
+
+ nnz_cache[scan8[0 + 8]] =
+ nnz_cache[scan8[1 + 8]] =
+ nnz_cache[scan8[2 + 8]] =
+ nnz_cache[scan8[3 + 8]] = (h->cbp & 0x4000) >> 12;
+
+ nnz_cache[scan8[0 + 12]] =
+ nnz_cache[scan8[1 + 12]] =
+ nnz_cache[scan8[2 + 12]] =
+ nnz_cache[scan8[3 + 12]] = (h->cbp & 0x8000) >> 12;
+ }
+ }
+
+ return 0;
+}
+
+static void loop_filter(H264Context *h, int start_x, int end_x)
+{
+ uint8_t *dest_y, *dest_cb, *dest_cr;
+ int linesize, uvlinesize, mb_x, mb_y;
+ const int end_mb_y = h->mb_y + FRAME_MBAFF(h);
+ const int old_slice_type = h->slice_type;
+ const int pixel_shift = h->pixel_shift;
+ const int block_h = 16 >> h->chroma_y_shift;
+
+ if (h->deblocking_filter) {
+ for (mb_x = start_x; mb_x < end_x; mb_x++)
+ for (mb_y = end_mb_y - FRAME_MBAFF(h); mb_y <= end_mb_y; mb_y++) {
+ int mb_xy, mb_type;
+ mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride;
+ h->slice_num = h->slice_table[mb_xy];
+ mb_type = h->cur_pic.mb_type[mb_xy];
+ h->list_count = h->list_counts[mb_xy];
+
+ if (FRAME_MBAFF(h))
+ h->mb_mbaff =
+ h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type);
+
+ h->mb_x = mb_x;
+ h->mb_y = mb_y;
+ dest_y = h->cur_pic.f.data[0] +
+ ((mb_x << pixel_shift) + mb_y * h->linesize) * 16;
+ dest_cb = h->cur_pic.f.data[1] +
+ (mb_x << pixel_shift) * (8 << CHROMA444(h)) +
+ mb_y * h->uvlinesize * block_h;
+ dest_cr = h->cur_pic.f.data[2] +
+ (mb_x << pixel_shift) * (8 << CHROMA444(h)) +
+ mb_y * h->uvlinesize * block_h;
+ // FIXME simplify above
+
+ if (MB_FIELD(h)) {
+ linesize = h->mb_linesize = h->linesize * 2;
+ uvlinesize = h->mb_uvlinesize = h->uvlinesize * 2;
+ if (mb_y & 1) { // FIXME move out of this function?
+ dest_y -= h->linesize * 15;
+ dest_cb -= h->uvlinesize * (block_h - 1);
+ dest_cr -= h->uvlinesize * (block_h - 1);
+ }
+ } else {
+ linesize = h->mb_linesize = h->linesize;
+ uvlinesize = h->mb_uvlinesize = h->uvlinesize;
+ }
+ backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize,
+ uvlinesize, 0);
+ if (fill_filter_caches(h, mb_type))
+ continue;
+ h->chroma_qp[0] = get_chroma_qp(h, 0, h->cur_pic.qscale_table[mb_xy]);
+ h->chroma_qp[1] = get_chroma_qp(h, 1, h->cur_pic.qscale_table[mb_xy]);
+
+ if (FRAME_MBAFF(h)) {
+ ff_h264_filter_mb(h, mb_x, mb_y, dest_y, dest_cb, dest_cr,
+ linesize, uvlinesize);
+ } else {
+ ff_h264_filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb,
+ dest_cr, linesize, uvlinesize);
+ }
+ }
+ }
+ h->slice_type = old_slice_type;
+ h->mb_x = end_x;
+ h->mb_y = end_mb_y - FRAME_MBAFF(h);
+ h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale);
+ h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale);
+}
+
+static void predict_field_decoding_flag(H264Context *h)
+{
+ const int mb_xy = h->mb_x + h->mb_y * h->mb_stride;
+ int mb_type = (h->slice_table[mb_xy - 1] == h->slice_num) ?
+ h->cur_pic.mb_type[mb_xy - 1] :
+ (h->slice_table[mb_xy - h->mb_stride] == h->slice_num) ?
+ h->cur_pic.mb_type[mb_xy - h->mb_stride] : 0;
+ h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0;
+}
+
+/**
+ * Draw edges and report progress for the last MB row.
+ */
+static void decode_finish_row(H264Context *h)
+{
+ int top = 16 * (h->mb_y >> FIELD_PICTURE(h));
+ int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h);
+ int height = 16 << FRAME_MBAFF(h);
+ int deblock_border = (16 + 4) << FRAME_MBAFF(h);
+
+ if (h->deblocking_filter) {
+ if ((top + height) >= pic_height)
+ height += deblock_border;
+ top -= deblock_border;
+ }
+
+ if (top >= pic_height || (top + height) < 0)
+ return;
+
+ height = FFMIN(height, pic_height - top);
+ if (top < 0) {
+ height = top + height;
+ top = 0;
+ }
+
+ ff_h264_draw_horiz_band(h, top, height);
+
+ if (h->droppable || h->er.error_occurred)
+ return;
+
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1,
+ h->picture_structure == PICT_BOTTOM_FIELD);
+}
+
+static void er_add_slice(H264Context *h, int startx, int starty,
+ int endx, int endy, int status)
+{
+ if (CONFIG_ERROR_RESILIENCE) {
+ ERContext *er = &h->er;
+
+ ff_er_add_slice(er, startx, starty, endx, endy, status);
+ }
+}
+
+static int decode_slice(struct AVCodecContext *avctx, void *arg)
+{
+ H264Context *h = *(void **)arg;
+ int lf_x_start = h->mb_x;
+
+ h->mb_skip_run = -1;
+
+ av_assert0(h->block_offset[15] == (4 * ((scan8[15] - scan8[0]) & 7) << h->pixel_shift) + 4 * h->linesize * ((scan8[15] - scan8[0]) >> 3));
+
+ h->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
+ avctx->codec_id != AV_CODEC_ID_H264 ||
+ (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY));
+
+ if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->er.error_status_table) {
+ const int start_i = av_clip(h->resync_mb_x + h->resync_mb_y * h->mb_width, 0, h->mb_num - 1);
+ if (start_i) {
+ int prev_status = h->er.error_status_table[h->er.mb_index2xy[start_i - 1]];
+ prev_status &= ~ VP_START;
+ if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
+ h->er.error_occurred = 1;
+ }
+ }
+
+ if (h->pps.cabac) {
+ /* realign */
+ align_get_bits(&h->gb);
+
+ /* init cabac */
+ ff_init_cabac_decoder(&h->cabac,
+ h->gb.buffer + get_bits_count(&h->gb) / 8,
+ (get_bits_left(&h->gb) + 7) / 8);
+
+ ff_h264_init_cabac_states(h);
+
+ for (;;) {
+ // START_TIMER
+ int ret = ff_h264_decode_mb_cabac(h);
+ int eos;
+ // STOP_TIMER("decode_mb_cabac")
+
+ if (ret >= 0)
+ ff_h264_hl_decode_mb(h);
+
+ // FIXME optimal? or let mb_decode decode 16x32 ?
+ if (ret >= 0 && FRAME_MBAFF(h)) {
+ h->mb_y++;
+
+ ret = ff_h264_decode_mb_cabac(h);
+
+ if (ret >= 0)
+ ff_h264_hl_decode_mb(h);
+ h->mb_y--;
+ }
+ eos = get_cabac_terminate(&h->cabac);
+
+ if ((h->workaround_bugs & FF_BUG_TRUNCATED) &&
+ h->cabac.bytestream > h->cabac.bytestream_end + 2) {
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
+ h->mb_y, ER_MB_END);
+ if (h->mb_x >= lf_x_start)
+ loop_filter(h, lf_x_start, h->mb_x + 1);
+ return 0;
+ }
+ if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
+ av_log(h->avctx, AV_LOG_DEBUG, "bytestream overread %"PTRDIFF_SPECIFIER"\n", h->cabac.bytestream_end - h->cabac.bytestream);
+ if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 4) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n",
+ h->mb_x, h->mb_y,
+ h->cabac.bytestream_end - h->cabac.bytestream);
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
+ h->mb_y, ER_MB_ERROR);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (++h->mb_x >= h->mb_width) {
+ loop_filter(h, lf_x_start, h->mb_x);
+ h->mb_x = lf_x_start = 0;
+ decode_finish_row(h);
+ ++h->mb_y;
+ if (FIELD_OR_MBAFF_PICTURE(h)) {
+ ++h->mb_y;
+ if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
+ predict_field_decoding_flag(h);
+ }
+ }
+
+ if (eos || h->mb_y >= h->mb_height) {
+ tprintf(h->avctx, "slice end %d %d\n",
+ get_bits_count(&h->gb), h->gb.size_in_bits);
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
+ h->mb_y, ER_MB_END);
+ if (h->mb_x > lf_x_start)
+ loop_filter(h, lf_x_start, h->mb_x);
+ return 0;
+ }
+ }
+ } else {
+ for (;;) {
+ int ret = ff_h264_decode_mb_cavlc(h);
+
+ if (ret >= 0)
+ ff_h264_hl_decode_mb(h);
+
+ // FIXME optimal? or let mb_decode decode 16x32 ?
+ if (ret >= 0 && FRAME_MBAFF(h)) {
+ h->mb_y++;
+ ret = ff_h264_decode_mb_cavlc(h);
+
+ if (ret >= 0)
+ ff_h264_hl_decode_mb(h);
+ h->mb_y--;
+ }
+
+ if (ret < 0) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "error while decoding MB %d %d\n", h->mb_x, h->mb_y);
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
+ h->mb_y, ER_MB_ERROR);
+ return ret;
+ }
+
+ if (++h->mb_x >= h->mb_width) {
+ loop_filter(h, lf_x_start, h->mb_x);
+ h->mb_x = lf_x_start = 0;
+ decode_finish_row(h);
+ ++h->mb_y;
+ if (FIELD_OR_MBAFF_PICTURE(h)) {
+ ++h->mb_y;
+ if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
+ predict_field_decoding_flag(h);
+ }
+ if (h->mb_y >= h->mb_height) {
+ tprintf(h->avctx, "slice end %d %d\n",
+ get_bits_count(&h->gb), h->gb.size_in_bits);
+
+ if ( get_bits_left(&h->gb) == 0
+ || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
+ h->mb_x - 1, h->mb_y,
+ ER_MB_END);
+
+ return 0;
+ } else {
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
+ h->mb_x, h->mb_y,
+ ER_MB_END);
+
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ }
+
+ if (get_bits_left(&h->gb) <= 0 && h->mb_skip_run <= 0) {
+ tprintf(h->avctx, "slice end %d %d\n",
+ get_bits_count(&h->gb), h->gb.size_in_bits);
+
+ if (get_bits_left(&h->gb) == 0) {
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y,
+ h->mb_x - 1, h->mb_y,
+ ER_MB_END);
+ if (h->mb_x > lf_x_start)
+ loop_filter(h, lf_x_start, h->mb_x);
+
+ return 0;
+ } else {
+ er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
+ h->mb_y, ER_MB_ERROR);
+
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Call decode_slice() for each context.
+ *
+ * @param h h264 master context
+ * @param context_count number of contexts to execute
+ */
+int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
+{
+ AVCodecContext *const avctx = h->avctx;
+ H264Context *hx;
+ int i;
+
+ av_assert0(h->mb_y < h->mb_height);
+
+ if (h->avctx->hwaccel ||
+ h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
+ return 0;
+ if (context_count == 1) {
+ return decode_slice(avctx, &h);
+ } else {
+ av_assert0(context_count > 0);
+ for (i = 1; i < context_count; i++) {
+ hx = h->thread_context[i];
+ if (CONFIG_ERROR_RESILIENCE) {
+ hx->er.error_count = 0;
+ }
+ hx->x264_build = h->x264_build;
+ }
+
+ avctx->execute(avctx, decode_slice, h->thread_context,
+ NULL, context_count, sizeof(void *));
+
+ /* pull back stuff from slices to master context */
+ hx = h->thread_context[context_count - 1];
+ h->mb_x = hx->mb_x;
+ h->mb_y = hx->mb_y;
+ h->droppable = hx->droppable;
+ h->picture_structure = hx->picture_structure;
+ if (CONFIG_ERROR_RESILIENCE) {
+ for (i = 1; i < context_count; i++)
+ h->er.error_count += h->thread_context[i]->er.error_count;
+ }
+ }
+
+ return 0;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264chroma.c b/chromium/third_party/ffmpeg/libavcodec/h264chroma.c
index 5f8ed9193b0..5b3e13bdacf 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264chroma.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264chroma.c
@@ -46,6 +46,8 @@ av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
SET_CHROMA(8);
}
+ if (ARCH_AARCH64)
+ ff_h264chroma_init_aarch64(c, bit_depth);
if (ARCH_ARM)
ff_h264chroma_init_arm(c, bit_depth);
if (ARCH_PPC)
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264chroma.h b/chromium/third_party/ffmpeg/libavcodec/h264chroma.h
index 45bbc7d35e6..d4b8a0eb0ef 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264chroma.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264chroma.h
@@ -30,6 +30,7 @@ typedef struct H264ChromaContext {
void ff_h264chroma_init(H264ChromaContext *c, int bit_depth);
+void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth);
void ff_h264chroma_init_arm(H264ChromaContext *c, int bit_depth);
void ff_h264chroma_init_ppc(H264ChromaContext *c, int bit_depth);
void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264chroma_template.c b/chromium/third_party/ffmpeg/libavcodec/h264chroma_template.c
index b64172aadfd..072b5e03f75 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264chroma_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264chroma_template.c
@@ -42,7 +42,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
- }else{\
+ } else if (B + C) {\
const int E= B+C;\
const int step= C ? stride : 1;\
for(i=0; i<h; i++){\
@@ -50,6 +50,12 @@ static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
+ } else {\
+ for(i=0; i<h; i++){\
+ OP(dst[0], (A*src[0]));\
+ dst+= stride;\
+ src+= stride;\
+ }\
}\
}\
static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
@@ -71,7 +77,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
- }else{\
+ } else if (B + C) {\
const int E= B+C;\
const int step= C ? stride : 1;\
for(i=0; i<h; i++){\
@@ -80,6 +86,13 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
+ } else {\
+ for ( i = 0; i < h; i++){\
+ OP(dst[0], A * src[0]);\
+ OP(dst[1], A * src[1]);\
+ dst += stride;\
+ src += stride;\
+ }\
}\
}\
\
@@ -104,7 +117,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
- }else{\
+ } else if (B + C) {\
const int E= B+C;\
const int step= C ? stride : 1;\
for(i=0; i<h; i++){\
@@ -115,6 +128,15 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
+ } else {\
+ for ( i = 0; i < h; i++){\
+ OP(dst[0], A * src[0]);\
+ OP(dst[1], A * src[1]);\
+ OP(dst[2], A * src[2]);\
+ OP(dst[3], A * src[3]);\
+ dst += stride;\
+ src += stride;\
+ }\
}\
}\
\
@@ -143,7 +165,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
- }else{\
+ } else if (B + C) {\
const int E= B+C;\
const int step= C ? stride : 1;\
for(i=0; i<h; i++){\
@@ -158,6 +180,19 @@ static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *
dst+= stride;\
src+= stride;\
}\
+ } else {\
+ for ( i = 0; i < h; i++){\
+ OP(dst[0], A * src[0]);\
+ OP(dst[1], A * src[1]);\
+ OP(dst[2], A * src[2]);\
+ OP(dst[3], A * src[3]);\
+ OP(dst[4], A * src[4]);\
+ OP(dst[5], A * src[5]);\
+ OP(dst[6], A * src[6]);\
+ OP(dst[7], A * src[7]);\
+ dst += stride;\
+ src += stride;\
+ }\
}\
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264data.h b/chromium/third_party/ffmpeg/libavcodec/h264data.h
index eb229f3f4d8..38f32583f60 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264data.h
@@ -32,7 +32,6 @@
#include <stdint.h>
#include "libavutil/rational.h"
-#include "mpegvideo.h"
#include "h264.h"
static const uint8_t golomb_to_pict_type[5] = {
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264dsp.c b/chromium/third_party/ffmpeg/libavcodec/h264dsp.c
index 1606e116b68..a4da7764ed4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264dsp.c
@@ -33,6 +33,7 @@
#include "avcodec.h"
#include "h264dsp.h"
#include "h264idct.h"
+#include "startcode.h"
#include "libavutil/common.h"
#define BIT_DEPTH 8
@@ -63,34 +64,6 @@
#include "h264addpx_template.c"
#undef BIT_DEPTH
-static int h264_find_start_code_candidate_c(const uint8_t *buf, int size)
-{
- int i = 0;
-#if HAVE_FAST_UNALIGNED
- /* we check i < size instead of i + 3 / 7 because it is
- * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE
- * bytes at the end.
- */
-# if HAVE_FAST_64BIT
- while (i < size &&
- !((~*(const uint64_t *)(buf + i) &
- (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) &
- 0x8080808080808080ULL))
- i += 8;
-# else
- while (i < size &&
- !((~*(const uint32_t *)(buf + i) &
- (*(const uint32_t *)(buf + i) - 0x01010101U)) &
- 0x80808080U))
- i += 4;
-# endif
-#endif
- for (; i < size; i++)
- if (!buf[i])
- break;
- return i;
-}
-
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
@@ -114,13 +87,13 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
else\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
@@ -141,20 +114,20 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
else\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
else\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
- if (chroma_format_idc == 1)\
+ if (chroma_format_idc <= 1)\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
@@ -178,8 +151,9 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
H264_DSP(8);
break;
}
- c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
+ c->h264_find_start_code_candidate = ff_startcode_find_candidate_c;
+ if (ARCH_AARCH64) ff_h264dsp_init_aarch64(c, bit_depth, chroma_format_idc);
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264dsp.h b/chromium/third_party/ffmpeg/libavcodec/h264dsp.h
index 1be48041751..2a0139cdb3b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264dsp.h
@@ -118,6 +118,8 @@ typedef struct H264DSPContext {
void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc);
+void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
+ const int chroma_format_idc);
void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc);
void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264idct_template.c b/chromium/third_party/ffmpeg/libavcodec/h264idct_template.c
index 42c32d15eda..abf888ed960 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264idct_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264idct_template.c
@@ -28,6 +28,7 @@
#include "bit_depth_template.c"
#include "libavutil/common.h"
#include "h264.h"
+#include "h264idct.h"
void FUNCC(ff_h264_idct_add)(uint8_t *_dst, int16_t *_block, int stride)
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264pred.c b/chromium/third_party/ffmpeg/libavcodec/h264pred.c
index 3a96654e3c3..044fc90c4eb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264pred.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264pred.c
@@ -27,9 +27,9 @@
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
-#include "dsputil.h"
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
#include "h264pred.h"
-#include "avcodec.h" // for AV_CODEC_ID_*
#define BIT_DEPTH 8
#include "h264pred_template.c"
@@ -279,7 +279,7 @@ static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src,
static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright,
ptrdiff_t stride)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
uint8_t *top = src-stride;
int y;
@@ -305,7 +305,7 @@ static void pred16x16_plane_rv40_c(uint8_t *src, ptrdiff_t stride)
static void pred16x16_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
uint8_t *top = src-stride;
int y;
@@ -387,7 +387,7 @@ static void pred8x8_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
uint8_t *top = src-stride;
int y;
@@ -420,7 +420,7 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
#define H264_PRED(depth) \
if(codec_id != AV_CODEC_ID_RV40){\
- if(codec_id == AV_CODEC_ID_VP8) {\
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\
h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\
h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\
} else {\
@@ -435,15 +435,14 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
- if (codec_id == AV_CODEC_ID_VP8) {\
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\
h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_vp8);\
} else\
h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\
h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\
- if(codec_id != AV_CODEC_ID_VP8) {\
+ if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {\
h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\
h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
- h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
} else {\
h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\
h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\
@@ -451,6 +450,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\
h->pred4x4[HOR_VP8_PRED ]= FUNCC(pred4x4_horizontal , depth);\
}\
+ if (codec_id != AV_CODEC_ID_VP8)\
+ h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
}else{\
h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
@@ -482,23 +483,24 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
\
- if (chroma_format_idc == 1) {\
+ if (chroma_format_idc <= 1) {\
h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
} else {\
h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
}\
- if (codec_id != AV_CODEC_ID_VP8) {\
- if (chroma_format_idc == 1) {\
+ if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {\
+ if (chroma_format_idc <= 1) {\
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
} else {\
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\
}\
} else\
h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
- if(codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8){\
- if (chroma_format_idc == 1) {\
+ if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && \
+ codec_id != AV_CODEC_ID_VP8) {\
+ if (chroma_format_idc <= 1) {\
h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
@@ -519,12 +521,12 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\
h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\
h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\
- if (codec_id == AV_CODEC_ID_VP8) {\
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\
h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\
h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
}\
}\
- if (chroma_format_idc == 1) {\
+ if (chroma_format_idc <= 1) {\
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
} else {\
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
@@ -540,6 +542,7 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
case AV_CODEC_ID_RV40:\
h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\
break;\
+ case AV_CODEC_ID_VP7:\
case AV_CODEC_ID_VP8:\
h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\
h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\
@@ -558,7 +561,9 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
- if (chroma_format_idc == 1) {\
+ h->pred8x8l_filter_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_filter_add , depth);\
+ h->pred8x8l_filter_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_filter_add , depth);\
+ if (chroma_format_idc <= 1) {\
h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
} else {\
@@ -568,9 +573,6 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add , depth);\
h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\
- if(!chroma_format_idc)
- chroma_format_idc = 1;
-
switch (bit_depth) {
case 9:
H264_PRED(9)
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264pred.h b/chromium/third_party/ffmpeg/libavcodec/h264pred.h
index ed67d2ef43e..67082920487 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264pred.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264pred.h
@@ -60,7 +60,7 @@
#define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
///< (left col+cur col x2+right col) / 4;
///< this is the "unaveraged" one
-#define HOR_VP8_PRED 11 ///< unaveraged version of #HOR_PRED, see
+#define HOR_VP8_PRED 14 ///< unaveraged version of #HOR_PRED, see
///< #VERT_VP8_PRED for details
#define DC_127_PRED 12
#define DC_129_PRED 13
@@ -101,6 +101,8 @@ typedef struct H264PredContext {
int16_t *block /*align 16*/, ptrdiff_t stride);
void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/,
int16_t *block /*align 16*/, ptrdiff_t stride);
+ void(*pred8x8l_filter_add[2])(uint8_t *pix /*align 8*/,
+ int16_t *block /*align 16*/, int topleft, int topright, ptrdiff_t stride);
void(*pred8x8_add[3])(uint8_t *pix /*align 8*/,
const int *block_offset,
int16_t *block /*align 16*/, ptrdiff_t stride);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264pred_template.c b/chromium/third_party/ffmpeg/libavcodec/h264pred_template.c
index 8d8d62e0b6f..f684433abef 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264pred_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264pred_template.c
@@ -25,6 +25,8 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
+#include "libavutil/intreadwrite.h"
+
#include "mathops.h"
#include "bit_depth_template.c"
@@ -1122,6 +1124,79 @@ static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft,
SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
}
+
+static void FUNCC(pred8x8l_vertical_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
+ int has_topright, ptrdiff_t _stride)
+{
+ int i;
+ pixel *src = (pixel*)_src;
+ const dctcoef *block = (const dctcoef*)_block;
+ pixel pix[8];
+ int stride = _stride>>(sizeof(pixel)-1);
+ PREDICT_8x8_LOAD_TOP;
+
+ pix[0] = t0;
+ pix[1] = t1;
+ pix[2] = t2;
+ pix[3] = t3;
+ pix[4] = t4;
+ pix[5] = t5;
+ pix[6] = t6;
+ pix[7] = t7;
+
+ for(i=0; i<8; i++){
+ pixel v = pix[i];
+ src[0*stride]= v += block[0];
+ src[1*stride]= v += block[8];
+ src[2*stride]= v += block[16];
+ src[3*stride]= v += block[24];
+ src[4*stride]= v += block[32];
+ src[5*stride]= v += block[40];
+ src[6*stride]= v += block[48];
+ src[7*stride]= v + block[56];
+ src++;
+ block++;
+ }
+
+ memset(_block, 0, sizeof(dctcoef) * 64);
+}
+
+static void FUNCC(pred8x8l_horizontal_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
+ int has_topright, ptrdiff_t _stride)
+{
+ int i;
+ pixel *src = (pixel*)_src;
+ const dctcoef *block = (const dctcoef*)_block;
+ pixel pix[8];
+ int stride = _stride>>(sizeof(pixel)-1);
+ PREDICT_8x8_LOAD_LEFT;
+
+ pix[0] = l0;
+ pix[1] = l1;
+ pix[2] = l2;
+ pix[3] = l3;
+ pix[4] = l4;
+ pix[5] = l5;
+ pix[6] = l6;
+ pix[7] = l7;
+
+ for(i=0; i<8; i++){
+ pixel v = pix[i];
+ src[0]= v += block[0];
+ src[1]= v += block[1];
+ src[2]= v += block[2];
+ src[3]= v += block[3];
+ src[4]= v += block[4];
+ src[5]= v += block[5];
+ src[6]= v += block[6];
+ src[7]= v + block[7];
+ src+= stride;
+ block+= 8;
+ }
+
+ memset(_block, 0, sizeof(dctcoef) * 64);
+}
+
#undef PREDICT_8x8_LOAD_LEFT
#undef PREDICT_8x8_LOAD_TOP
#undef PREDICT_8x8_LOAD_TOPLEFT
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264qpel.c b/chromium/third_party/ffmpeg/libavcodec/h264qpel.c
index 7c86d2a2a94..5f1bfa31764 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264qpel.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264qpel.c
@@ -96,6 +96,8 @@ av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
break;
}
+ if (ARCH_AARCH64)
+ ff_h264qpel_init_aarch64(c, bit_depth);
if (ARCH_ARM)
ff_h264qpel_init_arm(c, bit_depth);
if (ARCH_PPC)
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264qpel.h b/chromium/third_party/ffmpeg/libavcodec/h264qpel.h
index 6abfac042c5..041ee7d14bf 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264qpel.h
+++ b/chromium/third_party/ffmpeg/libavcodec/h264qpel.h
@@ -31,6 +31,7 @@ typedef struct H264QpelContext {
void ff_h264qpel_init(H264QpelContext *c, int bit_depth);
+void ff_h264qpel_init_aarch64(H264QpelContext *c, int bit_depth);
void ff_h264qpel_init_arm(H264QpelContext *c, int bit_depth);
void ff_h264qpel_init_ppc(H264QpelContext *c, int bit_depth);
void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth);
diff --git a/chromium/third_party/ffmpeg/libavcodec/h264qpel_template.c b/chromium/third_party/ffmpeg/libavcodec/h264qpel_template.c
index 48eb8c874b8..cb421b53093 100644
--- a/chromium/third_party/ffmpeg/libavcodec/h264qpel_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/h264qpel_template.c
@@ -20,8 +20,11 @@
*/
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+
#include "bit_depth_template.c"
#include "hpel_template.c"
+#include "tpel_template.c"
static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc.c b/chromium/third_party/ffmpeg/libavcodec/hevc.c
index 4294760bb72..6fadef3d231 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc.c
@@ -30,6 +30,7 @@
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
#include "bytestream.h"
#include "cabac_functions.h"
@@ -37,9 +38,7 @@
#include "golomb.h"
#include "hevc.h"
-const uint8_t ff_hevc_qpel_extra_before[4] = { 0, 3, 3, 2 };
-const uint8_t ff_hevc_qpel_extra_after[4] = { 0, 3, 4, 4 };
-const uint8_t ff_hevc_qpel_extra[4] = { 0, 6, 7, 6 };
+const uint8_t ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 };
/**
* NOTE: Each function hls_foo correspond to the function foo in the
@@ -106,7 +105,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
goto fail;
s->cbf_luma = av_malloc(sps->min_tb_width * sps->min_tb_height);
- s->tab_ipm = av_malloc(min_pu_size);
+ s->tab_ipm = av_mallocz(min_pu_size);
s->is_pcm = av_malloc(min_pu_size);
if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
goto fail;
@@ -125,7 +124,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
goto fail;
s->tab_mvf_pool = av_buffer_pool_init(min_pu_size * sizeof(MvField),
- av_buffer_alloc);
+ av_buffer_allocz);
s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
av_buffer_allocz);
if (!s->tab_mvf_pool || !s->rpl_tab_pool)
@@ -150,7 +149,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
s->sh.luma_log2_weight_denom = get_ue_golomb_long(gb);
if (s->sps->chroma_format_idc != 0) {
int delta = get_se_golomb(gb);
- s->sh.chroma_log2_weight_denom = av_clip_c(s->sh.luma_log2_weight_denom + delta, 0, 7);
+ s->sh.chroma_log2_weight_denom = av_clip(s->sh.luma_log2_weight_denom + delta, 0, 7);
}
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
@@ -178,7 +177,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
int delta_chroma_weight_l0 = get_se_golomb(gb);
int delta_chroma_offset_l0 = get_se_golomb(gb);
s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
- s->sh.chroma_offset_l0[i][j] = av_clip_c((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
+ s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
}
} else {
@@ -214,7 +213,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
int delta_chroma_weight_l1 = get_se_golomb(gb);
int delta_chroma_offset_l1 = get_se_golomb(gb);
s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
- s->sh.chroma_offset_l1[i][j] = av_clip_c((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
+ s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
}
} else {
@@ -232,7 +231,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
const HEVCSPS *sps = s->sps;
int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
int prev_delta_msb = 0;
- int nb_sps = 0, nb_sh;
+ unsigned int nb_sps = 0, nb_sh;
int i;
rps->nb_refs = 0;
@@ -282,6 +281,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
static int set_sps(HEVCContext *s, const HEVCSPS *sps)
{
int ret;
+ unsigned int num = 0, den = 0;
pic_arrays_free(s);
ret = pic_arrays_init(s, sps);
@@ -326,6 +326,19 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
s->sps = sps;
s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data;
+
+ if (s->vps->vps_timing_info_present_flag) {
+ num = s->vps->vps_num_units_in_tick;
+ den = s->vps->vps_time_scale;
+ } else if (sps->vui.vui_timing_info_present_flag) {
+ num = sps->vui.vui_num_units_in_tick;
+ den = sps->vui.vui_time_scale;
+ }
+
+ if (num != 0 && den != 0)
+ av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den,
+ num, den, 1 << 30);
+
return 0;
fail:
@@ -334,6 +347,17 @@ fail:
return ret;
}
+static int is_sps_exist(HEVCContext *s, const HEVCSPS* last_sps)
+{
+ int i;
+
+ for( i = 0; i < MAX_SPS_COUNT; i++)
+ if(s->sps_list[i])
+ if (last_sps == (HEVCSPS*)s->sps_list[i]->data)
+ return 1;
+ return 0;
+}
+
static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
@@ -348,8 +372,11 @@ static int hls_slice_header(HEVCContext *s)
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
+ sh->no_output_of_prior_pics_flag = 0;
if (s->nal_unit_type >= 16 && s->nal_unit_type <= 23)
sh->no_output_of_prior_pics_flag = get_bits1(gb);
+ if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1)
+ sh->no_output_of_prior_pics_flag = 1;
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) {
@@ -364,7 +391,16 @@ static int hls_slice_header(HEVCContext *s)
s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data;
if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) {
+ const HEVCSPS* last_sps = s->sps;
s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data;
+ if (last_sps) {
+ if (is_sps_exist(s, last_sps)) {
+ if (s->sps->width != last_sps->width || s->sps->height != last_sps->height ||
+ s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering != last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
+ sh->no_output_of_prior_pics_flag = 0;
+ } else
+ sh->no_output_of_prior_pics_flag = 0;
+ }
ff_hevc_clear_refs(s);
ret = set_sps(s, s->sps);
if (ret < 0)
@@ -374,8 +410,8 @@ static int hls_slice_header(HEVCContext *s)
s->max_ra = INT_MAX;
}
- s->avctx->profile = s->sps->ptl.general_PTL.profile_idc;
- s->avctx->level = s->sps->ptl.general_PTL.level_idc;
+ s->avctx->profile = s->sps->ptl.general_ptl.profile_idc;
+ s->avctx->level = s->sps->ptl.general_ptl.level_idc;
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
@@ -423,6 +459,7 @@ static int hls_slice_header(HEVCContext *s)
return AVERROR_INVALIDDATA;
}
+ sh->pic_output_flag = 1;
if (s->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
@@ -582,6 +619,7 @@ static int hls_slice_header(HEVCContext *s)
}
sh->slice_qp_delta = get_se_golomb(gb);
+
if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
@@ -639,6 +677,11 @@ static int hls_slice_header(HEVCContext *s)
sh->entry_point_offset = av_malloc(sh->num_entry_point_offsets * sizeof(int));
sh->offset = av_malloc(sh->num_entry_point_offsets * sizeof(int));
sh->size = av_malloc(sh->num_entry_point_offsets * sizeof(int));
+ if (!sh->entry_point_offset || !sh->offset || !sh->size) {
+ sh->num_entry_point_offsets = 0;
+ av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
+ return AVERROR(ENOMEM);
+ }
for (i = 0; i < sh->num_entry_point_offsets; i++) {
int val = 0;
for (j = 0; j < segments; j++) {
@@ -661,20 +704,34 @@ static int hls_slice_header(HEVCContext *s)
}
if (s->pps->slice_header_extension_present_flag) {
- int length = get_ue_golomb_long(gb);
+ unsigned int length = get_ue_golomb_long(gb);
for (i = 0; i < length; i++)
skip_bits(gb, 8); // slice_header_extension_data_byte
}
// Inferred parameters
- sh->slice_qp = 26 + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
+ sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
+ if (sh->slice_qp > 51 ||
+ sh->slice_qp < -s->sps->qp_bd_offset) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "The slice_qp %d is outside the valid range "
+ "[%d, 51].\n",
+ sh->slice_qp,
+ -s->sps->qp_bd_offset);
+ return AVERROR_INVALIDDATA;
+ }
+
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
+ if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
+ av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->pps->cu_qp_delta_enabled_flag)
- s->HEVClc->qp_y = ((s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset) %
- (52 + s->sps->qp_bd_offset)) - s->sps->qp_bd_offset;
+ s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
@@ -766,10 +823,10 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
#undef SET_SAO
#undef CTB
-static void hls_transform_unit(HEVCContext *s, int x0, int y0,
- int xBase, int yBase, int cb_xBase, int cb_yBase,
- int log2_cb_size, int log2_trafo_size,
- int trafo_depth, int blk_idx)
+static int hls_transform_unit(HEVCContext *s, int x0, int y0,
+ int xBase, int yBase, int cb_xBase, int cb_yBase,
+ int log2_cb_size, int log2_trafo_size,
+ int trafo_depth, int blk_idx)
{
HEVCLocalContext *lc = s->HEVClc;
@@ -804,6 +861,18 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
if (ff_hevc_cu_qp_delta_sign_flag(s) == 1)
lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta;
lc->tu.is_cu_qp_delta_coded = 1;
+
+ if (lc->tu.cu_qp_delta < -(26 + s->sps->qp_bd_offset / 2) ||
+ lc->tu.cu_qp_delta > (25 + s->sps->qp_bd_offset / 2)) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "The cu_qp_delta %d is outside the valid range "
+ "[%d, %d].\n",
+ lc->tu.cu_qp_delta,
+ -(26 + s->sps->qp_bd_offset / 2),
+ (25 + s->sps->qp_bd_offset / 2));
+ return AVERROR_INVALIDDATA;
+ }
+
ff_hevc_set_qPy(s, x0, y0, cb_xBase, cb_yBase, log2_cb_size);
}
@@ -839,6 +908,7 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
ff_hevc_hls_residual_coding(s, xBase, yBase, log2_trafo_size, scan_idx_c, 2);
}
}
+ return 0;
}
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
@@ -856,13 +926,14 @@ static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_si
s->is_pcm[i + j * min_pu_width] = 2;
}
-static void hls_transform_tree(HEVCContext *s, int x0, int y0,
- int xBase, int yBase, int cb_xBase, int cb_yBase,
- int log2_cb_size, int log2_trafo_size,
- int trafo_depth, int blk_idx)
+static int hls_transform_tree(HEVCContext *s, int x0, int y0,
+ int xBase, int yBase, int cb_xBase, int cb_yBase,
+ int log2_cb_size, int log2_trafo_size,
+ int trafo_depth, int blk_idx)
{
HEVCLocalContext *lc = s->HEVClc;
uint8_t split_transform_flag;
+ int ret;
if (trafo_depth > 0 && log2_trafo_size == 2) {
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
@@ -917,14 +988,26 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
int x1 = x0 + ((1 << log2_trafo_size) >> 1);
int y1 = y0 + ((1 << log2_trafo_size) >> 1);
- hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
- log2_trafo_size - 1, trafo_depth + 1, 0);
- hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
- log2_trafo_size - 1, trafo_depth + 1, 1);
- hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
- log2_trafo_size - 1, trafo_depth + 1, 2);
- hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
- log2_trafo_size - 1, trafo_depth + 1, 3);
+ ret = hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase,
+ log2_cb_size, log2_trafo_size - 1,
+ trafo_depth + 1, 0);
+ if (ret < 0)
+ return ret;
+ ret = hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase,
+ log2_cb_size, log2_trafo_size - 1,
+ trafo_depth + 1, 1);
+ if (ret < 0)
+ return ret;
+ ret = hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase,
+ log2_cb_size, log2_trafo_size - 1,
+ trafo_depth + 1, 2);
+ if (ret < 0)
+ return ret;
+ ret = hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase,
+ log2_cb_size, log2_trafo_size - 1,
+ trafo_depth + 1, 3);
+ if (ret < 0)
+ return ret;
} else {
int min_tu_size = 1 << s->sps->log2_min_tb_size;
int log2_min_tu_size = s->sps->log2_min_tb_size;
@@ -936,9 +1019,11 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
lc->tt.cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth);
}
- hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
- log2_cb_size, log2_trafo_size, trafo_depth, blk_idx);
-
+ ret = hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
+ log2_cb_size, log2_trafo_size, trafo_depth,
+ blk_idx);
+ if (ret < 0)
+ return ret;
// TODO: store cbf_luma somewhere else
if (lc->tt.cbf_luma) {
int i, j;
@@ -950,20 +1035,18 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
}
}
if (!s->sh.disable_deblocking_filter_flag) {
- ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_trafo_size,
- lc->slice_or_tiles_up_boundary,
- lc->slice_or_tiles_left_boundary);
+ ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_trafo_size);
if (s->pps->transquant_bypass_enable_flag &&
lc->cu.cu_transquant_bypass_flag)
set_deblocking_bypass(s, x0, y0, log2_trafo_size);
}
}
+ return 0;
}
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
{
//TODO: non-4:2:0 support
- HEVCLocalContext *lc = s->HEVClc;
GetBitContext gb;
int cb_size = 1 << log2_cb_size;
int stride0 = s->frame->linesize[0];
@@ -977,9 +1060,8 @@ static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
const uint8_t *pcm = skip_bytes(&s->HEVClc->cc, (length + 7) >> 3);
int ret;
- ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
- lc->slice_or_tiles_up_boundary,
- lc->slice_or_tiles_left_boundary);
+ if (!s->sh.disable_deblocking_filter_flag)
+ ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size);
ret = init_get_bits(&gb, pcm, length);
if (ret < 0)
@@ -992,7 +1074,7 @@ static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
}
/**
- * 8.5.3.2.2.1 Luma sample interpolation process
+ * 8.5.3.2.2.1 Luma sample unidirectional interpolation process
*
* @param s HEVC decoding context
* @param dst target buffer for block data at block position
@@ -1003,45 +1085,148 @@ static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
* @param y_off vertical position of block from origin (0, 0)
* @param block_w width of block
* @param block_h height of block
+ * @param luma_weight weighting factor applied to the luma prediction
+ * @param luma_offset additive offset applied to the luma prediction value
*/
-static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride,
- AVFrame *ref, const Mv *mv, int x_off, int y_off,
- int block_w, int block_h)
+
+static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride,
+ AVFrame *ref, const Mv *mv, int x_off, int y_off,
+ int block_w, int block_h, int luma_weight, int luma_offset)
{
HEVCLocalContext *lc = s->HEVClc;
uint8_t *src = ref->data[0];
ptrdiff_t srcstride = ref->linesize[0];
int pic_width = s->sps->width;
int pic_height = s->sps->height;
-
- int mx = mv->x & 3;
- int my = mv->y & 3;
- int extra_left = ff_hevc_qpel_extra_before[mx];
- int extra_top = ff_hevc_qpel_extra_before[my];
+ int mx = mv->x & 3;
+ int my = mv->y & 3;
+ int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
+ (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag);
+ int idx = ff_hevc_pel_weight[block_w];
x_off += mv->x >> 2;
y_off += mv->y >> 2;
src += y_off * srcstride + (x_off << s->sps->pixel_shift);
- if (x_off < extra_left || y_off < extra_top ||
- x_off >= pic_width - block_w - ff_hevc_qpel_extra_after[mx] ||
- y_off >= pic_height - block_h - ff_hevc_qpel_extra_after[my]) {
- int offset = extra_top * srcstride + (extra_left << s->sps->pixel_shift);
+ if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
+ x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
+ y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
+ int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset,
- srcstride, srcstride,
- block_w + ff_hevc_qpel_extra[mx],
- block_h + ff_hevc_qpel_extra[my],
- x_off - extra_left, y_off - extra_top,
+ edge_emu_stride, srcstride,
+ block_w + QPEL_EXTRA,
+ block_h + QPEL_EXTRA,
+ x_off - QPEL_EXTRA_BEFORE, y_off - QPEL_EXTRA_BEFORE,
+ pic_width, pic_height);
+ src = lc->edge_emu_buffer + buf_offset;
+ srcstride = edge_emu_stride;
+ }
+
+ if (!weight_flag)
+ s->hevcdsp.put_hevc_qpel_uni[idx][!!my][!!mx](dst, dststride, src, srcstride,
+ block_h, mx, my, block_w);
+ else
+ s->hevcdsp.put_hevc_qpel_uni_w[idx][!!my][!!mx](dst, dststride, src, srcstride,
+ block_h, s->sh.luma_log2_weight_denom,
+ luma_weight, luma_offset, mx, my, block_w);
+}
+
+/**
+ * 8.5.3.2.2.1 Luma sample bidirectional interpolation process
+ *
+ * @param s HEVC decoding context
+ * @param dst target buffer for block data at block position
+ * @param dststride stride of the dst buffer
+ * @param ref0 reference picture0 buffer at origin (0, 0)
+ * @param mv0 motion vector0 (relative to block position) to get pixel data from
+ * @param x_off horizontal position of block from origin (0, 0)
+ * @param y_off vertical position of block from origin (0, 0)
+ * @param block_w width of block
+ * @param block_h height of block
+ * @param ref1 reference picture1 buffer at origin (0, 0)
+ * @param mv1 motion vector1 (relative to block position) to get pixel data from
+ * @param current_mv current motion vector structure
+ */
+ static void luma_mc_bi(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride,
+ AVFrame *ref0, const Mv *mv0, int x_off, int y_off,
+ int block_w, int block_h, AVFrame *ref1, const Mv *mv1, struct MvField *current_mv)
+{
+ HEVCLocalContext *lc = s->HEVClc;
+ DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]);
+ ptrdiff_t src0stride = ref0->linesize[0];
+ ptrdiff_t src1stride = ref1->linesize[0];
+ int pic_width = s->sps->width;
+ int pic_height = s->sps->height;
+ int mx0 = mv0->x & 3;
+ int my0 = mv0->y & 3;
+ int mx1 = mv1->x & 3;
+ int my1 = mv1->y & 3;
+ int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
+ (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag);
+ int x_off0 = x_off + (mv0->x >> 2);
+ int y_off0 = y_off + (mv0->y >> 2);
+ int x_off1 = x_off + (mv1->x >> 2);
+ int y_off1 = y_off + (mv1->y >> 2);
+ int idx = ff_hevc_pel_weight[block_w];
+
+ uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->sps->pixel_shift);
+ uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->sps->pixel_shift);
+
+ if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER ||
+ x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER ||
+ y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
+ int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
+
+ s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset,
+ edge_emu_stride, src0stride,
+ block_w + QPEL_EXTRA,
+ block_h + QPEL_EXTRA,
+ x_off0 - QPEL_EXTRA_BEFORE, y_off0 - QPEL_EXTRA_BEFORE,
+ pic_width, pic_height);
+ src0 = lc->edge_emu_buffer + buf_offset;
+ src0stride = edge_emu_stride;
+ }
+
+ if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER ||
+ x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER ||
+ y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
+ int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift);
+
+ s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset,
+ edge_emu_stride, src1stride,
+ block_w + QPEL_EXTRA,
+ block_h + QPEL_EXTRA,
+ x_off1 - QPEL_EXTRA_BEFORE, y_off1 - QPEL_EXTRA_BEFORE,
pic_width, pic_height);
- src = lc->edge_emu_buffer + offset;
+ src1 = lc->edge_emu_buffer2 + buf_offset;
+ src1stride = edge_emu_stride;
}
- s->hevcdsp.put_hevc_qpel[my][mx](dst, dststride, src, srcstride, block_w,
- block_h, lc->mc_buffer);
+
+ s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](tmp, MAX_PB_SIZE, src0, src0stride,
+ block_h, mx0, my0, block_w);
+ if (!weight_flag)
+ s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, tmp, MAX_PB_SIZE,
+ block_h, mx1, my1, block_w);
+ else
+ s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride, src1, src1stride, tmp, MAX_PB_SIZE,
+ block_h, s->sh.luma_log2_weight_denom,
+ s->sh.luma_weight_l0[current_mv->ref_idx[0]],
+ s->sh.luma_weight_l1[current_mv->ref_idx[1]],
+ s->sh.luma_offset_l0[current_mv->ref_idx[0]],
+ s->sh.luma_offset_l1[current_mv->ref_idx[1]],
+ mx1, my1, block_w);
+
}
/**
- * 8.5.3.2.2.2 Chroma sample interpolation process
+ * 8.5.3.2.2.2 Chroma sample uniprediction interpolation process
*
* @param s HEVC decoding context
* @param dst1 target buffer for block data at block position (U plane)
@@ -1053,62 +1238,165 @@ static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride,
* @param y_off vertical position of block from origin (0, 0)
* @param block_w width of block
* @param block_h height of block
+ * @param chroma_weight weighting factor applied to the chroma prediction
+ * @param chroma_offset additive offset applied to the chroma prediction value
*/
-static void chroma_mc(HEVCContext *s, int16_t *dst1, int16_t *dst2,
- ptrdiff_t dststride, AVFrame *ref, const Mv *mv,
- int x_off, int y_off, int block_w, int block_h)
+
+static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
+ ptrdiff_t dststride, uint8_t *src0, ptrdiff_t srcstride, int reflist,
+ int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int chroma_weight, int chroma_offset)
{
HEVCLocalContext *lc = s->HEVClc;
- uint8_t *src1 = ref->data[1];
- uint8_t *src2 = ref->data[2];
- ptrdiff_t src1stride = ref->linesize[1];
- ptrdiff_t src2stride = ref->linesize[2];
- int pic_width = s->sps->width >> 1;
- int pic_height = s->sps->height >> 1;
-
- int mx = mv->x & 7;
- int my = mv->y & 7;
-
- x_off += mv->x >> 3;
- y_off += mv->y >> 3;
- src1 += y_off * src1stride + (x_off << s->sps->pixel_shift);
- src2 += y_off * src2stride + (x_off << s->sps->pixel_shift);
+ int pic_width = s->sps->width >> s->sps->hshift[1];
+ int pic_height = s->sps->height >> s->sps->vshift[1];
+ const Mv *mv = &current_mv->mv[reflist];
+ int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
+ (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag);
+ int idx = ff_hevc_pel_weight[block_w];
+ int hshift = s->sps->hshift[1];
+ int vshift = s->sps->vshift[1];
+ intptr_t mx = mv->x & ((1 << (2 + hshift)) - 1);
+ intptr_t my = mv->y & ((1 << (2 + vshift)) - 1);
+ intptr_t _mx = mx << (1 - hshift);
+ intptr_t _my = my << (1 - vshift);
+
+ x_off += mv->x >> (2 + hshift);
+ y_off += mv->y >> (2 + vshift);
+ src0 += y_off * srcstride + (x_off << s->sps->pixel_shift);
if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
+ int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->sps->pixel_shift));
+ int buf_offset0 = EPEL_EXTRA_BEFORE *
+ (edge_emu_stride + (1 << s->sps->pixel_shift));
+ s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0,
+ edge_emu_stride, srcstride,
+ block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
+ x_off - EPEL_EXTRA_BEFORE,
+ y_off - EPEL_EXTRA_BEFORE,
+ pic_width, pic_height);
+
+ src0 = lc->edge_emu_buffer + buf_offset0;
+ srcstride = edge_emu_stride;
+ }
+ if (!weight_flag)
+ s->hevcdsp.put_hevc_epel_uni[idx][!!my][!!mx](dst0, dststride, src0, srcstride,
+ block_h, _mx, _my, block_w);
+ else
+ s->hevcdsp.put_hevc_epel_uni_w[idx][!!my][!!mx](dst0, dststride, src0, srcstride,
+ block_h, s->sh.chroma_log2_weight_denom,
+ chroma_weight, chroma_offset, _mx, _my, block_w);
+}
+
+/**
+ * 8.5.3.2.2.2 Chroma sample bidirectional interpolation process
+ *
+ * @param s HEVC decoding context
+ * @param dst target buffer for block data at block position
+ * @param dststride stride of the dst buffer
+ * @param ref0 reference picture0 buffer at origin (0, 0)
+ * @param mv0 motion vector0 (relative to block position) to get pixel data from
+ * @param x_off horizontal position of block from origin (0, 0)
+ * @param y_off vertical position of block from origin (0, 0)
+ * @param block_w width of block
+ * @param block_h height of block
+ * @param ref1 reference picture1 buffer at origin (0, 0)
+ * @param mv1 motion vector1 (relative to block position) to get pixel data from
+ * @param current_mv current motion vector structure
+ * @param cidx chroma component(cb, cr)
+ */
+static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVFrame *ref0, AVFrame *ref1,
+ int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int cidx)
+{
+ DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);
+ int tmpstride = MAX_PB_SIZE;
+ HEVCLocalContext *lc = s->HEVClc;
+ uint8_t *src1 = ref0->data[cidx+1];
+ uint8_t *src2 = ref1->data[cidx+1];
+ ptrdiff_t src1stride = ref0->linesize[cidx+1];
+ ptrdiff_t src2stride = ref1->linesize[cidx+1];
+ int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
+ (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag);
+ int pic_width = s->sps->width >> s->sps->hshift[1];
+ int pic_height = s->sps->height >> s->sps->vshift[1];
+ Mv *mv0 = &current_mv->mv[0];
+ Mv *mv1 = &current_mv->mv[1];
+ int hshift = s->sps->hshift[1];
+ int vshift = s->sps->vshift[1];
+
+ intptr_t mx0 = mv0->x & ((1 << (2 + hshift)) - 1);
+ intptr_t my0 = mv0->y & ((1 << (2 + vshift)) - 1);
+ intptr_t mx1 = mv1->x & ((1 << (2 + hshift)) - 1);
+ intptr_t my1 = mv1->y & ((1 << (2 + vshift)) - 1);
+ intptr_t _mx0 = mx0 << (1 - hshift);
+ intptr_t _my0 = my0 << (1 - vshift);
+ intptr_t _mx1 = mx1 << (1 - hshift);
+ intptr_t _my1 = my1 << (1 - vshift);
+
+ int x_off0 = x_off + (mv0->x >> (2 + hshift));
+ int y_off0 = y_off + (mv0->y >> (2 + vshift));
+ int x_off1 = x_off + (mv1->x >> (2 + hshift));
+ int y_off1 = y_off + (mv1->y >> (2 + vshift));
+ int idx = ff_hevc_pel_weight[block_w];
+ src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->sps->pixel_shift);
+ src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->sps->pixel_shift);
+
+ if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER ||
+ x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER ||
+ y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->sps->pixel_shift));
- int offset2 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->sps->pixel_shift));
+ int buf_offset1 = EPEL_EXTRA_BEFORE *
+ (edge_emu_stride + (1 << s->sps->pixel_shift));
s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1,
- src1stride, src1stride,
+ edge_emu_stride, src1stride,
block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
- x_off - EPEL_EXTRA_BEFORE,
- y_off - EPEL_EXTRA_BEFORE,
+ x_off0 - EPEL_EXTRA_BEFORE,
+ y_off0 - EPEL_EXTRA_BEFORE,
pic_width, pic_height);
- src1 = lc->edge_emu_buffer + offset1;
- s->hevcdsp.put_hevc_epel[!!my][!!mx](dst1, dststride, src1, src1stride,
- block_w, block_h, mx, my, lc->mc_buffer);
+ src1 = lc->edge_emu_buffer + buf_offset1;
+ src1stride = edge_emu_stride;
+ }
+
+ if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER ||
+ x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER ||
+ y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) {
+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift;
+ int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->sps->pixel_shift));
+ int buf_offset1 = EPEL_EXTRA_BEFORE *
+ (edge_emu_stride + (1 << s->sps->pixel_shift));
- s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src2 - offset2,
- src2stride, src2stride,
+ s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1,
+ edge_emu_stride, src2stride,
block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
- x_off - EPEL_EXTRA_BEFORE,
- y_off - EPEL_EXTRA_BEFORE,
+ x_off1 - EPEL_EXTRA_BEFORE,
+ y_off1 - EPEL_EXTRA_BEFORE,
pic_width, pic_height);
- src2 = lc->edge_emu_buffer + offset2;
- s->hevcdsp.put_hevc_epel[!!my][!!mx](dst2, dststride, src2, src2stride,
- block_w, block_h, mx, my,
- lc->mc_buffer);
- } else {
- s->hevcdsp.put_hevc_epel[!!my][!!mx](dst1, dststride, src1, src1stride,
- block_w, block_h, mx, my,
- lc->mc_buffer);
- s->hevcdsp.put_hevc_epel[!!my][!!mx](dst2, dststride, src2, src2stride,
- block_w, block_h, mx, my,
- lc->mc_buffer);
+
+ src2 = lc->edge_emu_buffer2 + buf_offset1;
+ src2stride = edge_emu_stride;
}
+
+ s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](tmp, tmpstride, src1, src1stride,
+ block_h, _mx0, _my0, block_w);
+ if (!weight_flag)
+ s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],
+ src2, src2stride, tmp, tmpstride,
+ block_h, _mx1, _my1, block_w);
+ else
+ s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],
+ src2, src2stride, tmp, tmpstride,
+ block_h,
+ s->sh.chroma_log2_weight_denom,
+ s->sh.chroma_weight_l0[current_mv->ref_idx[0]][cidx],
+ s->sh.chroma_weight_l1[current_mv->ref_idx[1]][cidx],
+ s->sh.chroma_offset_l0[current_mv->ref_idx[0]][cidx],
+ s->sh.chroma_offset_l1[current_mv->ref_idx[1]][cidx],
+ _mx1, _my1, block_w);
}
static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref,
@@ -1136,9 +1424,6 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
MvField *tab_mvf = s->ref->tab_mvf;
RefPicList *refPicList = s->ref->refPicList;
HEVCFrame *ref0, *ref1;
-
- int tmpstride = MAX_PB_SIZE;
-
uint8_t *dst0 = POS(0, x0, y0);
uint8_t *dst1 = POS(1, x0, y0);
uint8_t *dst2 = POS(2, x0, y0);
@@ -1187,6 +1472,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
} else {
enum InterPredIdc inter_pred_idc = PRED_L0;
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
+ current_mv.pred_flag = 0;
if (s->sh.slice_type == B_SLICE)
inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH);
@@ -1195,7 +1481,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
ref_idx[0] = ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L0]);
current_mv.ref_idx[0] = ref_idx[0];
}
- current_mv.pred_flag[0] = 1;
+ current_mv.pred_flag = PF_L0;
ff_hevc_hls_mvd_coding(s, x0, y0, 0);
mvp_flag[0] = ff_hevc_mvp_lx_flag_decode(s);
ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size,
@@ -1218,7 +1504,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
ff_hevc_hls_mvd_coding(s, x0, y0, 1);
}
- current_mv.pred_flag[1] = 1;
+ current_mv.pred_flag += PF_L1;
mvp_flag[1] = ff_hevc_mvp_lx_flag_decode(s);
ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size,
partIdx, merge_idx, &current_mv,
@@ -1236,148 +1522,69 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
}
}
- if (current_mv.pred_flag[0]) {
+ if (current_mv.pred_flag & PF_L0) {
ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
if (!ref0)
return;
hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH);
}
- if (current_mv.pred_flag[1]) {
+ if (current_mv.pred_flag & PF_L1) {
ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
if (!ref1)
return;
hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH);
}
- if (current_mv.pred_flag[0] && !current_mv.pred_flag[1]) {
- DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);
-
- luma_mc(s, tmp, tmpstride, ref0->frame,
- &current_mv.mv[0], x0, y0, nPbW, nPbH);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom,
- s->sh.luma_weight_l0[current_mv.ref_idx[0]],
- s->sh.luma_offset_l0[current_mv.ref_idx[0]],
- dst0, s->frame->linesize[0], tmp,
- tmpstride, nPbW, nPbH);
- } else {
- s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH);
- }
- chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame,
- &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0],
- s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0],
- dst1, s->frame->linesize[1], tmp, tmpstride,
- nPbW / 2, nPbH / 2);
- s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1],
- s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1],
- dst2, s->frame->linesize[2], tmp2, tmpstride,
- nPbW / 2, nPbH / 2);
- } else {
- s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2);
- s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2);
- }
- } else if (!current_mv.pred_flag[0] && current_mv.pred_flag[1]) {
- DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);
-
- if (!ref1)
- return;
-
- luma_mc(s, tmp, tmpstride, ref1->frame,
- &current_mv.mv[1], x0, y0, nPbW, nPbH);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom,
- s->sh.luma_weight_l1[current_mv.ref_idx[1]],
- s->sh.luma_offset_l1[current_mv.ref_idx[1]],
- dst0, s->frame->linesize[0], tmp, tmpstride,
- nPbW, nPbH);
- } else {
- s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH);
- }
-
- chroma_mc(s, tmp, tmp2, tmpstride, ref1->frame,
- &current_mv.mv[1], x0/2, y0/2, nPbW/2, nPbH/2);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0],
- s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0],
- dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2);
- s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1],
- s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1],
- dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2);
- } else {
- s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2);
- s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2);
- }
- } else if (current_mv.pred_flag[0] && current_mv.pred_flag[1]) {
- DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, tmp3[MAX_PB_SIZE * MAX_PB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, tmp4[MAX_PB_SIZE * MAX_PB_SIZE]);
- HEVCFrame *ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
- HEVCFrame *ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
-
- if (!ref0 || !ref1)
- return;
-
- luma_mc(s, tmp, tmpstride, ref0->frame,
- &current_mv.mv[0], x0, y0, nPbW, nPbH);
- luma_mc(s, tmp2, tmpstride, ref1->frame,
- &current_mv.mv[1], x0, y0, nPbW, nPbH);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred_avg(s->sh.luma_log2_weight_denom,
- s->sh.luma_weight_l0[current_mv.ref_idx[0]],
- s->sh.luma_weight_l1[current_mv.ref_idx[1]],
- s->sh.luma_offset_l0[current_mv.ref_idx[0]],
- s->sh.luma_offset_l1[current_mv.ref_idx[1]],
- dst0, s->frame->linesize[0],
- tmp, tmp2, tmpstride, nPbW, nPbH);
- } else {
- s->hevcdsp.put_weighted_pred_avg(dst0, s->frame->linesize[0],
- tmp, tmp2, tmpstride, nPbW, nPbH);
- }
-
- chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame,
- &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
- chroma_mc(s, tmp3, tmp4, tmpstride, ref1->frame,
- &current_mv.mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
-
- if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) {
- s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0],
- s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0],
- s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0],
- s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0],
- dst1, s->frame->linesize[1], tmp, tmp3,
- tmpstride, nPbW / 2, nPbH / 2);
- s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom,
- s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1],
- s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1],
- s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1],
- s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1],
- dst2, s->frame->linesize[2], tmp2, tmp4,
- tmpstride, nPbW / 2, nPbH / 2);
- } else {
- s->hevcdsp.put_weighted_pred_avg(dst1, s->frame->linesize[1], tmp, tmp3, tmpstride, nPbW/2, nPbH/2);
- s->hevcdsp.put_weighted_pred_avg(dst2, s->frame->linesize[2], tmp2, tmp4, tmpstride, nPbW/2, nPbH/2);
- }
+ if (current_mv.pred_flag == PF_L0) {
+ int x0_c = x0 >> s->sps->hshift[1];
+ int y0_c = y0 >> s->sps->vshift[1];
+ int nPbW_c = nPbW >> s->sps->hshift[1];
+ int nPbH_c = nPbH >> s->sps->vshift[1];
+
+ luma_mc_uni(s, dst0, s->frame->linesize[0], ref0->frame,
+ &current_mv.mv[0], x0, y0, nPbW, nPbH,
+ s->sh.luma_weight_l0[current_mv.ref_idx[0]],
+ s->sh.luma_offset_l0[current_mv.ref_idx[0]]);
+
+ chroma_mc_uni(s, dst1, s->frame->linesize[1], ref0->frame->data[1], ref0->frame->linesize[1],
+ 0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
+ s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]);
+ chroma_mc_uni(s, dst2, s->frame->linesize[2], ref0->frame->data[2], ref0->frame->linesize[2],
+ 0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
+ s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]);
+ } else if (current_mv.pred_flag == PF_L1) {
+ int x0_c = x0 >> s->sps->hshift[1];
+ int y0_c = y0 >> s->sps->vshift[1];
+ int nPbW_c = nPbW >> s->sps->hshift[1];
+ int nPbH_c = nPbH >> s->sps->vshift[1];
+
+ luma_mc_uni(s, dst0, s->frame->linesize[0], ref1->frame,
+ &current_mv.mv[1], x0, y0, nPbW, nPbH,
+ s->sh.luma_weight_l1[current_mv.ref_idx[1]],
+ s->sh.luma_offset_l1[current_mv.ref_idx[1]]);
+
+ chroma_mc_uni(s, dst1, s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
+ 1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
+ s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]);
+
+ chroma_mc_uni(s, dst2, s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
+ 1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
+ s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]);
+ } else if (current_mv.pred_flag == PF_BI) {
+ int x0_c = x0 >> s->sps->hshift[1];
+ int y0_c = y0 >> s->sps->vshift[1];
+ int nPbW_c = nPbW >> s->sps->hshift[1];
+ int nPbH_c = nPbH >> s->sps->vshift[1];
+
+ luma_mc_bi(s, dst0, s->frame->linesize[0], ref0->frame,
+ &current_mv.mv[0], x0, y0, nPbW, nPbH,
+ ref1->frame, &current_mv.mv[1], &current_mv);
+
+ chroma_mc_bi(s, dst1, s->frame->linesize[1], ref0->frame, ref1->frame,
+ x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 0);
+
+ chroma_mc_bi(s, dst2, s->frame->linesize[2], ref0->frame, ref1->frame,
+ x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 1);
}
}
@@ -1457,15 +1664,7 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
intra_pred_mode, size_in_pus);
for (j = 0; j < size_in_pus; j++) {
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].is_intra = 1;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[0] = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[1] = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[0] = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[1] = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].x = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].y = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].x = 0;
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].y = 0;
+ tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag = PF_INTRA;
}
}
@@ -1540,11 +1739,12 @@ static void intra_prediction_unit_default_value(HEVCContext *s,
if (size_in_pus == 0)
size_in_pus = 1;
- for (j = 0; j < size_in_pus; j++) {
+ for (j = 0; j < size_in_pus; j++)
memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus);
- for (k = 0; k < size_in_pus; k++)
- tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;
- }
+ if (lc->cu.pred_mode == MODE_INTRA)
+ for (j = 0; j < size_in_pus; j++)
+ for (k = 0; k < size_in_pus; k++)
+ tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].pred_flag = PF_INTRA;
}
static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
@@ -1556,7 +1756,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
int min_cb_width = s->sps->min_cb_width;
int x_cb = x0 >> log2_min_cb_size;
int y_cb = y0 >> log2_min_cb_size;
- int x, y;
+ int x, y, ret;
+ int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
lc->cu.x = x0;
lc->cu.y = y0;
@@ -1579,7 +1780,6 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
if (s->sh.slice_type != I_SLICE) {
uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb);
- lc->cu.pred_mode = MODE_SKIP;
x = y_cb * min_cb_width + x_cb;
for (y = 0; y < length; y++) {
memset(&s->skip_flag[x], skip_flag, length);
@@ -1593,9 +1793,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
if (!s->sh.disable_deblocking_filter_flag)
- ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
- lc->slice_or_tiles_up_boundary,
- lc->slice_or_tiles_left_boundary);
+ ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size);
} else {
if (s->sh.slice_type != I_SLICE)
lc->cu.pred_mode = ff_hevc_pred_mode_decode(s);
@@ -1613,7 +1811,6 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s);
}
if (lc->cu.pcm_flag) {
- int ret;
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
if (s->sps->pcm.loop_filter_disable_flag)
@@ -1672,13 +1869,14 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
s->sps->max_transform_hierarchy_depth_inter;
- hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size,
- log2_cb_size, 0, 0);
+ ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0,
+ log2_cb_size,
+ log2_cb_size, 0, 0);
+ if (ret < 0)
+ return ret;
} else {
if (!s->sh.disable_deblocking_filter_flag)
- ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
- lc->slice_or_tiles_up_boundary,
- lc->slice_or_tiles_left_boundary);
+ ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size);
}
}
}
@@ -1692,6 +1890,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
x += min_cb_width;
}
+ if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
+ ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
+ lc->qPy_pred = lc->qp_y;
+ }
+
set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth);
return 0;
@@ -1703,6 +1906,7 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
HEVCLocalContext *lc = s->HEVClc;
const int cb_size = 1 << log2_cb_size;
int ret;
+ int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
lc->ct.depth = cb_depth;
if (x0 + cb_size <= s->sps->width &&
@@ -1731,14 +1935,27 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
if (more_data < 0)
return more_data;
- if (more_data && x1 < s->sps->width)
+ if (more_data && x1 < s->sps->width) {
more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1);
- if (more_data && y1 < s->sps->height)
+ if (more_data < 0)
+ return more_data;
+ }
+ if (more_data && y1 < s->sps->height) {
more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1);
+ if (more_data < 0)
+ return more_data;
+ }
if (more_data && x1 < s->sps->width &&
y1 < s->sps->height) {
- return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
+ more_data = hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
+ if (more_data < 0)
+ return more_data;
}
+
+ if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
+ ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
+ lc->qPy_pred = lc->qp_y;
+
if (more_data)
return ((x1 + cb_size_split) < s->sps->width ||
(y1 + cb_size_split) < s->sps->height);
@@ -1784,7 +2001,6 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb,
} else if (s->pps->tiles_enabled_flag) {
if (ctb_addr_ts && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) {
int idxX = s->pps->col_idxX[x_ctb >> s->sps->log2_ctb_size];
- lc->start_of_tiles_x = x_ctb;
lc->end_of_tiles_x = x_ctb + (s->pps->column_width[idxX] << s->sps->log2_ctb_size);
lc->first_qp_group = 1;
}
@@ -1826,6 +2042,19 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
int y_ctb = 0;
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
+ if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
+ av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (s->sh.dependent_slice_segment_flag) {
+ int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
+ if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
+ av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
while (more_data && ctb_addr_ts < s->sps->ctb_size) {
int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
@@ -1842,8 +2071,11 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
- if (more_data < 0)
+ if (more_data < 0) {
+ s->tab_slice_address[ctb_addr_rs] = -1;
return more_data;
+ }
+
ctb_addr_ts++;
ff_hevc_save_states(s, ctb_addr_ts);
@@ -1909,8 +2141,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size);
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
- if (more_data < 0)
+ if (more_data < 0) {
+ s->tab_slice_address[ctb_addr_rs] = -1;
return more_data;
+ }
ctb_addr_ts++;
@@ -1959,7 +2193,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
s->sList[i] = av_malloc(sizeof(HEVCContext));
memcpy(s->sList[i], s, sizeof(HEVCContext));
s->HEVClcList[i] = av_malloc(sizeof(HEVCLocalContext));
- s->HEVClcList[i]->edge_emu_buffer = av_malloc((MAX_PB_SIZE + 7) * s->frame->linesize[0]);
s->sList[i]->HEVClc = s->HEVClcList[i];
}
}
@@ -2072,18 +2305,57 @@ static void restore_tqb_pixels(HEVCContext *s)
}
}
+static int set_side_data(HEVCContext *s)
+{
+ AVFrame *out = s->ref->frame;
+
+ if (s->sei_frame_packing_present &&
+ s->frame_packing_arrangement_type >= 3 &&
+ s->frame_packing_arrangement_type <= 5 &&
+ s->content_interpretation_type > 0 &&
+ s->content_interpretation_type < 3) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(out);
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ switch (s->frame_packing_arrangement_type) {
+ case 3:
+ if (s->quincunx_subsampling)
+ stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ else
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 4:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case 5:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+ }
+
+ if (s->content_interpretation_type == 2)
+ stereo->flags = AV_STEREO3D_FLAG_INVERT;
+ }
+
+ return 0;
+}
+
static int hevc_frame_start(HEVCContext *s)
{
HEVCLocalContext *lc = s->HEVClc;
+ int pic_size_in_ctb = ((s->sps->width >> s->sps->log2_min_cb_size) + 1) *
+ ((s->sps->height >> s->sps->log2_min_cb_size) + 1);
int ret;
+ AVFrame *cur_frame;
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
+ memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address));
- lc->start_of_tiles_x = 0;
s->is_decoded = 0;
+ s->first_nal_type = s->nal_unit_type;
if (s->pps->tiles_enabled_flag)
lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size;
@@ -2093,19 +2365,19 @@ static int hevc_frame_start(HEVCContext *s)
if (ret < 0)
goto fail;
- av_fast_malloc(&lc->edge_emu_buffer, &lc->edge_emu_buffer_size,
- (MAX_PB_SIZE + 7) * s->ref->frame->linesize[0]);
- if (!lc->edge_emu_buffer) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
ret = ff_hevc_frame_rps(s);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Error constructing the frame RPS.\n");
goto fail;
}
+ ret = set_side_data(s);
+ if (ret < 0)
+ goto fail;
+
+ cur_frame = s->sps->sao_enabled ? s->sao_frame : s->frame;
+ cur_frame->pict_type = 3 - s->sh.slice_type;
+
av_frame_unref(s->output_frame);
ret = ff_hevc_output_frame(s, s->output_frame, 0);
if (ret < 0)
@@ -2136,9 +2408,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
s->nal_unit_type);
- if (s->avctx->err_recognition & AV_EF_EXPLODE)
- return ret;
- return 0;
+ goto fail;
} else if (!ret)
return 0;
@@ -2146,23 +2416,23 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
case NAL_VPS:
ret = ff_hevc_decode_nal_vps(s);
if (ret < 0)
- return ret;
+ goto fail;
break;
case NAL_SPS:
ret = ff_hevc_decode_nal_sps(s);
if (ret < 0)
- return ret;
+ goto fail;
break;
case NAL_PPS:
ret = ff_hevc_decode_nal_pps(s);
if (ret < 0)
- return ret;
+ goto fail;
break;
case NAL_SEI_PREFIX:
case NAL_SEI_SUFFIX:
ret = ff_hevc_decode_nal_sei(s);
if (ret < 0)
- return ret;
+ goto fail;
break;
case NAL_TRAIL_R:
case NAL_TRAIL_N:
@@ -2208,6 +2478,13 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
return ret;
} else if (!s->ref) {
av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
+ goto fail;
+ }
+
+ if (s->nal_unit_type != s->first_nal_type) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Non-matching NAL types of the VCL NALUs: %d %d\n",
+ s->first_nal_type, s->nal_unit_type);
return AVERROR_INVALIDDATA;
}
@@ -2217,8 +2494,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING,
"Error constructing the reference lists for the current slice.\n");
- if (s->avctx->err_recognition & AV_EF_EXPLODE)
- return ret;
+ goto fail;
}
}
@@ -2234,8 +2510,10 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
restore_tqb_pixels(s);
}
- if (ctb_addr_ts < 0)
- return ctb_addr_ts;
+ if (ctb_addr_ts < 0) {
+ ret = ctb_addr_ts;
+ goto fail;
+ }
break;
case NAL_EOS_NUT:
case NAL_EOB_NUT:
@@ -2251,10 +2529,14 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
}
return 0;
+fail:
+ if (s->avctx->err_recognition & AV_EF_EXPLODE)
+ return ret;
+ return 0;
}
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
- between these functions would be nice. */
+ * between these functions would be nice. */
int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
HEVCNAL *nal)
{
@@ -2367,6 +2649,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
int i, consumed, ret = 0;
s->ref = NULL;
+ s->last_eos = s->eos;
s->eos = 0;
/* split the input packet into NAL units, so we know the upper bound on the
@@ -2463,8 +2746,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING,
"Error parsing NAL unit #%d.\n", i);
- if (s->avctx->err_recognition & AV_EF_EXPLODE)
- goto fail;
+ goto fail;
}
}
@@ -2634,8 +2916,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
pic_arrays_free(s);
- if (lc)
- av_freep(&lc->edge_emu_buffer);
av_freep(&s->md5_ctx);
for(i=0; i < s->nals_allocated; i++) {
@@ -2669,11 +2949,12 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
for (i = 1; i < s->threads_number; i++) {
lc = s->HEVClcList[i];
if (lc) {
- av_freep(&lc->edge_emu_buffer);
av_freep(&s->HEVClcList[i]);
av_freep(&s->sList[i]);
}
}
+ if (s->HEVClc == s->HEVClcList[0])
+ s->HEVClc = NULL;
av_freep(&s->HEVClcList[0]);
for (i = 0; i < s->nals_allocated; i++)
@@ -2725,6 +3006,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
ff_dsputil_init(&s->dsp, avctx);
s->context_initialized = 1;
+ s->eos = 0;
return 0;
@@ -2789,6 +3071,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->seq_output = s0->seq_output;
s->pocTid0 = s0->pocTid0;
s->max_ra = s0->max_ra;
+ s->eos = s0->eos;
s->is_nalff = s0->is_nalff;
s->nal_length_size = s0->nal_length_size;
@@ -2817,7 +3100,7 @@ static int hevc_decode_extradata(HEVCContext *s)
avctx->extradata[2] > 1)) {
/* It seems the extradata is encoded as hvcC format.
* Temporarily, we support configurationVersion==0 until 14496-15 3rd
- * finalized. When finalized, configurationVersion will be 1 and we
+ * is finalized. When finalized, configurationVersion will be 1 and we
* can recognize hvcC by checking if avctx->extradata[0]==1 or not. */
int i, j, num_arrays, nal_len_size;
@@ -2930,9 +3213,9 @@ static void hevc_decode_flush(AVCodecContext *avctx)
#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
static const AVProfile profiles[] = {
- { FF_PROFILE_HEVC_MAIN, "Main" },
- { FF_PROFILE_HEVC_MAIN_10, "Main10" },
- { FF_PROFILE_HEVC_MAIN_STILL_PICTURE, "MainStillPicture" },
+ { FF_PROFILE_HEVC_MAIN, "Main" },
+ { FF_PROFILE_HEVC_MAIN_10, "Main 10" },
+ { FF_PROFILE_HEVC_MAIN_STILL_PICTURE, "Main Still Picture" },
{ FF_PROFILE_UNKNOWN },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc.h b/chromium/third_party/ffmpeg/libavcodec/hevc.h
index 74673a9f1ab..3c88b69a470 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc.h
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc.h
@@ -71,6 +71,11 @@
#define EPEL_EXTRA_BEFORE 1
#define EPEL_EXTRA_AFTER 2
#define EPEL_EXTRA 3
+#define QPEL_EXTRA_BEFORE 3
+#define QPEL_EXTRA_AFTER 4
+#define QPEL_EXTRA 7
+
+#define EDGE_EMU_BUFFER_STRIDE 80
/**
* Value of the luma sample at position (x, y) in the 2D array tab.
@@ -199,6 +204,13 @@ enum InterPredIdc {
PRED_BI,
};
+enum PredFlag {
+ PF_INTRA = 0,
+ PF_L0,
+ PF_L1,
+ PF_BI,
+};
+
enum IntraPredMode {
INTRA_PLANAR = 0,
INTRA_DC,
@@ -257,7 +269,7 @@ enum ScanType {
};
typedef struct ShortTermRPS {
- int num_negative_pics;
+ unsigned int num_negative_pics;
int num_delta_pocs;
int32_t delta_poc[32];
uint8_t used[32];
@@ -330,30 +342,24 @@ typedef struct VUI {
int log2_max_mv_length_vertical;
} VUI;
-typedef struct ProfileTierLevel {
- int profile_space;
+typedef struct PTLCommon {
+ uint8_t profile_space;
uint8_t tier_flag;
- int profile_idc;
- int profile_compatibility_flag[32];
- int level_idc;
- int progressive_source_flag;
- int interlaced_source_flag;
- int non_packed_constraint_flag;
- int frame_only_constraint_flag;
-} ProfileTierLevel;
+ uint8_t profile_idc;
+ uint8_t profile_compatibility_flag[32];
+ uint8_t level_idc;
+ uint8_t progressive_source_flag;
+ uint8_t interlaced_source_flag;
+ uint8_t non_packed_constraint_flag;
+ uint8_t frame_only_constraint_flag;
+} PTLCommon;
typedef struct PTL {
- ProfileTierLevel general_PTL;
- ProfileTierLevel sub_layer_PTL[MAX_SUB_LAYERS];
+ PTLCommon general_ptl;
+ PTLCommon sub_layer_ptl[MAX_SUB_LAYERS];
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
-
- int sub_layer_profile_space[MAX_SUB_LAYERS];
- uint8_t sub_layer_tier_flag[MAX_SUB_LAYERS];
- int sub_layer_profile_idc[MAX_SUB_LAYERS];
- uint8_t sub_layer_profile_compatibility_flags[MAX_SUB_LAYERS][32];
- int sub_layer_level_idc[MAX_SUB_LAYERS];
} PTL;
typedef struct HEVCVPS {
@@ -374,8 +380,6 @@ typedef struct HEVCVPS {
uint8_t vps_poc_proportional_to_timing_flag;
int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
int vps_num_hrd_parameters;
-
- int vps_extension_flag;
} HEVCVPS;
typedef struct ScalingList {
@@ -386,7 +390,7 @@ typedef struct ScalingList {
} ScalingList;
typedef struct HEVCSPS {
- int vps_id;
+ unsigned vps_id;
int chroma_format_idc;
uint8_t separate_colour_plane_flag;
@@ -467,7 +471,7 @@ typedef struct HEVCSPS {
} HEVCSPS;
typedef struct HEVCPPS {
- int sps_id; ///< seq_parameter_set_id
+ unsigned int sps_id; ///< seq_parameter_set_id
uint8_t sign_data_hiding_flag;
@@ -508,7 +512,7 @@ typedef struct HEVCPPS {
int beta_offset; ///< beta_offset_div2 * 2
int tc_offset; ///< tc_offset_div2 * 2
- int scaling_list_data_present_flag;
+ uint8_t scaling_list_data_present_flag;
ScalingList scaling_list;
uint8_t lists_modification_present_flag;
@@ -516,14 +520,11 @@ typedef struct HEVCPPS {
int num_extra_slice_header_bits;
uint8_t slice_header_extension_present_flag;
- uint8_t pps_extension_flag;
- uint8_t pps_extension_data_flag;
-
// Inferred parameters
- int *column_width; ///< ColumnWidth
- int *row_height; ///< RowHeight
- int *col_bd; ///< ColBd
- int *row_bd; ///< RowBd
+ unsigned int *column_width; ///< ColumnWidth
+ unsigned int *row_height; ///< RowHeight
+ unsigned int *col_bd; ///< ColBd
+ unsigned int *row_bd; ///< RowBd
int *col_idxX;
int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
@@ -535,7 +536,7 @@ typedef struct HEVCPPS {
} HEVCPPS;
typedef struct SliceHeader {
- int pps_id;
+ unsigned int pps_id;
///< address (in raster order) of the first block in the current slice segment
unsigned int slice_segment_addr;
@@ -580,8 +581,7 @@ typedef struct SliceHeader {
int beta_offset; ///< beta_offset_div2 * 2
int tc_offset; ///< tc_offset_div2 * 2
- int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
-
+ unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
int *entry_point_offset;
int * offset;
@@ -636,8 +636,7 @@ typedef struct Mv {
typedef struct MvField {
Mv mv[2];
int8_t ref_idx[2];
- int8_t pred_flag[2];
- uint8_t is_intra;
+ int8_t pred_flag;
} MvField;
typedef struct NeighbourAvailable {
@@ -675,19 +674,6 @@ typedef struct TransformUnit {
uint8_t is_cu_qp_delta_coded;
} TransformUnit;
-typedef struct SAOParams {
- int offset_abs[3][4]; ///< sao_offset_abs
- int offset_sign[3][4]; ///< sao_offset_sign
-
- int band_position[3]; ///< sao_band_position
-
- int eo_class[3]; ///< sao_eo_class
-
- int offset_val[3][5]; ///<SaoOffsetVal
-
- uint8_t type_idx[3]; ///< sao_type_idx
-} SAOParams;
-
typedef struct DBParams {
int beta_offset;
int tc_offset;
@@ -746,17 +732,20 @@ typedef struct HEVCLocalContext {
int8_t qp_y;
int8_t curr_qp_y;
+ int qPy_pred;
+
TransformUnit tu;
uint8_t ctb_left_flag;
uint8_t ctb_up_flag;
uint8_t ctb_up_right_flag;
uint8_t ctb_up_left_flag;
- int start_of_tiles_x;
int end_of_tiles_x;
int end_of_tiles_y;
- uint8_t *edge_emu_buffer;
- int edge_emu_buffer_size;
+ /* +7 is for subpixel interpolation, *2 for high bit depths */
+ DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
+ DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer2)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
+
CodingTree ct;
CodingUnit cu;
PredictionUnit pu;
@@ -768,7 +757,7 @@ typedef struct HEVCLocalContext {
typedef struct HEVCContext {
const AVClass *c; // needed by private avoptions
- AVCodecContext *avctx;
+ AVCodecContext *avctx;
struct HEVCContext *sList[MAX_NB_THREADS];
@@ -791,9 +780,9 @@ typedef struct HEVCContext {
AVFrame *tmp_frame;
AVFrame *output_frame;
- HEVCVPS *vps;
+ const HEVCVPS *vps;
const HEVCSPS *sps;
- HEVCPPS *pps;
+ const HEVCPPS *pps;
AVBufferRef *vps_list[MAX_VPS_COUNT];
AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT];
@@ -815,6 +804,7 @@ typedef struct HEVCContext {
int pocTid0;
int slice_idx; ///< number of the slice being currently decoded
int eos; ///< current packet contains an EOS/EOB NAL
+ int last_eos; ///< last packet contains an EOS/EOB NAL
int max_ra;
int bs_width;
int bs_height;
@@ -865,19 +855,21 @@ typedef struct HEVCContext {
int **skipped_bytes_pos_nal;
int *skipped_bytes_pos_size_nal;
- uint8_t *data;
+ const uint8_t *data;
HEVCNAL *nals;
int nb_nals;
int nals_allocated;
+ // type of the first VCL NAL of the current frame
+ enum NALUnitType first_nal_type;
// for checking the frame checksums
struct AVMD5 *md5_ctx;
uint8_t md5[3][16];
uint8_t is_md5;
- int context_initialized;
- int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
+ uint8_t context_initialized;
+ uint8_t is_nalff; ///< this flag is != 0 if bitstream is encapsulated
///< as a format defined in 14496-15
int apply_defdispwin;
@@ -886,6 +878,12 @@ typedef struct HEVCContext {
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
int nuh_layer_id;
+ /** frame packing arrangement variables */
+ int sei_frame_packing_present;
+ int frame_packing_arrangement_type;
+ int content_interpretation_type;
+ int quincunx_subsampling;
+
int picture_struct;
} HEVCContext;
@@ -986,9 +984,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase,
int log2_cb_size);
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
- int log2_trafo_size,
- int slice_or_tiles_up_boundary,
- int slice_or_tiles_left_boundary);
+ int log2_trafo_size);
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s);
int ff_hevc_cu_qp_delta_abs(HEVCContext *s);
void ff_hevc_hls_filter(HEVCContext *s, int x, int y);
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_cabac.c b/chromium/third_party/ffmpeg/libavcodec/hevc_cabac.c
index da7a21373d9..288f88576cb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_cabac.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_cabac.c
@@ -27,7 +27,7 @@
#include "cabac_functions.h"
#include "hevc.h"
-#define CABAC_MAX_BIN 100
+#define CABAC_MAX_BIN 31
/**
* number of bin by SyntaxElement.
@@ -537,7 +537,7 @@ static void cabac_init_state(HEVCContext *s)
int init_value = init_values[init_type][i];
int m = (init_value >> 4) * 5 - 45;
int n = ((init_value & 15) << 3) - 16;
- int pre = 2 * (((m * av_clip_c(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127;
+ int pre = 2 * (((m * av_clip(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127;
pre ^= pre >> 31;
if (pre > 124)
@@ -1114,7 +1114,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
else
offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset;
- qp_i = av_clip_c(qp_y + offset, - s->sps->qp_bd_offset, 57);
+ qp_i = av_clip(qp_y + offset, - s->sps->qp_bd_offset, 57);
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_filter.c b/chromium/third_party/ffmpeg/libavcodec/hevc_filter.c
index ae72fbbe498..ec7a21187d4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_filter.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_filter.c
@@ -60,7 +60,7 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
else
offset = s->pps->cr_qp_offset;
- qp_i = av_clip_c(qp_y + offset, 0, 57);
+ qp_i = av_clip(qp_y + offset, 0, 57);
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
@@ -68,7 +68,7 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
else
qp = qp_c[qp_i - 30];
- idxt = av_clip_c(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53);
+ idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53);
return tctable[idxt];
}
@@ -82,7 +82,6 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC,
int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
int min_cb_width = s->sps->min_cb_width;
- int min_cb_height = s->sps->min_cb_height;
int x_cb = xQgBase >> s->sps->log2_min_cb_size;
int y_cb = yQgBase >> s->sps->log2_min_cb_size;
int availableA = (xBase & ctb_size_mask) &&
@@ -92,50 +91,11 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC,
int qPy_pred, qPy_a, qPy_b;
// qPy_pred
- if (lc->first_qp_group) {
+ if (lc->first_qp_group || (!xQgBase && !yQgBase)) {
lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded;
qPy_pred = s->sh.slice_qp;
} else {
- qPy_pred = lc->qp_y;
- if (log2_cb_size < s->sps->log2_ctb_size -
- s->pps->diff_cu_qp_delta_depth) {
- static const int offsetX[8][8] = {
- { -1, 1, 3, 1, 7, 1, 3, 1 },
- { 0, 0, 0, 0, 0, 0, 0, 0 },
- { 1, 3, 1, 3, 1, 3, 1, 3 },
- { 2, 2, 2, 2, 2, 2, 2, 2 },
- { 3, 5, 7, 5, 3, 5, 7, 5 },
- { 4, 4, 4, 4, 4, 4, 4, 4 },
- { 5, 7, 5, 7, 5, 7, 5, 7 },
- { 6, 6, 6, 6, 6, 6, 6, 6 }
- };
- static const int offsetY[8][8] = {
- { 7, 0, 1, 2, 3, 4, 5, 6 },
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 1, 0, 3, 2, 5, 4, 7, 6 },
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 3, 0, 1, 2, 7, 4, 5, 6 },
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 1, 0, 3, 2, 5, 4, 7, 6 },
- { 0, 1, 2, 3, 4, 5, 6, 7 }
- };
- int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
- int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
- int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
- int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
- int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size;
- int x, y;
-
- x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1);
- y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1);
-
- if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) &&
- offsetX[idxX][idxY] == -1) {
- x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1;
- y = yC0b - 1;
- }
- qPy_pred = s->qp_y_tab[y * min_cb_width + x];
- }
+ qPy_pred = lc->qPy_pred;
}
// qPy_a
@@ -150,6 +110,9 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC,
else
qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
+ av_assert2(qPy_a >= -s->sps->qp_bd_offset && qPy_a < 52);
+ av_assert2(qPy_b >= -s->sps->qp_bd_offset && qPy_b < 52);
+
return (qPy_a + qPy_b + 1) >> 1;
}
@@ -160,8 +123,8 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC,
if (s->HEVClc->tu.cu_qp_delta != 0) {
int off = s->sps->qp_bd_offset;
- s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) %
- (52 + off)) - off;
+ s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
+ 52 + off) - off;
} else
s->HEVClc->qp_y = qp_y;
}
@@ -320,11 +283,15 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
static int get_pcm(HEVCContext *s, int x, int y)
{
int log2_min_pu_size = s->sps->log2_min_pu_size;
- int x_pu = x >> log2_min_pu_size;
- int y_pu = y >> log2_min_pu_size;
+ int x_pu, y_pu;
- if (x < 0 || x_pu >= s->sps->min_pu_width ||
- y < 0 || y_pu >= s->sps->min_pu_height)
+ if (x < 0 || y < 0)
+ return 2;
+
+ x_pu = x >> log2_min_pu_size;
+ y_pu = y >> log2_min_pu_size;
+
+ if (x_pu >= s->sps->min_pu_width || y_pu >= s->sps->min_pu_height)
return 2;
return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];
}
@@ -380,8 +347,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x - 1, y + 4) + get_qPy(s, x, y + 4) + 1) >> 1;
- beta[0] = betatable[av_clip(qp0 + (beta_offset >> 1 << 1), 0, MAX_QP)];
- beta[1] = betatable[av_clip(qp1 + (beta_offset >> 1 << 1), 0, MAX_QP)];
+ beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
+ beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
@@ -445,8 +412,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
- beta[0] = betatable[av_clip(qp0 + (beta_offset >> 1 << 1), 0, MAX_QP)];
- beta[1] = betatable[av_clip(qp1 + (beta_offset >> 1 << 1), 0, MAX_QP)];
+ beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
+ beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
@@ -510,138 +477,96 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
}
}
-static int boundary_strength(HEVCContext *s, MvField *curr,
- uint8_t curr_cbf_luma, MvField *neigh,
- uint8_t neigh_cbf_luma,
- RefPicList *neigh_refPicList,
- int tu_border)
+static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh,
+ RefPicList *neigh_refPicList)
{
- int mvs = curr->pred_flag[0] + curr->pred_flag[1];
-
- if (tu_border) {
- if (curr->is_intra || neigh->is_intra)
- return 2;
- if (curr_cbf_luma || neigh_cbf_luma)
- return 1;
- }
-
- if (mvs == neigh->pred_flag[0] + neigh->pred_flag[1]) {
- if (mvs == 2) {
- // same L0 and L1
- if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] &&
- s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] &&
- neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) {
- if ((abs(neigh->mv[0].x - curr->mv[0].x) >= 4 || abs(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
- abs(neigh->mv[1].x - curr->mv[1].x) >= 4 || abs(neigh->mv[1].y - curr->mv[1].y) >= 4) &&
- (abs(neigh->mv[1].x - curr->mv[0].x) >= 4 || abs(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
- abs(neigh->mv[0].x - curr->mv[1].x) >= 4 || abs(neigh->mv[0].y - curr->mv[1].y) >= 4))
- return 1;
- else
- return 0;
- } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
- neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
- if (abs(neigh->mv[0].x - curr->mv[0].x) >= 4 || abs(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
- abs(neigh->mv[1].x - curr->mv[1].x) >= 4 || abs(neigh->mv[1].y - curr->mv[1].y) >= 4)
- return 1;
- else
- return 0;
- } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
- neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
- if (abs(neigh->mv[1].x - curr->mv[0].x) >= 4 || abs(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
- abs(neigh->mv[0].x - curr->mv[1].x) >= 4 || abs(neigh->mv[0].y - curr->mv[1].y) >= 4)
- return 1;
- else
- return 0;
- } else {
+ if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) {
+ // same L0 and L1
+ if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] &&
+ s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] &&
+ neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) {
+ if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
+ FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) &&
+ (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
+ FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4))
return 1;
- }
- } else { // 1 MV
- Mv A, B;
- int ref_A, ref_B;
-
- if (curr->pred_flag[0]) {
- A = curr->mv[0];
- ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]];
- } else {
- A = curr->mv[1];
- ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]];
- }
+ else
+ return 0;
+ } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
+ neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
+ if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
+ FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4)
+ return 1;
+ else
+ return 0;
+ } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
+ neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
+ if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
+ FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4)
+ return 1;
+ else
+ return 0;
+ } else {
+ return 1;
+ }
+ } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV
+ Mv A, B;
+ int ref_A, ref_B;
+
+ if (curr->pred_flag & 1) {
+ A = curr->mv[0];
+ ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]];
+ } else {
+ A = curr->mv[1];
+ ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]];
+ }
- if (neigh->pred_flag[0]) {
- B = neigh->mv[0];
- ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]];
- } else {
- B = neigh->mv[1];
- ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]];
- }
+ if (neigh->pred_flag & 1) {
+ B = neigh->mv[0];
+ ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]];
+ } else {
+ B = neigh->mv[1];
+ ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]];
+ }
- if (ref_A == ref_B) {
- if (abs(A.x - B.x) >= 4 || abs(A.y - B.y) >= 4)
- return 1;
- else
- return 0;
- } else
+ if (ref_A == ref_B) {
+ if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4)
return 1;
- }
+ else
+ return 0;
+ } else
+ return 1;
}
return 1;
}
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
- int log2_trafo_size,
- int slice_or_tiles_up_boundary,
- int slice_or_tiles_left_boundary)
+ int log2_trafo_size)
{
+ HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int log2_min_pu_size = s->sps->log2_min_pu_size;
int log2_min_tu_size = s->sps->log2_min_tb_size;
int min_pu_width = s->sps->min_pu_width;
int min_tu_width = s->sps->min_tb_width;
int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
- (x0 >> log2_min_pu_size)].is_intra;
+ (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
int i, j, bs;
if (y0 > 0 && (y0 & 7) == 0) {
- int yp_pu = (y0 - 1) >> log2_min_pu_size;
- int yq_pu = y0 >> log2_min_pu_size;
- int yp_tu = (y0 - 1) >> log2_min_tu_size;
- int yq_tu = y0 >> log2_min_tu_size;
-
- for (i = 0; i < (1 << log2_trafo_size); i += 4) {
- int x_pu = (x0 + i) >> log2_min_pu_size;
- int x_tu = (x0 + i) >> log2_min_tu_size;
- MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
- MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
- uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu];
- uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu];
+ int bd_ctby = y0 & ((1 << s->sps->log2_ctb_size) - 1);
+ int bd_slice = s->sh.slice_loop_filter_across_slices_enabled_flag ||
+ !(lc->slice_or_tiles_up_boundary & 1);
+ int bd_tiles = s->pps->loop_filter_across_tiles_enabled_flag ||
+ !(lc->slice_or_tiles_up_boundary & 2);
+ if (((bd_slice && bd_tiles) || bd_ctby)) {
+ int yp_pu = (y0 - 1) >> log2_min_pu_size;
+ int yq_pu = y0 >> log2_min_pu_size;
+ int yp_tu = (y0 - 1) >> log2_min_tu_size;
+ int yq_tu = y0 >> log2_min_tu_size;
RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref,
- x0 + i, y0 - 1);
-
- bs = boundary_strength(s, curr, curr_cbf_luma,
- top, top_cbf_luma, top_refPicList, 1);
- if (!s->sh.slice_loop_filter_across_slices_enabled_flag &&
- (slice_or_tiles_up_boundary & 1) &&
- (y0 % (1 << s->sps->log2_ctb_size)) == 0)
- bs = 0;
- else if (!s->pps->loop_filter_across_tiles_enabled_flag &&
- (slice_or_tiles_up_boundary & 2) &&
- (y0 % (1 << s->sps->log2_ctb_size)) == 0)
- bs = 0;
- if (y0 == 0 || s->sh.disable_deblocking_filter_flag == 1)
- bs = 0;
- if (bs)
- s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs;
- }
- }
-
- // bs for TU internal horizontal PU boundaries
- if (log2_trafo_size > s->sps->log2_min_pu_size && !is_intra)
- for (j = 8; j < (1 << log2_trafo_size); j += 8) {
- int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
- int yq_pu = (y0 + j) >> log2_min_pu_size;
- int yp_tu = (y0 + j - 1) >> log2_min_tu_size;
- int yq_tu = (y0 + j) >> log2_min_tu_size;
+ x0, y0 - 1);
for (i = 0; i < (1 << log2_trafo_size); i += 4) {
int x_pu = (x0 + i) >> log2_min_pu_size;
@@ -650,81 +575,86 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu];
uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu];
- RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref,
- x0 + i,
- y0 + j - 1);
-
- bs = boundary_strength(s, curr, curr_cbf_luma,
- top, top_cbf_luma, top_refPicList, 0);
- if (s->sh.disable_deblocking_filter_flag == 1)
- bs = 0;
- if (bs)
- s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
+
+ if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA)
+ bs = 2;
+ else if (curr_cbf_luma || top_cbf_luma)
+ bs = 1;
+ else
+ bs = boundary_strength(s, curr, top, top_refPicList);
+ s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs;
}
}
+ }
// bs for vertical TU boundaries
if (x0 > 0 && (x0 & 7) == 0) {
- int xp_pu = (x0 - 1) >> log2_min_pu_size;
- int xq_pu = x0 >> log2_min_pu_size;
- int xp_tu = (x0 - 1) >> log2_min_tu_size;
- int xq_tu = x0 >> log2_min_tu_size;
-
- for (i = 0; i < (1 << log2_trafo_size); i += 4) {
- int y_pu = (y0 + i) >> log2_min_pu_size;
- int y_tu = (y0 + i) >> log2_min_tu_size;
- MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
- MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
-
- uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
- uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
+ int bd_ctbx = x0 & ((1 << s->sps->log2_ctb_size) - 1);
+ int bd_slice = s->sh.slice_loop_filter_across_slices_enabled_flag ||
+ !(lc->slice_or_tiles_left_boundary & 1);
+ int bd_tiles = s->pps->loop_filter_across_tiles_enabled_flag ||
+ !(lc->slice_or_tiles_left_boundary & 2);
+ if (((bd_slice && bd_tiles) || bd_ctbx)) {
+ int xp_pu = (x0 - 1) >> log2_min_pu_size;
+ int xq_pu = x0 >> log2_min_pu_size;
+ int xp_tu = (x0 - 1) >> log2_min_tu_size;
+ int xq_tu = x0 >> log2_min_tu_size;
RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref,
- x0 - 1, y0 + i);
-
- bs = boundary_strength(s, curr, curr_cbf_luma,
- left, left_cbf_luma, left_refPicList, 1);
- if (!s->sh.slice_loop_filter_across_slices_enabled_flag &&
- (slice_or_tiles_left_boundary & 1) &&
- (x0 % (1 << s->sps->log2_ctb_size)) == 0)
- bs = 0;
- else if (!s->pps->loop_filter_across_tiles_enabled_flag &&
- (slice_or_tiles_left_boundary & 2) &&
- (x0 % (1 << s->sps->log2_ctb_size)) == 0)
- bs = 0;
- if (x0 == 0 || s->sh.disable_deblocking_filter_flag == 1)
- bs = 0;
- if (bs)
+ x0 - 1, y0);
+
+ for (i = 0; i < (1 << log2_trafo_size); i += 4) {
+ int y_pu = (y0 + i) >> log2_min_pu_size;
+ int y_tu = (y0 + i) >> log2_min_tu_size;
+ MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
+ MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
+ uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
+ uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
+
+ if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA)
+ bs = 2;
+ else if (curr_cbf_luma || left_cbf_luma)
+ bs = 1;
+ else
+ bs = boundary_strength(s, curr, left, left_refPicList);
s->vertical_bs[(x0 >> 3) + ((y0 + i) >> 2) * s->bs_width] = bs;
+ }
}
}
- // bs for TU internal vertical PU boundaries
- if (log2_trafo_size > log2_min_pu_size && !is_intra)
+ if (log2_trafo_size > log2_min_pu_size && !is_intra) {
+ RefPicList *refPicList = ff_hevc_get_ref_list(s, s->ref,
+ x0,
+ y0);
+ // bs for TU internal horizontal PU boundaries
+ for (j = 8; j < (1 << log2_trafo_size); j += 8) {
+ int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
+ int yq_pu = (y0 + j) >> log2_min_pu_size;
+
+ for (i = 0; i < (1 << log2_trafo_size); i += 4) {
+ int x_pu = (x0 + i) >> log2_min_pu_size;
+ MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
+ MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
+
+ bs = boundary_strength(s, curr, top, refPicList);
+ s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
+ }
+ }
+
+ // bs for TU internal vertical PU boundaries
for (j = 0; j < (1 << log2_trafo_size); j += 4) {
int y_pu = (y0 + j) >> log2_min_pu_size;
- int y_tu = (y0 + j) >> log2_min_tu_size;
for (i = 8; i < (1 << log2_trafo_size); i += 8) {
int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
int xq_pu = (x0 + i) >> log2_min_pu_size;
- int xp_tu = (x0 + i - 1) >> log2_min_tu_size;
- int xq_tu = (x0 + i) >> log2_min_tu_size;
MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
- uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
- uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
- RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref,
- x0 + i - 1,
- y0 + j);
-
- bs = boundary_strength(s, curr, curr_cbf_luma,
- left, left_cbf_luma, left_refPicList, 0);
- if (s->sh.disable_deblocking_filter_flag == 1)
- bs = 0;
- if (bs)
- s->vertical_bs[((x0 + i) >> 3) + ((y0 + j) >> 2) * s->bs_width] = bs;
+
+ bs = boundary_strength(s, curr, left, refPicList);
+ s->vertical_bs[((x0 + i) >> 3) + ((y0 + j) >> 2) * s->bs_width] = bs;
}
}
+ }
}
#undef LUMA
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_mvs.c b/chromium/third_party/ffmpeg/libavcodec/hevc_mvs.c
index b4e067b8766..b7ca79c35e0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_mvs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_mvs.c
@@ -123,16 +123,18 @@ static int isDiffMER(HEVCContext *s, int xN, int yN, int xP, int yP)
// check if the mv's and refidx are the same between A and B
static int compareMVrefidx(struct MvField A, struct MvField B)
{
- if (A.pred_flag[0] && A.pred_flag[1] && B.pred_flag[0] && B.pred_flag[1])
- return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y) &&
- MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
-
- if (A.pred_flag[0] && !A.pred_flag[1] && B.pred_flag[0] && !B.pred_flag[1])
- return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y);
-
- if (!A.pred_flag[0] && A.pred_flag[1] && !B.pred_flag[0] && B.pred_flag[1])
- return MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
-
+ int a_pf = A.pred_flag;
+ int b_pf = B.pred_flag;
+ if (a_pf == b_pf) {
+ if (a_pf == PF_BI) {
+ return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y) &&
+ MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
+ } else if (a_pf == PF_L0) {
+ return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y);
+ } else if (a_pf == PF_L1) {
+ return MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
+ }
+ }
return 0;
}
@@ -140,14 +142,14 @@ static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
{
int tx, scale_factor;
- td = av_clip_int8_c(td);
- tb = av_clip_int8_c(tb);
+ td = av_clip_int8(td);
+ tb = av_clip_int8(tb);
tx = (0x4000 + abs(td / 2)) / td;
- scale_factor = av_clip_c((tb * tx + 32) >> 6, -4096, 4095);
- dst->x = av_clip_int16_c((scale_factor * src->x + 127 +
- (scale_factor * src->x < 0)) >> 8);
- dst->y = av_clip_int16_c((scale_factor * src->y + 127 +
- (scale_factor * src->y < 0)) >> 8);
+ scale_factor = av_clip((tb * tx + 32) >> 6, -4096, 4095);
+ dst->x = av_clip_int16((scale_factor * src->x + 127 +
+ (scale_factor * src->x < 0)) >> 8);
+ dst->y = av_clip_int16((scale_factor * src->y + 127 +
+ (scale_factor * src->y < 0)) >> 8);
}
static int check_mvset(Mv *mvLXCol, Mv *mvCol,
@@ -168,10 +170,7 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
cur_poc_diff = poc - refPicList[X].list[refIdxLx];
- if (!col_poc_diff)
- col_poc_diff = 1; // error resilience
-
- if (cur_lt || col_poc_diff == cur_poc_diff) {
+ if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
mvLXCol->x = mvCol->x;
mvLXCol->y = mvCol->y;
} else {
@@ -193,17 +192,14 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
{
RefPicList *refPicList = s->ref->refPicList;
- if (temp_col.is_intra) {
- mvLXCol->x = 0;
- mvLXCol->y = 0;
+ if (temp_col.pred_flag == PF_INTRA)
return 0;
- }
- if (temp_col.pred_flag[0] == 0)
+ if (!(temp_col.pred_flag & PF_L0))
return CHECK_MVSET(1);
- else if (temp_col.pred_flag[0] == 1 && temp_col.pred_flag[1] == 0)
+ else if (temp_col.pred_flag == PF_L0)
return CHECK_MVSET(0);
- else if (temp_col.pred_flag[0] == 1 && temp_col.pred_flag[1] == 1) {
+ else if (temp_col.pred_flag == PF_BI) {
int check_diffpicount = 0;
int i = 0;
for (i = 0; i < refPicList[0].nb_refs; i++) {
@@ -295,7 +291,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
}
#define AVAILABLE(cand, v) \
- (cand && !TAB_MVF_PU(v).is_intra)
+ (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
#define PRED_BLOCK_AVAILABLE(v) \
check_prediction_block_available(s, log2_cb_size, \
@@ -458,9 +454,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
0, &mv_l1_col, 1) : 0;
if (available_l0 || available_l1) {
- mergecandlist[nb_merge_cand].is_intra = 0;
- mergecandlist[nb_merge_cand].pred_flag[0] = available_l0;
- mergecandlist[nb_merge_cand].pred_flag[1] = available_l1;
+ mergecandlist[nb_merge_cand].pred_flag = available_l0 + (available_l1 << 1);
if (available_l0) {
mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
mergecandlist[nb_merge_cand].ref_idx[0] = 0;
@@ -487,20 +481,18 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
MvField l0_cand = mergecandlist[l0_cand_idx];
MvField l1_cand = mergecandlist[l1_cand_idx];
- if (l0_cand.pred_flag[0] && l1_cand.pred_flag[1] &&
+ if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
(refPicList[0].list[l0_cand.ref_idx[0]] !=
refPicList[1].list[l1_cand.ref_idx[1]] ||
l0_cand.mv[0].x != l1_cand.mv[1].x ||
l0_cand.mv[0].y != l1_cand.mv[1].y)) {
mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0];
mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1];
- mergecandlist[nb_merge_cand].pred_flag[0] = 1;
- mergecandlist[nb_merge_cand].pred_flag[1] = 1;
+ mergecandlist[nb_merge_cand].pred_flag = PF_BI;
mergecandlist[nb_merge_cand].mv[0].x = l0_cand.mv[0].x;
mergecandlist[nb_merge_cand].mv[0].y = l0_cand.mv[0].y;
mergecandlist[nb_merge_cand].mv[1].x = l1_cand.mv[1].x;
mergecandlist[nb_merge_cand].mv[1].y = l1_cand.mv[1].y;
- mergecandlist[nb_merge_cand].is_intra = 0;
nb_merge_cand++;
}
}
@@ -508,13 +500,11 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// append Zero motion vector candidates
while (nb_merge_cand < s->sh.max_num_merge_cand) {
- mergecandlist[nb_merge_cand].pred_flag[0] = 1;
- mergecandlist[nb_merge_cand].pred_flag[1] = s->sh.slice_type == B_SLICE;
+ mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == B_SLICE) << 1);
mergecandlist[nb_merge_cand].mv[0].x = 0;
mergecandlist[nb_merge_cand].mv[0].y = 0;
mergecandlist[nb_merge_cand].mv[1].x = 0;
mergecandlist[nb_merge_cand].mv[1].y = 0;
- mergecandlist[nb_merge_cand].is_intra = 0;
mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
@@ -550,11 +540,9 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size,
singleMCLFlag, part_idx, mergecand_list);
- if (mergecand_list[merge_idx].pred_flag[0] == 1 &&
- mergecand_list[merge_idx].pred_flag[1] == 1 &&
+ if (mergecand_list[merge_idx].pred_flag == PF_BI &&
(nPbW2 + nPbH2) == 12) {
- mergecand_list[merge_idx].ref_idx[1] = -1;
- mergecand_list[merge_idx].pred_flag[1] = 0;
+ mergecand_list[merge_idx].pred_flag = PF_L0;
}
*mv = mergecand_list[merge_idx];
@@ -569,8 +557,12 @@ static av_always_inline void dist_scale(HEVCContext *s, Mv *mv,
int ref_pic_elist = refPicList[elist].list[TAB_MVF(x, y).ref_idx[elist]];
int ref_pic_curr = refPicList[ref_idx_curr].list[ref_idx];
- if (ref_pic_elist != ref_pic_curr)
- mv_scale(mv, mv, s->poc - ref_pic_elist, s->poc - ref_pic_curr);
+ if (ref_pic_elist != ref_pic_curr) {
+ int poc_diff = s->poc - ref_pic_elist;
+ if (!poc_diff)
+ poc_diff = 1;
+ mv_scale(mv, mv, poc_diff, s->poc - ref_pic_curr);
+ }
}
static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
@@ -581,7 +573,7 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
RefPicList *refPicList = s->ref->refPicList;
- if (TAB_MVF(x, y).pred_flag[pred_flag_index] == 1 &&
+ if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
*mv = TAB_MVF(x, y).mv[pred_flag_index];
return 1;
@@ -596,18 +588,20 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
int min_pu_width = s->sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList;
- int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
- int colIsLongTerm =
- refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
+ if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
+ int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
- if (TAB_MVF(x, y).pred_flag[pred_flag_index] &&
- colIsLongTerm == currIsLongTerm) {
- *mv = TAB_MVF(x, y).mv[pred_flag_index];
- if (!currIsLongTerm)
- dist_scale(s, mv, min_pu_width, x, y,
- pred_flag_index, ref_idx_curr, ref_idx);
- return 1;
+ int colIsLongTerm =
+ refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
+
+ if (colIsLongTerm == currIsLongTerm) {
+ *mv = TAB_MVF(x, y).mv[pred_flag_index];
+ if (!currIsLongTerm)
+ dist_scale(s, mv, min_pu_width, x, y,
+ pred_flag_index, ref_idx_curr, ref_idx);
+ return 1;
+ }
}
return 0;
}
@@ -653,8 +647,8 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int xB2_pu = 0, yB2_pu = 0;
int is_available_b2 = 0;
Mv mvpcand_list[2] = { { 0 } };
- Mv mxA = { 0 };
- Mv mxB = { 0 };
+ Mv mxA;
+ Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
@@ -808,10 +802,5 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
mvpcand_list[numMVPCandLX++] = mv_col;
}
- // insert zero motion vectors when the number of available candidates are less than 2
- while (numMVPCandLX < 2)
- mvpcand_list[numMVPCandLX++] = (Mv){ 0, 0 };
-
- mv->mv[LX].x = mvpcand_list[mvp_lx_flag].x;
- mv->mv[LX].y = mvpcand_list[mvp_lx_flag].y;
+ mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_ps.c b/chromium/third_party/ffmpeg/libavcodec/hevc_ps.c
index 16eeab40cd4..647f83eec6d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_ps.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_ps.c
@@ -92,7 +92,7 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
uint8_t delta_rps_sign;
if (is_slice_header) {
- int delta_idx = get_ue_golomb_long(gb) + 1;
+ unsigned int delta_idx = get_ue_golomb_long(gb) + 1;
if (delta_idx > sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid value of delta_idx in slice header RPS: %d > %d.\n",
@@ -192,7 +192,7 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,
}
-static int decode_profile_tier_level(HEVCContext *s, ProfileTierLevel *ptl)
+static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
@@ -201,12 +201,14 @@ static int decode_profile_tier_level(HEVCContext *s, ProfileTierLevel *ptl)
ptl->profile_space = get_bits(gb, 2);
ptl->tier_flag = get_bits1(gb);
ptl->profile_idc = get_bits(gb, 5);
- if (ptl->profile_idc == 1)
+ if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(s->avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
- else if (ptl->profile_idc == 2)
- av_log(s->avctx, AV_LOG_DEBUG, "Main10 profile bitstream\n");
+ else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10)
+ av_log(s->avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
+ else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
+ av_log(s->avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else
- av_log(s->avctx, AV_LOG_WARNING, "No profile indication! (%d)\n", ptl->profile_idc);
+ av_log(s->avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc);
for (i = 0; i < 32; i++)
ptl->profile_compatibility_flag[i] = get_bits1(gb);
@@ -214,22 +216,19 @@ static int decode_profile_tier_level(HEVCContext *s, ProfileTierLevel *ptl)
ptl->interlaced_source_flag = get_bits1(gb);
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
- if (get_bits(gb, 16) != 0) // XXX_reserved_zero_44bits[0..15]
- return -1;
- if (get_bits(gb, 16) != 0) // XXX_reserved_zero_44bits[16..31]
- return -1;
- if (get_bits(gb, 12) != 0) // XXX_reserved_zero_44bits[32..43]
- return -1;
- ptl->level_idc = get_bits(gb, 8);
- return 0;
+
+ skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
+ skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
+ skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
}
-static int parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
+static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb;
- decode_profile_tier_level(s, &ptl->general_PTL);
+ decode_profile_tier_level(s, &ptl->general_ptl);
+ ptl->general_ptl.level_idc = get_bits(gb, 8);
for (i = 0; i < max_num_sub_layers - 1; i++) {
ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);
@@ -239,15 +238,14 @@ static int parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
for (i = max_num_sub_layers - 1; i < 8; i++)
skip_bits(gb, 2); // reserved_zero_2bits[i]
for (i = 0; i < max_num_sub_layers - 1; i++) {
- if (ptl->sub_layer_profile_present_flag[i]) {
- decode_profile_tier_level(s, &ptl->sub_layer_PTL[i]);
- ptl->sub_layer_PTL[i].level_idc = get_bits(gb, 8);
- }
+ if (ptl->sub_layer_profile_present_flag[i])
+ decode_profile_tier_level(s, &ptl->sub_layer_ptl[i]);
+ if (ptl->sub_layer_level_present_flag[i])
+ ptl->sub_layer_ptl[i].level_idc = get_bits(gb, 8);
}
- return 0;
}
-static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb,
+static void decode_sublayer_hrd(HEVCContext *s, unsigned int nb_cpb,
int subpic_params_present)
{
GetBitContext *gb = &s->HEVClc->gb;
@@ -301,7 +299,7 @@ static void decode_hrd(HEVCContext *s, int common_inf_present,
for (i = 0; i < max_sublayers; i++) {
int low_delay = 0;
- int nb_cpb = 1;
+ unsigned int nb_cpb = 1;
int fixed_rate = get_bits1(gb);
if (!fixed_rate)
@@ -336,9 +334,6 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n");
- if (!vps)
- return AVERROR(ENOMEM);
-
vps_id = get_bits(gb, 4);
if (vps_id >= MAX_VPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
@@ -365,10 +360,8 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
goto err;
}
- if (parse_ptl(s, &vps->ptl, vps->vps_max_sub_layers) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Error decoding profile tier level.\n");
- goto err;
- }
+ parse_ptl(s, &vps->ptl, vps->vps_max_sub_layers);
+
vps->vps_sub_layer_ordering_info_present_flag = get_bits1(gb);
i = vps->vps_sub_layer_ordering_info_present_flag ? 0 : vps->vps_max_sub_layers - 1;
@@ -412,12 +405,10 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
decode_hrd(s, common_inf_present, vps->vps_max_sub_layers);
}
}
-
- vps->vps_extension_flag = get_bits1(gb);
+ get_bits1(gb); /* vps_extension_flag */
av_buffer_unref(&s->vps_list[vps_id]);
s->vps_list[vps_id] = vps_buf;
-
return 0;
err:
@@ -510,10 +501,8 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
vui->vui_timing_info_present_flag = get_bits1(gb);
if (vui->vui_timing_info_present_flag) {
- vui->vui_num_units_in_tick = get_bits(gb, 32);
- vui->vui_time_scale = get_bits(gb, 32);
- s->avctx->time_base.num = vui->vui_num_units_in_tick;
- s->avctx->time_base.den = vui->vui_time_scale;
+ vui->vui_num_units_in_tick = get_bits_long(gb, 32);
+ vui->vui_time_scale = get_bits_long(gb, 32);
vui->vui_poc_proportional_to_timing_flag = get_bits1(gb);
if (vui->vui_poc_proportional_to_timing_flag)
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
@@ -566,18 +555,18 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl)
GetBitContext *gb = &s->HEVClc->gb;
uint8_t scaling_list_pred_mode_flag[4][6];
int32_t scaling_list_dc_coef[2][6];
- int size_id, matrix_id, i, pos, delta;
+ int size_id, matrix_id, i, pos;
for (size_id = 0; size_id < 4; size_id++)
for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {
scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb);
if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
- delta = get_ue_golomb_long(gb);
+ unsigned int delta = get_ue_golomb_long(gb);
/* Only need to handle non-zero delta. Zero means default,
* which should already be in the arrays. */
if (delta) {
// Copy from previous array.
- if (matrix_id - delta < 0) {
+ if (matrix_id < delta) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid delta in scaling list data: %d.\n", delta);
return AVERROR_INVALIDDATA;
@@ -622,8 +611,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
{
const AVPixFmtDescriptor *desc;
GetBitContext *gb = &s->HEVClc->gb;
- int ret = 0;
- int sps_id = 0;
+ int ret = 0;
+ unsigned int sps_id = 0;
int log2_diff_max_min_transform_block_size;
int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
int i;
@@ -646,6 +635,13 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
goto err;
}
+ if (!s->vps_list[sps->vps_id]) {
+ av_log(s->avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
+ sps->vps_id);
+ ret = AVERROR_INVALIDDATA;
+ goto err;
+ }
+
sps->max_sub_layers = get_bits(gb, 3) + 1;
if (sps->max_sub_layers > MAX_SUB_LAYERS) {
av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
@@ -656,11 +652,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
skip_bits1(gb); // temporal_id_nesting_flag
- if (parse_ptl(s, &sps->ptl, sps->max_sub_layers) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "error decoding profile tier level\n");
- ret = AVERROR_INVALIDDATA;
- goto err;
- }
+ parse_ptl(s, &sps->ptl, sps->max_sub_layers);
+
sps_id = get_ue_golomb_long(gb);
if (sps_id >= MAX_SPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", sps_id);
@@ -771,8 +764,11 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
if (sps->temporal_layer[i].num_reorder_pics > sps->temporal_layer[i].max_dec_pic_buffering - 1) {
av_log(s->avctx, AV_LOG_ERROR, "sps_max_num_reorder_pics out of range: %d\n",
sps->temporal_layer[i].num_reorder_pics);
- ret = AVERROR_INVALIDDATA;
- goto err;
+ if (sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) {
+ ret = AVERROR_INVALIDDATA;
+ goto err;
+ }
+ sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[i].num_reorder_pics + 1;
}
}
@@ -997,8 +993,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
int log2_diff_ctb_min_tb_size;
int i, j, x, y, ctb_addr_rs, tile_id;
- int ret = 0;
- int pps_id = 0;
+ int ret = 0;
+ unsigned int pps_id = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
@@ -1038,7 +1034,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
goto err;
}
if (!s->sps_list[pps->sps_id]) {
- av_log(s->avctx, AV_LOG_ERROR, "SPS does not exist \n");
+ av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
@@ -1115,7 +1111,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
- int sum = 0;
+ uint64_t sum = 0;
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[i];
@@ -1183,7 +1179,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
}
pps->slice_header_extension_present_flag = get_bits1(gb);
- pps->pps_extension_flag = get_bits1(gb);
+ skip_bits1(gb); // pps_extension_flag
// Inferred parameters
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_refs.c b/chromium/third_party/ffmpeg/libavcodec/hevc_refs.c
index 118688f55f2..24d55d15bec 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_refs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_refs.c
@@ -1,5 +1,5 @@
/*
- * HEVC video Decoder
+ * HEVC video decoder
*
* Copyright (C) 2012 - 2013 Guillaume Martres
* Copyright (C) 2012 - 2013 Gildas Cocherel
@@ -146,6 +146,8 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
ref->poc = poc;
ref->flags = HEVC_FRAME_FLAG_OUTPUT | HEVC_FRAME_FLAG_SHORT_REF;
+ if (s->sh.pic_output_flag == 0)
+ ref->flags &= ~(HEVC_FRAME_FLAG_OUTPUT);
ref->sequence = s->seq_decode;
ref->window = s->sps->output_window;
@@ -159,6 +161,16 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
int min_poc = INT_MAX;
int i, min_idx, ret;
+ if (s->sh.no_output_of_prior_pics_flag == 1) {
+ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
+ HEVCFrame *frame = &s->DPB[i];
+ if ((frame->flags & HEVC_FRAME_FLAG_OUTPUT) && frame->poc != s->poc &&
+ frame->sequence == s->seq_output) {
+ frame->flags &= ~(HEVC_FRAME_FLAG_OUTPUT);
+ }
+ }
+ }
+
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *frame = &s->DPB[i];
if ((frame->flags & HEVC_FRAME_FLAG_OUTPUT) &&
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevc_sei.c b/chromium/third_party/ffmpeg/libavcodec/hevc_sei.c
index af8cb7d60eb..216db37e537 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevc_sei.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevc_sei.c
@@ -22,8 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "hevc.h"
#include "golomb.h"
+#include "hevc.h"
static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
{
@@ -52,21 +52,21 @@ static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
- int cancel, type, quincunx;
get_ue_golomb(gb); // frame_packing_arrangement_id
- cancel = get_bits1(gb); // frame_packing_cancel_flag
- if (cancel == 0) {
- type = get_bits(gb, 7); // frame_packing_arrangement_type
- quincunx = get_bits1(gb); // quincunx_sampling_flag
- skip_bits(gb, 6); // content_interpretation_type
+ s->sei_frame_packing_present = !get_bits1(gb);
+
+ if (s->sei_frame_packing_present) {
+ s->frame_packing_arrangement_type = get_bits(gb, 7);
+ s->quincunx_subsampling = get_bits1(gb);
+ s->content_interpretation_type = get_bits(gb, 6);
// the following skips spatial_flipping_flag frame0_flipped_flag
// field_views_flag current_frame_is_frame0_flag
// frame0_self_contained_flag frame1_self_contained_flag
skip_bits(gb, 6);
- if (quincunx == 0 && type != 5)
+ if (!s->quincunx_subsampling && s->frame_packing_arrangement_type != 5)
skip_bits(gb, 16); // frame[01]_grid_position_[xy]
skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
skip_bits1(gb); // frame_packing_arrangement_persistance_flag
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevcdsp.c b/chromium/third_party/ffmpeg/libavcodec/hevcdsp.c
index b3abc9d8a58..e6f56386e77 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevcdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevcdsp.c
@@ -2,6 +2,8 @@
* HEVC video decoder
*
* Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2013 - 2014 Pierre-Edouard Lepere
+ *
*
* This file is part of FFmpeg.
*
@@ -20,7 +22,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "hevc.h"
#include "hevcdsp.h"
static const int8_t transform[32][32] = {
@@ -90,14 +91,20 @@ static const int8_t transform[32][32] = {
90, -90, 88, -85, 82, -78, 73, -67, 61, -54, 46, -38, 31, -22, 13, -4 },
};
-DECLARE_ALIGNED(16, const int8_t, ff_hevc_epel_filters[7][16]) = {
- { -2, 58, 10, -2, -2, 58, 10, -2, -2, 58, 10, -2, -2, 58, 10, -2 },
- { -4, 54, 16, -2, -4, 54, 16, -2, -4, 54, 16, -2, -4, 54, 16, -2 },
- { -6, 46, 28, -4, -6, 46, 28, -4, -6, 46, 28, -4, -6, 46, 28, -4 },
- { -4, 36, 36, -4, -4, 36, 36, -4, -4, 36, 36, -4, -4, 36, 36, -4 },
- { -4, 28, 46, -6, -4, 28, 46, -6, -4, 28, 46, -6, -4, 28, 46, -6 },
- { -2, 16, 54, -4, -2, 16, 54, -4, -2, 16, 54, -4, -2, 16, 54, -4 },
- { -2, 10, 58, -2, -2, 10, 58, -2, -2, 10, 58, -2, -2, 10, 58, -2 },
+DECLARE_ALIGNED(16, const int8_t, ff_hevc_epel_filters[7][4]) = {
+ { -2, 58, 10, -2},
+ { -4, 54, 16, -2},
+ { -6, 46, 28, -4},
+ { -4, 36, 36, -4},
+ { -4, 28, 46, -6},
+ { -2, 16, 54, -4},
+ { -2, 10, 58, -2},
+};
+
+DECLARE_ALIGNED(16, const int8_t, ff_hevc_qpel_filters[3][16]) = {
+ { -1, 4,-10, 58, 17, -5, 1, 0, -1, 4,-10, 58, 17, -5, 1, 0},
+ { -1, 4,-11, 40, 40,-11, 4, -1, -1, 4,-11, 40, 40,-11, 4, -1},
+ { 0, 1, -5, 17, 58,-10, 4, -1, 0, 1, -5, 17, 58,-10, 4, -1}
};
#define BIT_DEPTH 8
@@ -117,6 +124,71 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth
+#undef PEL_FUNC
+#define PEL_FUNC(dst1, idx1, idx2, a, depth) \
+ for(i = 0 ; i < 10 ; i++) \
+{ \
+ hevcdsp->dst1[i][idx1][idx2] = a ## _ ## depth; \
+}
+
+#undef EPEL_FUNCS
+#define EPEL_FUNCS(depth) \
+ PEL_FUNC(put_hevc_epel, 0, 0, put_hevc_pel_pixels, depth); \
+ PEL_FUNC(put_hevc_epel, 0, 1, put_hevc_epel_h, depth); \
+ PEL_FUNC(put_hevc_epel, 1, 0, put_hevc_epel_v, depth); \
+ PEL_FUNC(put_hevc_epel, 1, 1, put_hevc_epel_hv, depth)
+
+#undef EPEL_UNI_FUNCS
+#define EPEL_UNI_FUNCS(depth) \
+ PEL_FUNC(put_hevc_epel_uni, 0, 0, put_hevc_pel_uni_pixels, depth); \
+ PEL_FUNC(put_hevc_epel_uni, 0, 1, put_hevc_epel_uni_h, depth); \
+ PEL_FUNC(put_hevc_epel_uni, 1, 0, put_hevc_epel_uni_v, depth); \
+ PEL_FUNC(put_hevc_epel_uni, 1, 1, put_hevc_epel_uni_hv, depth); \
+ PEL_FUNC(put_hevc_epel_uni_w, 0, 0, put_hevc_pel_uni_w_pixels, depth); \
+ PEL_FUNC(put_hevc_epel_uni_w, 0, 1, put_hevc_epel_uni_w_h, depth); \
+ PEL_FUNC(put_hevc_epel_uni_w, 1, 0, put_hevc_epel_uni_w_v, depth); \
+ PEL_FUNC(put_hevc_epel_uni_w, 1, 1, put_hevc_epel_uni_w_hv, depth)
+
+#undef EPEL_BI_FUNCS
+#define EPEL_BI_FUNCS(depth) \
+ PEL_FUNC(put_hevc_epel_bi, 0, 0, put_hevc_pel_bi_pixels, depth); \
+ PEL_FUNC(put_hevc_epel_bi, 0, 1, put_hevc_epel_bi_h, depth); \
+ PEL_FUNC(put_hevc_epel_bi, 1, 0, put_hevc_epel_bi_v, depth); \
+ PEL_FUNC(put_hevc_epel_bi, 1, 1, put_hevc_epel_bi_hv, depth); \
+ PEL_FUNC(put_hevc_epel_bi_w, 0, 0, put_hevc_pel_bi_w_pixels, depth); \
+ PEL_FUNC(put_hevc_epel_bi_w, 0, 1, put_hevc_epel_bi_w_h, depth); \
+ PEL_FUNC(put_hevc_epel_bi_w, 1, 0, put_hevc_epel_bi_w_v, depth); \
+ PEL_FUNC(put_hevc_epel_bi_w, 1, 1, put_hevc_epel_bi_w_hv, depth)
+
+#undef QPEL_FUNCS
+#define QPEL_FUNCS(depth) \
+ PEL_FUNC(put_hevc_qpel, 0, 0, put_hevc_pel_pixels, depth); \
+ PEL_FUNC(put_hevc_qpel, 0, 1, put_hevc_qpel_h, depth); \
+ PEL_FUNC(put_hevc_qpel, 1, 0, put_hevc_qpel_v, depth); \
+ PEL_FUNC(put_hevc_qpel, 1, 1, put_hevc_qpel_hv, depth)
+
+#undef QPEL_UNI_FUNCS
+#define QPEL_UNI_FUNCS(depth) \
+ PEL_FUNC(put_hevc_qpel_uni, 0, 0, put_hevc_pel_uni_pixels, depth); \
+ PEL_FUNC(put_hevc_qpel_uni, 0, 1, put_hevc_qpel_uni_h, depth); \
+ PEL_FUNC(put_hevc_qpel_uni, 1, 0, put_hevc_qpel_uni_v, depth); \
+ PEL_FUNC(put_hevc_qpel_uni, 1, 1, put_hevc_qpel_uni_hv, depth); \
+ PEL_FUNC(put_hevc_qpel_uni_w, 0, 0, put_hevc_pel_uni_w_pixels, depth); \
+ PEL_FUNC(put_hevc_qpel_uni_w, 0, 1, put_hevc_qpel_uni_w_h, depth); \
+ PEL_FUNC(put_hevc_qpel_uni_w, 1, 0, put_hevc_qpel_uni_w_v, depth); \
+ PEL_FUNC(put_hevc_qpel_uni_w, 1, 1, put_hevc_qpel_uni_w_hv, depth)
+
+#undef QPEL_BI_FUNCS
+#define QPEL_BI_FUNCS(depth) \
+ PEL_FUNC(put_hevc_qpel_bi, 0, 0, put_hevc_pel_bi_pixels, depth); \
+ PEL_FUNC(put_hevc_qpel_bi, 0, 1, put_hevc_qpel_bi_h, depth); \
+ PEL_FUNC(put_hevc_qpel_bi, 1, 0, put_hevc_qpel_bi_v, depth); \
+ PEL_FUNC(put_hevc_qpel_bi, 1, 1, put_hevc_qpel_bi_hv, depth); \
+ PEL_FUNC(put_hevc_qpel_bi_w, 0, 0, put_hevc_pel_bi_w_pixels, depth); \
+ PEL_FUNC(put_hevc_qpel_bi_w, 0, 1, put_hevc_qpel_bi_w_h, depth); \
+ PEL_FUNC(put_hevc_qpel_bi_w, 1, 0, put_hevc_qpel_bi_w_v, depth); \
+ PEL_FUNC(put_hevc_qpel_bi_w, 1, 1, put_hevc_qpel_bi_w_hv, depth)
+
#define HEVC_DSP(depth) \
hevcdsp->put_pcm = FUNC(put_pcm, depth); \
hevcdsp->transquant_bypass[0] = FUNC(transquant_bypass4x4, depth); \
@@ -139,35 +211,14 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
hevcdsp->sao_edge_filter[1] = FUNC(sao_edge_filter_1, depth); \
hevcdsp->sao_edge_filter[2] = FUNC(sao_edge_filter_2, depth); \
hevcdsp->sao_edge_filter[3] = FUNC(sao_edge_filter_3, depth); \
- \
- hevcdsp->put_hevc_qpel[0][0] = FUNC(put_hevc_qpel_pixels, depth); \
- hevcdsp->put_hevc_qpel[0][1] = FUNC(put_hevc_qpel_h1, depth); \
- hevcdsp->put_hevc_qpel[0][2] = FUNC(put_hevc_qpel_h2, depth); \
- hevcdsp->put_hevc_qpel[0][3] = FUNC(put_hevc_qpel_h3, depth); \
- hevcdsp->put_hevc_qpel[1][0] = FUNC(put_hevc_qpel_v1, depth); \
- hevcdsp->put_hevc_qpel[1][1] = FUNC(put_hevc_qpel_h1v1, depth); \
- hevcdsp->put_hevc_qpel[1][2] = FUNC(put_hevc_qpel_h2v1, depth); \
- hevcdsp->put_hevc_qpel[1][3] = FUNC(put_hevc_qpel_h3v1, depth); \
- hevcdsp->put_hevc_qpel[2][0] = FUNC(put_hevc_qpel_v2, depth); \
- hevcdsp->put_hevc_qpel[2][1] = FUNC(put_hevc_qpel_h1v2, depth); \
- hevcdsp->put_hevc_qpel[2][2] = FUNC(put_hevc_qpel_h2v2, depth); \
- hevcdsp->put_hevc_qpel[2][3] = FUNC(put_hevc_qpel_h3v2, depth); \
- hevcdsp->put_hevc_qpel[3][0] = FUNC(put_hevc_qpel_v3, depth); \
- hevcdsp->put_hevc_qpel[3][1] = FUNC(put_hevc_qpel_h1v3, depth); \
- hevcdsp->put_hevc_qpel[3][2] = FUNC(put_hevc_qpel_h2v3, depth); \
- hevcdsp->put_hevc_qpel[3][3] = FUNC(put_hevc_qpel_h3v3, depth); \
- \
- hevcdsp->put_hevc_epel[0][0] = FUNC(put_hevc_epel_pixels, depth); \
- hevcdsp->put_hevc_epel[0][1] = FUNC(put_hevc_epel_h, depth); \
- hevcdsp->put_hevc_epel[1][0] = FUNC(put_hevc_epel_v, depth); \
- hevcdsp->put_hevc_epel[1][1] = FUNC(put_hevc_epel_hv, depth); \
- \
- hevcdsp->put_unweighted_pred = FUNC(put_unweighted_pred, depth); \
- hevcdsp->put_weighted_pred_avg = FUNC(put_weighted_pred_avg, depth); \
- \
- hevcdsp->weighted_pred = FUNC(weighted_pred, depth); \
- hevcdsp->weighted_pred_avg = FUNC(weighted_pred_avg, depth); \
- \
+ \
+ QPEL_FUNCS(depth); \
+ QPEL_UNI_FUNCS(depth); \
+ QPEL_BI_FUNCS(depth); \
+ EPEL_FUNCS(depth); \
+ EPEL_UNI_FUNCS(depth); \
+ EPEL_BI_FUNCS(depth); \
+ \
hevcdsp->hevc_h_loop_filter_luma = FUNC(hevc_h_loop_filter_luma, depth); \
hevcdsp->hevc_v_loop_filter_luma = FUNC(hevc_v_loop_filter_luma, depth); \
hevcdsp->hevc_h_loop_filter_chroma = FUNC(hevc_h_loop_filter_chroma, depth); \
@@ -175,7 +226,8 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
hevcdsp->hevc_h_loop_filter_luma_c = FUNC(hevc_h_loop_filter_luma, depth); \
hevcdsp->hevc_v_loop_filter_luma_c = FUNC(hevc_v_loop_filter_luma, depth); \
hevcdsp->hevc_h_loop_filter_chroma_c = FUNC(hevc_h_loop_filter_chroma, depth); \
- hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth);
+ hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth)
+int i = 0;
switch (bit_depth) {
case 9:
@@ -188,4 +240,5 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
HEVC_DSP(8);
break;
}
+ if (ARCH_X86) ff_hevcdsp_init_x86(hevcdsp, bit_depth);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevcdsp.h b/chromium/third_party/ffmpeg/libavcodec/hevcdsp.h
index c6511b01ac9..6fd5469ba14 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevcdsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/hevcdsp.h
@@ -1,7 +1,9 @@
/*
- * HEVC video Decoder
+ * HEVC video decoder
*
* Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2013 - 2014 Pierre-Edouard Lepere
+ *
*
* This file is part of FFmpeg.
*
@@ -25,53 +27,97 @@
#include "get_bits.h"
-struct SAOParams;
-
-typedef struct HEVCDSPContext {
- void (*put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int size,
- GetBitContext *gb, int pcm_bit_depth);
-
- void (*transquant_bypass[4])(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _stride);
-
- void (*transform_skip)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
+typedef struct SAOParams {
+ int offset_abs[3][4]; ///< sao_offset_abs
+ int offset_sign[3][4]; ///< sao_offset_sign
- void (*transform_4x4_luma_add)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
+ int band_position[3]; ///< sao_band_position
- void (*transform_add[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t _stride);
+ int eo_class[3]; ///< sao_eo_class
- void (*sao_band_filter[4])( uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride, struct SAOParams *sao, int *borders, int width, int height, int c_idx);
+ int offset_val[3][5]; ///<SaoOffsetVal
- void (*sao_edge_filter[4])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride, struct SAOParams *sao, int *borders, int _width, int _height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge);
+ uint8_t type_idx[3]; ///< sao_type_idx
+} SAOParams;
+typedef struct HEVCDSPContext {
+ void (*put_pcm)(uint8_t *dst, ptrdiff_t stride, int size,
+ GetBitContext *gb, int pcm_bit_depth);
- void (*put_hevc_qpel[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
- int width, int height, int16_t* mcbuffer);
-
- void (*put_hevc_epel[2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
- int width, int height, int mx, int my, int16_t* mcbuffer);
-
- void (*put_unweighted_pred)(uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride,
- int width, int height);
+ void (*transquant_bypass[4])(uint8_t *dst, int16_t *coeffs,
+ ptrdiff_t stride);
- void (*put_weighted_pred_avg)(uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2,
- ptrdiff_t srcstride, int width, int height);
- void (*weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag, uint8_t *dst, ptrdiff_t dststride, int16_t *src,
- ptrdiff_t srcstride, int width, int height);
- void (*weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag,
- uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2,
- ptrdiff_t srcstride, int width, int height);
- void (*hevc_h_loop_filter_luma)(uint8_t *_pix, ptrdiff_t _stride, int *_beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_v_loop_filter_luma)(uint8_t *_pix, ptrdiff_t _stride, int *_beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_h_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_v_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_h_loop_filter_luma_c)(uint8_t *_pix, ptrdiff_t _stride, int *_beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_v_loop_filter_luma_c)(uint8_t *_pix, ptrdiff_t _stride, int *_beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_h_loop_filter_chroma_c)(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
- void (*hevc_v_loop_filter_chroma_c)(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
+ void (*transform_skip)(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
+ void (*transform_4x4_luma_add)(uint8_t *dst, int16_t *coeffs,
+ ptrdiff_t stride);
+ void (*transform_add[4])(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
+
+ void (*sao_band_filter[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+ struct SAOParams *sao, int *borders,
+ int width, int height, int c_idx);
+ void (*sao_edge_filter[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+ struct SAOParams *sao, int *borders, int width,
+ int height, int c_idx, uint8_t vert_edge,
+ uint8_t horiz_edge, uint8_t diag_edge);
+
+ void (*put_hevc_qpel[10][2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_qpel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_qpel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
+
+ void (*put_hevc_qpel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_qpel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_epel[10][2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
+
+ void (*put_hevc_epel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_epel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_epel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width);
+ void (*put_hevc_epel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int ox0, int wx1,
+ int ox1, intptr_t mx, intptr_t my, int width);
+
+ void (*hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
+ int *beta, int *tc,
+ uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
+ int *beta, int *tc,
+ uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
+ int *tc, uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
+ int *tc, uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_h_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride,
+ int *beta, int *tc,
+ uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_v_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride,
+ int *beta, int *tc,
+ uint8_t *no_p, uint8_t *no_q);
+ void (*hevc_h_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride,
+ int *tc, uint8_t *no_p,
+ uint8_t *no_q);
+ void (*hevc_v_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride,
+ int *tc, uint8_t *no_p,
+ uint8_t *no_q);
} HEVCDSPContext;
void ff_hevc_dsp_init(HEVCDSPContext *hpc, int bit_depth);
-extern const int8_t ff_hevc_epel_filters[7][16];
+extern const int8_t ff_hevc_epel_filters[7][4];
+extern const int8_t ff_hevc_qpel_filters[3][16];
+
+void ff_hevcdsp_init_x86(HEVCDSPContext *c, const int bit_depth);
#endif /* AVCODEC_HEVCDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevcdsp_template.c b/chromium/third_party/ffmpeg/libavcodec/hevcdsp_template.c
index c9386e0dfb5..be90c7002b1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevcdsp_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevcdsp_template.c
@@ -52,7 +52,7 @@ static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs,
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
- dst[x] += *coeffs;
+ dst[x] = av_clip_pixel(dst[x] + *coeffs);
coeffs++;
}
dst += stride;
@@ -69,7 +69,7 @@ static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
- dst[x] += *coeffs;
+ dst[x] = av_clip_pixel(dst[x] + *coeffs);
coeffs++;
}
dst += stride;
@@ -86,7 +86,7 @@ static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
for (y = 0; y < 16; y++) {
for (x = 0; x < 16; x++) {
- dst[x] += *coeffs;
+ dst[x] = av_clip_pixel(dst[x] + *coeffs);
coeffs++;
}
dst += stride;
@@ -103,7 +103,7 @@ static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
for (y = 0; y < 32; y++) {
for (x = 0; x < 32; x++) {
- dst[x] += *coeffs;
+ dst[x] = av_clip_pixel(dst[x] + *coeffs);
coeffs++;
}
dst += stride;
@@ -194,8 +194,6 @@ static void FUNC(transform_4x4_luma_add)(uint8_t *_dst, int16_t *coeffs,
assign(dst[2 * dstep], e1 - o1); \
assign(dst[3 * dstep], e0 - o0); \
} while (0)
-#define TR_4_1(dst, src) TR_4(dst, src, 4, 4, SCALE)
-#define TR_4_2(dst, src) TR_4(dst, src, 1, 1, ADD_AND_SCALE)
static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
@@ -209,14 +207,14 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
stride /= sizeof(pixel);
for (i = 0; i < 4; i++) {
- TR_4_1(src, src);
+ TR_4(src, src, 4, 4, SCALE);
src++;
}
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 4; i++) {
- TR_4_2(dst, coeffs);
+ TR_4(dst, coeffs, 1, 1, ADD_AND_SCALE);
coeffs += 4;
dst += stride;
}
@@ -270,13 +268,7 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs,
} \
} while (0)
-#define TR_8_1(dst, src) TR_8(dst, src, 8, 8, SCALE)
-#define TR_16_1(dst, src) TR_16(dst, src, 16, 16, SCALE)
-#define TR_32_1(dst, src) TR_32(dst, src, 32, 32, SCALE)
-#define TR_8_2(dst, src) TR_8(dst, src, 1, 1, ADD_AND_SCALE)
-#define TR_16_2(dst, src) TR_16(dst, src, 1, 1, ADD_AND_SCALE)
-#define TR_32_2(dst, src) TR_32(dst, src, 1, 1, ADD_AND_SCALE)
static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
@@ -290,14 +282,14 @@ static void FUNC(transform_8x8_add)(uint8_t *_dst, int16_t *coeffs,
stride /= sizeof(pixel);
for (i = 0; i < 8; i++) {
- TR_8_1(src, src);
+ TR_8(src, src, 8, 8, SCALE);
src++;
}
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 8; i++) {
- TR_8_2(dst, coeffs);
+ TR_8(dst, coeffs, 1, 1, ADD_AND_SCALE);
coeffs += 8;
dst += stride;
}
@@ -315,14 +307,14 @@ static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
stride /= sizeof(pixel);
for (i = 0; i < 16; i++) {
- TR_16_1(src, src);
+ TR_16(src, src, 16, 16, SCALE);
src++;
}
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 16; i++) {
- TR_16_2(dst, coeffs);
+ TR_16(dst, coeffs, 1, 1, ADD_AND_SCALE);
coeffs += 16;
dst += stride;
}
@@ -331,15 +323,6 @@ static void FUNC(transform_16x16_add)(uint8_t *_dst, int16_t *coeffs,
static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
-#define IT32x32_even(i,w) ( src[ 0*w] * transform[ 0][i] ) + ( src[16*w] * transform[16][i] )
-#define IT32x32_odd(i,w) ( src[ 8*w] * transform[ 8][i] ) + ( src[24*w] * transform[24][i] )
-#define IT16x16(i,w) ( src[ 4*w] * transform[ 4][i] ) + ( src[12*w] * transform[12][i] ) + ( src[20*w] * transform[20][i] ) + ( src[28*w] * transform[28][i] )
-#define IT8x8(i,w) ( src[ 2*w] * transform[ 2][i] ) + ( src[ 6*w] * transform[ 6][i] ) + ( src[10*w] * transform[10][i] ) + ( src[14*w] * transform[14][i] ) + \
- ( src[18*w] * transform[18][i] ) + ( src[22*w] * transform[22][i] ) + ( src[26*w] * transform[26][i] ) + ( src[30*w] * transform[30][i] )
-#define IT4x4(i,w) ( src[ 1*w] * transform[ 1][i] ) + ( src[ 3*w] * transform[ 3][i] ) + ( src[ 5*w] * transform[ 5][i] ) + ( src[ 7*w] * transform[ 7][i] ) + \
- ( src[ 9*w] * transform[ 9][i] ) + ( src[11*w] * transform[11][i] ) + ( src[13*w] * transform[13][i] ) + ( src[15*w] * transform[15][i] ) + \
- ( src[17*w] * transform[17][i] ) + ( src[19*w] * transform[19][i] ) + ( src[21*w] * transform[21][i] ) + ( src[23*w] * transform[23][i] ) + \
- ( src[25*w] * transform[25][i] ) + ( src[27*w] * transform[27][i] ) + ( src[29*w] * transform[29][i] ) + ( src[31*w] * transform[31][i] )
int i;
pixel *dst = (pixel *)_dst;
int shift = 7;
@@ -349,22 +332,17 @@ static void FUNC(transform_32x32_add)(uint8_t *_dst, int16_t *coeffs,
stride /= sizeof(pixel);
for (i = 0; i < 32; i++) {
- TR_32_1(src, src);
+ TR_32(src, src, 32, 32, SCALE);
src++;
}
src = coeffs;
shift = 20 - BIT_DEPTH;
add = 1 << (shift - 1);
for (i = 0; i < 32; i++) {
- TR_32_2(dst, coeffs);
+ TR_32(dst, coeffs, 1, 1, ADD_AND_SCALE);
coeffs += 32;
dst += stride;
}
-#undef IT32x32_even
-#undef IT32x32_odd
-#undef IT16x16
-#undef IT8x8
-#undef IT4x4
}
static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
@@ -417,7 +395,7 @@ static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- dst[x] = av_clip_pixel(src[x] + offset_table[av_clip_pixel(src[x] >> shift)]);
+ dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
dst += stride;
src += stride;
}
@@ -670,6 +648,7 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
int chroma = !!c_idx;
int *sao_offset_val = sao->offset_val[c_idx];
int sao_eo_class = sao->eo_class[c_idx];
+ int init_x = 0, init_y = 0, width = _width, height = _height;
static const int8_t pos[4][2][2] = {
{ { -1, 0 }, { 1, 0 } }, // horizontal
@@ -679,9 +658,8 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
};
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
- int init_x = 0, init_y = 0, width = _width, height = _height;
-
#define CMP(a, b) ((a) > (b) ? 1 : ((a) == (b) ? 0 : -1))
+
stride /= sizeof(pixel);
init_x = -(8 >> chroma) - 2;
@@ -822,21 +800,17 @@ static void FUNC(sao_edge_filter_3)(uint8_t *_dst, uint8_t *_src,
#undef SCALE
#undef ADD_AND_SCALE
#undef TR_4
-#undef TR_4_1
-#undef TR_4_2
#undef TR_8
-#undef TR_8_1
-#undef TR_8_2
#undef TR_16
-#undef TR_16_1
-#undef TR_16_2
#undef TR_32
-#undef TR_32_1
-#undef TR_32_2
-static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
- uint8_t *_src, ptrdiff_t _srcstride,
- int width, int height, int16_t* mcbuffer)
+
+////////////////////////////////////////////////////////////////////////////////
+//
+////////////////////////////////////////////////////////////////////////////////
+static void FUNC(put_hevc_pel_pixels)(int16_t *dst, ptrdiff_t dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
@@ -850,157 +824,573 @@ static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
}
}
-#define QPEL_FILTER_1(src, stride) \
- (1 * -src[x - 3 * stride] + \
- 4 * src[x - 2 * stride] - \
- 10 * src[x - stride] + \
- 58 * src[x] + \
- 17 * src[x + stride] - \
- 5 * src[x + 2 * stride] + \
- 1 * src[x + 3 * stride])
-
-#define QPEL_FILTER_2(src, stride) \
- (1 * -src[x - 3 * stride] + \
- 4 * src[x - 2 * stride] - \
- 11 * src[x - stride] + \
- 40 * src[x] + \
- 40 * src[x + stride] - \
- 11 * src[x + 2 * stride] + \
- 4 * src[x + 3 * stride] - \
- 1 * src[x + 4 * stride])
-
-#define QPEL_FILTER_3(src, stride) \
- (1 * src[x - 2 * stride] - \
- 5 * src[x - stride] + \
- 17 * src[x] + \
- 58 * src[x + stride] - \
- 10 * src[x + 2 * stride] + \
- 4 * src[x + 3 * stride] - \
- 1 * src[x + 4 * stride])
-
-
-#define PUT_HEVC_QPEL_H(H) \
-static void FUNC(put_hevc_qpel_h ## H)(int16_t *dst, ptrdiff_t dststride, \
- uint8_t *_src, ptrdiff_t _srcstride, \
- int width, int height, \
- int16_t* mcbuffer) \
-{ \
- int x, y; \
- pixel *src = (pixel*)_src; \
- ptrdiff_t srcstride = _srcstride / sizeof(pixel); \
- \
- for (y = 0; y < height; y++) { \
- for (x = 0; x < width; x++) \
- dst[x] = QPEL_FILTER_ ## H(src, 1) >> (BIT_DEPTH - 8); \
- src += srcstride; \
- dst += dststride; \
- } \
+static void FUNC(put_hevc_pel_uni_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ for (y = 0; y < height; y++) {
+ memcpy(dst, src, width * sizeof(pixel));
+ src += srcstride;
+ dst += dststride;
+ }
}
-#define PUT_HEVC_QPEL_V(V) \
-static void FUNC(put_hevc_qpel_v ## V)(int16_t *dst, ptrdiff_t dststride, \
- uint8_t *_src, ptrdiff_t _srcstride, \
- int width, int height, \
- int16_t* mcbuffer) \
-{ \
- int x, y; \
- pixel *src = (pixel*)_src; \
- ptrdiff_t srcstride = _srcstride / sizeof(pixel); \
- \
- for (y = 0; y < height; y++) { \
- for (x = 0; x < width; x++) \
- dst[x] = QPEL_FILTER_ ## V(src, srcstride) >> (BIT_DEPTH - 8); \
- src += srcstride; \
- dst += dststride; \
- } \
+static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((src[x] << (14 - BIT_DEPTH)) + src2[x] + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
}
-#define PUT_HEVC_QPEL_HV(H, V) \
-static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, \
- ptrdiff_t dststride, \
- uint8_t *_src, \
- ptrdiff_t _srcstride, \
- int width, int height, \
- int16_t* mcbuffer) \
-{ \
- int x, y; \
- pixel *src = (pixel*)_src; \
- ptrdiff_t srcstride = _srcstride / sizeof(pixel); \
- \
- int16_t tmp_array[(MAX_PB_SIZE + 7) * MAX_PB_SIZE]; \
- int16_t *tmp = tmp_array; \
- \
- src -= ff_hevc_qpel_extra_before[V] * srcstride; \
- \
- for (y = 0; y < height + ff_hevc_qpel_extra[V]; y++) { \
- for (x = 0; x < width; x++) \
- tmp[x] = QPEL_FILTER_ ## H(src, 1) >> (BIT_DEPTH - 8); \
- src += srcstride; \
- tmp += MAX_PB_SIZE; \
- } \
- \
- tmp = tmp_array + ff_hevc_qpel_extra_before[V] * MAX_PB_SIZE; \
- \
- for (y = 0; y < height; y++) { \
- for (x = 0; x < width; x++) \
- dst[x] = QPEL_FILTER_ ## V(tmp, MAX_PB_SIZE) >> 6; \
- tmp += MAX_PB_SIZE; \
- dst += dststride; \
- } \
+static void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel((((src[x] << (14 - BIT_DEPTH)) * wx + offset) >> shift) + ox);
+ src += srcstride;
+ dst += dststride;
+ }
}
-PUT_HEVC_QPEL_H(1)
-PUT_HEVC_QPEL_H(2)
-PUT_HEVC_QPEL_H(3)
-PUT_HEVC_QPEL_V(1)
-PUT_HEVC_QPEL_V(2)
-PUT_HEVC_QPEL_V(3)
-PUT_HEVC_QPEL_HV(1, 1)
-PUT_HEVC_QPEL_HV(1, 2)
-PUT_HEVC_QPEL_HV(1, 3)
-PUT_HEVC_QPEL_HV(2, 1)
-PUT_HEVC_QPEL_HV(2, 2)
-PUT_HEVC_QPEL_HV(2, 3)
-PUT_HEVC_QPEL_HV(3, 1)
-PUT_HEVC_QPEL_HV(3, 2)
-PUT_HEVC_QPEL_HV(3, 3)
-
-static void FUNC(put_hevc_epel_pixels)(int16_t *dst, ptrdiff_t dststride,
- uint8_t *_src, ptrdiff_t _srcstride,
- int width, int height, int mx, int my,
- int16_t* mcbuffer)
+static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dst[x] = av_clip_pixel(( (src[x] << (14 - BIT_DEPTH)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ }
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+////////////////////////////////////////////////////////////////////////////////
+#define QPEL_FILTER(src, stride) \
+ (filter[0] * src[x - 3 * stride] + \
+ filter[1] * src[x - 2 * stride] + \
+ filter[2] * src[x - stride] + \
+ filter[3] * src[x ] + \
+ filter[4] * src[x + stride] + \
+ filter[5] * src[x + 2 * stride] + \
+ filter[6] * src[x + 3 * stride] + \
+ filter[7] * src[x + 4 * stride])
+
+static void FUNC(put_hevc_qpel_h)(int16_t *dst, ptrdiff_t dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- dst[x] = src[x] << (14 - BIT_DEPTH);
+ dst[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_v)(int16_t *dst, ptrdiff_t dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[my - 1];
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_hv)(int16_t *dst,
+ ptrdiff_t dststride,
+ uint8_t *_src,
+ ptrdiff_t _srcstride,
+ int height, intptr_t mx,
+ intptr_t my, int width)
+{
+ int x, y;
+ const int8_t *filter;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+
+ src -= QPEL_EXTRA_BEFORE * srcstride;
+ filter = ff_hevc_qpel_filters[mx - 1];
+ for (y = 0; y < height + QPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_qpel_filters[my - 1];
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6;
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
+ int shift = 14 - BIT_DEPTH;
+
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
+
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[my - 1];
+ int shift = 14 - BIT_DEPTH;
+
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+
+static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ const int8_t *filter = ff_hevc_qpel_filters[my - 1];
+
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ const int8_t *filter;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 - BIT_DEPTH;
+
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= QPEL_EXTRA_BEFORE * srcstride;
+ filter = ff_hevc_qpel_filters[mx - 1];
+ for (y = 0; y < height + QPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_qpel_filters[my - 1];
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ const int8_t *filter;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= QPEL_EXTRA_BEFORE * srcstride;
+ filter = ff_hevc_qpel_filters[mx - 1];
+ for (y = 0; y < height + QPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_qpel_filters[my - 1];
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox,
+ intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel((((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
src += srcstride;
dst += dststride;
}
}
-#define EPEL_FILTER(src, stride) \
- (filter_0 * src[x - stride] + \
- filter_1 * src[x] + \
- filter_2 * src[x + stride] + \
- filter_3 * src[x + 2 * stride])
+static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
+
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox,
+ intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_qpel_filters[my - 1];
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel((((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+
+ const int8_t *filter = ff_hevc_qpel_filters[my - 1];
+
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+ uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox,
+ intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ const int8_t *filter;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= QPEL_EXTRA_BEFORE * srcstride;
+ filter = ff_hevc_qpel_filters[mx - 1];
+ for (y = 0; y < height + QPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_qpel_filters[my - 1];
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel((((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ const int8_t *filter;
+ pixel *src = (pixel*)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ src -= QPEL_EXTRA_BEFORE * srcstride;
+ filter = ff_hevc_qpel_filters[mx - 1];
+ for (y = 0; y < height + QPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_qpel_filters[my - 1];
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+////////////////////////////////////////////////////////////////////////////////
+#define EPEL_FILTER(src, stride) \
+ (filter[0] * src[x - stride] + \
+ filter[1] * src[x] + \
+ filter[2] * src[x + stride] + \
+ filter[3] * src[x + 2 * stride])
static void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
uint8_t *_src, ptrdiff_t _srcstride,
- int width, int height, int mx, int my,
- int16_t* mcbuffer)
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
const int8_t *filter = ff_hevc_epel_filters[mx - 1];
- int8_t filter_0 = filter[0];
- int8_t filter_1 = filter[1];
- int8_t filter_2 = filter[2];
- int8_t filter_3 = filter[3];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
dst[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
@@ -1011,17 +1401,12 @@ static void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
static void FUNC(put_hevc_epel_v)(int16_t *dst, ptrdiff_t dststride,
uint8_t *_src, ptrdiff_t _srcstride,
- int width, int height, int mx, int my,
- int16_t* mcbuffer)
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
const int8_t *filter = ff_hevc_epel_filters[my - 1];
- int8_t filter_0 = filter[0];
- int8_t filter_1 = filter[1];
- int8_t filter_2 = filter[2];
- int8_t filter_3 = filter[3];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
@@ -1033,19 +1418,13 @@ static void FUNC(put_hevc_epel_v)(int16_t *dst, ptrdiff_t dststride,
static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
uint8_t *_src, ptrdiff_t _srcstride,
- int width, int height, int mx, int my,
- int16_t* mcbuffer)
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
pixel *src = (pixel *)_src;
ptrdiff_t srcstride = _srcstride / sizeof(pixel);
- const int8_t *filter_h = ff_hevc_epel_filters[mx - 1];
- const int8_t *filter_v = ff_hevc_epel_filters[my - 1];
- int8_t filter_0 = filter_h[0];
- int8_t filter_1 = filter_h[1];
- int8_t filter_2 = filter_h[2];
- int8_t filter_3 = filter_h[3];
- int16_t tmp_array[(MAX_PB_SIZE + 3) * MAX_PB_SIZE];
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
int16_t *tmp = tmp_array;
src -= EPEL_EXTRA_BEFORE * srcstride;
@@ -1058,10 +1437,8 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
}
tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
- filter_0 = filter_v[0];
- filter_1 = filter_v[1];
- filter_2 = filter_v[2];
- filter_3 = filter_v[3];
+ filter = ff_hevc_epel_filters[my - 1];
+
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
dst[x] = EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6;
@@ -1070,37 +1447,91 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
}
}
-static void FUNC(put_unweighted_pred)(uint8_t *_dst, ptrdiff_t _dststride,
- int16_t *src, ptrdiff_t srcstride,
- int width, int height)
+static void FUNC(put_hevc_epel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
-
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
int shift = 14 - BIT_DEPTH;
#if BIT_DEPTH < 14
int offset = 1 << (shift - 1);
#else
int offset = 0;
#endif
+
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- dst[x] = av_clip_pixel((src[x] + offset) >> shift);
- dst += dststride;
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
+ }
+ dst += dststride;
+ src += srcstride;
+ src2 += src2stride;
}
}
-static void FUNC(put_weighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
- int16_t *src1, int16_t *src2,
- ptrdiff_t srcstride,
- int width, int height)
+static void FUNC(put_hevc_epel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
{
int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[my - 1];
+ int shift = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + offset) >> shift);
+ src += srcstride;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[my - 1];
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
int shift = 14 + 1 - BIT_DEPTH;
#if BIT_DEPTH < 14
int offset = 1 << (shift - 1);
@@ -1110,71 +1541,273 @@ static void FUNC(put_weighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- dst[x] = av_clip_pixel((src1[x] + src2[x] + offset) >> shift);
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
dst += dststride;
- src1 += srcstride;
- src2 += srcstride;
+ src += srcstride;
+ src2 += src2stride;
}
}
-static void FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
- uint8_t *_dst, ptrdiff_t _dststride,
- int16_t *src, ptrdiff_t srcstride,
- int width, int height)
+static void FUNC(put_hevc_epel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, intptr_t mx, intptr_t my, int width)
{
- int shift, log2Wd, wx, ox, x, y, offset;
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= EPEL_EXTRA_BEFORE * srcstride;
+
+ for (y = 0; y < height + EPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
- shift = 14 - BIT_DEPTH;
- log2Wd = denom + shift;
- offset = 1 << (log2Wd - 1);
- wx = wlxFlag;
- ox = olxFlag * (1 << (BIT_DEPTH - 8));
+ tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_epel_filters[my - 1];
for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ }
+}
+
+static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 + 1 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= EPEL_EXTRA_BEFORE * srcstride;
+
+ for (y = 0; y < height + EPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_epel_filters[my - 1];
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- if (log2Wd >= 1) {
- dst[x] = av_clip_pixel(((src[x] * wx + offset) >> log2Wd) + ox);
- } else {
- dst[x] = av_clip_pixel(src[x] * wx + ox);
- }
+ dst[x] = av_clip_pixel((((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
}
dst += dststride;
src += srcstride;
}
}
-static void FUNC(weighted_pred_avg)(uint8_t denom,
- int16_t wl0Flag, int16_t wl1Flag,
- int16_t ol0Flag, int16_t ol1Flag,
- uint8_t *_dst, ptrdiff_t _dststride,
- int16_t *src1, int16_t *src2,
- ptrdiff_t srcstride,
- int width, int height)
+static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
{
- int shift, log2Wd, w0, w1, o0, o1, x, y;
- pixel *dst = (pixel *)_dst;
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ src += srcstride;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}
- shift = 14 - BIT_DEPTH;
- log2Wd = denom + shift;
- w0 = wl0Flag;
- w1 = wl1Flag;
- o0 = ol0Flag * (1 << (BIT_DEPTH - 8));
- o1 = ol1Flag * (1 << (BIT_DEPTH - 8));
+static void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[my - 1];
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dst[x] = av_clip_pixel((((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+ }
+ dst += dststride;
+ src += srcstride;
+ }
+}
+
+static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[my - 1];
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- dst[x] = av_clip_pixel((src1[x] * w0 + src2[x] * w1 +
- ((o0 + o1 + 1) << log2Wd)) >> (log2Wd + 1));
+ dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ src += srcstride;
dst += dststride;
- src1 += srcstride;
- src2 += srcstride;
+ src2 += src2stride;
+ }
+}
+
+static void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+ int offset = 1 << (shift - 1);
+#else
+ int offset = 0;
+#endif
+
+ src -= EPEL_EXTRA_BEFORE * srcstride;
+
+ for (y = 0; y < height + EPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_epel_filters[my - 1];
+
+ ox = ox * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel((((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
}
}
-// line zero
+static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+ int16_t *src2, ptrdiff_t src2stride,
+ int height, int denom, int wx0, int wx1,
+ int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+{
+ int x, y;
+ pixel *src = (pixel *)_src;
+ ptrdiff_t srcstride = _srcstride / sizeof(pixel);
+ pixel *dst = (pixel *)_dst;
+ ptrdiff_t dststride = _dststride / sizeof(pixel);
+ const int8_t *filter = ff_hevc_epel_filters[mx - 1];
+ int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
+ int16_t *tmp = tmp_array;
+ int shift = 14 + 1 - BIT_DEPTH;
+ int log2Wd = denom + shift - 1;
+
+ src -= EPEL_EXTRA_BEFORE * srcstride;
+
+ for (y = 0; y < height + EPEL_EXTRA; y++) {
+ for (x = 0; x < width; x++)
+ tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
+ src += srcstride;
+ tmp += MAX_PB_SIZE;
+ }
+
+ tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
+ filter = ff_hevc_epel_filters[my - 1];
+
+ ox0 = ox0 * (1 << (BIT_DEPTH - 8));
+ ox1 = ox1 * (1 << (BIT_DEPTH - 8));
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
+ ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1));
+ tmp += MAX_PB_SIZE;
+ dst += dststride;
+ src2 += src2stride;
+ }
+}// line zero
#define P3 pix[-4 * xstride]
#define P2 pix[-3 * xstride]
#define P1 pix[-2 * xstride]
@@ -1216,7 +1849,7 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
const int no_p = _no_p[j];
const int no_q = _no_q[j];
- if (d0 + d3 >= beta /*|| tc <= 0*/) {
+ if (d0 + d3 >= beta) {
pix += 4 * ystride;
continue;
} else {
@@ -1313,7 +1946,7 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
const int p0 = P0;
const int q0 = Q0;
const int q1 = Q1;
- delta0 = av_clip((((q0 - p0) << 2) + p1 - q1 + 4) >> 3, -tc, tc);
+ delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc);
if (!no_p)
P0 = av_clip_pixel(p0 + delta0);
if (!no_q)
diff --git a/chromium/third_party/ffmpeg/libavcodec/hevcpred_template.c b/chromium/third_party/ffmpeg/libavcodec/hevcpred_template.c
index 5ba95919b1d..5ed7647f921 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hevcpred_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hevcpred_template.c
@@ -36,43 +36,44 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
#define MVF_PU(x, y) \
MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift)))
#define IS_INTRA(x, y) \
- MVF_PU(x, y).is_intra
+ (MVF_PU(x, y).pred_flag == PF_INTRA)
#define MIN_TB_ADDR_ZS(x, y) \
s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)]
-#define EXTEND_LEFT(ptr, start, length) \
- for (i = (start); i > (start) - (length); i--) \
- ptr[i - 1] = ptr[i]
-#define EXTEND_RIGHT(ptr, start, length) \
- for (i = (start); i < (start) + (length); i++) \
- ptr[i] = ptr[i - 1]
-#define EXTEND_UP(ptr, start, length) EXTEND_LEFT(ptr, start, length)
-#define EXTEND_DOWN(ptr, start, length) EXTEND_RIGHT(ptr, start, length)
+#define EXTEND(ptr, start, length) \
+ for (i = start; i < (start) + (length); i += 4) \
+ AV_WN4P(&(ptr[i]), a)
+#define EXTEND_RIGHT_CIP(ptr, start, length) \
+ for (i = start; i < (start) + (length); i += 4) \
+ if (!IS_INTRA(i, -1)) \
+ AV_WN4P(&ptr[i], a); \
+ else \
+ a = PIXEL_SPLAT_X4(ptr[i+3])
#define EXTEND_LEFT_CIP(ptr, start, length) \
- for (i = (start); i > (start) - (length); i--) \
+ for (i = start; i > (start) - (length); i--) \
if (!IS_INTRA(i - 1, -1)) \
ptr[i - 1] = ptr[i]
-#define EXTEND_RIGHT_CIP(ptr, start, length) \
- for (i = (start); i < (start) + (length); i++) \
- if (!IS_INTRA(i, -1)) \
- ptr[i] = ptr[i - 1]
-#define EXTEND_UP_CIP(ptr, start, length) \
- for (i = (start); i > (start) - (length); i--) \
- if (!IS_INTRA(-1, i - 1)) \
- ptr[i - 1] = ptr[i]
-#define EXTEND_UP_CIP_0(ptr, start, length) \
- for (i = (start); i > (start) - (length); i--) \
- ptr[i - 1] = ptr[i]
-#define EXTEND_DOWN_CIP(ptr, start, length) \
- for (i = (start); i < (start) + (length); i++) \
- if (!IS_INTRA(-1, i)) \
- ptr[i] = ptr[i - 1]
+#define EXTEND_UP_CIP(ptr, start, length) \
+ for (i = (start); i > (start) - (length); i -= 4) \
+ if (!IS_INTRA(-1, i - 3)) \
+ AV_WN4P(&ptr[i - 3], a); \
+ else \
+ a = PIXEL_SPLAT_X4(ptr[i - 3])
+#define EXTEND_DOWN_CIP(ptr, start, length) \
+ for (i = start; i < (start) + (length); i += 4) \
+ if (!IS_INTRA(-1, i)) \
+ AV_WN4P(&ptr[i], a); \
+ else \
+ a = PIXEL_SPLAT_X4(ptr[i + 3])
+
HEVCLocalContext *lc = s->HEVClc;
int i;
int hshift = s->sps->hshift[c_idx];
int vshift = s->sps->vshift[c_idx];
int size = (1 << log2_size);
- int size_in_luma = size << hshift;
- int size_in_tbs = size_in_luma >> s->sps->log2_min_tb_size;
+ int size_in_luma_h = size << hshift;
+ int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size;
+ int size_in_luma_v = size << vshift;
+ int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size;
int x = x0 >> hshift;
int y = y0 >> vshift;
int x_tb = x0 >> s->sps->log2_min_tb_size;
@@ -86,106 +87,100 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
enum IntraPredMode mode = c_idx ? lc->pu.intra_pred_mode_c :
lc->tu.cur_intra_pred_mode;
+ pixel4 a;
+ pixel left_array[2 * MAX_TB_SIZE + 1];
+ pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
+ pixel top_array[2 * MAX_TB_SIZE + 1];
+ pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
- pixel left_array[2 * MAX_TB_SIZE + 1];
- pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
- pixel top_array[2 * MAX_TB_SIZE + 1];
- pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
-
- pixel *left = left_array + 1;
- pixel *top = top_array + 1;
- pixel *filtered_left = filtered_left_array + 1;
- pixel *filtered_top = filtered_top_array + 1;
+ pixel *left = left_array + 1;
+ pixel *top = top_array + 1;
+ pixel *filtered_left = filtered_left_array + 1;
+ pixel *filtered_top = filtered_top_array + 1;
- int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs);
+ int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs_v);
int cand_left = lc->na.cand_left;
int cand_up_left = lc->na.cand_up_left;
int cand_up = lc->na.cand_up;
- int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs, y_tb - 1);
+ int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs_h, y_tb - 1);
- int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma, s->sps->height) -
- (y0 + size_in_luma)) >> vshift;
- int top_right_size = (FFMIN(x0 + 2 * size_in_luma, s->sps->width) -
- (x0 + size_in_luma)) >> hshift;
+ int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->sps->height) -
+ (y0 + size_in_luma_v)) >> vshift;
+ int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->sps->width) -
+ (x0 + size_in_luma_h)) >> hshift;
if (s->pps->constrained_intra_pred_flag == 1) {
- int size_in_luma_pu = PU(size_in_luma);
+ int size_in_luma_pu_v = PU(size_in_luma_v);
+ int size_in_luma_pu_h = PU(size_in_luma_h);
int on_pu_edge_x = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));
int on_pu_edge_y = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));
- if (!size_in_luma_pu)
- size_in_luma_pu++;
+ if (!size_in_luma_pu_h)
+ size_in_luma_pu_h++;
if (cand_bottom_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
- int y_bottom_pu = PU(y0 + size_in_luma);
- int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu);
+ int y_bottom_pu = PU(y0 + size_in_luma_v);
+ int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_bottom_pu);
cand_bottom_left = 0;
- for (i = 0; i < max; i++)
- cand_bottom_left |= MVF(x_left_pu, y_bottom_pu + i).is_intra;
+ for (i = 0; i < max; i += 2)
+ cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
}
if (cand_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
int y_left_pu = PU(y0);
- int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu);
+ int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_left_pu);
cand_left = 0;
- for (i = 0; i < max; i++)
- cand_left |= MVF(x_left_pu, y_left_pu + i).is_intra;
+ for (i = 0; i < max; i += 2)
+ cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
}
if (cand_up_left == 1) {
int x_left_pu = PU(x0 - 1);
int y_top_pu = PU(y0 - 1);
- cand_up_left = MVF(x_left_pu, y_top_pu).is_intra;
+ cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
}
if (cand_up == 1 && on_pu_edge_y) {
int x_top_pu = PU(x0);
int y_top_pu = PU(y0 - 1);
- int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu);
+ int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_top_pu);
cand_up = 0;
- for (i = 0; i < max; i++)
- cand_up |= MVF(x_top_pu + i, y_top_pu).is_intra;
+ for (i = 0; i < max; i += 2)
+ cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
}
if (cand_up_right == 1 && on_pu_edge_y) {
int y_top_pu = PU(y0 - 1);
- int x_right_pu = PU(x0 + size_in_luma);
- int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu);
+ int x_right_pu = PU(x0 + size_in_luma_h);
+ int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_right_pu);
cand_up_right = 0;
- for (i = 0; i < max; i++)
- cand_up_right |= MVF(x_right_pu + i, y_top_pu).is_intra;
- }
- for (i = 0; i < 2 * MAX_TB_SIZE; i++) {
- left[i] = 128;
- top[i] = 128;
+ for (i = 0; i < max; i += 2)
+ cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
}
+ memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel));
+ memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel));
+ top[-1] = 128;
}
- if (cand_bottom_left) {
- for (i = size + bottom_left_size; i < (size << 1); i++)
- if (IS_INTRA(-1, size + bottom_left_size - 1) ||
- !s->pps->constrained_intra_pred_flag)
- left[i] = POS(-1, size + bottom_left_size - 1);
- for (i = size + bottom_left_size - 1; i >= size; i--)
- if (IS_INTRA(-1, i) || !s->pps->constrained_intra_pred_flag)
- left[i] = POS(-1, i);
+ if (cand_up_left) {
+ left[-1] = POS(-1, -1);
+ top[-1] = left[-1];
}
- if (cand_left)
- for (i = size - 1; i >= 0; i--)
- if (IS_INTRA(-1, i) || !s->pps->constrained_intra_pred_flag)
- left[i] = POS(-1, i);
- if (cand_up_left)
- if (IS_INTRA(-1, -1) || !s->pps->constrained_intra_pred_flag) {
- left[-1] = POS(-1, -1);
- top[-1] = left[-1];
- }
if (cand_up)
- for (i = size - 1; i >= 0; i--)
- if (IS_INTRA(i, -1) || !s->pps->constrained_intra_pred_flag)
- top[i] = POS(i, -1);
+ for (i = 0; i <size; i+=4)
+ AV_WN4P(&top[i], AV_RN4P(&POS(i, -1)));
+
if (cand_up_right) {
- for (i = size + top_right_size; i < (size << 1); i++)
- if (IS_INTRA(size + top_right_size - 1, -1) ||
- !s->pps->constrained_intra_pred_flag)
- top[i] = POS(size + top_right_size - 1, -1);
- for (i = size + top_right_size - 1; i >= size; i--)
- if (IS_INTRA(i, -1) || !s->pps->constrained_intra_pred_flag)
- top[i] = POS(i, -1);
+ a = PIXEL_SPLAT_X4(POS(size + top_right_size - 1, -1));
+ for (i = size + top_right_size; i < (size << 1); i += 4)
+ AV_WN4P(&top[i], a);
+ for (i = size ; i < size+top_right_size; i+=4)
+ AV_WN4P(&top[i], AV_RN4P(&POS(i, -1)));
+ }
+ if (cand_left)
+ for (i = 0; i < size; i++)
+ left[i] = POS(-1, i);
+ if (cand_bottom_left) {
+ for (i = size ; i < size+bottom_left_size; i++)
+ left[i] = POS(-1, i);
+ a = PIXEL_SPLAT_X4(POS(-1, size + bottom_left_size - 1));
+ for (i = size + bottom_left_size; i < (size << 1); i+=4)
+ AV_WN4P(&left[i], a);
}
if (s->pps->constrained_intra_pred_flag == 1) {
@@ -228,24 +223,34 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
left[-1] = top[-1];
j = 0;
}
+ left[-1] = top[-1];
if (cand_bottom_left || cand_left) {
- EXTEND_DOWN_CIP(left, j, size_max_y - j);
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND_DOWN_CIP(left, 0, size_max_y);
}
if (!cand_left) {
- EXTEND_DOWN(left, 0, size);
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(left, 0, size);
}
if (!cand_bottom_left) {
- EXTEND_DOWN(left, size, size);
+ a = PIXEL_SPLAT_X4(left[size - 1]);
+ EXTEND(left, size, size);
}
if (x0 != 0 && y0 != 0) {
+ a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
+ if (!IS_INTRA(-1, - 1))
+ left[-1] = left[0];
} else if (x0 == 0) {
- EXTEND_UP_CIP_0(left, size_max_y - 1, size_max_y);
+ a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
+ EXTEND(left, 0, size_max_y);
} else {
- EXTEND_UP_CIP(left, size_max_y - 1, size_max_y - 1);
+ a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
+ EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
}
top[-1] = left[-1];
if (y0 != 0) {
+ a = PIXEL_SPLAT_X4(left[-1]);
EXTEND_RIGHT_CIP(top, 0, size_max_x);
}
}
@@ -253,80 +258,89 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
// Infer the unavailable samples
if (!cand_bottom_left) {
if (cand_left) {
- EXTEND_DOWN(left, size, size);
+ a = PIXEL_SPLAT_X4(left[size-1]);
+ EXTEND(left, size, size);
} else if (cand_up_left) {
- EXTEND_DOWN(left, 0, 2 * size);
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(left, 0, 2 * size);
cand_left = 1;
} else if (cand_up) {
left[-1] = top[0];
- EXTEND_DOWN(left, 0, 2 * size);
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(left, 0, 2 * size);
cand_up_left = 1;
cand_left = 1;
} else if (cand_up_right) {
- EXTEND_LEFT(top, size, size);
- left[-1] = top[0];
- EXTEND_DOWN(left, 0, 2 * size);
+ left[-1] = top[size];
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(top, 0, size);
+ EXTEND(left, 0, 2 * size);
cand_up = 1;
cand_up_left = 1;
cand_left = 1;
} else { // No samples available
- top[0] = left[-1] = (1 << (BIT_DEPTH - 1));
- EXTEND_RIGHT(top, 1, 2 * size - 1);
- EXTEND_DOWN(left, 0, 2 * size);
+ left[-1] = (1 << (BIT_DEPTH - 1));
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(top, 0, 2 * size);
+ EXTEND(left, 0, 2 * size);
}
}
if (!cand_left) {
- EXTEND_UP(left, size, size);
+ a = PIXEL_SPLAT_X4(left[size]);
+ EXTEND(left, 0, size);
}
if (!cand_up_left) {
left[-1] = left[0];
}
if (!cand_up) {
- top[0] = left[-1];
- EXTEND_RIGHT(top, 1, size - 1);
+ a = PIXEL_SPLAT_X4(left[-1]);
+ EXTEND(top, 0, size);
}
if (!cand_up_right) {
- EXTEND_RIGHT(top, size, size);
+ a = PIXEL_SPLAT_X4(top[size-1]);
+ EXTEND(top, size, size);
}
top[-1] = left[-1];
// Filtering process
- if (c_idx == 0 && mode != INTRA_DC && size != 4) {
- int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
- int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
- FFABS((int)(mode - 10U)));
- if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
- int threshold = 1 << (BIT_DEPTH - 5);
- if (s->sps->sps_strong_intra_smoothing_enable_flag &&
- log2_size == 5 &&
- FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
- FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
- // We can't just overwrite values in top because it could be
- // a pointer into src
- filtered_top[-1] = top[-1];
- filtered_top[63] = top[63];
- for (i = 0; i < 63; i++)
- filtered_top[i] = ((64 - (i + 1)) * top[-1] +
- (i + 1) * top[63] + 32) >> 6;
- for (i = 0; i < 63; i++)
- left[i] = ((64 - (i + 1)) * left[-1] +
- (i + 1) * left[63] + 32) >> 6;
- top = filtered_top;
- } else {
- filtered_left[2 * size - 1] = left[2 * size - 1];
- filtered_top[2 * size - 1] = top[2 * size - 1];
- for (i = 2 * size - 2; i >= 0; i--)
- filtered_left[i] = (left[i + 1] + 2 * left[i] +
- left[i - 1] + 2) >> 2;
- filtered_top[-1] =
- filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
- for (i = 2 * size - 2; i >= 0; i--)
- filtered_top[i] = (top[i + 1] + 2 * top[i] +
- top[i - 1] + 2) >> 2;
- left = filtered_left;
- top = filtered_top;
+ if (c_idx == 0) {
+ if (mode != INTRA_DC && size != 4){
+ int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
+ int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
+ FFABS((int)(mode - 10U)));
+ if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
+ int threshold = 1 << (BIT_DEPTH - 5);
+ if (s->sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
+ log2_size == 5 &&
+ FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
+ FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
+ // We can't just overwrite values in top because it could be
+ // a pointer into src
+ filtered_top[-1] = top[-1];
+ filtered_top[63] = top[63];
+ for (i = 0; i < 63; i++)
+ filtered_top[i] = ((64 - (i + 1)) * top[-1] +
+ (i + 1) * top[63] + 32) >> 6;
+ for (i = 0; i < 63; i++)
+ left[i] = ((64 - (i + 1)) * left[-1] +
+ (i + 1) * left[63] + 32) >> 6;
+ top = filtered_top;
+ } else {
+ filtered_left[2 * size - 1] = left[2 * size - 1];
+ filtered_top[2 * size - 1] = top[2 * size - 1];
+ for (i = 2 * size - 2; i >= 0; i--)
+ filtered_left[i] = (left[i + 1] + 2 * left[i] +
+ left[i - 1] + 2) >> 2;
+ filtered_top[-1] =
+ filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
+ for (i = 2 * size - 2; i >= 0; i--)
+ filtered_top[i] = (top[i + 1] + 2 * top[i] +
+ top[i - 1] + 2) >> 2;
+ left = filtered_left;
+ top = filtered_top;
+ }
}
}
}
@@ -348,57 +362,43 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
}
}
-static void FUNC(pred_planar_0)(uint8_t *_src, const uint8_t *_top,
- const uint8_t *_left,
- ptrdiff_t stride)
+static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
+ const uint8_t *_left, ptrdiff_t stride,
+ int trafo_size)
{
int x, y;
pixel *src = (pixel *)_src;
const pixel *top = (const pixel *)_top;
const pixel *left = (const pixel *)_left;
- for (y = 0; y < 4; y++)
- for (x = 0; x < 4; x++)
- POS(x, y) = ((3 - x) * left[y] + (x + 1) * top[4] +
- (3 - y) * top[x] + (y + 1) * left[4] + 4) >> 3;
+ int size = 1 << trafo_size;
+ for (y = 0; y < size; y++)
+ for (x = 0; x < size; x++)
+ POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
+ (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
+}
+
+static void FUNC(pred_planar_0)(uint8_t *_src, const uint8_t *_top,
+ const uint8_t *_left, ptrdiff_t stride)
+{
+ FUNC(pred_planar)(_src, _top, _left, stride, 2);
}
static void FUNC(pred_planar_1)(uint8_t *_src, const uint8_t *_top,
const uint8_t *_left, ptrdiff_t stride)
{
- int x, y;
- pixel *src = (pixel *)_src;
- const pixel *top = (const pixel *)_top;
- const pixel *left = (const pixel *)_left;
- for (y = 0; y < 8; y++)
- for (x = 0; x < 8; x++)
- POS(x, y) = ((7 - x) * left[y] + (x + 1) * top[8] +
- (7 - y) * top[x] + (y + 1) * left[8] + 8) >> 4;
+ FUNC(pred_planar)(_src, _top, _left, stride, 3);
}
static void FUNC(pred_planar_2)(uint8_t *_src, const uint8_t *_top,
const uint8_t *_left, ptrdiff_t stride)
{
- int x, y;
- pixel *src = (pixel *)_src;
- const pixel *top = (const pixel *)_top;
- const pixel *left = (const pixel *)_left;
- for (y = 0; y < 16; y++)
- for (x = 0; x < 16; x++)
- POS(x, y) = ((15 - x) * left[y] + (x + 1) * top[16] +
- (15 - y) * top[x] + (y + 1) * left[16] + 16) >> 5;
+ FUNC(pred_planar)(_src, _top, _left, stride, 4);
}
static void FUNC(pred_planar_3)(uint8_t *_src, const uint8_t *_top,
const uint8_t *_left, ptrdiff_t stride)
{
- int x, y;
- pixel *src = (pixel *)_src;
- const pixel *top = (const pixel *)_top;
- const pixel *left = (const pixel *)_left;
- for (y = 0; y < 32; y++)
- for (x = 0; x < 32; x++)
- POS(x, y) = ((31 - x) * left[y] + (x + 1) * top[32] +
- (31 - y) * top[x] + (y + 1) * left[32] + 32) >> 6;
+ FUNC(pred_planar)(_src, _top, _left, stride, 5);
}
static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
@@ -420,8 +420,8 @@ static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
a = PIXEL_SPLAT_X4(dc);
for (i = 0; i < size; i++)
- for (j = 0; j < size / 4; j++)
- AV_WN4PA(&POS(j * 4, i), a);
+ for (j = 0; j < size; j+=4)
+ AV_WN4P(&POS(j, i), a);
if (c_idx == 0 && size < 32) {
POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
@@ -453,7 +453,7 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
};
int angle = intra_pred_angle[mode - 2];
- pixel ref_array[3 * MAX_TB_SIZE + 1];
+ pixel ref_array[3 * MAX_TB_SIZE + 4];
pixel *ref_tmp = ref_array + size;
const pixel *ref;
int last = (size * angle) >> 5;
@@ -461,8 +461,8 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
if (mode >= 18) {
ref = top - 1;
if (angle < 0 && last < -1) {
- for (x = 0; x <= size; x++)
- ref_tmp[x] = top[x - 1];
+ for (x = 0; x <= size; x += 4)
+ AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1]));
for (x = last; x <= -1; x++)
ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
ref = ref_tmp;
@@ -472,13 +472,19 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
int idx = ((y + 1) * angle) >> 5;
int fact = ((y + 1) * angle) & 31;
if (fact) {
- for (x = 0; x < size; x++) {
- POS(x, y) = ((32 - fact) * ref[x + idx + 1] +
- fact * ref[x + idx + 2] + 16) >> 5;
+ for (x = 0; x < size; x += 4) {
+ POS(x , y) = ((32 - fact) * ref[x + idx + 1] +
+ fact * ref[x + idx + 2] + 16) >> 5;
+ POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] +
+ fact * ref[x + 1 + idx + 2] + 16) >> 5;
+ POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] +
+ fact * ref[x + 2 + idx + 2] + 16) >> 5;
+ POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] +
+ fact * ref[x + 3 + idx + 2] + 16) >> 5;
}
} else {
- for (x = 0; x < size; x++)
- POS(x, y) = ref[x + idx + 1];
+ for (x = 0; x < size; x += 4)
+ AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1]));
}
}
if (mode == 26 && c_idx == 0 && size < 32) {
@@ -488,8 +494,8 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
} else {
ref = left - 1;
if (angle < 0 && last < -1) {
- for (x = 0; x <= size; x++)
- ref_tmp[x] = left[x - 1];
+ for (x = 0; x <= size; x += 4)
+ AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1]));
for (x = last; x <= -1; x++)
ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
ref = ref_tmp;
@@ -509,8 +515,12 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
}
}
if (mode == 10 && c_idx == 0 && size < 32) {
- for (x = 0; x < size; x++)
- POS(x, 0) = av_clip_pixel(left[0] + ((top[x] - top[-1]) >> 1));
+ for (x = 0; x < size; x += 4) {
+ POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1));
+ POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1));
+ POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1));
+ POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1));
+ }
}
}
}
@@ -551,9 +561,6 @@ static void FUNC(pred_angular_3)(uint8_t *src, const uint8_t *top,
#undef MVF_PU
#undef MVF
#undef PU
-#undef EXTEND_LEFT
-#undef EXTEND_RIGHT
-#undef EXTEND_UP
-#undef EXTEND_DOWN
+#undef EXTEND
#undef MIN_TB_ADDR_ZS
#undef POS
diff --git a/chromium/third_party/ffmpeg/libavcodec/hnm4video.c b/chromium/third_party/ffmpeg/libavcodec/hnm4video.c
index 177972ba64d..d8c51d0b751 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hnm4video.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hnm4video.c
@@ -36,8 +36,8 @@
typedef struct Hnm4VideoContext {
uint8_t version;
- uint16_t width;
- uint16_t height;
+ int width;
+ int height;
uint8_t *current;
uint8_t *previous;
uint8_t *buffer1;
@@ -311,8 +311,13 @@ static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
offset = writeoffset;
offset += bytestream2_get_le16(&gb);
- if (delta)
+ if (delta) {
+ if (offset < 0x10000) {
+ av_log(avctx, AV_LOG_ERROR, "Attempting to read out of bounds\n");
+ break;
+ }
offset -= 0x10000;
+ }
if (offset + hnm->width + count >= hnm->width * hnm->height) {
av_log(avctx, AV_LOG_ERROR, "Attempting to read out of bounds\n");
diff --git a/chromium/third_party/ffmpeg/libavcodec/hpel_template.c b/chromium/third_party/ffmpeg/libavcodec/hpel_template.c
index 3b4699927f0..fccfe7610fe 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hpel_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hpel_template.c
@@ -19,81 +19,87 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define DEF_HPEL(OPNAME, OP) \
-static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- int i;\
- for(i=0; i<h; i++){\
- OP(*((pixel2*)(block )), AV_RN2P(pixels ));\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}\
-static inline void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- int i;\
- for(i=0; i<h; i++){\
- OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}\
-static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- int i;\
- for(i=0; i<h; i++){\
- OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
- OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- int i;\
- for(i=0; i<h; i++){\
- pixel4 a,b;\
- a= AV_RN4P(&src1[i*src_stride1 ]);\
- b= AV_RN4P(&src2[i*src_stride2 ]);\
- OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
- a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
- b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
- OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), rnd_avg_pixel4(a, b));\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- int i;\
- for(i=0; i<h; i++){\
- pixel4 a,b;\
- a= AV_RN4P(&src1[i*src_stride1 ]);\
- b= AV_RN4P(&src2[i*src_stride2 ]);\
- OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- int i;\
- for(i=0; i<h; i++){\
- pixel4 a,b;\
- a= AV_RN2P(&src1[i*src_stride1 ]);\
- b= AV_RN2P(&src2[i*src_stride2 ]);\
- OP(*((pixel2*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
- }\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- FUNC(OPNAME ## _pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
- FUNC(OPNAME ## _pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
-}\
-\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))
+#include "libavutil/intreadwrite.h"
+#include "pixels.h"
+
+#include "bit_depth_template.c"
+
+#define DEF_HPEL(OPNAME, OP) \
+static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ pixel4 a, b; \
+ a = AV_RN4P(&src1[i * src_stride1]); \
+ b = AV_RN4P(&src2[i * src_stride2]); \
+ OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
+ a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
+ b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
+ OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
+ rnd_avg_pixel4(a, b)); \
+ } \
+} \
+ \
+static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ pixel4 a, b; \
+ a = AV_RN4P(&src1[i * src_stride1]); \
+ b = AV_RN4P(&src2[i * src_stride2]); \
+ OP(*((pixel4 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
+ } \
+} \
+ \
+static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ pixel4 a, b; \
+ a = AV_RN2P(&src1[i * src_stride1]); \
+ b = AV_RN2P(&src2[i * src_stride2]); \
+ OP(*((pixel2 *) &dst[i * dst_stride]), rnd_avg_pixel4(a, b)); \
+ } \
+} \
+ \
+static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ FUNC(OPNAME ## _pixels8_l2)(dst, src1, src2, dst_stride, \
+ src_stride1, src_stride2, h); \
+ FUNC(OPNAME ## _pixels8_l2)(dst + 8 * sizeof(pixel), \
+ src1 + 8 * sizeof(pixel), \
+ src2 + 8 * sizeof(pixel), \
+ dst_stride, src_stride1, \
+ src_stride2, h); \
+} \
#define op_avg(a, b) a = rnd_avg_pixel4(a, b)
#define op_put(a, b) a = b
-
DEF_HPEL(avg, op_avg)
DEF_HPEL(put, op_put)
#undef op_avg
diff --git a/chromium/third_party/ffmpeg/libavcodec/hpeldsp.c b/chromium/third_party/ffmpeg/libavcodec/hpeldsp.c
index 473102dddea..63449930412 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hpeldsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/hpeldsp.c
@@ -32,7 +32,308 @@
#include "hpeldsp.h"
#define BIT_DEPTH 8
-#include "hpeldsp_template.c"
+#include "hpel_template.c"
+#include "tpel_template.c"
+
+#define PIXOP2(OPNAME, OP) \
+static inline void OPNAME ## _no_rnd_pixels8_l2_8(uint8_t *dst, \
+ const uint8_t *src1, \
+ const uint8_t *src2, \
+ int dst_stride, \
+ int src_stride1, \
+ int src_stride2, \
+ int h) \
+{ \
+ int i; \
+ \
+ for (i = 0; i < h; i++) { \
+ uint32_t a, b; \
+ a = AV_RN32(&src1[i * src_stride1]); \
+ b = AV_RN32(&src2[i * src_stride2]); \
+ OP(*((uint32_t *) &dst[i * dst_stride]), \
+ no_rnd_avg32(a, b)); \
+ a = AV_RN32(&src1[i * src_stride1 + 4]); \
+ b = AV_RN32(&src2[i * src_stride2 + 4]); \
+ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
+ no_rnd_avg32(a, b)); \
+ } \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels8_x2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _no_rnd_pixels8_l2_8(block, pixels, pixels + 1, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels8_x2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels8_l2_8(block, pixels, pixels + 1, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels8_y2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _no_rnd_pixels8_l2_8(block, pixels, pixels + line_size, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels8_y2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels8_l2_8(block, pixels, pixels + line_size, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels4_x2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels4_l2_8(block, pixels, pixels + 1, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels4_y2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels4_l2_8(block, pixels, pixels + line_size, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels2_x2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels2_l2_8(block, pixels, pixels + 1, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels2_y2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ OPNAME ## _pixels2_l2_8(block, pixels, pixels + line_size, \
+ line_size, line_size, line_size, h); \
+} \
+ \
+static inline void OPNAME ## _pixels2_xy2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ int i, a1, b1; \
+ int a0 = pixels[0]; \
+ int b0 = pixels[1] + 2; \
+ \
+ a0 += b0; \
+ b0 += pixels[2]; \
+ pixels += line_size; \
+ for (i = 0; i < h; i += 2) { \
+ a1 = pixels[0]; \
+ b1 = pixels[1]; \
+ a1 += b1; \
+ b1 += pixels[2]; \
+ \
+ block[0] = (a1 + a0) >> 2; /* FIXME non put */ \
+ block[1] = (b1 + b0) >> 2; \
+ \
+ pixels += line_size; \
+ block += line_size; \
+ \
+ a0 = pixels[0]; \
+ b0 = pixels[1] + 2; \
+ a0 += b0; \
+ b0 += pixels[2]; \
+ \
+ block[0] = (a1 + a0) >> 2; \
+ block[1] = (b1 + b0) >> 2; \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+} \
+ \
+static inline void OPNAME ## _pixels4_xy2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int i; \
+ const uint32_t a = AV_RN32(pixels); \
+ const uint32_t b = AV_RN32(pixels + 1); \
+ uint32_t l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ uint32_t l1, h1; \
+ \
+ pixels += line_size; \
+ for (i = 0; i < h; i += 2) { \
+ uint32_t a = AV_RN32(pixels); \
+ uint32_t b = AV_RN32(pixels + 1); \
+ l1 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL); \
+ h1 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ a = AV_RN32(pixels); \
+ b = AV_RN32(pixels + 1); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+} \
+ \
+static inline void OPNAME ## _pixels8_xy2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int j; \
+ \
+ for (j = 0; j < 2; j++) { \
+ int i; \
+ const uint32_t a = AV_RN32(pixels); \
+ const uint32_t b = AV_RN32(pixels + 1); \
+ uint32_t l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ uint32_t l1, h1; \
+ \
+ pixels += line_size; \
+ for (i = 0; i < h; i += 2) { \
+ uint32_t a = AV_RN32(pixels); \
+ uint32_t b = AV_RN32(pixels + 1); \
+ l1 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL); \
+ h1 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ a = AV_RN32(pixels); \
+ b = AV_RN32(pixels + 1); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+ pixels += 4 - line_size * (h + 1); \
+ block += 4 - line_size * h; \
+ } \
+} \
+ \
+static inline void OPNAME ## _no_rnd_pixels8_xy2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int j; \
+ \
+ for (j = 0; j < 2; j++) { \
+ int i; \
+ const uint32_t a = AV_RN32(pixels); \
+ const uint32_t b = AV_RN32(pixels + 1); \
+ uint32_t l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x01010101UL; \
+ uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ uint32_t l1, h1; \
+ \
+ pixels += line_size; \
+ for (i = 0; i < h; i += 2) { \
+ uint32_t a = AV_RN32(pixels); \
+ uint32_t b = AV_RN32(pixels + 1); \
+ l1 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL); \
+ h1 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ a = AV_RN32(pixels); \
+ b = AV_RN32(pixels + 1); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x01010101UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), h0 + h1 + \
+ (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+ pixels += 4 - line_size * (h + 1); \
+ block += 4 - line_size * h; \
+ } \
+} \
+ \
+CALL_2X_PIXELS(OPNAME ## _pixels16_x2_8_c, \
+ OPNAME ## _pixels8_x2_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _pixels16_y2_8_c, \
+ OPNAME ## _pixels8_y2_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_8_c, \
+ OPNAME ## _pixels8_xy2_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_8_c, \
+ OPNAME ## _pixels8_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_8_c, \
+ OPNAME ## _no_rnd_pixels8_x2_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_8_c, \
+ OPNAME ## _no_rnd_pixels8_y2_8_c, \
+ 8) \
+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_8_c, \
+ OPNAME ## _no_rnd_pixels8_xy2_8_c, \
+ 8) \
+
+#define op_avg(a, b) a = rnd_avg32(a, b)
+#define op_put(a, b) a = b
+#define put_no_rnd_pixels8_8_c put_pixels8_8_c
+PIXOP2(avg, op_avg)
+PIXOP2(put, op_put)
+#undef op_avg
+#undef op_put
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
{
@@ -54,6 +355,8 @@ av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
hpel_funcs(avg, [3], 2);
hpel_funcs(avg_no_rnd,, 16);
+ if (ARCH_AARCH64)
+ ff_hpeldsp_init_aarch64(c, flags);
if (ARCH_ALPHA)
ff_hpeldsp_init_alpha(c, flags);
if (ARCH_ARM)
@@ -62,8 +365,6 @@ av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
ff_hpeldsp_init_bfin(c, flags);
if (ARCH_PPC)
ff_hpeldsp_init_ppc(c, flags);
- if (HAVE_VIS)
- ff_hpeldsp_init_vis(c, flags);
if (ARCH_X86)
ff_hpeldsp_init_x86(c, flags);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/hpeldsp.h b/chromium/third_party/ffmpeg/libavcodec/hpeldsp.h
index ec9006c31da..f8e7b028512 100644
--- a/chromium/third_party/ffmpeg/libavcodec/hpeldsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/hpeldsp.h
@@ -94,11 +94,11 @@ typedef struct HpelDSPContext {
void ff_hpeldsp_init(HpelDSPContext *c, int flags);
+void ff_hpeldsp_init_aarch64(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_alpha(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_arm(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_ppc(HpelDSPContext *c, int flags);
-void ff_hpeldsp_init_vis(HpelDSPContext *c, int flags);
void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags);
#endif /* AVCODEC_HPELDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/hpeldsp_template.c b/chromium/third_party/ffmpeg/libavcodec/hpeldsp_template.c
deleted file mode 100644
index 9c9fd2b9e71..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/hpeldsp_template.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Half-pel DSP functions.
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Half-pel DSP functions.
- */
-
-#include "bit_depth_template.c"
-
-#include "hpel_template.c"
-
-#define PIXOP2(OPNAME, OP) \
-static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
- int src_stride1, int src_stride2, int h){\
- int i;\
- for(i=0; i<h; i++){\
- pixel4 a,b;\
- a= AV_RN4P(&src1[i*src_stride1 ]);\
- b= AV_RN4P(&src2[i*src_stride2 ]);\
- OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\
- a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
- b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
- OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
- }\
-}\
-\
-static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *_block, const uint8_t *_pixels, ptrdiff_t line_size, int h)\
-{\
- int i, a0, b0, a1, b1;\
- pixel *block = (pixel*)_block;\
- const pixel *pixels = (const pixel*)_pixels;\
- line_size >>= sizeof(pixel)-1;\
- a0= pixels[0];\
- b0= pixels[1] + 2;\
- a0 += b0;\
- b0 += pixels[2];\
-\
- pixels+=line_size;\
- for(i=0; i<h; i+=2){\
- a1= pixels[0];\
- b1= pixels[1];\
- a1 += b1;\
- b1 += pixels[2];\
-\
- block[0]= (a1+a0)>>2; /* FIXME non put */\
- block[1]= (b1+b0)>>2;\
-\
- pixels+=line_size;\
- block +=line_size;\
-\
- a0= pixels[0];\
- b0= pixels[1] + 2;\
- a0 += b0;\
- b0 += pixels[2];\
-\
- block[0]= (a1+a0)>>2;\
- block[1]= (b1+b0)>>2;\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\
-{\
- /* FIXME HIGH BIT DEPTH */\
- int i;\
- const uint32_t a= AV_RN32(pixels );\
- const uint32_t b= AV_RN32(pixels+1);\
- uint32_t l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- uint32_t l1,h1;\
-\
- pixels+=line_size;\
- for(i=0; i<h; i+=2){\
- uint32_t a= AV_RN32(pixels );\
- uint32_t b= AV_RN32(pixels+1);\
- l1= (a&0x03030303UL)\
- + (b&0x03030303UL);\
- h1= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- a= AV_RN32(pixels );\
- b= AV_RN32(pixels+1);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\
-{\
- /* FIXME HIGH BIT DEPTH */\
- int j;\
- for(j=0; j<2; j++){\
- int i;\
- const uint32_t a= AV_RN32(pixels );\
- const uint32_t b= AV_RN32(pixels+1);\
- uint32_t l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- uint32_t l1,h1;\
-\
- pixels+=line_size;\
- for(i=0; i<h; i+=2){\
- uint32_t a= AV_RN32(pixels );\
- uint32_t b= AV_RN32(pixels+1);\
- l1= (a&0x03030303UL)\
- + (b&0x03030303UL);\
- h1= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- a= AV_RN32(pixels );\
- b= AV_RN32(pixels+1);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x02020202UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- }\
- pixels+=4-line_size*(h+1);\
- block +=4-line_size*h;\
- }\
-}\
-\
-static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\
-{\
- /* FIXME HIGH BIT DEPTH */\
- int j;\
- for(j=0; j<2; j++){\
- int i;\
- const uint32_t a= AV_RN32(pixels );\
- const uint32_t b= AV_RN32(pixels+1);\
- uint32_t l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x01010101UL;\
- uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- uint32_t l1,h1;\
-\
- pixels+=line_size;\
- for(i=0; i<h; i+=2){\
- uint32_t a= AV_RN32(pixels );\
- uint32_t b= AV_RN32(pixels+1);\
- l1= (a&0x03030303UL)\
- + (b&0x03030303UL);\
- h1= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- a= AV_RN32(pixels );\
- b= AV_RN32(pixels+1);\
- l0= (a&0x03030303UL)\
- + (b&0x03030303UL)\
- + 0x01010101UL;\
- h0= ((a&0xFCFCFCFCUL)>>2)\
- + ((b&0xFCFCFCFCUL)>>2);\
- OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
- pixels+=line_size;\
- block +=line_size;\
- }\
- pixels+=4-line_size*(h+1);\
- block +=4-line_size*h;\
- }\
-}\
-\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
-av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
-
-#define op_avg(a, b) a = rnd_avg_pixel4(a, b)
-#define op_put(a, b) a = b
-#if BIT_DEPTH == 8
-#define put_no_rnd_pixels8_8_c put_pixels8_8_c
-PIXOP2(avg, op_avg)
-PIXOP2(put, op_put)
-#endif
-#undef op_avg
-#undef op_put
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffman.c b/chromium/third_party/ffmpeg/libavcodec/huffman.c
index 8dd356dde41..0fc2055dbeb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffman.c
+++ b/chromium/third_party/ffmpeg/libavcodec/huffman.c
@@ -52,18 +52,23 @@ static void heap_sift(HeapElem *h, int root, int size)
}
}
-void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
+int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int size)
{
- HeapElem h[256];
- int up[2*256];
- int len[2*256];
+ HeapElem *h = av_malloc_array(sizeof(*h), size);
+ int *up = av_malloc_array(sizeof(*up) * 2, size);
+ uint8_t *len = av_malloc_array(sizeof(*len) * 2, size);
int offset, i, next;
- int size = 256;
+ int ret = 0;
+
+ if (!h || !up || !len) {
+ ret = AVERROR(ENOMEM);
+ goto end;
+ }
for (offset = 1; ; offset <<= 1) {
for (i=0; i < size; i++) {
h[i].name = i;
- h[i].val = (stats[i] << 8) + offset;
+ h[i].val = (stats[i] << 14) + offset;
}
for (i = size / 2 - 1; i >= 0; i--)
heap_sift(h, i, size);
@@ -89,6 +94,11 @@ void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
}
if (i==size) break;
}
+end:
+ av_free(h);
+ av_free(up);
+ av_free(len);
+ return ret;
}
static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffman.h b/chromium/third_party/ffmpeg/libavcodec/huffman.h
index cec95379acc..b1ace62201d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffman.h
+++ b/chromium/third_party/ffmpeg/libavcodec/huffman.h
@@ -43,6 +43,6 @@ typedef int (*HuffCmp)(const void *va, const void *vb);
int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bits,
Node *nodes, HuffCmp cmp, int flags);
-void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats);
+int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int n);
#endif /* AVCODEC_HUFFMAN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffyuv.c b/chromium/third_party/ffmpeg/libavcodec/huffyuv.c
index b4ef76f1983..386653518f9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffyuv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/huffyuv.c
@@ -1,7 +1,7 @@
/*
* huffyuv codec for libavcodec
*
- * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
* see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
* the algorithm used
@@ -35,13 +35,13 @@
#include "avcodec.h"
#include "huffyuv.h"
-int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table)
+int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n)
{
int len, index;
uint32_t bits = 0;
for (len = 32; len > 0; len--) {
- for (index = 0; index < 256; index++) {
+ for (index = 0; index < n; index++) {
if (len_table[index] == len)
dst[index] = bits++;
}
@@ -58,16 +58,11 @@ av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
{
int i;
- if (s->bitstream_bpp<24) {
- for (i=0; i<3; i++) {
- s->temp[i]= av_malloc(s->width + 16);
- if (!s->temp[i])
- return AVERROR(ENOMEM);
- }
- } else {
- s->temp[0]= av_mallocz(4*s->width + 16);
- if (!s->temp[0])
+ for (i=0; i<3; i++) {
+ s->temp[i]= av_malloc(4*s->width + 16);
+ if (!s->temp[i])
return AVERROR(ENOMEM);
+ s->temp16[i] = (uint16_t*)s->temp[i];
}
return 0;
}
@@ -80,6 +75,7 @@ av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
s->flags = avctx->flags;
ff_dsputil_init(&s->dsp, avctx);
+ ff_llviddsp_init(&s->llviddsp, avctx);
s->width = avctx->width;
s->height = avctx->height;
@@ -93,5 +89,6 @@ av_cold void ff_huffyuv_common_end(HYuvContext *s)
for(i = 0; i < 3; i++) {
av_freep(&s->temp[i]);
+ s->temp16[i] = NULL;
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffyuv.h b/chromium/third_party/ffmpeg/libavcodec/huffyuv.h
index e2cacc1ae47..da4e3b5a132 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffyuv.h
+++ b/chromium/third_party/ffmpeg/libavcodec/huffyuv.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
* see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
* the algorithm used
@@ -35,9 +35,14 @@
#include "dsputil.h"
#include "get_bits.h"
#include "put_bits.h"
+#include "lossless_videodsp.h"
#define VLC_BITS 11
+#define MAX_BITS 16
+#define MAX_N (1<<MAX_BITS)
+#define MAX_VLC_N 16384
+
#if HAVE_BIGENDIAN
#define B 3
#define G 2
@@ -67,25 +72,35 @@ typedef struct HYuvContext {
int version;
int yuy2; //use yuy2 instead of 422P
int bgr32; //use bgr32 instead of bgr24
+ int bps;
+ int n; // 1<<bps
+ int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
+ int alpha;
+ int chroma;
+ int yuv;
+ int chroma_h_shift;
+ int chroma_v_shift;
int width, height;
int flags;
int context;
int picture_number;
int last_slice_end;
uint8_t *temp[3];
- uint64_t stats[3][256];
- uint8_t len[3][256];
- uint32_t bits[3][256];
+ uint16_t *temp16[3]; ///< identical to temp but 16bit type
+ uint64_t stats[4][MAX_VLC_N];
+ uint8_t len[4][MAX_VLC_N];
+ uint32_t bits[4][MAX_VLC_N];
uint32_t pix_bgr_map[1<<VLC_BITS];
- VLC vlc[6]; //Y,U,V,YY,YU,YV
+ VLC vlc[8]; //Y,U,V,A,YY,YU,YV,AA
uint8_t *bitstream_buffer;
unsigned int bitstream_buffer_size;
DSPContext dsp;
+ LLVidDSPContext llviddsp;
} HYuvContext;
void ff_huffyuv_common_init(AVCodecContext *s);
void ff_huffyuv_common_end(HYuvContext *s);
int ff_huffyuv_alloc_temp(HYuvContext *s);
-int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table);
+int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n);
#endif /* AVCODEC_HUFFYUV_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffyuvdec.c b/chromium/third_party/ffmpeg/libavcodec/huffyuvdec.c
index 3cfda9b7677..6ab12c475e4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffyuvdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/huffyuvdec.c
@@ -1,7 +1,7 @@
/*
* huffyuv decoder
*
- * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
* see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
* the algorithm used
@@ -21,6 +21,8 @@
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * yuva, gray, 4:4:4, 4:1:1, 4:1:0 and >8 bit per sample support sponsored by NOA
*/
/**
@@ -32,6 +34,7 @@
#include "get_bits.h"
#include "huffyuv.h"
#include "thread.h"
+#include "libavutil/pixdesc.h"
#define classic_shift_luma_table_size 42
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
@@ -87,16 +90,16 @@ static const unsigned char classic_add_chroma[256] = {
6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2,
};
-static int read_len_table(uint8_t *dst, GetBitContext *gb)
+static int read_len_table(uint8_t *dst, GetBitContext *gb, int n)
{
int i, val, repeat;
- for (i = 0; i < 256;) {
+ for (i = 0; i < n;) {
repeat = get_bits(gb, 3);
val = get_bits(gb, 5);
if (repeat == 0)
repeat = get_bits(gb, 8);
- if (i + repeat > 256 || get_bits_left(gb) < 0) {
+ if (i + repeat > n || get_bits_left(gb) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n");
return -1;
}
@@ -113,28 +116,33 @@ static int generate_joint_tables(HYuvContext *s)
uint8_t len[1 << VLC_BITS];
int ret;
- if (s->bitstream_bpp < 24) {
+ if (s->bitstream_bpp < 24 || s->version > 2) {
int p, i, y, u;
- for (p = 0; p < 3; p++) {
- for (i = y = 0; y < 256; y++) {
- int len0 = s->len[0][y];
+ for (p = 0; p < 4; p++) {
+ int p0 = s->version > 2 ? p : 0;
+ for (i = y = 0; y < s->vlc_n; y++) {
+ int len0 = s->len[p0][y];
int limit = VLC_BITS - len0;
if(limit <= 0 || !len0)
continue;
- for (u = 0; u < 256; u++) {
+ if((sign_extend(y, 8) & (s->vlc_n-1)) != y)
+ continue;
+ for (u = 0; u < s->vlc_n; u++) {
int len1 = s->len[p][u];
if (len1 > limit || !len1)
continue;
+ if((sign_extend(u, 8) & (s->vlc_n-1)) != u)
+ continue;
av_assert0(i < (1 << VLC_BITS));
len[i] = len0 + len1;
- bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
- symbols[i] = (y << 8) + u;
+ bits[i] = (s->bits[p0][y] << len1) + s->bits[p][u];
+ symbols[i] = (y << 8) + (u & 0xFF);
if(symbols[i] != 0xffff) // reserved to mean "invalid"
i++;
}
}
- ff_free_vlc(&s->vlc[3 + p]);
- if ((ret = ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,
+ ff_free_vlc(&s->vlc[4 + p]);
+ if ((ret = ff_init_vlc_sparse(&s->vlc[4 + p], VLC_BITS, i, len, 1, 1,
bits, 2, 2, symbols, 2, 2, 0)) < 0)
return ret;
}
@@ -177,8 +185,8 @@ static int generate_joint_tables(HYuvContext *s)
}
}
}
- ff_free_vlc(&s->vlc[3]);
- if ((ret = init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0)
+ ff_free_vlc(&s->vlc[4]);
+ if ((ret = init_vlc(&s->vlc[4], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0)
return ret;
}
return 0;
@@ -189,17 +197,21 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)
GetBitContext gb;
int i;
int ret;
+ int count = 3;
init_get_bits(&gb, src, length * 8);
- for (i = 0; i < 3; i++) {
- if (read_len_table(s->len[i], &gb) < 0)
+ if (s->version > 2)
+ count = 1 + s->alpha + 2*s->chroma;
+
+ for (i = 0; i < count; i++) {
+ if (read_len_table(s->len[i], &gb, s->vlc_n) < 0)
return -1;
- if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0) {
+ if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0) {
return -1;
}
ff_free_vlc(&s->vlc[i]);
- if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
+ if ((ret = init_vlc(&s->vlc[i], VLC_BITS, s->vlc_n, s->len[i], 1, 1,
s->bits[i], 4, 4, 0)) < 0)
return ret;
}
@@ -218,12 +230,12 @@ static int read_old_huffman_tables(HYuvContext *s)
init_get_bits(&gb, classic_shift_luma,
classic_shift_luma_table_size * 8);
- if (read_len_table(s->len[0], &gb) < 0)
+ if (read_len_table(s->len[0], &gb, 256) < 0)
return -1;
init_get_bits(&gb, classic_shift_chroma,
classic_shift_chroma_table_size * 8);
- if (read_len_table(s->len[1], &gb) < 0)
+ if (read_len_table(s->len[1], &gb, 256) < 0)
return -1;
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
@@ -236,7 +248,7 @@ static int read_old_huffman_tables(HYuvContext *s)
memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
ff_free_vlc(&s->vlc[i]);
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
s->bits[i], 4, 4, 0)) < 0)
@@ -253,10 +265,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
- ff_huffyuv_common_init(avctx);
- memset(s->vlc, 0, 3 * sizeof(VLC));
+ memset(s->vlc, 0, 4 * sizeof(VLC));
- s->interlaced = s->height > 288;
+ s->interlaced = avctx->height > 288;
s->bgr32 = 1;
@@ -264,12 +275,18 @@ static av_cold int decode_init(AVCodecContext *avctx)
if ((avctx->bits_per_coded_sample & 7) &&
avctx->bits_per_coded_sample != 12)
s->version = 1; // do such files exist at all?
- else
+ else if (avctx->extradata_size > 3 && avctx->extradata[3] == 0)
s->version = 2;
+ else
+ s->version = 3;
} else
s->version = 0;
- if (s->version == 2) {
+ s->bps = 8;
+ s->n = 1<<s->bps;
+ s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+ s->chroma = 1;
+ if (s->version >= 2) {
int method, interlace;
if (avctx->extradata_size < 4)
@@ -278,9 +295,20 @@ static av_cold int decode_init(AVCodecContext *avctx)
method = ((uint8_t*)avctx->extradata)[0];
s->decorrelate = method & 64 ? 1 : 0;
s->predictor = method & 63;
- s->bitstream_bpp = ((uint8_t*)avctx->extradata)[1];
- if (s->bitstream_bpp == 0)
- s->bitstream_bpp = avctx->bits_per_coded_sample & ~7;
+ if (s->version == 2) {
+ s->bitstream_bpp = ((uint8_t*)avctx->extradata)[1];
+ if (s->bitstream_bpp == 0)
+ s->bitstream_bpp = avctx->bits_per_coded_sample & ~7;
+ } else {
+ s->bps = (avctx->extradata[1] >> 4) + 1;
+ s->n = 1<<s->bps;
+ s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+ s->chroma_h_shift = avctx->extradata[1] & 3;
+ s->chroma_v_shift = (avctx->extradata[1] >> 2) & 3;
+ s->yuv = !!(((uint8_t*)avctx->extradata)[2] & 1);
+ s->chroma= !!(((uint8_t*)avctx->extradata)[2] & 3);
+ s->alpha = !!(((uint8_t*)avctx->extradata)[2] & 4);
+ }
interlace = (((uint8_t*)avctx->extradata)[2] & 0x30) >> 4;
s->interlaced = (interlace == 1) ? 1 : (interlace == 2) ? 0 : s->interlaced;
s->context = ((uint8_t*)avctx->extradata)[2] & 0x40 ? 1 : 0;
@@ -318,29 +346,176 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- switch (s->bitstream_bpp) {
- case 12:
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
- break;
- case 16:
- if (s->yuy2) {
- avctx->pix_fmt = AV_PIX_FMT_YUYV422;
- } else {
- avctx->pix_fmt = AV_PIX_FMT_YUV422P;
- }
- break;
- case 24:
- case 32:
- if (s->bgr32) {
+ if (s->version <= 2) {
+ switch (s->bitstream_bpp) {
+ case 12:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ s->yuv = 1;
+ break;
+ case 16:
+ if (s->yuy2) {
+ avctx->pix_fmt = AV_PIX_FMT_YUYV422;
+ } else {
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+ }
+ s->yuv = 1;
+ break;
+ case 24:
+ if (s->bgr32) {
+ avctx->pix_fmt = AV_PIX_FMT_0RGB32;
+ } else {
+ avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ }
+ break;
+ case 32:
+ av_assert0(s->bgr32);
avctx->pix_fmt = AV_PIX_FMT_RGB32;
- } else {
- avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ s->alpha = 1;
+ break;
+ default:
+ return AVERROR_INVALIDDATA;
+ }
+ av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
+ &s->chroma_h_shift,
+ &s->chroma_v_shift);
+ } else {
+ switch ( (s->chroma<<10) | (s->yuv<<9) | (s->alpha<<8) | ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2)) {
+ case 0x070:
+ avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+ break;
+ case 0x0F0:
+ avctx->pix_fmt = AV_PIX_FMT_GRAY16;
+ break;
+ case 0x170:
+ avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
+ break;
+ case 0x470:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP;
+ break;
+ case 0x480:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP9;
+ break;
+ case 0x490:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP10;
+ break;
+ case 0x4B0:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP12;
+ break;
+ case 0x4D0:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP14;
+ break;
+ case 0x4F0:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP16;
+ break;
+ case 0x570:
+ avctx->pix_fmt = AV_PIX_FMT_GBRAP;
+ break;
+ case 0x670:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+ break;
+ case 0x680:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P9;
+ break;
+ case 0x690:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+ break;
+ case 0x6B0:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P12;
+ break;
+ case 0x6D0:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P14;
+ break;
+ case 0x6F0:
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
+ break;
+ case 0x671:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+ break;
+ case 0x681:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P9;
+ break;
+ case 0x691:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
+ break;
+ case 0x6B1:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P12;
+ break;
+ case 0x6D1:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P14;
+ break;
+ case 0x6F1:
+ avctx->pix_fmt = AV_PIX_FMT_YUV422P16;
+ break;
+ case 0x672:
+ avctx->pix_fmt = AV_PIX_FMT_YUV411P;
+ break;
+ case 0x674:
+ avctx->pix_fmt = AV_PIX_FMT_YUV440P;
+ break;
+ case 0x675:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ break;
+ case 0x685:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
+ break;
+ case 0x695:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
+ break;
+ case 0x6B5:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P12;
+ break;
+ case 0x6D5:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P14;
+ break;
+ case 0x6F5:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
+ break;
+ case 0x67A:
+ avctx->pix_fmt = AV_PIX_FMT_YUV410P;
+ break;
+ case 0x770:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
+ break;
+ case 0x780:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA444P9;
+ break;
+ case 0x790:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA444P10;
+ break;
+ case 0x7F0:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA444P16;
+ break;
+ case 0x771:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA422P;
+ break;
+ case 0x781:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA422P9;
+ break;
+ case 0x791:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA422P10;
+ break;
+ case 0x7F1:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA422P16;
+ break;
+ case 0x775:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
+ break;
+ case 0x785:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P9;
+ break;
+ case 0x795:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P10;
+ break;
+ case 0x7F5:
+ avctx->pix_fmt = AV_PIX_FMT_YUVA420P16;
+ break;
+ default:
+ return AVERROR_INVALIDDATA;
}
- break;
- default:
- return AVERROR_INVALIDDATA;
}
+ ff_huffyuv_common_init(avctx);
+
if ((avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV420P) && avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
return AVERROR_INVALIDDATA;
@@ -367,10 +542,10 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 8; i++)
s->vlc[i].table = NULL;
- if (s->version == 2) {
+ if (s->version >= 2) {
if (read_huffman_tables(s, ((uint8_t*)avctx->extradata) + 4,
avctx->extradata_size) < 0)
return AVERROR_INVALIDDATA;
@@ -385,7 +560,7 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
/* TODO instead of restarting the read when the code isn't in the first level
* of the joint table, jump into the 2nd level of the individual table. */
#define READ_2PIX(dst0, dst1, plane1){\
- uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\
+ uint16_t code = get_vlc2(&s->gb, s->vlc[4+plane1].table, VLC_BITS, 1);\
if(code != 0xffff){\
dst0 = code>>8;\
dst1 = code;\
@@ -406,6 +581,9 @@ static void decode_422_bitstream(HYuvContext *s, int count)
READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);
}
+ for (; i < count; i++)
+ s->temp[0][2 * i ] = s->temp[1][i] =
+ s->temp[0][2 * i + 1] = s->temp[2][i] = 128;
} else {
for (i = 0; i < count; i++) {
READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);
@@ -414,6 +592,72 @@ static void decode_422_bitstream(HYuvContext *s, int count)
}
}
+#define READ_2PIX_PLANE(dst0, dst1, plane){\
+ uint16_t code = get_vlc2(&s->gb, s->vlc[4+plane].table, VLC_BITS, 1);\
+ if(code != 0xffff){\
+ dst0 = code>>8;\
+ dst1 = code;\
+ }else{\
+ dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ }\
+}
+#define READ_2PIX_PLANE14(dst0, dst1, plane){\
+ int16_t code = get_vlc2(&s->gb, s->vlc[4+plane].table, VLC_BITS, 1);\
+ if(code != (int16_t)0xffff){\
+ dst0 = code>>8;\
+ dst1 = sign_extend(code, 8);\
+ }else{\
+ dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ }\
+}
+
+#define READ_2PIX_PLANE16(dst0, dst1, plane){\
+ dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;\
+ dst0 += get_bits(&s->gb, 2);\
+ dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;\
+ dst1 += get_bits(&s->gb, 2);\
+}
+static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
+{
+ int i;
+
+ count/=2;
+
+ if (s->bps <= 8) {
+ if (count >= (get_bits_left(&s->gb)) / (31 * 2)) {
+ for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
+ READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane);
+ }
+ } else {
+ for(i=0; i<count; i++){
+ READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane);
+ }
+ }
+ } else if (s->bps <= 14) {
+ if (count >= (get_bits_left(&s->gb)) / (31 * 2)) {
+ for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
+ READ_2PIX_PLANE14(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
+ }
+ } else {
+ for(i=0; i<count; i++){
+ READ_2PIX_PLANE14(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
+ }
+ }
+ } else {
+ if (count >= (get_bits_left(&s->gb)) / (31 * 2)) {
+ for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
+ READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
+ }
+ } else {
+ for(i=0; i<count; i++){
+ READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
+ }
+ }
+ }
+}
+
static void decode_gray_bitstream(HYuvContext *s, int count)
{
int i;
@@ -436,7 +680,7 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
{
int i;
for (i = 0; i < count; i++) {
- int code = get_vlc2(&s->gb, s->vlc[3].table, VLC_BITS, 1);
+ int code = get_vlc2(&s->gb, s->vlc[4].table, VLC_BITS, 1);
if (code != -1) {
*(uint32_t*)&s->temp[0][4 * i] = s->pix_bgr_map[code];
} else if(decorrelate) {
@@ -499,6 +743,32 @@ static void draw_slice(HYuvContext *s, AVFrame *frame, int y)
s->last_slice_end = y + h;
}
+static int left_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int acc)
+{
+ if (s->bps <= 8) {
+ return s->dsp.add_hfyu_left_prediction(dst, src, w, acc);
+ } else {
+ return s->llviddsp.add_hfyu_left_prediction_int16(( uint16_t *)dst, (const uint16_t *)src, s->n-1, w, acc);
+ }
+}
+
+static void add_bytes(HYuvContext *s, uint8_t *dst, uint8_t *src, int w)
+{
+ if (s->bps <= 8) {
+ s->dsp.add_bytes(dst, src, w);
+ } else {
+ s->llviddsp.add_int16((uint16_t*)dst, (const uint16_t*)src, s->n - 1, w);
+ }
+}
+
+static void add_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, const uint8_t *diff, int w, int *left, int *left_top)
+{
+ if (s->bps <= 8) {
+ s->dsp.add_hfyu_median_prediction(dst, src, diff, w, left, left_top);
+ } else {
+ s->llviddsp.add_hfyu_median_prediction_int16((uint16_t *)dst, (const uint16_t *)src, (const uint16_t *)diff, s->n-1, w, left, left_top);
+ }
+}
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
@@ -543,7 +813,72 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->last_slice_end = 0;
- if (s->bitstream_bpp < 24) {
+ if (s->version > 2) {
+ int plane;
+ for(plane = 0; plane < 1 + 2*s->chroma + s->alpha; plane++) {
+ int left, lefttop, y;
+ int w = width;
+ int h = height;
+ int fake_stride = fake_ystride;
+
+ if (s->chroma && (plane == 1 || plane == 2)) {
+ w >>= s->chroma_h_shift;
+ h >>= s->chroma_v_shift;
+ fake_stride = plane == 1 ? fake_ustride : fake_vstride;
+ }
+
+ switch (s->predictor) {
+ case LEFT:
+ case PLANE:
+ decode_plane_bitstream(s, w, plane);
+ left = left_prediction(s, p->data[plane], s->temp[0], w, 0);
+
+ for (y = 1; y < h; y++) {
+ uint8_t *dst = p->data[plane] + p->linesize[plane]*y;
+
+ decode_plane_bitstream(s, w, plane);
+ left = left_prediction(s, dst, s->temp[0], w, left);
+ if (s->predictor == PLANE) {
+ if (y > s->interlaced) {
+ add_bytes(s, dst, dst - fake_stride, w);
+ }
+ }
+ }
+
+ break;
+ case MEDIAN:
+ decode_plane_bitstream(s, w, plane);
+ left= left_prediction(s, p->data[plane], s->temp[0], w, 0);
+
+ y = 1;
+
+ /* second line is left predicted for interlaced case */
+ if (s->interlaced) {
+ decode_plane_bitstream(s, w, plane);
+ left = left_prediction(s, p->data[plane] + p->linesize[plane], s->temp[0], w, left);
+ y++;
+ }
+
+ lefttop = p->data[plane][0];
+ decode_plane_bitstream(s, w, plane);
+ add_median_prediction(s, p->data[plane] + fake_stride, p->data[plane], s->temp[0], w, &left, &lefttop);
+ y++;
+
+ for (; y<h; y++) {
+ uint8_t *dst;
+
+ decode_plane_bitstream(s, w, plane);
+
+ dst = p->data[plane] + p->linesize[plane] * y;
+
+ add_median_prediction(s, dst, dst - fake_stride, s->temp[0], w, &left, &lefttop);
+ }
+
+ break;
+ }
+ }
+ draw_slice(s, p, height);
+ } else if (s->bitstream_bpp < 24) {
int y, cy;
int lefty, leftu, leftv;
int lefttopy, lefttopu, lefttopv;
@@ -756,14 +1091,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
ff_huffyuv_common_end(s);
av_freep(&s->bitstream_buffer);
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 8; i++) {
ff_free_vlc(&s->vlc[i]);
}
return 0;
}
-#if CONFIG_HUFFYUV_DECODER
AVCodec ff_huffyuv_decoder = {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -777,7 +1111,6 @@ AVCodec ff_huffyuv_decoder = {
CODEC_CAP_FRAME_THREADS,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
};
-#endif
#if CONFIG_FFVHUFF_DECODER
AVCodec ff_ffvhuff_decoder = {
diff --git a/chromium/third_party/ffmpeg/libavcodec/huffyuvenc.c b/chromium/third_party/ffmpeg/libavcodec/huffyuvenc.c
index 3a55d543a9a..4a001b922c7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/huffyuvenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/huffyuvenc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
* see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
* the algorithm used
@@ -19,6 +19,8 @@
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * yuva, gray, 4:4:4, 4:1:1, 4:1:0 and >8 bit per sample support sponsored by NOA
*/
/**
@@ -31,26 +33,58 @@
#include "huffman.h"
#include "internal.h"
#include "put_bits.h"
+#include "libavutil/pixdesc.h"
+
+static inline void diff_bytes(HYuvContext *s, uint8_t *dst,
+ const uint8_t *src0, const uint8_t *src1, int w)
+{
+ if (s->bps <= 8) {
+ s->dsp.diff_bytes(dst, src0, src1, w);
+ } else {
+ s->llviddsp.diff_int16((uint16_t *)dst, (const uint16_t *)src0, (const uint16_t *)src1, s->n - 1, w);
+ }
+}
static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst,
const uint8_t *src, int w, int left)
{
int i;
- if (w < 32) {
- for (i = 0; i < w; i++) {
- const int temp = src[i];
- dst[i] = temp - left;
- left = temp;
+ if (s->bps <= 8) {
+ if (w < 32) {
+ for (i = 0; i < w; i++) {
+ const int temp = src[i];
+ dst[i] = temp - left;
+ left = temp;
+ }
+ return left;
+ } else {
+ for (i = 0; i < 16; i++) {
+ const int temp = src[i];
+ dst[i] = temp - left;
+ left = temp;
+ }
+ s->dsp.diff_bytes(dst + 16, src + 16, src + 15, w - 16);
+ return src[w-1];
}
- return left;
} else {
- for (i = 0; i < 16; i++) {
- const int temp = src[i];
- dst[i] = temp - left;
- left = temp;
+ const uint16_t *src16 = (const uint16_t *)src;
+ uint16_t *dst16 = ( uint16_t *)dst;
+ if (w < 32) {
+ for (i = 0; i < w; i++) {
+ const int temp = src16[i];
+ dst16[i] = temp - left;
+ left = temp;
+ }
+ return left;
+ } else {
+ for (i = 0; i < 16; i++) {
+ const int temp = src16[i];
+ dst16[i] = temp - left;
+ left = temp;
+ }
+ s->llviddsp.diff_int16(dst16 + 16, src16 + 16, src16 + 15, s->n - 1, w - 16);
+ return src16[w-1];
}
- s->dsp.diff_bytes(dst + 16, src + 16, src + 15, w - 16);
- return src[w-1];
}
}
@@ -117,19 +151,29 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
*blue = src[(w - 1) * 3 + 2];
}
+static void sub_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
+{
+ if (s->bps <= 8) {
+ s->dsp.sub_hfyu_median_prediction(dst, src1, src2, w , left, left_top);
+ } else {
+ s->llviddsp.sub_hfyu_median_prediction_int16((uint16_t *)dst, (const uint16_t *)src1, (const uint16_t *)src2, s->n - 1, w , left, left_top);
+ }
+}
+
static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
{
int i;
int index = 0;
+ int n = s->vlc_n;
- for (i = 0; i < 256;) {
+ for (i = 0; i < n;) {
int val = len[i];
int repeat = 0;
- for (; i < 256 && len[i] == val && repeat < 255; i++)
+ for (; i < n && len[i] == val && repeat < 255; i++)
repeat++;
- av_assert0(val < 32 && val >0 && repeat<256 && repeat>0);
+ av_assert0(val < 32 && val >0 && repeat < 256 && repeat>0);
if (repeat > 7) {
buf[index++] = val;
buf[index++] = repeat;
@@ -141,18 +185,45 @@ static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
return index;
}
+static int store_huffman_tables(HYuvContext *s, uint8_t *buf)
+{
+ int i, ret;
+ int size = 0;
+ int count = 3;
+
+ if (s->version > 2)
+ count = 1 + s->alpha + 2*s->chroma;
+
+ for (i = 0; i < count; i++) {
+ if ((ret = ff_huff_gen_len_table(s->len[i], s->stats[i], s->vlc_n)) < 0)
+ return ret;
+
+ if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0) {
+ return -1;
+ }
+
+ size += store_table(s, s->len[i], buf + size);
+ }
+ return size;
+}
+
static av_cold int encode_init(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
int i, j;
+ int ret;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
ff_huffyuv_common_init(avctx);
- avctx->extradata = av_mallocz(1024*30); // 256*3+4 == 772
- avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
- if (!avctx->extradata || !avctx->stats_out) {
- av_freep(&avctx->stats_out);
+ avctx->extradata = av_mallocz(3*MAX_N + 4);
+ if (!avctx->extradata)
return AVERROR(ENOMEM);
+ if (s->flags&CODEC_FLAG_PASS1) {
+#define STATS_OUT_SIZE 21*MAX_N*3 + 4
+ avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
+ if (!avctx->stats_out)
+ return AVERROR(ENOMEM);
}
s->version = 2;
@@ -163,6 +234,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
+ s->bps = desc->comp[0].depth_minus1 + 1;
+ s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
+ s->chroma = desc->nb_components > 2;
+ s->alpha = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
+ av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
+ &s->chroma_h_shift,
+ &s->chroma_v_shift);
+
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
@@ -172,6 +251,49 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
s->bitstream_bpp = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 12 : 16;
break;
+ case AV_PIX_FMT_YUV444P:
+ case AV_PIX_FMT_YUV410P:
+ case AV_PIX_FMT_YUV411P:
+ case AV_PIX_FMT_YUV440P:
+ case AV_PIX_FMT_GBRP:
+ case AV_PIX_FMT_GBRP9:
+ case AV_PIX_FMT_GBRP10:
+ case AV_PIX_FMT_GBRP12:
+ case AV_PIX_FMT_GBRP14:
+ case AV_PIX_FMT_GBRP16:
+ case AV_PIX_FMT_GRAY8:
+ case AV_PIX_FMT_GRAY16:
+ case AV_PIX_FMT_YUVA444P:
+ case AV_PIX_FMT_YUVA420P:
+ case AV_PIX_FMT_YUVA422P:
+ case AV_PIX_FMT_GBRAP:
+ case AV_PIX_FMT_GRAY8A:
+ case AV_PIX_FMT_YUV420P9:
+ case AV_PIX_FMT_YUV420P10:
+ case AV_PIX_FMT_YUV420P12:
+ case AV_PIX_FMT_YUV420P14:
+ case AV_PIX_FMT_YUV420P16:
+ case AV_PIX_FMT_YUV422P9:
+ case AV_PIX_FMT_YUV422P10:
+ case AV_PIX_FMT_YUV422P12:
+ case AV_PIX_FMT_YUV422P14:
+ case AV_PIX_FMT_YUV422P16:
+ case AV_PIX_FMT_YUV444P9:
+ case AV_PIX_FMT_YUV444P10:
+ case AV_PIX_FMT_YUV444P12:
+ case AV_PIX_FMT_YUV444P14:
+ case AV_PIX_FMT_YUV444P16:
+ case AV_PIX_FMT_YUVA420P9:
+ case AV_PIX_FMT_YUVA420P10:
+ case AV_PIX_FMT_YUVA420P16:
+ case AV_PIX_FMT_YUVA422P9:
+ case AV_PIX_FMT_YUVA422P10:
+ case AV_PIX_FMT_YUVA422P16:
+ case AV_PIX_FMT_YUVA444P9:
+ case AV_PIX_FMT_YUVA444P10:
+ case AV_PIX_FMT_YUVA444P16:
+ s->version = 3;
+ break;
case AV_PIX_FMT_RGB32:
s->bitstream_bpp = 32;
break;
@@ -182,8 +304,11 @@ static av_cold int encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "format not supported\n");
return AVERROR(EINVAL);
}
+ s->n = 1<<s->bps;
+ s->vlc_n = FFMIN(s->n, MAX_VLC_N);
+
avctx->bits_per_coded_sample = s->bitstream_bpp;
- s->decorrelate = s->bitstream_bpp >= 24;
+ s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
s->predictor = avctx->prediction_method;
s->interlaced = avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0;
if (avctx->context_model == 1) {
@@ -209,37 +334,58 @@ static av_cold int encode_init(AVCodecContext *avctx)
"by huffyuv; use vcodec=ffvhuff\n");
return AVERROR(EINVAL);
}
+ if (s->version > 2) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Error: ver>2 is not supported "
+ "by huffyuv; use vcodec=ffvhuff\n");
+ return AVERROR(EINVAL);
+ }
if (s->interlaced != ( s->height > 288 ))
av_log(avctx, AV_LOG_INFO,
"using huffyuv 2.2.0 or newer interlacing flag\n");
}
- if (s->bitstream_bpp >= 24 && s->predictor == MEDIAN) {
+ if (s->version > 3 && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+ av_log(avctx, AV_LOG_ERROR, "Ver > 3 is under development, files encoded with it may not be decodable with future versions!!!\n"
+ "Use vstrict=-2 / -strict -2 to use it anyway.\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (s->bitstream_bpp >= 24 && s->predictor == MEDIAN && s->version <= 2) {
av_log(avctx, AV_LOG_ERROR,
"Error: RGB is incompatible with median predictor\n");
return AVERROR(EINVAL);
}
((uint8_t*)avctx->extradata)[0] = s->predictor | (s->decorrelate << 6);
- ((uint8_t*)avctx->extradata)[1] = s->bitstream_bpp;
((uint8_t*)avctx->extradata)[2] = s->interlaced ? 0x10 : 0x20;
if (s->context)
((uint8_t*)avctx->extradata)[2] |= 0x40;
- ((uint8_t*)avctx->extradata)[3] = 0;
+ if (s->version < 3) {
+ ((uint8_t*)avctx->extradata)[1] = s->bitstream_bpp;
+ ((uint8_t*)avctx->extradata)[3] = 0;
+ } else {
+ ((uint8_t*)avctx->extradata)[1] = ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2);
+ if (s->chroma)
+ ((uint8_t*)avctx->extradata)[2] |= s->yuv ? 1 : 2;
+ if (s->alpha)
+ ((uint8_t*)avctx->extradata)[2] |= 4;
+ ((uint8_t*)avctx->extradata)[3] = 1;
+ }
s->avctx->extradata_size = 4;
if (avctx->stats_in) {
char *p = avctx->stats_in;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 256; j++)
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < s->vlc_n; j++)
s->stats[i][j] = 1;
for (;;) {
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
char *next;
- for (j = 0; j < 256; j++) {
+ for (j = 0; j < s->vlc_n; j++) {
s->stats[i][j] += strtol(p, &next, 0);
if (next == p) return -1;
p = next;
@@ -248,36 +394,30 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (p[0] == 0 || p[1] == 0 || p[2] == 0) break;
}
} else {
- for (i = 0; i < 3; i++)
- for (j = 0; j < 256; j++) {
- int d = FFMIN(j, 256 - j);
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < s->vlc_n; j++) {
+ int d = FFMIN(j, s->vlc_n - j);
s->stats[i][j] = 100000000 / (d + 1);
}
}
- for (i = 0; i < 3; i++) {
- ff_huff_gen_len_table(s->len[i], s->stats[i]);
-
- if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0) {
- return -1;
- }
-
- s->avctx->extradata_size +=
- store_table(s, s->len[i], &((uint8_t*)s->avctx->extradata)[s->avctx->extradata_size]);
- }
+ ret = store_huffman_tables(s, s->avctx->extradata + s->avctx->extradata_size);
+ if (ret < 0)
+ return ret;
+ s->avctx->extradata_size += ret;
if (s->context) {
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
int pels = s->width * s->height / (i ? 40 : 10);
- for (j = 0; j < 256; j++) {
- int d = FFMIN(j, 256 - j);
+ for (j = 0; j < s->vlc_n; j++) {
+ int d = FFMIN(j, s->vlc_n - j);
s->stats[i][j] = pels/(d + 1);
}
}
} else {
- for (i = 0; i < 3; i++)
- for (j = 0; j < 256; j++)
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < s->vlc_n; j++)
s->stats[i][j]= 0;
}
@@ -345,6 +485,115 @@ static int encode_422_bitstream(HYuvContext *s, int offset, int count)
return 0;
}
+static int encode_plane_bitstream(HYuvContext *s, int count, int plane)
+{
+ int i;
+
+ if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) < count * s->bps / 2) {
+ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
+ return -1;
+ }
+
+#define LOAD2\
+ int y0 = s->temp[0][2 * i];\
+ int y1 = s->temp[0][2 * i + 1];
+#define LOAD2_14\
+ int y0 = s->temp16[0][2 * i] & mask;\
+ int y1 = s->temp16[0][2 * i + 1] & mask;
+#define LOAD2_16\
+ int y0 = s->temp16[0][2 * i];\
+ int y1 = s->temp16[0][2 * i + 1];
+#define STAT2\
+ s->stats[plane][y0]++;\
+ s->stats[plane][y1]++;
+#define STAT2_16\
+ s->stats[plane][y0>>2]++;\
+ s->stats[plane][y1>>2]++;
+#define WRITE2\
+ put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);\
+ put_bits(&s->pb, s->len[plane][y1], s->bits[plane][y1]);
+#define WRITE2_16\
+ put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
+ put_bits(&s->pb, 2, y0&3);\
+ put_bits(&s->pb, s->len[plane][y1>>2], s->bits[plane][y1>>2]);\
+ put_bits(&s->pb, 2, y1&3);
+
+ count /= 2;
+
+ if (s->bps <= 8) {
+ if (s->flags & CODEC_FLAG_PASS1) {
+ for (i = 0; i < count; i++) {
+ LOAD2;
+ STAT2;
+ }
+ }
+ if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)
+ return 0;
+
+ if (s->context) {
+ for (i = 0; i < count; i++) {
+ LOAD2;
+ STAT2;
+ WRITE2;
+ }
+ } else {
+ for (i = 0; i < count; i++) {
+ LOAD2;
+ WRITE2;
+ }
+ }
+ } else if (s->bps <= 14) {
+ int mask = s->n - 1;
+ if (s->flags & CODEC_FLAG_PASS1) {
+ for (i = 0; i < count; i++) {
+ LOAD2_14;
+ STAT2;
+ }
+ }
+ if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)
+ return 0;
+
+ if (s->context) {
+ for (i = 0; i < count; i++) {
+ LOAD2_14;
+ STAT2;
+ WRITE2;
+ }
+ } else {
+ for (i = 0; i < count; i++) {
+ LOAD2_14;
+ WRITE2;
+ }
+ }
+ } else {
+ if (s->flags & CODEC_FLAG_PASS1) {
+ for (i = 0; i < count; i++) {
+ LOAD2_16;
+ STAT2_16;
+ }
+ }
+ if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)
+ return 0;
+
+ if (s->context) {
+ for (i = 0; i < count; i++) {
+ LOAD2_16;
+ STAT2_16;
+ WRITE2_16;
+ }
+ } else {
+ for (i = 0; i < count; i++) {
+ LOAD2_16;
+ WRITE2_16;
+ }
+ }
+ }
+#undef LOAD2
+#undef STAT2
+#undef WRITE2
+ return 0;
+}
+
static int encode_gray_bitstream(HYuvContext *s, int count)
{
int i;
@@ -458,15 +707,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
if (s->context) {
- for (i = 0; i < 3; i++) {
- ff_huff_gen_len_table(s->len[i], s->stats[i]);
- if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0)
- return -1;
- size += store_table(s, s->len[i], &pkt->data[size]);
- }
+ size = store_huffman_tables(s, pkt->data);
+ if (size < 0)
+ return size;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 256; j++)
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < s->vlc_n; j++)
s->stats[i][j] >>= 1;
}
@@ -634,6 +880,59 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
encode_bgra_bitstream(s, width, 3);
}
+ } else if (s->version > 2) {
+ int plane;
+ for (plane = 0; plane < 1 + 2*s->chroma + s->alpha; plane++) {
+ int left, y;
+ int w = width;
+ int h = height;
+ int fake_stride = fake_ystride;
+
+ if (s->chroma && (plane == 1 || plane == 2)) {
+ w >>= s->chroma_h_shift;
+ h >>= s->chroma_v_shift;
+ fake_stride = plane == 1 ? fake_ustride : fake_vstride;
+ }
+
+ left = sub_left_prediction(s, s->temp[0], p->data[plane], w , 0);
+
+ encode_plane_bitstream(s, w, plane);
+
+ if (s->predictor==MEDIAN) {
+ int lefttop;
+ y = 1;
+ if (s->interlaced) {
+ left = sub_left_prediction(s, s->temp[0], p->data[plane] + p->linesize[plane], w , left);
+
+ encode_plane_bitstream(s, w, plane);
+ y++;
+ }
+
+ lefttop = p->data[plane][0];
+
+ for (; y < h; y++) {
+ uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
+
+ sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop);
+
+ encode_plane_bitstream(s, w, plane);
+ }
+ } else {
+ for (y = 1; y < h; y++) {
+ uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
+
+ if (s->predictor == PLANE && s->interlaced < y) {
+ diff_bytes(s, s->temp[1], dst, dst - fake_stride, w);
+
+ left = sub_left_prediction(s, s->temp[0], s->temp[1], w , left);
+ } else {
+ left = sub_left_prediction(s, s->temp[0], dst, w , left);
+ }
+
+ encode_plane_bitstream(s, w, plane);
+ }
+ }
+ }
} else {
av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");
}
@@ -647,17 +946,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if ((s->flags&CODEC_FLAG_PASS1) && (s->picture_number & 31) == 0) {
int j;
char *p = avctx->stats_out;
- char *end = p + 1024*30;
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 256; j++) {
+ char *end = p + STATS_OUT_SIZE;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < s->vlc_n; j++) {
snprintf(p, end-p, "%"PRIu64" ", s->stats[i][j]);
p += strlen(p);
s->stats[i][j]= 0;
}
snprintf(p, end-p, "\n");
p++;
+ if (end <= p)
+ return AVERROR(ENOMEM);
}
- } else
+ } else if (avctx->stats_out)
avctx->stats_out[0] = '\0';
if (!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)) {
flush_put_bits(&s->pb);
@@ -687,7 +988,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
-#if CONFIG_HUFFYUV_ENCODER
AVCodec ff_huffyuv_encoder = {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -697,12 +997,12 @@ AVCodec ff_huffyuv_encoder = {
.init = encode_init,
.encode2 = encode_frame,
.close = encode_end,
+ .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_YUV422P, AV_PIX_FMT_RGB24,
AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE
},
};
-#endif
#if CONFIG_FFVHUFF_ENCODER
AVCodec ff_ffvhuff_encoder = {
@@ -714,8 +1014,23 @@ AVCodec ff_ffvhuff_encoder = {
.init = encode_init,
.encode2 = encode_frame,
.close = encode_end,
+ .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
.pix_fmts = (const enum AVPixelFormat[]){
- AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_RGB24,
+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV411P,
+ AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P,
+ AV_PIX_FMT_GBRP,
+ AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14,
+ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
+ AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
+ AV_PIX_FMT_GBRAP,
+ AV_PIX_FMT_GRAY8A,
+ AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV420P16,
+ AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV422P16,
+ AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV444P16,
+ AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
+ AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P16,
+ AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P16,
+ AV_PIX_FMT_RGB24,
AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE
},
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/iff.c b/chromium/third_party/ffmpeg/libavcodec/iff.c
index e71f5b00b96..f08a0f70cef 100644
--- a/chromium/third_party/ffmpeg/libavcodec/iff.c
+++ b/chromium/third_party/ffmpeg/libavcodec/iff.c
@@ -488,17 +488,21 @@ static int decode_byterun(uint8_t *dst, int dst_size,
unsigned length;
const int8_t value = *buf++;
if (value >= 0) {
- length = value + 1;
- memcpy(dst + x, buf, FFMIN3(length, dst_size - x, buf_end - buf));
+ length = FFMIN3(value + 1, dst_size - x, buf_end - buf);
+ memcpy(dst + x, buf, length);
buf += length;
} else if (value > -128) {
- length = -value + 1;
- memset(dst + x, *buf++, FFMIN(length, dst_size - x));
+ length = FFMIN(-value + 1, dst_size - x);
+ memset(dst + x, *buf++, length);
} else { // noop
continue;
}
x += length;
}
+ if (x < dst_size) {
+ av_log(NULL, AV_LOG_WARNING, "decode_byterun ended before plane size\n");
+ memset(dst+x, 0, dst_size - x);
+ }
return buf - buf_start;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/imgconvert.c b/chromium/third_party/ffmpeg/libavcodec/imgconvert.c
index ee58cfb49ae..27c984a6707 100644
--- a/chromium/third_party/ffmpeg/libavcodec/imgconvert.c
+++ b/chromium/third_party/ffmpeg/libavcodec/imgconvert.c
@@ -31,9 +31,9 @@
*/
#include "avcodec.h"
-#include "dsputil.h"
#include "imgconvert.h"
#include "internal.h"
+#include "mathops.h"
#include "libavutil/avassert.h"
#include "libavutil/colorspace.h"
#include "libavutil/common.h"
@@ -41,16 +41,6 @@
#include "libavutil/imgutils.h"
#if HAVE_MMX_EXTERNAL
-#include "x86/dsputil_x86.h"
-#endif
-
-#define FF_COLOR_NA -1
-#define FF_COLOR_RGB 0 /**< RGB color space */
-#define FF_COLOR_GRAY 1 /**< gray color space */
-#define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
-#define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
-
-#if HAVE_MMX_EXTERNAL
#define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
#define deinterlace_line ff_deinterlace_line_mmx
#else
@@ -58,10 +48,6 @@
#define deinterlace_line deinterlace_line_c
#endif
-#define pixdesc_has_alpha(pixdesc) \
- ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL)
-
-
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
@@ -70,184 +56,17 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int
*v_shift = desc->log2_chroma_h;
}
-static int get_color_type(const AVPixFmtDescriptor *desc) {
- if (desc->flags & AV_PIX_FMT_FLAG_PAL)
- return FF_COLOR_RGB;
-
- if(desc->nb_components == 1 || desc->nb_components == 2)
- return FF_COLOR_GRAY;
-
- if(desc->name && !strncmp(desc->name, "yuvj", 4))
- return FF_COLOR_YUV_JPEG;
-
- if(desc->flags & AV_PIX_FMT_FLAG_RGB)
- return FF_COLOR_RGB;
-
- if(desc->nb_components == 0)
- return FF_COLOR_NA;
-
- return FF_COLOR_YUV;
-}
-
-static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int i;
-
- if (!desc || !desc->nb_components) {
- *min = *max = 0;
- return AVERROR(EINVAL);
- }
-
- *min = INT_MAX, *max = -INT_MAX;
- for (i = 0; i < desc->nb_components; i++) {
- *min = FFMIN(desc->comp[i].depth_minus1+1, *min);
- *max = FFMAX(desc->comp[i].depth_minus1+1, *max);
- }
- return 0;
-}
-
-static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
- enum AVPixelFormat src_pix_fmt,
- unsigned *lossp, unsigned consider)
-{
- const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
- const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
- int src_color, dst_color;
- int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
- int ret, loss, i, nb_components;
- int score = INT_MAX - 1;
-
- if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE)
- return ~0;
-
- /* compute loss */
- *lossp = loss = 0;
-
- if (dst_pix_fmt == src_pix_fmt)
- return INT_MAX;
-
- if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
- return ret;
- if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
- return ret;
-
- src_color = get_color_type(src_desc);
- dst_color = get_color_type(dst_desc);
- nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
-
- for (i = 0; i < nb_components; i++)
- if (src_desc->comp[i].depth_minus1 > dst_desc->comp[i].depth_minus1 && (consider & FF_LOSS_DEPTH)) {
- loss |= FF_LOSS_DEPTH;
- score -= 65536 >> dst_desc->comp[i].depth_minus1;
- }
-
- if (consider & FF_LOSS_RESOLUTION) {
- if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
- loss |= FF_LOSS_RESOLUTION;
- score -= 256 << dst_desc->log2_chroma_w;
- }
- if (dst_desc->log2_chroma_h > src_desc->log2_chroma_h) {
- loss |= FF_LOSS_RESOLUTION;
- score -= 256 << dst_desc->log2_chroma_h;
- }
- // don't favor 422 over 420 if downsampling is needed, because 420 has much better support on the decoder side
- if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 0 &&
- dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 0 ) {
- score += 512;
- }
- }
-
- if(consider & FF_LOSS_COLORSPACE)
- switch(dst_color) {
- case FF_COLOR_RGB:
- if (src_color != FF_COLOR_RGB &&
- src_color != FF_COLOR_GRAY)
- loss |= FF_LOSS_COLORSPACE;
- break;
- case FF_COLOR_GRAY:
- if (src_color != FF_COLOR_GRAY)
- loss |= FF_LOSS_COLORSPACE;
- break;
- case FF_COLOR_YUV:
- if (src_color != FF_COLOR_YUV)
- loss |= FF_LOSS_COLORSPACE;
- break;
- case FF_COLOR_YUV_JPEG:
- if (src_color != FF_COLOR_YUV_JPEG &&
- src_color != FF_COLOR_YUV &&
- src_color != FF_COLOR_GRAY)
- loss |= FF_LOSS_COLORSPACE;
- break;
- default:
- /* fail safe test */
- if (src_color != dst_color)
- loss |= FF_LOSS_COLORSPACE;
- break;
- }
- if(loss & FF_LOSS_COLORSPACE)
- score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth_minus1, src_desc->comp[0].depth_minus1);
-
- if (dst_color == FF_COLOR_GRAY &&
- src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
- loss |= FF_LOSS_CHROMA;
- score -= 2 * 65536;
- }
- if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) {
- loss |= FF_LOSS_ALPHA;
- score -= 65536;
- }
- if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) &&
- (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) {
- loss |= FF_LOSS_COLORQUANT;
- score -= 65536;
- }
-
- *lossp = loss;
- return score;
-}
-
int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
enum AVPixelFormat src_pix_fmt,
int has_alpha)
{
- int loss;
- int ret = get_pix_fmt_score(dst_pix_fmt, src_pix_fmt, &loss, has_alpha ? ~0 : ~FF_LOSS_ALPHA);
- if (ret < 0)
- return ret;
- return loss;
+ return av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
}
enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
{
- enum AVPixelFormat dst_pix_fmt;
- int loss1, loss2, loss_mask;
- const AVPixFmtDescriptor *desc1 = av_pix_fmt_desc_get(dst_pix_fmt1);
- const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2);
- int score1, score2;
-
- loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */
- if(!has_alpha)
- loss_mask &= ~FF_LOSS_ALPHA;
-
- dst_pix_fmt = AV_PIX_FMT_NONE;
- score1 = get_pix_fmt_score(dst_pix_fmt1, src_pix_fmt, &loss1, loss_mask);
- score2 = get_pix_fmt_score(dst_pix_fmt2, src_pix_fmt, &loss2, loss_mask);
-
- if (score1 == score2) {
- if(av_get_padded_bits_per_pixel(desc2) != av_get_padded_bits_per_pixel(desc1)) {
- dst_pix_fmt = av_get_padded_bits_per_pixel(desc2) < av_get_padded_bits_per_pixel(desc1) ? dst_pix_fmt2 : dst_pix_fmt1;
- } else {
- dst_pix_fmt = desc2->nb_components < desc1->nb_components ? dst_pix_fmt2 : dst_pix_fmt1;
- }
- } else {
- dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
- }
-
- if (loss_ptr)
- *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
- return dst_pix_fmt;
+ return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
}
#if AV_HAVE_INCOMPATIBLE_LIBAV_ABI
@@ -486,7 +305,7 @@ static void deinterlace_line_c(uint8_t *dst,
const uint8_t *lum,
int size)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int sum;
for(;size > 0;size--) {
@@ -509,7 +328,7 @@ static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3,
uint8_t *lum_m2, uint8_t *lum_m1,
uint8_t *lum, int size)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int sum;
for(;size > 0;size--) {
@@ -656,7 +475,7 @@ int main(void){
av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip);
skip = 0;
}
- av_log(NULL, AV_LOG_INFO, "pix fmt %s yuv_plan:%d avg_bpp:%d colortype:%d\n", desc->name, is_yuv_planar(desc), av_get_padded_bits_per_pixel(desc), get_color_type(desc));
+ av_log(NULL, AV_LOG_INFO, "pix fmt %s yuv_plan:%d avg_bpp:%d\n", desc->name, is_yuv_planar(desc), av_get_padded_bits_per_pixel(desc));
if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) {
av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n");
err = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/imgconvert.h b/chromium/third_party/ffmpeg/libavcodec/imgconvert.h
index df8cee794fc..0ce626d7a24 100644
--- a/chromium/third_party/ffmpeg/libavcodec/imgconvert.h
+++ b/chromium/third_party/ffmpeg/libavcodec/imgconvert.h
@@ -21,6 +21,24 @@
#include <stdint.h>
+#include "version.h"
+
+#if FF_API_DEINTERLACE
+
+void ff_deinterlace_line_mmx(uint8_t *dst,
+ const uint8_t *lum_m4, const uint8_t *lum_m3,
+ const uint8_t *lum_m2, const uint8_t *lum_m1,
+ const uint8_t *lum,
+ int size);
+
+void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4,
+ const uint8_t *lum_m3,
+ const uint8_t *lum_m2,
+ const uint8_t *lum_m1,
+ const uint8_t *lum, int size);
+
+#endif /* FF_API_DEINTERLACE */
+
/* 1/2^n downscaling functions */
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
diff --git a/chromium/third_party/ffmpeg/libavcodec/indeo3.c b/chromium/third_party/ffmpeg/libavcodec/indeo3.c
index ddb4ad0deea..aa9c30aca95 100644
--- a/chromium/third_party/ffmpeg/libavcodec/indeo3.c
+++ b/chromium/third_party/ffmpeg/libavcodec/indeo3.c
@@ -956,7 +956,8 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
free_frame_buffers(ctx);
if ((res = allocate_frame_buffers(ctx, avctx, width, height)) < 0)
return res;
- ff_set_dimensions(avctx, width, height);
+ if ((res = ff_set_dimensions(avctx, width, height)) < 0)
+ return res;
}
y_offset = bytestream2_get_le32(&gb);
diff --git a/chromium/third_party/ffmpeg/libavcodec/indeo4data.h b/chromium/third_party/ffmpeg/libavcodec/indeo4data.h
index 0ea4f405ad7..d96ee985023 100644
--- a/chromium/third_party/ffmpeg/libavcodec/indeo4data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/indeo4data.h
@@ -28,8 +28,9 @@
#define AVCODEC_INDEO4DATA_H
#include <stdint.h>
-#include "dsputil.h"
+
#include "ivi_common.h"
+#include "mathops.h"
/**
* standard picture dimensions
diff --git a/chromium/third_party/ffmpeg/libavcodec/indeo5.c b/chromium/third_party/ffmpeg/libavcodec/indeo5.c
index e48cb43407c..0477c977397 100644
--- a/chromium/third_party/ffmpeg/libavcodec/indeo5.c
+++ b/chromium/third_party/ffmpeg/libavcodec/indeo5.c
@@ -30,7 +30,6 @@
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
-#include "dsputil.h"
#include "ivi_dsp.h"
#include "ivi_common.h"
#include "indeo5data.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/intelh263dec.c b/chromium/third_party/ffmpeg/libavcodec/intelh263dec.c
index 5da420243d8..7ea62465fa5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/intelh263dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/intelh263dec.c
@@ -133,5 +133,8 @@ AVCodec ff_h263i_decoder = {
.close = ff_h263_decode_end,
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/internal.h b/chromium/third_party/ffmpeg/libavcodec/internal.h
index 35bfcd47551..603ffcf8f60 100644
--- a/chromium/third_party/ffmpeg/libavcodec/internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/internal.h
@@ -27,6 +27,7 @@
#include <stdint.h>
#include "libavutil/buffer.h"
+#include "libavutil/channel_layout.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
@@ -34,6 +35,12 @@
#define FF_SANE_NB_CHANNELS 63U
+#if HAVE_NEON || ARCH_PPC || HAVE_MMX
+# define STRIDE_ALIGN 16
+#else
+# define STRIDE_ALIGN 8
+#endif
+
typedef struct FramePool {
/**
* Pools for each data plane. For audio all the planes have the same size,
@@ -115,6 +122,11 @@ typedef struct AVCodecInternal {
* Number of audio samples to skip at the start of the next decoded frame
*/
int skip_samples;
+
+ /**
+ * hwaccel-specific private data
+ */
+ void *hwaccel_priv_data;
} AVCodecInternal;
struct AVCodecDefault {
@@ -122,14 +134,7 @@ struct AVCodecDefault {
const uint8_t *value;
};
-/**
- * Return the hardware accelerated codec for codec codec_id and
- * pixel format pix_fmt.
- *
- * @param avctx The codec context containing the codec_id and pixel format.
- * @return the hardware accelerated codec, or NULL if none was found.
- */
-AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx);
+extern const uint8_t ff_log2_run[41];
/**
* Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
@@ -238,4 +243,22 @@ const uint8_t *avpriv_find_start_code(const uint8_t *p,
*/
int ff_set_dimensions(AVCodecContext *s, int width, int height);
+/**
+ * Add or update AV_FRAME_DATA_MATRIXENCODING side data.
+ */
+int ff_side_data_update_matrix_encoding(AVFrame *frame,
+ enum AVMatrixEncoding matrix_encoding);
+
+/**
+ * Select the (possibly hardware accelerated) pixel format.
+ * This is a wrapper around AVCodecContext.get_format() and should be used
+ * instead of calling get_format() directly.
+ */
+int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
+
+/**
+ * Set various frame properties from the codec context / packet data.
+ */
+int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
+
#endif /* AVCODEC_INTERNAL_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/interplayvideo.c b/chromium/third_party/ffmpeg/libavcodec/interplayvideo.c
index 7ac14569544..542fefe146c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/interplayvideo.c
+++ b/chromium/third_party/ffmpeg/libavcodec/interplayvideo.c
@@ -197,6 +197,11 @@ static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s, AVFrame *frame)
unsigned char P[2];
unsigned int flags;
+ if (bytestream2_get_bytes_left(&s->stream_ptr) < 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0x7\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* 2-color encoding */
P[0] = bytestream2_get_byte(&s->stream_ptr);
P[1] = bytestream2_get_byte(&s->stream_ptr);
@@ -236,6 +241,11 @@ static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s, AVFrame *frame)
unsigned char P[4];
unsigned int flags = 0;
+ if (bytestream2_get_bytes_left(&s->stream_ptr) < 12) {
+ av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0x8\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
* either top and bottom or left and right halves */
P[0] = bytestream2_get_byte(&s->stream_ptr);
@@ -308,6 +318,11 @@ static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s, AVFrame *frame)
int x, y;
unsigned char P[4];
+ if (bytestream2_get_bytes_left(&s->stream_ptr) < 8) {
+ av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0x9\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* 4-color encoding */
bytestream2_get_buffer(&s->stream_ptr, P, 4);
@@ -374,6 +389,11 @@ static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s, AVFrame *frame)
unsigned char P[8];
int flags = 0;
+ if (bytestream2_get_bytes_left(&s->stream_ptr) < 16) {
+ av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0xA\n");
+ return AVERROR_INVALIDDATA;
+ }
+
bytestream2_get_buffer(&s->stream_ptr, P, 4);
/* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
@@ -467,6 +487,11 @@ static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s, AVFrame *frame)
int y;
unsigned char P[2];
+ if (bytestream2_get_bytes_left(&s->stream_ptr) < 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "too little data for opcode 0xD\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* 4-color block encoding: each 4x4 block is a different color */
for (y = 0; y < 8; y++) {
if (!(y & 3)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/intrax8.c b/chromium/third_party/ffmpeg/libavcodec/intrax8.c
index ffdfb079b78..4008ef6d957 100644
--- a/chromium/third_party/ffmpeg/libavcodec/intrax8.c
+++ b/chromium/third_party/ffmpeg/libavcodec/intrax8.c
@@ -303,7 +303,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma
int quant;
w->dsp.setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer,
- s->current_picture.f.linesize[chroma>0],
+ s->current_picture.f->linesize[chroma>0],
&range, &sum, w->edges);
if(chroma){
w->orient=w->chroma_orient;
@@ -612,7 +612,7 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
dc_level+= (w->predicted_dc*divide_quant + (1<<12) )>>13;
dsp_x8_put_solidcolor( av_clip_uint8((dc_level*dc_quant+4)>>3),
- s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
+ s->dest[chroma], s->current_picture.f->linesize[!!chroma]);
goto block_placed;
}
@@ -636,15 +636,15 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
}
if(w->flat_dc){
- dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
+ dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f->linesize[!!chroma]);
}else{
w->dsp.spatial_compensation[w->orient]( s->edge_emu_buffer,
s->dest[chroma],
- s->current_picture.f.linesize[!!chroma] );
+ s->current_picture.f->linesize[!!chroma] );
}
if(!zeros_only)
w->wdsp.idct_add (s->dest[chroma],
- s->current_picture.f.linesize[!!chroma],
+ s->current_picture.f->linesize[!!chroma],
s->block[0] );
block_placed:
@@ -655,7 +655,7 @@ block_placed:
if(s->loop_filter){
uint8_t* ptr = s->dest[chroma];
- int linesize = s->current_picture.f.linesize[!!chroma];
+ int linesize = s->current_picture.f->linesize[!!chroma];
if(!( (w->edges&2) || ( zeros_only && (w->orient|4)==4 ) )){
w->dsp.h_loop_filter(ptr, linesize, w->quant);
@@ -670,12 +670,12 @@ block_placed:
static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
//not s->linesize as this would be wrong for field pics
//not that IntraX8 has interlacing support ;)
- const int linesize = s->current_picture.f.linesize[0];
- const int uvlinesize = s->current_picture.f.linesize[1];
+ const int linesize = s->current_picture.f->linesize[0];
+ const int uvlinesize = s->current_picture.f->linesize[1];
- s->dest[0] = s->current_picture.f.data[0];
- s->dest[1] = s->current_picture.f.data[1];
- s->dest[2] = s->current_picture.f.data[2];
+ s->dest[0] = s->current_picture.f->data[0];
+ s->dest[1] = s->current_picture.f->data[1];
+ s->dest[2] = s->current_picture.f->data[2];
s->dest[0] += s->mb_y * linesize << 3;
s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;//chroma blocks are on add rows
diff --git a/chromium/third_party/ffmpeg/libavcodec/ituh263dec.c b/chromium/third_party/ffmpeg/libavcodec/ituh263dec.c
index 8a17c6f3cae..33526554c21 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ituh263dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ituh263dec.c
@@ -36,6 +36,7 @@
#include "mpegvideo.h"
#include "h263.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "unary.h"
#include "flv.h"
#include "mpeg4video.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/ituh263enc.c b/chromium/third_party/ffmpeg/libavcodec/ituh263enc.c
index 2db95811190..5db3a7512ab 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ituh263enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ituh263enc.c
@@ -34,6 +34,7 @@
#include "mpegvideo.h"
#include "h263.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "unary.h"
#include "flv.h"
#include "mpeg4video.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/ivi_common.c b/chromium/third_party/ffmpeg/libavcodec/ivi_common.c
index 9b5f5f876e8..7b1db42b067 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ivi_common.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ivi_common.c
@@ -26,8 +26,11 @@
* Indeo5 decoders.
*/
+#include <inttypes.h>
+
#define BITSTREAM_READER_LE
#include "libavutil/attributes.h"
+#include "libavutil/timer.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
@@ -297,7 +300,7 @@ av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
planes[1].num_bands = planes[2].num_bands = cfg->chroma_bands;
for (p = 0; p < 3; p++) {
- planes[p].bands = av_mallocz(planes[p].num_bands * sizeof(IVIBandDesc));
+ planes[p].bands = av_mallocz_array(planes[p].num_bands, sizeof(IVIBandDesc));
if (!planes[p].bands)
return AVERROR(ENOMEM);
@@ -363,7 +366,7 @@ static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile,
band->mb_size);
av_freep(&tile->mbs);
- tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
+ tile->mbs = av_mallocz_array(tile->num_MBs, sizeof(IVIMbInfo));
if (!tile->mbs)
return AVERROR(ENOMEM);
@@ -407,7 +410,7 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
band->num_tiles = x_tiles * y_tiles;
av_freep(&band->tiles);
- band->tiles = av_mallocz(band->num_tiles * sizeof(IVITile));
+ band->tiles = av_mallocz_array(band->num_tiles, sizeof(IVITile));
if (!band->tiles)
return AVERROR(ENOMEM);
@@ -512,7 +515,7 @@ static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
val = IVI_TOSIGNED((hi << 6) | lo);
} else {
if (sym >= 256U) {
- av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
+ av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %"PRIu32".\n", sym);
return AVERROR_INVALIDDATA;
}
run = rvmap->runtab[sym];
@@ -961,7 +964,7 @@ static int decode_band(IVI45DecContext *ctx,
if (chksum != band->checksum) {
av_log(avctx, AV_LOG_ERROR,
"Band checksum mismatch! Plane %d, band %d, "
- "received: %x, calculated: %x\n",
+ "received: %"PRIx32", calculated: %"PRIx16"\n",
band->plane, band->band_num, band->checksum, chksum);
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/j2kenc.c b/chromium/third_party/ffmpeg/libavcodec/j2kenc.c
index d9f5eaf5f42..ddb0b686cb9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/j2kenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/j2kenc.c
@@ -60,7 +60,7 @@ typedef struct {
typedef struct {
AVCodecContext *avctx;
- AVFrame picture;
+ const AVFrame *picture;
int width, height; ///< image width and height
uint8_t cbps[4]; ///< bits per sample in particular components
@@ -343,14 +343,14 @@ static int init_tiles(Jpeg2000EncoderContext *s)
s->numXtiles = ff_jpeg2000_ceildiv(s->width, s->tile_width);
s->numYtiles = ff_jpeg2000_ceildiv(s->height, s->tile_height);
- s->tile = av_malloc(s->numXtiles * s->numYtiles * sizeof(Jpeg2000Tile));
+ s->tile = av_malloc_array(s->numXtiles, s->numYtiles * sizeof(Jpeg2000Tile));
if (!s->tile)
return AVERROR(ENOMEM);
for (tileno = 0, tiley = 0; tiley < s->numYtiles; tiley++)
for (tilex = 0; tilex < s->numXtiles; tilex++, tileno++){
Jpeg2000Tile *tile = s->tile + tileno;
- tile->comp = av_mallocz(s->ncomponents * sizeof(Jpeg2000Component));
+ tile->comp = av_mallocz_array(s->ncomponents, sizeof(Jpeg2000Component));
if (!tile->comp)
return AVERROR(ENOMEM);
for (compno = 0; compno < s->ncomponents; compno++){
@@ -390,18 +390,18 @@ static void copy_frame(Jpeg2000EncoderContext *s)
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = tile->comp + compno;
int *dst = comp->i_data;
- line = s->picture.data[compno]
- + comp->coord[1][0] * s->picture.linesize[compno]
+ line = s->picture->data[compno]
+ + comp->coord[1][0] * s->picture->linesize[compno]
+ comp->coord[0][0];
for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){
uint8_t *ptr = line;
for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++)
*dst++ = *ptr++ - (1 << 7);
- line += s->picture.linesize[compno];
+ line += s->picture->linesize[compno];
}
}
} else{
- line = s->picture.data[0] + tile->comp[0].coord[1][0] * s->picture.linesize[0]
+ line = s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0]
+ tile->comp[0].coord[0][0] * s->ncomponents;
i = 0;
@@ -412,7 +412,7 @@ static void copy_frame(Jpeg2000EncoderContext *s)
tile->comp[compno].i_data[i] = *ptr++ - (1 << 7);
}
}
- line += s->picture.linesize[0];
+ line += s->picture->linesize[0];
}
}
}
@@ -927,10 +927,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->buf = s->buf_start = pkt->data;
s->buf_end = pkt->data + pkt->size;
- s->picture = *pict;
- avctx->coded_frame= &s->picture;
+ s->picture = pict;
- s->lambda = s->picture.quality * LAMBDA_SCALE;
+ s->lambda = s->picture->quality * LAMBDA_SCALE;
copy_frame(s);
reinit(s);
diff --git a/chromium/third_party/ffmpeg/libavcodec/jpeg2000dec.c b/chromium/third_party/ffmpeg/libavcodec/jpeg2000dec.c
index d3e49a19e6e..fbfb7d1e5f0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/jpeg2000dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/jpeg2000dec.c
@@ -25,6 +25,8 @@
* JPEG 2000 image decoder
*/
+#include <inttypes.h>
+
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
@@ -344,7 +346,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
break;
}
}
- if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
+ if (i == possible_fmts_nb) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown pix_fmt, profile: %d, colour_space: %d, "
"components: %d, precision: %d, "
@@ -354,6 +356,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
ncomponents > 2 ? s->cdy[1] : 0,
ncomponents > 2 ? s->cdx[2] : 0,
ncomponents > 2 ? s->cdy[2] : 0);
+ return AVERROR_PATCHWELCOME;
}
s->avctx->bits_per_raw_sample = s->precision;
return 0;
@@ -445,7 +448,7 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
if (tmp.mct && s->ncomponents < 3) {
av_log(s->avctx, AV_LOG_ERROR,
- "MCT %d with too few components (%d)\n",
+ "MCT %"PRIu8" with too few components (%d)\n",
tmp.mct, s->ncomponents);
return AVERROR_INVALIDDATA;
}
@@ -540,6 +543,8 @@ static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
Jpeg2000QuantStyle tmp;
int compno, ret;
+ memset(&tmp, 0, sizeof(tmp));
+
if ((ret = get_qcx(s, n, &tmp)) < 0)
return ret;
for (compno = 0; compno < s->ncomponents; compno++)
@@ -595,12 +600,12 @@ static int get_sot(Jpeg2000DecoderContext *s, int n)
bytestream2_get_byteu(&s->g); // TNsot
if (Psot > bytestream2_get_bytes_left(&s->g) + n + 2) {
- av_log(s->avctx, AV_LOG_ERROR, "Psot %d too big\n", Psot);
+ av_log(s->avctx, AV_LOG_ERROR, "Psot %"PRIu32" too big\n", Psot);
return AVERROR_INVALIDDATA;
}
if (TPsot >= FF_ARRAY_ELEMS(s->tile[Isot].tile_part)) {
- avpriv_request_sample(s->avctx, "Support for %d components", TPsot);
+ avpriv_request_sample(s->avctx, "Support for %"PRIu8" components", TPsot);
return AVERROR_PATCHWELCOME;
}
@@ -777,7 +782,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
return ret;
if (ret > sizeof(cblk->data)) {
avpriv_request_sample(s->avctx,
- "Block with lengthinc greater than %zu",
+ "Block with lengthinc greater than %"SIZE_SPECIFIER"",
sizeof(cblk->data));
return AVERROR_PATCHWELCOME;
}
@@ -805,7 +810,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
|| sizeof(cblk->data) < cblk->length + cblk->lengthinc + 2
) {
av_log(s->avctx, AV_LOG_ERROR,
- "Block length %d or lengthinc %d is too large\n",
+ "Block length %"PRIu16" or lengthinc %d is too large\n",
cblk->length, cblk->lengthinc);
return AVERROR_INVALIDDATA;
}
@@ -1210,8 +1215,11 @@ static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
AVFrame *picture)
{
+ const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int compno, reslevelno, bandno;
int x, y;
+ int planar = !!(pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR);
+ int pixelsize = planar ? 1 : pixdesc->nb_components;
uint8_t *line;
Jpeg2000T1Context t1;
@@ -1285,8 +1293,6 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
int32_t *i_datap = comp->i_data;
int cbps = s->cbps[compno];
int w = tile->comp[compno].coord[0][1] - s->image_offset_x;
- int planar = !!picture->data[2];
- int pixelsize = planar ? 1 : s->ncomponents;
int plane = 0;
if (planar)
@@ -1332,8 +1338,6 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
uint16_t *linel;
int cbps = s->cbps[compno];
int w = tile->comp[compno].coord[0][1] - s->image_offset_x;
- int planar = !!picture->data[2];
- int pixelsize = planar ? 1 : s->ncomponents;
int plane = 0;
if (planar)
@@ -1481,14 +1485,15 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
- "unsupported marker 0x%.4X at pos 0x%X\n",
+ "unsupported marker 0x%.4"PRIX16" at pos 0x%X\n",
marker, bytestream2_tell(&s->g) - 4);
bytestream2_skip(&s->g, len - 2);
break;
}
if (bytestream2_tell(&s->g) - oldpos != len || ret) {
av_log(s->avctx, AV_LOG_ERROR,
- "error during processing marker segment %.4x\n", marker);
+ "error during processing marker segment %.4"PRIx16"\n",
+ marker);
return ret ? ret : -1;
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/jpeg2000dwt.c b/chromium/third_party/ffmpeg/libavcodec/jpeg2000dwt.c
index 266edece04f..ceceda36dc4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/jpeg2000dwt.c
+++ b/chromium/third_party/ffmpeg/libavcodec/jpeg2000dwt.c
@@ -518,17 +518,17 @@ int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2],
}
switch (type) {
case FF_DWT97:
- s->f_linebuf = av_malloc((maxlen + 12) * sizeof(*s->f_linebuf));
+ s->f_linebuf = av_malloc_array((maxlen + 12), sizeof(*s->f_linebuf));
if (!s->f_linebuf)
return AVERROR(ENOMEM);
break;
case FF_DWT97_INT:
- s->i_linebuf = av_malloc((maxlen + 12) * sizeof(*s->i_linebuf));
+ s->i_linebuf = av_malloc_array((maxlen + 12), sizeof(*s->i_linebuf));
if (!s->i_linebuf)
return AVERROR(ENOMEM);
break;
case FF_DWT53:
- s->i_linebuf = av_malloc((maxlen + 6) * sizeof(*s->i_linebuf));
+ s->i_linebuf = av_malloc_array((maxlen + 6), sizeof(*s->i_linebuf));
if (!s->i_linebuf)
return AVERROR(ENOMEM);
break;
diff --git a/chromium/third_party/ffmpeg/libavcodec/jpegls.h b/chromium/third_party/ffmpeg/libavcodec/jpegls.h
index 10ae054a7b3..c8997c78618 100644
--- a/chromium/third_party/ffmpeg/libavcodec/jpegls.h
+++ b/chromium/third_party/ffmpeg/libavcodec/jpegls.h
@@ -30,6 +30,7 @@
#include "libavutil/common.h"
#include "avcodec.h"
+#include "internal.h"
typedef struct JpeglsContext {
AVCodecContext *avctx;
@@ -43,8 +44,6 @@ typedef struct JLSState {
int run_index[4];
} JLSState;
-extern const uint8_t ff_log2_run[32];
-
/**
* Calculate initial JPEG-LS parameters
*/
diff --git a/chromium/third_party/ffmpeg/libavcodec/jpeglsdec.c b/chromium/third_party/ffmpeg/libavcodec/jpeglsdec.c
index 190b9b6d264..fb3762dad05 100644
--- a/chromium/third_party/ffmpeg/libavcodec/jpeglsdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/jpeglsdec.c
@@ -50,27 +50,79 @@
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
{
int id;
+ int tid, wt, maxtab, i, j;
- skip_bits(&s->gb, 16); /* length: FIXME: verify field validity */
+ int len = get_bits(&s->gb, 16);
id = get_bits(&s->gb, 8);
switch (id) {
case 1:
+ if (len < 13)
+ return AVERROR_INVALIDDATA;
+
s->maxval = get_bits(&s->gb, 16);
s->t1 = get_bits(&s->gb, 16);
s->t2 = get_bits(&s->gb, 16);
s->t3 = get_bits(&s->gb, 16);
s->reset = get_bits(&s->gb, 16);
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d T2:%d T3:%d reset:%d\n",
+ s->maxval, s->t1, s->t2, s->t3, s->reset);
+ }
+
// ff_jpegls_reset_coding_parameters(s, 0);
//FIXME quant table?
break;
case 2:
+ s->palette_index = 0;
case 3:
- av_log(s->avctx, AV_LOG_ERROR, "palette not supported\n");
- return AVERROR(ENOSYS);
+ tid= get_bits(&s->gb, 8);
+ wt = get_bits(&s->gb, 8);
+
+ if (len < 5)
+ return AVERROR_INVALIDDATA;
+
+ if (wt < 1 || wt > MAX_COMPONENTS) {
+ avpriv_request_sample(s->avctx, "wt %d", wt);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ if (!s->maxval)
+ maxtab = 255;
+ else if ((5 + wt*(s->maxval+1)) < 65535)
+ maxtab = s->maxval;
+ else
+ maxtab = 65530/wt - 1;
+
+ if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
+ av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab);
+ }
+ if (maxtab >= 256) {
+ avpriv_request_sample(s->avctx, ">8bit palette");
+ return AVERROR_PATCHWELCOME;
+ }
+ maxtab = FFMIN(maxtab, (len - 5) / wt + s->palette_index);
+
+ if (s->palette_index > maxtab)
+ return AVERROR_INVALIDDATA;
+
+ if ((s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) &&
+ (s->picture_ptr->format == AV_PIX_FMT_GRAY8 || s->picture_ptr->format == AV_PIX_FMT_PAL8)) {
+ uint32_t *pal = (uint32_t *)s->picture_ptr->data[1];
+ s->picture_ptr->format =
+ s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
+ for (i=s->palette_index; i<=maxtab; i++) {
+ pal[i] = 0;
+ for (j=0; j<wt; j++) {
+ pal[i] |= get_bits(&s->gb, 8) << (8*(wt-j-1));
+ }
+ }
+ s->palette_index = i;
+ }
+ break;
case 4:
- av_log(s->avctx, AV_LOG_ERROR, "oversize image not supported\n");
+ avpriv_request_sample(s->avctx, "oversize image");
return AVERROR(ENOSYS);
default:
av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
diff --git a/chromium/third_party/ffmpeg/libavcodec/jvdec.c b/chromium/third_party/ffmpeg/libavcodec/jvdec.c
index cad053289a0..03da880b7fc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/jvdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/jvdec.c
@@ -25,11 +25,12 @@
* @author Peter Ross <pross@xvid.org>
*/
+#include "libavutil/intreadwrite.h"
+
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
#include "internal.h"
-#include "libavutil/intreadwrite.h"
typedef struct JvContext {
DSPContext dsp;
@@ -62,19 +63,19 @@ static inline void decode2x2(GetBitContext *gb, uint8_t *dst, int linesize)
case 1:
v[0] = get_bits(gb, 8);
for (j = 0; j < 2; j++)
- memset(dst + j*linesize, v[0], 2);
+ memset(dst + j * linesize, v[0], 2);
break;
case 2:
v[0] = get_bits(gb, 8);
v[1] = get_bits(gb, 8);
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
- dst[j*linesize + i] = v[get_bits1(gb)];
+ dst[j * linesize + i] = v[get_bits1(gb)];
break;
case 3:
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
- dst[j*linesize + i] = get_bits(gb, 8);
+ dst[j * linesize + i] = get_bits(gb, 8);
}
}
@@ -89,29 +90,30 @@ static inline void decode4x4(GetBitContext *gb, uint8_t *dst, int linesize)
case 1:
v[0] = get_bits(gb, 8);
for (j = 0; j < 4; j++)
- memset(dst + j*linesize, v[0], 4);
+ memset(dst + j * linesize, v[0], 4);
break;
case 2:
v[0] = get_bits(gb, 8);
v[1] = get_bits(gb, 8);
for (j = 2; j >= 0; j -= 2) {
for (i = 0; i < 4; i++)
- dst[j*linesize + i] = v[get_bits1(gb)];
+ dst[j * linesize + i] = v[get_bits1(gb)];
for (i = 0; i < 4; i++)
- dst[(j+1)*linesize + i] = v[get_bits1(gb)];
+ dst[(j + 1) * linesize + i] = v[get_bits1(gb)];
}
break;
case 3:
for (j = 0; j < 4; j += 2)
for (i = 0; i < 4; i += 2)
- decode2x2(gb, dst + j*linesize + i, linesize);
+ decode2x2(gb, dst + j * linesize + i, linesize);
}
}
/**
* Decode 8x8 block
*/
-static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPContext *dsp)
+static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize,
+ DSPContext *dsp)
{
int i, j, v[2];
@@ -124,22 +126,21 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC
v[0] = get_bits(gb, 8);
v[1] = get_bits(gb, 8);
for (j = 7; j >= 0; j--)
- for (i = 0; i < 8; i++)
- dst[j*linesize + i] = v[get_bits1(gb)];
+ for (i = 0; i < 8; i++)
+ dst[j * linesize + i] = v[get_bits1(gb)];
break;
case 3:
for (j = 0; j < 8; j += 4)
for (i = 0; i < 8; i += 4)
- decode4x4(gb, dst + j*linesize + i, linesize);
+ decode4x4(gb, dst + j * linesize + i, linesize);
}
}
-static int decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
- JvContext *s = avctx->priv_data;
- const uint8_t *buf = avpkt->data;
+ JvContext *s = avctx->priv_data;
+ const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = buf + avpkt->size;
int video_size, video_type, i, j, ret;
@@ -164,16 +165,19 @@ static int decode_frame(AVCodecContext *avctx,
for (j = 0; j < avctx->height; j += 8)
for (i = 0; i < avctx->width; i += 8)
- decode8x8(&gb, s->frame->data[0] + j * s->frame->linesize[0] + i,
+ decode8x8(&gb,
+ s->frame->data[0] + j * s->frame->linesize[0] + i,
s->frame->linesize[0], &s->dsp);
buf += video_size;
} else if (video_type == 2) {
int v = *buf++;
for (j = 0; j < avctx->height; j++)
- memset(s->frame->data[0] + j * s->frame->linesize[0], v, avctx->width);
+ memset(s->frame->data[0] + j * s->frame->linesize[0],
+ v, avctx->width);
} else {
- av_log(avctx, AV_LOG_WARNING, "unsupported frame type %i\n", video_type);
+ av_log(avctx, AV_LOG_WARNING,
+ "unsupported frame type %i\n", video_type);
return AVERROR_INVALIDDATA;
}
}
@@ -191,7 +195,7 @@ static int decode_frame(AVCodecContext *avctx,
s->frame->key_frame = 1;
s->frame->pict_type = AV_PICTURE_TYPE_I;
s->frame->palette_has_changed = s->palette_has_changed;
- s->palette_has_changed = 0;
+ s->palette_has_changed = 0;
memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
if ((ret = av_frame_ref(data, s->frame)) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/kbdwin.c b/chromium/third_party/ffmpeg/libavcodec/kbdwin.c
index 5a62e9da2bd..bf32aeb3176 100644
--- a/chromium/third_party/ffmpeg/libavcodec/kbdwin.c
+++ b/chromium/third_party/ffmpeg/libavcodec/kbdwin.c
@@ -45,3 +45,13 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n)
for (i = 0; i < n; i++)
window[i] = sqrt(local_window[i] / sum);
}
+
+av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
+{
+ int i;
+ float local_window[FF_KBD_WINDOW_MAX];
+
+ ff_kbd_window_init(local_window, alpha, n);
+ for (i = 0; i < n; i++)
+ window[i] = (int)floor(2147483647.0 * local_window[i] + 0.5);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/kbdwin.h b/chromium/third_party/ffmpeg/libavcodec/kbdwin.h
index 4b939756c10..4185c4206f8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/kbdwin.h
+++ b/chromium/third_party/ffmpeg/libavcodec/kbdwin.h
@@ -19,6 +19,8 @@
#ifndef AVCODEC_KBDWIN_H
#define AVCODEC_KBDWIN_H
+#include <stdint.h>
+
/**
* Maximum window size for ff_kbd_window_init.
*/
@@ -31,5 +33,6 @@
* @param n size of half window, max FF_KBD_WINDOW_MAX
*/
void ff_kbd_window_init(float *window, float alpha, int n);
+void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n);
#endif /* AVCODEC_KBDWIN_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/kgv1dec.c b/chromium/third_party/ffmpeg/libavcodec/kgv1dec.c
index 5528c6f3612..b81ba75325b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/kgv1dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/kgv1dec.c
@@ -31,14 +31,16 @@
#include "internal.h"
typedef struct {
- AVFrame *prev;
+ uint16_t *frame_buffer;
+ uint16_t *last_frame_buffer;
} KgvContext;
static void decode_flush(AVCodecContext *avctx)
{
KgvContext * const c = avctx->priv_data;
- av_frame_free(&c->prev);
+ av_freep(&c->frame_buffer);
+ av_freep(&c->last_frame_buffer);
}
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
@@ -61,21 +63,27 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
buf += 2;
if (w != avctx->width || h != avctx->height) {
- av_frame_unref(c->prev);
+ av_freep(&c->frame_buffer);
+ av_freep(&c->last_frame_buffer);
if ((res = ff_set_dimensions(avctx, w, h)) < 0)
return res;
}
+ if (!c->frame_buffer) {
+ c->frame_buffer = av_mallocz(avctx->width * avctx->height * 2);
+ c->last_frame_buffer = av_mallocz(avctx->width * avctx->height * 2);
+ if (!c->frame_buffer || !c->last_frame_buffer) {
+ decode_flush(avctx);
+ return AVERROR(ENOMEM);
+ }
+ }
+
maxcnt = w * h;
- if ((res = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
+ if ((res = ff_get_buffer(avctx, frame, 0)) < 0)
return res;
- out = frame->data[0];
- if (c->prev->data[0]) {
- prev = c->prev->data[0];
- } else {
- prev = NULL;
- }
+ out = (uint8_t*)c->frame_buffer;
+ prev = (uint8_t*)c->last_frame_buffer;
for (i = 0; i < 8; i++)
offsets[i] = -1;
@@ -142,9 +150,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (outcnt - maxcnt)
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
- av_frame_unref(c->prev);
- if ((res = av_frame_ref(c->prev, frame)) < 0)
- return res;
+ av_image_copy_plane(frame->data[0], frame->linesize[0],
+ (const uint8_t*)c->frame_buffer, avctx->width * 2,
+ avctx->width * 2, avctx->height);
+ FFSWAP(uint16_t *, c->frame_buffer, c->last_frame_buffer);
*got_frame = 1;
@@ -153,22 +162,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
static av_cold int decode_init(AVCodecContext *avctx)
{
- KgvContext * const c = avctx->priv_data;
-
- c->prev = av_frame_alloc();
- if (!c->prev)
- return AVERROR(ENOMEM);
-
avctx->pix_fmt = AV_PIX_FMT_RGB555;
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
- KgvContext * const c = avctx->priv_data;
- av_frame_free(&c->prev);
+ decode_flush(avctx);
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/lagarith.c b/chromium/third_party/ffmpeg/libavcodec/lagarith.c
index 0a4d23e7a21..6571baf2e70 100644
--- a/chromium/third_party/ffmpeg/libavcodec/lagarith.c
+++ b/chromium/third_party/ffmpeg/libavcodec/lagarith.c
@@ -25,6 +25,8 @@
* @author Nathan Caldwell
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "get_bits.h"
#include "mathops.h"
@@ -52,6 +54,7 @@ typedef struct LagarithContext {
int zeros; /**< number of consecutive zero bytes encountered */
int zeros_rem; /**< number of zero bytes remaining to output */
uint8_t *rgb_planes;
+ int rgb_planes_allocated;
int rgb_stride;
} LagarithContext;
@@ -302,16 +305,16 @@ static void lag_pred_line_yuy2(LagarithContext *l, uint8_t *buf,
L += buf[i];
buf[i] = L;
}
- for (; i<width; i++) {
- L = mid_pred(L&0xFF, buf[i-stride], (L + buf[i-stride] - TL)&0xFF) + buf[i];
- TL = buf[i-stride];
- buf[i]= L;
+ for (; i < width; i++) {
+ L = mid_pred(L & 0xFF, buf[i - stride], (L + buf[i - stride] - TL) & 0xFF) + buf[i];
+ TL = buf[i - stride];
+ buf[i] = L;
}
} else {
TL = buf[width - (2 * stride) - 1];
L = buf[width - stride - 1];
l->dsp.add_hfyu_median_prediction(buf, buf - stride, buf, width,
- &L, &TL);
+ &L, &TL);
}
}
@@ -369,6 +372,10 @@ static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
uint8_t mask2 = -(esc_count < 3);
uint8_t *end = dst + (width - 2);
+ avpriv_request_sample(l->avctx, "zero_run_line");
+
+ memset(dst, 0, width);
+
output_zeros:
if (l->zeros_rem) {
count = FFMIN(l->zeros_rem, width - i);
@@ -423,6 +430,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
GetBitContext gb;
lag_rac rac;
const uint8_t *src_end = src + src_size;
+ int ret;
rac.avctx = l->avctx;
l->zeros = 0;
@@ -440,7 +448,8 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
offset += 4;
}
- init_get_bits(&gb, src + offset, src_size * 8);
+ if ((ret = init_get_bits8(&gb, src + offset, src_size - offset)) < 0)
+ return ret;
if (lag_read_prob_header(&rac, &gb) < 0)
return -1;
@@ -453,10 +462,12 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
if (read > length)
av_log(l->avctx, AV_LOG_WARNING,
- "Output more bytes than length (%d of %d)\n", read,
+ "Output more bytes than length (%d of %"PRIu32")\n", read,
length);
} else if (esc_count < 8) {
esc_count -= 4;
+ src ++;
+ src_size --;
if (esc_count > 0) {
/* Zero run coding only, no range coding. */
for (i = 0; i < height; i++) {
@@ -603,13 +614,12 @@ static int lag_decode_frame(AVCodecContext *avctx,
offs[1] = offset_gu;
offs[2] = offset_ry;
+ l->rgb_stride = FFALIGN(avctx->width, 16);
+ av_fast_malloc(&l->rgb_planes, &l->rgb_planes_allocated,
+ l->rgb_stride * avctx->height * planes + 1);
if (!l->rgb_planes) {
- l->rgb_stride = FFALIGN(avctx->width, 16);
- l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * 4 + 16);
- if (!l->rgb_planes) {
- av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
- return AVERROR(ENOMEM);
- }
+ av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
+ return AVERROR(ENOMEM);
}
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
@@ -703,7 +713,7 @@ static int lag_decode_frame(AVCodecContext *avctx,
break;
default:
av_log(avctx, AV_LOG_ERROR,
- "Unsupported Lagarith frame type: %#x\n", frametype);
+ "Unsupported Lagarith frame type: %#"PRIx8"\n", frametype);
return AVERROR_PATCHWELCOME;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/libfdk-aacdec.c b/chromium/third_party/ffmpeg/libavcodec/libfdk-aacdec.c
index c833a98a82a..de1089dd8d6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libfdk-aacdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libfdk-aacdec.c
@@ -4,19 +4,29 @@
*
* This file is part of FFmpeg.
*
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fdk-aac/aacdecoder_lib.h>
diff --git a/chromium/third_party/ffmpeg/libavcodec/libfdk-aacenc.c b/chromium/third_party/ffmpeg/libavcodec/libfdk-aacenc.c
index 755b76f958c..7a85dfff54a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libfdk-aacenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libfdk-aacenc.c
@@ -4,19 +4,29 @@
*
* This file is part of FFmpeg.
*
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fdk-aac/aacenc_lib.h>
@@ -151,6 +161,20 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
case 4: mode = MODE_1_2_1; sce = 2; cpe = 1; break;
case 5: mode = MODE_1_2_2; sce = 1; cpe = 2; break;
case 6: mode = MODE_1_2_2_1; sce = 2; cpe = 2; break;
+/* The version macro is introduced the same time as the 7.1 support, so this
+ should suffice. */
+#ifdef AACENCODER_LIB_VL0
+ case 8:
+ sce = 2;
+ cpe = 3;
+ if (avctx->channel_layout == AV_CH_LAYOUT_7POINT1) {
+ mode = MODE_7_1_REAR_SURROUND;
+ } else {
+ // MODE_1_2_2_2_1 and MODE_7_1_FRONT_CENTER use the same channel layout
+ mode = MODE_7_1_FRONT_CENTER;
+ }
+ break;
+#endif
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported number of channels %d\n", avctx->channels);
@@ -384,6 +408,10 @@ static const uint64_t aac_channel_layout[] = {
AV_CH_LAYOUT_4POINT0,
AV_CH_LAYOUT_5POINT0_BACK,
AV_CH_LAYOUT_5POINT1_BACK,
+#ifdef AACENCODER_LIB_VL0
+ AV_CH_LAYOUT_7POINT1_WIDE_BACK,
+ AV_CH_LAYOUT_7POINT1,
+#endif
0,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libopencore-amr.c b/chromium/third_party/ffmpeg/libavcodec/libopencore-amr.c
index 75c467ff59f..4c7b6afc7ce 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libopencore-amr.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libopencore-amr.c
@@ -205,7 +205,6 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
s->enc_state = Encoder_Interface_init(s->enc_dtx);
if (!s->enc_state) {
av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
- av_freep(&avctx->coded_frame);
return -1;
}
@@ -242,7 +241,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (frame) {
if (frame->nb_samples < avctx->frame_size) {
- flush_buf = av_mallocz(avctx->frame_size * sizeof(*flush_buf));
+ flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
memcpy(flush_buf, samples, frame->nb_samples * sizeof(*flush_buf));
@@ -257,7 +256,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
} else {
if (s->enc_last_frame < 0)
return 0;
- flush_buf = av_mallocz(avctx->frame_size * sizeof(*flush_buf));
+ flush_buf = av_mallocz_array(avctx->frame_size, sizeof(*flush_buf));
if (!flush_buf)
return AVERROR(ENOMEM);
samples = flush_buf;
diff --git a/chromium/third_party/ffmpeg/libavcodec/libopenjpegdec.c b/chromium/third_party/ffmpeg/libavcodec/libopenjpegdec.c
index 0543e3a8978..178e4488c41 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libopenjpegdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libopenjpegdec.c
@@ -27,10 +27,11 @@
#define OPJ_STATIC
#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
-#include "libavutil/pixfmt.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
+#include "libavutil/pixfmt.h"
+
#include "avcodec.h"
#include "internal.h"
#include "thread.h"
@@ -46,29 +47,38 @@
// pix_fmts with lower bpp have to be listed before
// similar pix_fmts with higher bpp.
-#define RGB_PIXEL_FORMATS AV_PIX_FMT_RGB24,AV_PIX_FMT_RGBA,AV_PIX_FMT_RGB48,AV_PIX_FMT_RGBA64
-#define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8,AV_PIX_FMT_GRAY8A,AV_PIX_FMT_GRAY16
-#define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P,AV_PIX_FMT_YUV411P,AV_PIX_FMT_YUVA420P, \
- AV_PIX_FMT_YUV420P,AV_PIX_FMT_YUV422P,AV_PIX_FMT_YUVA422P, \
- AV_PIX_FMT_YUV440P,AV_PIX_FMT_YUV444P,AV_PIX_FMT_YUVA444P, \
- AV_PIX_FMT_YUV420P9,AV_PIX_FMT_YUV422P9,AV_PIX_FMT_YUV444P9, \
- AV_PIX_FMT_YUVA420P9,AV_PIX_FMT_YUVA422P9,AV_PIX_FMT_YUVA444P9, \
- AV_PIX_FMT_YUV420P10,AV_PIX_FMT_YUV422P10,AV_PIX_FMT_YUV444P10, \
- AV_PIX_FMT_YUVA420P10,AV_PIX_FMT_YUVA422P10,AV_PIX_FMT_YUVA444P10, \
- AV_PIX_FMT_YUV420P12,AV_PIX_FMT_YUV422P12,AV_PIX_FMT_YUV444P12, \
- AV_PIX_FMT_YUV420P14,AV_PIX_FMT_YUV422P14,AV_PIX_FMT_YUV444P14, \
- AV_PIX_FMT_YUV420P16,AV_PIX_FMT_YUV422P16,AV_PIX_FMT_YUV444P16, \
- AV_PIX_FMT_YUVA420P16,AV_PIX_FMT_YUVA422P16,AV_PIX_FMT_YUVA444P16
+#define RGB_PIXEL_FORMATS AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, \
+ AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64
+
+#define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, \
+ AV_PIX_FMT_GRAY16
+
+#define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUVA420P, \
+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
+ AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
+ AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, \
+ AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, \
+ AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, \
+ AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, \
+ AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, \
+ AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, \
+ AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, \
+ AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16
#define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
-static const enum AVPixelFormat libopenjpeg_rgb_pix_fmts[] = {RGB_PIXEL_FORMATS};
-static const enum AVPixelFormat libopenjpeg_gray_pix_fmts[] = {GRAY_PIXEL_FORMATS};
-static const enum AVPixelFormat libopenjpeg_yuv_pix_fmts[] = {YUV_PIXEL_FORMATS};
-static const enum AVPixelFormat libopenjpeg_all_pix_fmts[] = {RGB_PIXEL_FORMATS,
- GRAY_PIXEL_FORMATS,
- YUV_PIXEL_FORMATS,
- XYZ_PIXEL_FORMATS};
+static const enum AVPixelFormat libopenjpeg_rgb_pix_fmts[] = {
+ RGB_PIXEL_FORMATS
+};
+static const enum AVPixelFormat libopenjpeg_gray_pix_fmts[] = {
+ GRAY_PIXEL_FORMATS
+};
+static const enum AVPixelFormat libopenjpeg_yuv_pix_fmts[] = {
+ YUV_PIXEL_FORMATS
+};
+static const enum AVPixelFormat libopenjpeg_all_pix_fmts[] = {
+ RGB_PIXEL_FORMATS, GRAY_PIXEL_FORMATS, YUV_PIXEL_FORMATS, XYZ_PIXEL_FORMATS
+};
typedef struct {
AVClass *class;
@@ -86,18 +96,26 @@ static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVP
}
switch (desc->nb_components) {
- case 4: match = match && desc->comp[3].depth_minus1 + 1 >= image->comps[3].prec &&
- 1 == image->comps[3].dx &&
- 1 == image->comps[3].dy;
- case 3: match = match && desc->comp[2].depth_minus1 + 1 >= image->comps[2].prec &&
- 1 << desc->log2_chroma_w == image->comps[2].dx &&
- 1 << desc->log2_chroma_h == image->comps[2].dy;
- case 2: match = match && desc->comp[1].depth_minus1 + 1 >= image->comps[1].prec &&
- 1 << desc->log2_chroma_w == image->comps[1].dx &&
- 1 << desc->log2_chroma_h == image->comps[1].dy;
- case 1: match = match && desc->comp[0].depth_minus1 + 1 >= image->comps[0].prec &&
- 1 == image->comps[0].dx &&
- 1 == image->comps[0].dy;
+ case 4:
+ match = match &&
+ desc->comp[3].depth_minus1 + 1 >= image->comps[3].prec &&
+ 1 == image->comps[3].dx &&
+ 1 == image->comps[3].dy;
+ case 3:
+ match = match &&
+ desc->comp[2].depth_minus1 + 1 >= image->comps[2].prec &&
+ 1 << desc->log2_chroma_w == image->comps[2].dx &&
+ 1 << desc->log2_chroma_h == image->comps[2].dy;
+ case 2:
+ match = match &&
+ desc->comp[1].depth_minus1 + 1 >= image->comps[1].prec &&
+ 1 << desc->log2_chroma_w == image->comps[1].dx &&
+ 1 << desc->log2_chroma_h == image->comps[1].dy;
+ case 1:
+ match = match &&
+ desc->comp[0].depth_minus1 + 1 >= image->comps[0].prec &&
+ 1 == image->comps[0].dx &&
+ 1 == image->comps[0].dy;
default:
break;
}
@@ -112,28 +130,27 @@ static inline enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *im
switch (image->color_space) {
case CLRSPC_SRGB:
- possible_fmts = libopenjpeg_rgb_pix_fmts;
+ possible_fmts = libopenjpeg_rgb_pix_fmts;
possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_rgb_pix_fmts);
break;
case CLRSPC_GRAY:
- possible_fmts = libopenjpeg_gray_pix_fmts;
+ possible_fmts = libopenjpeg_gray_pix_fmts;
possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_gray_pix_fmts);
break;
case CLRSPC_SYCC:
- possible_fmts = libopenjpeg_yuv_pix_fmts;
+ possible_fmts = libopenjpeg_yuv_pix_fmts;
possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_yuv_pix_fmts);
break;
default:
- possible_fmts = libopenjpeg_all_pix_fmts;
+ possible_fmts = libopenjpeg_all_pix_fmts;
possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_all_pix_fmts);
break;
}
- for (index = 0; index < possible_fmts_nb; ++index) {
+ for (index = 0; index < possible_fmts_nb; ++index)
if (libopenjpeg_matches_pix_fmt(image, possible_fmts[index])) {
return possible_fmts[index];
}
- }
return AV_PIX_FMT_NONE;
}
@@ -147,10 +164,9 @@ static inline int libopenjpeg_ispacked(enum AVPixelFormat pix_fmt)
return 0;
component_plane = desc->comp[0].plane;
- for (i = 1; i < desc->nb_components; i++) {
+ for (i = 1; i < desc->nb_components; i++)
if (component_plane != desc->comp[i].plane)
return 0;
- }
return 1;
}
@@ -158,13 +174,11 @@ static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *im
uint8_t *img_ptr;
int index, x, y, c;
for (y = 0; y < picture->height; y++) {
- index = y*picture->width;
- img_ptr = picture->data[0] + y*picture->linesize[0];
- for (x = 0; x < picture->width; x++, index++) {
- for (c = 0; c < image->numcomps; c++) {
- *img_ptr++ = image->comps[c].data[index];
- }
- }
+ index = y * picture->width;
+ img_ptr = picture->data[0] + y * picture->linesize[0];
+ for (x = 0; x < picture->width; x++, index++)
+ for (c = 0; c < image->numcomps; c++)
+ *img_ptr++ = 0x80 * image->comps[c].sgnd + image->comps[c].data[index];
}
}
@@ -173,16 +187,15 @@ static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *i
int index, x, y, c;
int adjust[4];
for (x = 0; x < image->numcomps; x++)
- adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0);
+ adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);
for (y = 0; y < picture->height; y++) {
- index = y*picture->width;
- img_ptr = (uint16_t*) (picture->data[0] + y*picture->linesize[0]);
- for (x = 0; x < picture->width; x++, index++) {
- for (c = 0; c < image->numcomps; c++) {
- *img_ptr++ = image->comps[c].data[index] << adjust[c];
- }
- }
+ index = y * picture->width;
+ img_ptr = (uint16_t *) (picture->data[0] + y * picture->linesize[0]);
+ for (x = 0; x < picture->width; x++, index++)
+ for (c = 0; c < image->numcomps; c++)
+ *img_ptr++ = (1 << image->comps[c].prec - 1) * image->comps[c].sgnd +
+ (unsigned)image->comps[c].data[index] << adjust[c];
}
}
@@ -196,7 +209,7 @@ static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
for (y = 0; y < image->comps[index].h; y++) {
img_ptr = picture->data[index] + y * picture->linesize[index];
for (x = 0; x < image->comps[index].w; x++) {
- *img_ptr = (uint8_t) *comp_data;
+ *img_ptr = 0x80 * image->comps[index].sgnd + *comp_data;
img_ptr++;
comp_data++;
}
@@ -210,14 +223,15 @@ static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
int index, x, y;
int adjust[4];
for (x = 0; x < image->numcomps; x++)
- adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0);
+ adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);
for (index = 0; index < image->numcomps; index++) {
comp_data = image->comps[index].data;
for (y = 0; y < image->comps[index].h; y++) {
- img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
+ img_ptr = (uint16_t *)(picture->data[index] + y * picture->linesize[index]);
for (x = 0; x < image->comps[index].w; x++) {
- *img_ptr = *comp_data << adjust[index];
+ *img_ptr = (1 << image->comps[index].prec - 1) * image->comps[index].sgnd +
+ (unsigned)*comp_data << adjust[index];
img_ptr++;
comp_data++;
}
@@ -237,24 +251,24 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
- uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
LibOpenJPEGContext *ctx = avctx->priv_data;
- ThreadFrame frame = { .f = data };
- AVFrame *picture = data;
+ ThreadFrame frame = { .f = data };
+ AVFrame *picture = data;
const AVPixFmtDescriptor *desc;
opj_dinfo_t *dec;
opj_cio_t *stream;
opj_image_t *image;
int width, height, ret;
int pixel_size = 0;
- int ispacked = 0;
+ int ispacked = 0;
int i;
*got_frame = 0;
// Check if input is a raw jpeg2k codestream or in jp2 wrapping
- if ((AV_RB32(buf) == 12) &&
+ if ((AV_RB32(buf) == 12) &&
(AV_RB32(buf + 4) == JP2_SIG_TYPE) &&
(AV_RB32(buf + 8) == JP2_SIG_VALUE)) {
dec = opj_create_decompress(CODEC_JP2);
@@ -270,12 +284,12 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n");
return AVERROR_UNKNOWN;
}
- opj_set_event_mgr((opj_common_ptr)dec, NULL, NULL);
+ opj_set_event_mgr((opj_common_ptr) dec, NULL, NULL);
ctx->dec_params.cp_limit_decoding = LIMIT_TO_MAIN_HEADER;
ctx->dec_params.cp_layer = ctx->lowqual;
// Tie decoder with decoding parameters
opj_setup_decoder(dec, &ctx->dec_params);
- stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
+ stream = opj_cio_open((opj_common_ptr) dec, buf, buf_size);
if (!stream) {
av_log(avctx, AV_LOG_ERROR,
@@ -323,7 +337,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
ctx->dec_params.cp_reduce = avctx->lowres;
// Tie decoder with decoding parameters.
opj_setup_decoder(dec, &ctx->dec_params);
- stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
+ stream = opj_cio_open((opj_common_ptr) dec, buf, buf_size);
if (!stream) {
av_log(avctx, AV_LOG_ERROR,
"Codestream could not be opened for reading.\n");
@@ -342,9 +356,9 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
goto done;
}
- desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ desc = av_pix_fmt_desc_get(avctx->pix_fmt);
pixel_size = desc->comp[0].step_minus1 + 1;
- ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
+ ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
switch (pixel_size) {
case 1:
@@ -392,7 +406,8 @@ done:
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
- { "lowqual", "Limit the number of layers used for decoding", OFFSET(lowqual), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
+ { "lowqual", "Limit the number of layers used for decoding",
+ OFFSET(lowqual), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
{ NULL },
};
@@ -404,14 +419,14 @@ static const AVClass openjpeg_class = {
};
AVCodec ff_libopenjpeg_decoder = {
- .name = "libopenjpeg",
- .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_JPEG2000,
- .priv_data_size = sizeof(LibOpenJPEGContext),
- .init = libopenjpeg_decode_init,
- .decode = libopenjpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
- .max_lowres = 31,
- .priv_class = &openjpeg_class,
+ .name = "libopenjpeg",
+ .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_JPEG2000,
+ .priv_data_size = sizeof(LibOpenJPEGContext),
+ .init = libopenjpeg_decode_init,
+ .decode = libopenjpeg_decode_frame,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
+ .max_lowres = 31,
+ .priv_class = &openjpeg_class,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libopenjpegenc.c b/chromium/third_party/ffmpeg/libavcodec/libopenjpegenc.c
index 14579b68f31..ac77c7d1963 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libopenjpegenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libopenjpegenc.c
@@ -235,7 +235,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
}
opj_setup_encoder(ctx->compress, &ctx->enc_params, ctx->image);
- ctx->stream = opj_cio_open((opj_common_ptr)ctx->compress, NULL, 0);
+ ctx->stream = opj_cio_open((opj_common_ptr) ctx->compress, NULL, 0);
if (!ctx->stream) {
av_log(avctx, AV_LOG_ERROR, "Error creating the cio stream\n");
err = AVERROR(ENOMEM);
@@ -252,7 +252,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
ctx->event_mgr.info_handler = info_callback;
ctx->event_mgr.error_handler = error_callback;
ctx->event_mgr.warning_handler = warning_callback;
- opj_set_event_mgr((opj_common_ptr)ctx->compress, &ctx->event_mgr, avctx);
+ opj_set_event_mgr((opj_common_ptr) ctx->compress, &ctx->event_mgr, avctx);
return 0;
@@ -310,12 +310,11 @@ static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame,
static int libopenjpeg_copy_packed12(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
{
int compno;
- int x;
- int y;
+ int x, y;
int *image_line;
int frame_index;
- const int numcomps = image->numcomps;
- uint16_t *frame_ptr = (uint16_t*)frame->data[0];
+ const int numcomps = image->numcomps;
+ uint16_t *frame_ptr = (uint16_t *)frame->data[0];
for (compno = 0; compno < numcomps; ++compno) {
if (image->comps[compno].w > frame->linesize[0] / numcomps) {
@@ -406,7 +405,7 @@ static int libopenjpeg_copy_unpacked8(AVCodecContext *avctx, const AVFrame *fram
}
for (compno = 0; compno < numcomps; ++compno) {
- width = avctx->width / image->comps[compno].dx;
+ width = avctx->width / image->comps[compno].dx;
height = avctx->height / image->comps[compno].dy;
for (y = 0; y < height; ++y) {
image_line = image->comps[compno].data + y * image->comps[compno].w;
@@ -448,9 +447,9 @@ static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *fra
}
for (compno = 0; compno < numcomps; ++compno) {
- width = avctx->width / image->comps[compno].dx;
- height = avctx->height / image->comps[compno].dy;
- frame_ptr = (uint16_t*)frame->data[compno];
+ width = avctx->width / image->comps[compno].dx;
+ height = avctx->height / image->comps[compno].dy;
+ frame_ptr = (uint16_t *)frame->data[compno];
for (y = 0; y < height; ++y) {
image_line = image->comps[compno].data + y * image->comps[compno].w;
frame_index = y * (frame->linesize[compno] / 2);
@@ -475,12 +474,12 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
LibOpenJPEGContext *ctx = avctx->priv_data;
- opj_cinfo_t *compress = ctx->compress;
- opj_image_t *image = ctx->image;
- opj_cio_t *stream = ctx->stream;
+ opj_cinfo_t *compress = ctx->compress;
+ opj_image_t *image = ctx->image;
+ opj_cio_t *stream = ctx->stream;
int cpyresult = 0;
int ret, len;
- AVFrame gbrframe;
+ AVFrame *gbrframe;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
@@ -501,18 +500,21 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case AV_PIX_FMT_GBRP12:
case AV_PIX_FMT_GBRP14:
case AV_PIX_FMT_GBRP16:
- gbrframe = *frame;
- gbrframe.data[0] = frame->data[2]; // swap to be rgb
- gbrframe.data[1] = frame->data[0];
- gbrframe.data[2] = frame->data[1];
- gbrframe.linesize[0] = frame->linesize[2];
- gbrframe.linesize[1] = frame->linesize[0];
- gbrframe.linesize[2] = frame->linesize[1];
+ gbrframe = av_frame_clone(frame);
+ if (!gbrframe)
+ return AVERROR(ENOMEM);
+ gbrframe->data[0] = frame->data[2]; // swap to be rgb
+ gbrframe->data[1] = frame->data[0];
+ gbrframe->data[2] = frame->data[1];
+ gbrframe->linesize[0] = frame->linesize[2];
+ gbrframe->linesize[1] = frame->linesize[0];
+ gbrframe->linesize[2] = frame->linesize[1];
if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) {
- cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image);
+ cpyresult = libopenjpeg_copy_unpacked8(avctx, gbrframe, image);
} else {
- cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image);
+ cpyresult = libopenjpeg_copy_unpacked16(avctx, gbrframe, image);
}
+ av_frame_free(&gbrframe);
break;
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YUV410P:
@@ -645,8 +647,8 @@ AVCodec ff_libopenjpeg_encoder = {
.close = libopenjpeg_encode_close,
.capabilities = 0,
.pix_fmts = (const enum AVPixelFormat[]) {
- AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,
- AV_PIX_FMT_GBR24P,
+ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48,
+ AV_PIX_FMT_RGBA64, AV_PIX_FMT_GBR24P,
AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, AV_PIX_FMT_GRAY16,
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P,
diff --git a/chromium/third_party/ffmpeg/libavcodec/libopusdec.c b/chromium/third_party/ffmpeg/libavcodec/libopusdec.c
index 2409de23a0f..8436302a9bd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libopusdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libopusdec.c
@@ -108,8 +108,8 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
}
#endif
- avc->internal->skip_samples = opus->pre_skip;
- avc->delay = 3840; /* Decoder delay (in samples) at 48kHz */
+ /* Decoder delay (in samples) at 48kHz */
+ avc->delay = avc->internal->skip_samples = opus->pre_skip;
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/libspeexdec.c b/chromium/third_party/ffmpeg/libavcodec/libspeexdec.c
index afe11761985..53e06d9b9e0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libspeexdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libspeexdec.c
@@ -43,7 +43,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
SpeexHeader *header = NULL;
int spx_mode;
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_NONE;
if (avctx->extradata && avctx->extradata_size >= 80) {
header = speex_packet_to_header(avctx->extradata,
avctx->extradata_size);
@@ -125,6 +125,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
AVFrame *frame = data;
int16_t *output;
int ret, consumed = 0;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
/* get output buffer */
frame->nb_samples = s->frame_size;
@@ -159,6 +160,8 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data,
*got_frame_ptr = 1;
+ if (!avctx->bit_rate)
+ speex_decoder_ctl(s->dec_state, SPEEX_GET_BITRATE, &avctx->bit_rate);
return consumed;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/libstagefright.cpp b/chromium/third_party/ffmpeg/libavcodec/libstagefright.cpp
index bb49d8a6258..346cc9ce607 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libstagefright.cpp
+++ b/chromium/third_party/ffmpeg/libavcodec/libstagefright.cpp
@@ -179,7 +179,7 @@ void* decode_thread(void *arg)
sp<MetaData> outFormat = (*s->decoder)->getFormat();
outFormat->findInt32(kKeyWidth , &w);
outFormat->findInt32(kKeyHeight, &h);
- frame->vframe = (AVFrame*)av_mallocz(sizeof(AVFrame));
+ frame->vframe = av_frame_alloc();
if (!frame->vframe) {
frame->status = AVERROR(ENOMEM);
decode_done = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/libtwolame.c b/chromium/third_party/ffmpeg/libavcodec/libtwolame.c
index dc4efe58bab..542abbc32a6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libtwolame.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libtwolame.c
@@ -26,22 +26,25 @@
#include <twolame.h>
+#include "libavutil/common.h"
#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "internal.h"
#include "mpegaudio.h"
typedef struct TWOLAMEContext {
- AVClass *class;
- int mode;
- int psymodel;
- int energy;
- int error_protection;
- int copyright;
- int original;
+ AVClass *class;
+ int mode;
+ int psymodel;
+ int energy;
+ int error_protection;
+ int copyright;
+ int original;
+ int verbosity;
twolame_options *glopts;
- int64_t next_pts;
+ int64_t next_pts;
} TWOLAMEContext;
static av_cold int twolame_encode_close(AVCodecContext *avctx)
@@ -57,12 +60,13 @@ static av_cold int twolame_encode_init(AVCodecContext *avctx)
int ret;
avctx->frame_size = TWOLAME_SAMPLES_PER_FRAME;
+ avctx->delay = 512 - 32 + 1;
s->glopts = twolame_init();
if (!s->glopts)
return AVERROR(ENOMEM);
- twolame_set_verbosity(s->glopts, 0);
+ twolame_set_verbosity(s->glopts, s->verbosity);
twolame_set_mode(s->glopts, s->mode);
twolame_set_psymodel(s->glopts, s->psymodel);
twolame_set_energy_levels(s->glopts, s->energy);
@@ -75,19 +79,21 @@ static av_cold int twolame_encode_init(AVCodecContext *avctx)
twolame_set_out_samplerate(s->glopts, avctx->sample_rate);
if (avctx->flags & CODEC_FLAG_QSCALE || !avctx->bit_rate) {
twolame_set_VBR(s->glopts, TRUE);
- twolame_set_VBR_level(s->glopts, avctx->global_quality);
- av_log(avctx, AV_LOG_WARNING, "VBR mode is experimental!\n");
+ twolame_set_VBR_level(s->glopts,
+ avctx->global_quality / (float) FF_QP2LAMBDA);
+ av_log(avctx, AV_LOG_WARNING,
+ "VBR in MP2 is a hack, use another codec that supports it.\n");
} else {
twolame_set_bitrate(s->glopts, avctx->bit_rate / 1000);
}
- if ((ret = twolame_init_params(s->glopts)))
- goto error;
+ ret = twolame_init_params(s->glopts);
+ if (ret) {
+ twolame_encode_close(avctx);
+ return AVERROR_UNKNOWN;
+ }
return 0;
-error:
- twolame_encode_close(avctx);
- return ret;
}
static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
@@ -103,96 +109,117 @@ static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
switch (avctx->sample_fmt) {
case AV_SAMPLE_FMT_FLT:
ret = twolame_encode_buffer_float32_interleaved(s->glopts,
- frame->data[0],
- frame->nb_samples,
- avpkt->data, avpkt->size);
+ (const float *)frame->data[0],
+ frame->nb_samples,
+ avpkt->data,
+ avpkt->size);
break;
case AV_SAMPLE_FMT_FLTP:
ret = twolame_encode_buffer_float32(s->glopts,
- frame->data[0], frame->data[1],
- frame->nb_samples,
- avpkt->data, avpkt->size);
+ (const float *)frame->data[0],
+ (const float *)frame->data[1],
+ frame->nb_samples,
+ avpkt->data, avpkt->size);
break;
case AV_SAMPLE_FMT_S16:
ret = twolame_encode_buffer_interleaved(s->glopts,
- frame->data[0],
- frame->nb_samples,
- avpkt->data, avpkt->size);
+ (const short int *)frame->data[0],
+ frame->nb_samples,
+ avpkt->data, avpkt->size);
break;
case AV_SAMPLE_FMT_S16P:
ret = twolame_encode_buffer(s->glopts,
- frame->data[0], frame->data[1],
+ (const short int *)frame->data[0],
+ (const short int *)frame->data[1],
frame->nb_samples,
avpkt->data, avpkt->size);
break;
default:
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported sample format %d.\n", avctx->sample_fmt);
return AVERROR_BUG;
}
} else {
ret = twolame_encode_flush(s->glopts, avpkt->data, avpkt->size);
}
- if (ret > 0) {
- avpkt->duration = ff_samples_to_time_base(avctx, avctx->frame_size);
- if (frame) {
- if (frame->pts != AV_NOPTS_VALUE)
- avpkt->pts = frame->pts;
- } else {
- avpkt->pts = s->next_pts;
- }
- if (avpkt->pts != AV_NOPTS_VALUE)
- s->next_pts = avpkt->pts + avpkt->duration;
-
- avpkt->size = ret;
- *got_packet_ptr = 1;
+ if (!ret) // no bytes written
return 0;
+ if (ret < 0) // twolame error
+ return AVERROR_UNKNOWN;
+
+ avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
+ if (frame) {
+ if (frame->pts != AV_NOPTS_VALUE)
+ avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);
+ } else {
+ avpkt->pts = s->next_pts;
}
+ // this is for setting pts for flushed packet(s).
+ if (avpkt->pts != AV_NOPTS_VALUE)
+ s->next_pts = avpkt->pts + avpkt->duration;
- return ret;
+ av_shrink_packet(avpkt, ret);
+ *got_packet_ptr = 1;
+ return 0;
}
#define OFFSET(x) offsetof(TWOLAMEContext, x)
#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "mode", "Mpeg Mode", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = TWOLAME_AUTO_MODE }, TWOLAME_AUTO_MODE, TWOLAME_MONO, AE, "mode"},
- { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_AUTO_MODE }, 0, 0, AE, "mode" },
- { "stereo", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_STEREO }, 0, 0, AE, "mode" },
- { "joint_stereo", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_JOINT_STEREO }, 0, 0, AE, "mode" },
- { "dual_channel", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_DUAL_CHANNEL }, 0, 0, AE, "mode" },
- { "mono", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_MONO }, 0, 0, AE, "mode" },
- { "psymodel", "Psychoacoustic Model", OFFSET(psymodel), AV_OPT_TYPE_INT, { .i64 = 3 }, -1, 4, AE},
- { "energy_levels","enable energy levels", OFFSET(energy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
+ { "mode", "Mpeg Mode", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = TWOLAME_AUTO_MODE }, TWOLAME_AUTO_MODE, TWOLAME_MONO, AE, "mode"},
+ { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_AUTO_MODE }, 0, 0, AE, "mode" },
+ { "stereo", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_STEREO }, 0, 0, AE, "mode" },
+ { "joint_stereo", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_JOINT_STEREO }, 0, 0, AE, "mode" },
+ { "dual_channel", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_DUAL_CHANNEL }, 0, 0, AE, "mode" },
+ { "mono", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = TWOLAME_MONO }, 0, 0, AE, "mode" },
+ { "psymodel", "Psychoacoustic Model", OFFSET(psymodel), AV_OPT_TYPE_INT, { .i64 = 3 }, -1, 4, AE},
+ { "energy_levels","enable energy levels", OFFSET(energy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
{ "error_protection","enable CRC error protection", OFFSET(error_protection), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
- { "copyright", "set MPEG Audio Copyright flag", OFFSET(copyright), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
- { "original", "set MPEG Audio Original flag", OFFSET(original), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
+ { "copyright", "set MPEG Audio Copyright flag", OFFSET(copyright), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
+ { "original", "set MPEG Audio Original flag", OFFSET(original), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE},
+ { "verbosity", "set library optput level (0-10)", OFFSET(verbosity), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10, AE},
{ NULL },
};
-static const AVClass libtwolame_class = {
+static const AVClass twolame_class = {
.class_name = "libtwolame encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
+static const AVCodecDefault twolame_defaults[] = {
+ { "b", "384000" },
+ { NULL },
+};
+
+static const int twolame_samplerates[] = {
+ 16000, 22050, 24000, 32000, 44100, 48000, 0
+};
+
AVCodec ff_libtwolame_encoder = {
- .name = "libtwolame",
- .long_name = NULL_IF_CONFIG_SMALL("libtwolame MP2 (MPEG audio layer 2)"),
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP2,
- .priv_data_size = sizeof(TWOLAMEContext),
- .init = twolame_encode_init,
- .encode2 = twolame_encode_frame,
- .close = twolame_encode_close,
- .capabilities = CODEC_CAP_DELAY,
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_NONE },
- .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- 0 },
- .supported_samplerates = (const int[]){ 16000, 22050, 24000, 32000, 44100, 48000, 0 },
- .priv_class = &libtwolame_class,
+ .name = "libtwolame",
+ .long_name = NULL_IF_CONFIG_SMALL("libtwolame MP2 (MPEG audio layer 2)"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_MP2,
+ .priv_data_size = sizeof(TWOLAMEContext),
+ .init = twolame_encode_init,
+ .encode2 = twolame_encode_frame,
+ .close = twolame_encode_close,
+ .capabilities = CODEC_CAP_DELAY,
+ .defaults = twolame_defaults,
+ .priv_class = &twolame_class,
+ .sample_fmts = (const enum AVSampleFormat[]) {
+ AV_SAMPLE_FMT_FLT,
+ AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_S16P,
+ AV_SAMPLE_FMT_NONE
+ },
+ .channel_layouts = (const uint64_t[]) {
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ 0 },
+ .supported_samplerates = twolame_samplerates,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libutvideodec.cpp b/chromium/third_party/ffmpeg/libavcodec/libutvideodec.cpp
index 0d8fa1a7f6e..60dbd15fa88 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libutvideodec.cpp
+++ b/chromium/third_party/ffmpeg/libavcodec/libutvideodec.cpp
@@ -164,7 +164,7 @@ static int utvideo_decode_frame(AVCodecContext *avctx, void *data,
}
*got_frame = 1;
- *(AVFrame *)data = *pic;
+ av_frame_move_ref((AVFrame*)data, pic);
return avpkt->size;
}
@@ -174,7 +174,7 @@ static av_cold int utvideo_decode_close(AVCodecContext *avctx)
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
/* Free output */
- av_freep(&avctx->coded_frame);
+ av_frame_free(&avctx->coded_frame);
av_freep(&utv->buffer);
/* Finish decoding and clean up the instance */
diff --git a/chromium/third_party/ffmpeg/libavcodec/libutvideoenc.cpp b/chromium/third_party/ffmpeg/libavcodec/libutvideoenc.cpp
index ad70669a6b8..f0d56194b4a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libutvideoenc.cpp
+++ b/chromium/third_party/ffmpeg/libavcodec/libutvideoenc.cpp
@@ -44,12 +44,18 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
case AV_PIX_FMT_YUV420P:
in_format = UTVF_YV12;
avctx->bits_per_coded_sample = 12;
- avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
+ if (avctx->colorspace == AVCOL_SPC_BT709)
+ avctx->codec_tag = MKTAG('U', 'L', 'H', '0');
+ else
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
break;
case AV_PIX_FMT_YUYV422:
in_format = UTVF_YUYV;
avctx->bits_per_coded_sample = 16;
- avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
+ if (avctx->colorspace == AVCOL_SPC_BT709)
+ avctx->codec_tag = MKTAG('U', 'L', 'H', '2');
+ else
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
break;
case AV_PIX_FMT_BGR24:
in_format = UTVF_NFCC_BGR_BU;
diff --git a/chromium/third_party/ffmpeg/libavcodec/libvorbisenc.c b/chromium/third_party/ffmpeg/libavcodec/libvorbisenc.c
index a2faac702b2..c655c21bd60 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libvorbisenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libvorbisenc.c
@@ -35,13 +35,12 @@
* an output packet will always start at the same point as one of the input
* packets.
*/
-#define OGGVORBIS_FRAME_SIZE 64
+#define LIBVORBIS_FRAME_SIZE 64
#define BUFFER_SIZE (1024 * 64)
-typedef struct OggVorbisEncContext {
+typedef struct LibvorbisEncContext {
AVClass *av_class; /**< class for AVOptions */
- AVFrame frame;
vorbis_info vi; /**< vorbis_info used during init */
vorbis_dsp_state vd; /**< DSP state used for analysis */
vorbis_block vb; /**< vorbis_block used for analysis */
@@ -52,10 +51,10 @@ typedef struct OggVorbisEncContext {
double iblock; /**< impulse block bias option */
VorbisParseContext vp; /**< parse context to get durations */
AudioFrameQueue afq; /**< frame queue for timestamps */
-} OggVorbisEncContext;
+} LibvorbisEncContext;
static const AVOption options[] = {
- { "iblock", "Sets the impulse block bias", offsetof(OggVorbisEncContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+ { "iblock", "Sets the impulse block bias", offsetof(LibvorbisEncContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
{ NULL }
};
@@ -81,10 +80,9 @@ static int vorbis_error_to_averror(int ov_err)
}
}
-static av_cold int oggvorbis_init_encoder(vorbis_info *vi,
- AVCodecContext *avctx)
+static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
{
- OggVorbisEncContext *s = avctx->priv_data;
+ LibvorbisEncContext *s = avctx->priv_data;
double cfreq;
int ret;
@@ -173,9 +171,9 @@ static int xiph_len(int l)
return 1 + l / 255 + l;
}
-static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
+static av_cold int libvorbis_encode_close(AVCodecContext *avctx)
{
- OggVorbisEncContext *s = avctx->priv_data;
+ LibvorbisEncContext *s = avctx->priv_data;
/* notify vorbisenc this is EOF */
if (s->dsp_initialized)
@@ -185,23 +183,23 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
vorbis_dsp_clear(&s->vd);
vorbis_info_clear(&s->vi);
- av_fifo_free(s->pkt_fifo);
+ av_fifo_freep(&s->pkt_fifo);
ff_af_queue_close(&s->afq);
av_freep(&avctx->extradata);
return 0;
}
-static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
+static av_cold int libvorbis_encode_init(AVCodecContext *avctx)
{
- OggVorbisEncContext *s = avctx->priv_data;
+ LibvorbisEncContext *s = avctx->priv_data;
ogg_packet header, header_comm, header_code;
uint8_t *p;
unsigned int offset;
int ret;
vorbis_info_init(&s->vi);
- if ((ret = oggvorbis_init_encoder(&s->vi, avctx))) {
+ if ((ret = libvorbis_setup(&s->vi, avctx))) {
av_log(avctx, AV_LOG_ERROR, "encoder setup failed\n");
goto error;
}
@@ -255,7 +253,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
vorbis_comment_clear(&s->vc);
- avctx->frame_size = OGGVORBIS_FRAME_SIZE;
+ avctx->frame_size = LIBVORBIS_FRAME_SIZE;
ff_af_queue_init(avctx, &s->afq);
s->pkt_fifo = av_fifo_alloc(BUFFER_SIZE);
@@ -266,14 +264,14 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
return 0;
error:
- oggvorbis_encode_close(avctx);
+ libvorbis_encode_close(avctx);
return ret;
}
-static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
- OggVorbisEncContext *s = avctx->priv_data;
+ LibvorbisEncContext *s = avctx->priv_data;
ogg_packet op;
int ret, duration;
@@ -366,10 +364,10 @@ AVCodec ff_libvorbis_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("libvorbis"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_VORBIS,
- .priv_data_size = sizeof(OggVorbisEncContext),
- .init = oggvorbis_encode_init,
- .encode2 = oggvorbis_encode_frame,
- .close = oggvorbis_encode_close,
+ .priv_data_size = sizeof(LibvorbisEncContext),
+ .init = libvorbis_encode_init,
+ .encode2 = libvorbis_encode_frame,
+ .close = libvorbis_encode_close,
.capabilities = CODEC_CAP_DELAY,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
diff --git a/chromium/third_party/ffmpeg/libavcodec/libvpx.c b/chromium/third_party/ffmpeg/libavcodec/libvpx.c
index 9ff2e91bc47..5d298936022 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libvpx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libvpx.c
@@ -22,14 +22,9 @@
#include "libvpx.h"
-int ff_vp9_check_experimental(AVCodecContext *avctx)
+av_cold void ff_vp9_init_static(AVCodec *codec)
{
- if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
- (vpx_codec_version_major() < 1 ||
- (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))) {
- av_log(avctx, AV_LOG_ERROR,
- "Non-experimental support of VP9 requires libvpx >= 1.3.0\n");
- return AVERROR_EXPERIMENTAL;
- }
- return 0;
+ if ( vpx_codec_version_major() < 1
+ || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
+ codec->capabilities |= CODEC_CAP_EXPERIMENTAL;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/libvpx.h b/chromium/third_party/ffmpeg/libavcodec/libvpx.h
index 2c901f92ef7..36a275c5d22 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libvpx.h
+++ b/chromium/third_party/ffmpeg/libavcodec/libvpx.h
@@ -23,6 +23,6 @@
#include "avcodec.h"
-int ff_vp9_check_experimental(AVCodecContext *avctx);
+void ff_vp9_init_static(AVCodec *codec);
#endif /* AVCODEC_LIBVPX_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/libvpxdec.c b/chromium/third_party/ffmpeg/libavcodec/libvpxdec.c
index 8d608c38603..94e1e4d1efe 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libvpxdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libvpxdec.c
@@ -133,9 +133,6 @@ AVCodec ff_libvpx_vp8_decoder = {
#if CONFIG_LIBVPX_VP9_DECODER
static av_cold int vp9_init(AVCodecContext *avctx)
{
- int ret;
- if ((ret = ff_vp9_check_experimental(avctx)))
- return ret;
return vpx_init(avctx, &vpx_codec_vp9_dx_algo);
}
@@ -149,5 +146,6 @@ AVCodec ff_libvpx_vp9_decoder = {
.close = vp8_free,
.decode = vp8_decode,
.capabilities = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1,
+ .init_static_data = ff_vp9_init_static,
};
#endif /* CONFIG_LIBVPX_VP9_DECODER */
diff --git a/chromium/third_party/ffmpeg/libavcodec/libvpxenc.c b/chromium/third_party/ffmpeg/libavcodec/libvpxenc.c
index c7ca050b178..bc0cf96b064 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libvpxenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libvpxenc.c
@@ -158,7 +158,7 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
width, "g_lag_in_frames:", cfg->g_lag_in_frames);
av_log(avctx, level, "rate control settings\n"
" %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
- " %*s%d\n %*s%p(%zu)\n %*s%u\n",
+ " %*s%d\n %*s%p(%"SIZE_SPECIFIER")\n %*s%u\n",
width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
width, "rc_resize_allowed:", cfg->rc_resize_allowed,
width, "rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
@@ -373,7 +373,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
if (!ctx->twopass_stats.buf) {
av_log(avctx, AV_LOG_ERROR,
- "Stat buffer alloc (%zu bytes) failed\n",
+ "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
ctx->twopass_stats.sz);
return AVERROR(ENOMEM);
}
@@ -616,7 +616,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out,
if (!cx_frame->buf) {
av_log(avctx, AV_LOG_ERROR,
- "Data buffer alloc (%zu bytes) failed\n",
+ "Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
cx_frame->sz);
av_free(cx_frame);
return AVERROR(ENOMEM);
@@ -626,7 +626,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out,
cx_frame->buf_alpha = av_malloc(cx_frame->sz_alpha);
if (!cx_frame->buf_alpha) {
av_log(avctx, AV_LOG_ERROR,
- "Data buffer alloc (%zu bytes) failed\n",
+ "Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
cx_frame->sz_alpha);
av_free(cx_frame);
return AVERROR(ENOMEM);
@@ -852,9 +852,6 @@ AVCodec ff_libvpx_vp8_encoder = {
#if CONFIG_LIBVPX_VP9_ENCODER
static av_cold int vp9_init(AVCodecContext *avctx)
{
- int ret;
- if ((ret = ff_vp9_check_experimental(avctx)))
- return ret;
return vpx_init(avctx, &vpx_codec_vp9_cx_algo);
}
@@ -878,5 +875,6 @@ AVCodec ff_libvpx_vp9_encoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
.priv_class = &class_vp9,
.defaults = defaults,
+ .init_static_data = ff_vp9_init_static,
};
#endif /* CONFIG_LIBVPX_VP9_ENCODER */
diff --git a/chromium/third_party/ffmpeg/libavcodec/libwebpenc.c b/chromium/third_party/ffmpeg/libavcodec/libwebpenc.c
new file mode 100644
index 00000000000..5283da50706
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/libwebpenc.c
@@ -0,0 +1,285 @@
+/*
+ * WebP encoding support via libwebp
+ * Copyright (c) 2013 Justin Ruggles <justin.ruggles@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * WebP encoder using libwebp
+ */
+
+#include <webp/encode.h>
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "avcodec.h"
+#include "internal.h"
+
+typedef struct LibWebPContext {
+ AVClass *class; // class for AVOptions
+ float quality; // lossy quality 0 - 100
+ int lossless; // use lossless encoding
+ int preset; // configuration preset
+ int chroma_warning; // chroma linesize mismatch warning has been printed
+ int conversion_warning; // pixel format conversion warning has been printed
+ WebPConfig config; // libwebp configuration
+} LibWebPContext;
+
+static int libwebp_error_to_averror(int err)
+{
+ switch (err) {
+ case VP8_ENC_ERROR_OUT_OF_MEMORY:
+ case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY:
+ return AVERROR(ENOMEM);
+ case VP8_ENC_ERROR_NULL_PARAMETER:
+ case VP8_ENC_ERROR_INVALID_CONFIGURATION:
+ case VP8_ENC_ERROR_BAD_DIMENSION:
+ return AVERROR(EINVAL);
+ }
+ return AVERROR_UNKNOWN;
+}
+
+static av_cold int libwebp_encode_init(AVCodecContext *avctx)
+{
+ LibWebPContext *s = avctx->priv_data;
+ int ret;
+
+ if (avctx->global_quality < 0)
+ avctx->global_quality = 75 * FF_QP2LAMBDA;
+ s->quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA,
+ 0.0f, 100.0f);
+
+ if (avctx->compression_level < 0 || avctx->compression_level > 6) {
+ av_log(avctx, AV_LOG_WARNING, "invalid compression level: %d\n",
+ avctx->compression_level);
+ avctx->compression_level = av_clip(avctx->compression_level, 0, 6);
+ }
+
+ if (s->preset >= WEBP_PRESET_DEFAULT) {
+ ret = WebPConfigPreset(&s->config, s->preset, s->quality);
+ if (!ret)
+ return AVERROR_UNKNOWN;
+ s->lossless = s->config.lossless;
+ s->quality = s->config.quality;
+ avctx->compression_level = s->config.method;
+ } else {
+ ret = WebPConfigInit(&s->config);
+ if (!ret)
+ return AVERROR_UNKNOWN;
+
+ s->config.lossless = s->lossless;
+ s->config.quality = s->quality;
+ s->config.method = avctx->compression_level;
+
+ ret = WebPValidateConfig(&s->config);
+ if (!ret)
+ return AVERROR(EINVAL);
+ }
+
+ av_log(avctx, AV_LOG_DEBUG, "%s - quality=%.1f method=%d\n",
+ s->lossless ? "Lossless" : "Lossy", s->quality,
+ avctx->compression_level);
+
+ return 0;
+}
+
+static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
+{
+ LibWebPContext *s = avctx->priv_data;
+ AVFrame *alt_frame = NULL;
+ WebPPicture *pic = NULL;
+ WebPMemoryWriter mw = { 0 };
+ int ret;
+
+ if (avctx->width > WEBP_MAX_DIMENSION || avctx->height > WEBP_MAX_DIMENSION) {
+ av_log(avctx, AV_LOG_ERROR, "Picture size is too large. Max is %dx%d.\n",
+ WEBP_MAX_DIMENSION, WEBP_MAX_DIMENSION);
+ return AVERROR(EINVAL);
+ }
+
+ pic = av_malloc(sizeof(*pic));
+ if (!pic)
+ return AVERROR(ENOMEM);
+
+ ret = WebPPictureInit(pic);
+ if (!ret) {
+ ret = AVERROR_UNKNOWN;
+ goto end;
+ }
+ pic->width = avctx->width;
+ pic->height = avctx->height;
+
+ if (avctx->pix_fmt == AV_PIX_FMT_RGB32) {
+ if (!s->lossless) {
+ /* libwebp will automatically convert RGB input to YUV when
+ encoding lossy. */
+ if (!s->conversion_warning) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Using libwebp for RGB-to-YUV conversion. You may want "
+ "to consider passing in YUV instead for lossy "
+ "encoding.\n");
+ s->conversion_warning = 1;
+ }
+ }
+ pic->use_argb = 1;
+ pic->argb = (uint32_t *)frame->data[0];
+ pic->argb_stride = frame->linesize[0] / 4;
+ } else {
+ if (frame->linesize[1] != frame->linesize[2]) {
+ if (!s->chroma_warning) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Copying frame due to differing chroma linesizes.\n");
+ s->chroma_warning = 1;
+ }
+ alt_frame = av_frame_alloc();
+ if (!alt_frame) {
+ ret = AVERROR(ENOMEM);
+ goto end;
+ }
+ alt_frame->width = frame->width;
+ alt_frame->height = frame->height;
+ alt_frame->format = frame->format;
+ ret = av_frame_get_buffer(alt_frame, 32);
+ if (ret < 0)
+ goto end;
+ av_frame_copy(alt_frame, frame);
+ frame = alt_frame;
+ }
+ pic->use_argb = 0;
+ pic->y = frame->data[0];
+ pic->u = frame->data[1];
+ pic->v = frame->data[2];
+ pic->y_stride = frame->linesize[0];
+ pic->uv_stride = frame->linesize[1];
+ if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) {
+ pic->colorspace = WEBP_YUV420A;
+ pic->a = frame->data[3];
+ pic->a_stride = frame->linesize[3];
+ } else {
+ pic->colorspace = WEBP_YUV420;
+ }
+
+ if (s->lossless) {
+ /* We do not have a way to automatically prioritize RGB over YUV
+ in automatic pixel format conversion based on whether we're
+ encoding lossless or lossy, so we do conversion with libwebp as
+ a convenience. */
+ if (!s->conversion_warning) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Using libwebp for YUV-to-RGB conversion. You may want "
+ "to consider passing in RGB instead for lossless "
+ "encoding.\n");
+ s->conversion_warning = 1;
+ }
+
+#if (WEBP_ENCODER_ABI_VERSION <= 0x201)
+ /* libwebp should do the conversion automatically, but there is a
+ bug that causes it to return an error instead, so a work-around
+ is required.
+ See https://code.google.com/p/webp/issues/detail?id=178 */
+ pic->memory_ = (void*)1; /* something non-null */
+ ret = WebPPictureYUVAToARGB(pic);
+ if (!ret) {
+ av_log(avctx, AV_LOG_ERROR,
+ "WebPPictureYUVAToARGB() failed with error: %d\n",
+ pic->error_code);
+ ret = libwebp_error_to_averror(pic->error_code);
+ goto end;
+ }
+ pic->memory_ = NULL; /* restore pointer */
+#endif
+ }
+ }
+
+ WebPMemoryWriterInit(&mw);
+ pic->custom_ptr = &mw;
+ pic->writer = WebPMemoryWrite;
+
+ ret = WebPEncode(&s->config, pic);
+ if (!ret) {
+ av_log(avctx, AV_LOG_ERROR, "WebPEncode() failed with error: %d\n",
+ pic->error_code);
+ ret = libwebp_error_to_averror(pic->error_code);
+ goto end;
+ }
+
+ ret = ff_alloc_packet(pkt, mw.size);
+ if (ret < 0)
+ goto end;
+ memcpy(pkt->data, mw.mem, mw.size);
+
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+end:
+ free(mw.mem); /* must use free() according to libwebp documentation */
+ WebPPictureFree(pic);
+ av_freep(&pic);
+ av_frame_free(&alt_frame);
+
+ return ret;
+}
+
+#define OFFSET(x) offsetof(LibWebPContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "lossless", "Use lossless mode", OFFSET(lossless), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { "preset", "Configuration preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, WEBP_PRESET_TEXT, VE, "preset" },
+ { "none", "do not use a preset", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "preset" },
+ { "default", "default preset", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DEFAULT }, 0, 0, VE, "preset" },
+ { "picture", "digital picture, like portrait, inner shot", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PICTURE }, 0, 0, VE, "preset" },
+ { "photo", "outdoor photograph, with natural lighting", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PHOTO }, 0, 0, VE, "preset" },
+ { "drawing", "hand or line drawing, with high-contrast details", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DRAWING }, 0, 0, VE, "preset" },
+ { "icon", "small-sized colorful images", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_ICON }, 0, 0, VE, "preset" },
+ { "text", "text-like", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_TEXT }, 0, 0, VE, "preset" },
+ { NULL },
+};
+
+static const AVClass class = {
+ .class_name = "libwebp",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVCodecDefault libwebp_defaults[] = {
+ { "compression_level", "4" },
+ { "global_quality", "-1" },
+ { NULL },
+};
+
+AVCodec ff_libwebp_encoder = {
+ .name = "libwebp",
+ .long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_WEBP,
+ .priv_data_size = sizeof(LibWebPContext),
+ .init = libwebp_encode_init,
+ .encode2 = libwebp_encode_frame,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_RGB32,
+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P,
+ AV_PIX_FMT_NONE
+ },
+ .priv_class = &class,
+ .defaults = libwebp_defaults,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libx264.c b/chromium/third_party/ffmpeg/libavcodec/libx264.c
index 89df55fac6c..474c247f453 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libx264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libx264.c
@@ -19,10 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/eval.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "internal.h"
@@ -161,6 +163,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
x264_nal_t *nal;
int nnal, i, ret;
x264_picture_t pic_out = {0};
+ AVFrameSideData *side_data;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
@@ -190,8 +193,42 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
x264_encoder_reconfig(x4->enc, &x4->params);
}
- }
+ side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_STEREO3D);
+ if (side_data) {
+ AVStereo3D *stereo = (AVStereo3D *)side_data->data;
+ int fpa_type;
+
+ switch (stereo->type) {
+ case AV_STEREO3D_CHECKERBOARD:
+ fpa_type = 0;
+ break;
+ case AV_STEREO3D_LINES:
+ fpa_type = 1;
+ break;
+ case AV_STEREO3D_COLUMNS:
+ fpa_type = 2;
+ break;
+ case AV_STEREO3D_SIDEBYSIDE:
+ fpa_type = 3;
+ break;
+ case AV_STEREO3D_TOPBOTTOM:
+ fpa_type = 4;
+ break;
+ case AV_STEREO3D_FRAMESEQUENCE:
+ fpa_type = 5;
+ break;
+ default:
+ fpa_type = -1;
+ break;
+ }
+
+ if (fpa_type != x4->params.i_frame_packing) {
+ x4->params.i_frame_packing = fpa_type;
+ x264_encoder_reconfig(x4->enc, &x4->params);
+ }
+ }
+ }
do {
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
return -1;
@@ -294,6 +331,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
X264Context *x4 = avctx->priv_data;
int sw,sh;
+ if (avctx->global_quality > 0)
+ av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n");
+
x264_param_default(&x4->params);
x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
@@ -355,19 +395,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
OPT_STR("level", x4->level);
- if(x4->x264opts){
- const char *p= x4->x264opts;
- while(p){
- char param[256]={0}, val[256]={0};
- if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
- OPT_STR(param, "1");
- }else
- OPT_STR(param, val);
- p= strchr(p, ':');
- p+=!!p;
- }
- }
-
if (avctx->i_quant_factor > 0)
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
@@ -400,6 +427,28 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
if (avctx->refs >= 0)
x4->params.i_frame_reference = avctx->refs;
+ else if (x4->level) {
+ int i;
+ int mbn = FF_CEIL_RSHIFT(avctx->width, 4) * FF_CEIL_RSHIFT(avctx->height, 4);
+ int level_id = -1;
+ char *tail;
+ int scale = X264_BUILD < 129 ? 384 : 1;
+
+ if (!strcmp(x4->level, "1b")) {
+ level_id = 9;
+ } else if (strlen(x4->level) <= 3){
+ level_id = av_strtod(x4->level, &tail) * 10 + 0.5;
+ if (*tail)
+ level_id = -1;
+ }
+ if (level_id <= 0)
+ av_log(avctx, AV_LOG_WARNING, "Failed to parse level\n");
+
+ for (i = 0; i<x264_levels[i].level_idc; i++)
+ if (x264_levels[i].level_idc == level_id)
+ x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn / scale, 1, x4->params.i_frame_reference);
+ }
+
if (avctx->trellis >= 0)
x4->params.analyse.i_trellis = avctx->trellis;
if (avctx->me_range >= 0)
@@ -521,8 +570,10 @@ static av_cold int X264_init(AVCodecContext *avctx)
av_reduce(&sw, &sh, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 4096);
x4->params.vui.i_sar_width = sw;
x4->params.vui.i_sar_height = sh;
- x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
- x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
+ x4->params.i_timebase_den = avctx->time_base.den;
+ x4->params.i_timebase_num = avctx->time_base.num;
+ x4->params.i_fps_num = avctx->time_base.den;
+ x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame;
x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
@@ -538,11 +589,32 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.vui.b_fullrange = avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
- avctx->pix_fmt == AV_PIX_FMT_YUVJ444P;
+ avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
+ avctx->color_range == AVCOL_RANGE_JPEG;
+
+ if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
+ x4->params.vui.i_colmatrix = avctx->colorspace;
+ if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
+ x4->params.vui.i_colorprim = avctx->color_primaries;
+ if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
+ x4->params.vui.i_transfer = avctx->color_trc;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0;
+ if(x4->x264opts){
+ const char *p= x4->x264opts;
+ while(p){
+ char param[256]={0}, val[256]={0};
+ if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
+ OPT_STR(param, "1");
+ }else
+ OPT_STR(param, val);
+ p= strchr(p, ':');
+ p+=!!p;
+ }
+ }
+
if (x4->x264_params) {
AVDictionary *dict = NULL;
AVDictionaryEntry *en = NULL;
diff --git a/chromium/third_party/ffmpeg/libavcodec/libx265.c b/chromium/third_party/ffmpeg/libavcodec/libx265.c
new file mode 100644
index 00000000000..4de504a9fe1
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/libx265.c
@@ -0,0 +1,313 @@
+/*
+ * libx265 encoder
+ *
+ * Copyright (c) 2013-2014 Derek Buitenhuis
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <x265.h>
+
+#include "libavutil/internal.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avcodec.h"
+#include "internal.h"
+
+#if defined(_MSC_VER)
+#define X265_API_IMPORTS 1
+#endif
+
+typedef struct libx265Context {
+ const AVClass *class;
+
+ x265_encoder *encoder;
+ x265_param *params;
+
+ char *preset;
+ char *tune;
+ char *x265_opts;
+} libx265Context;
+
+static int is_keyframe(NalUnitType naltype)
+{
+ switch (naltype) {
+ case NAL_UNIT_CODED_SLICE_BLA_W_LP:
+ case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
+ case NAL_UNIT_CODED_SLICE_BLA_N_LP:
+ case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
+ case NAL_UNIT_CODED_SLICE_IDR_N_LP:
+ case NAL_UNIT_CODED_SLICE_CRA:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static av_cold int libx265_encode_close(AVCodecContext *avctx)
+{
+ libx265Context *ctx = avctx->priv_data;
+
+ av_frame_free(&avctx->coded_frame);
+
+ x265_param_free(ctx->params);
+
+ if (ctx->encoder)
+ x265_encoder_close(ctx->encoder);
+
+ return 0;
+}
+
+static av_cold int libx265_encode_init(AVCodecContext *avctx)
+{
+ libx265Context *ctx = avctx->priv_data;
+ x265_nal *nal;
+ char sar[12];
+ int sar_num, sar_den;
+ int nnal;
+
+ if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
+ !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_w &&
+ !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_h) {
+ av_log(avctx, AV_LOG_ERROR,
+ "4:4:4 support is not fully defined for HEVC yet. "
+ "Set -strict experimental to encode anyway.\n");
+ return AVERROR(ENOSYS);
+ }
+
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ ctx->params = x265_param_alloc();
+ if (!ctx->params) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ if (x265_param_default_preset(ctx->params, ctx->preset, ctx->tune) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid preset or tune.\n");
+ return AVERROR(EINVAL);
+ }
+
+ ctx->params->frameNumThreads = avctx->thread_count;
+ ctx->params->fpsNum = avctx->time_base.den;
+ ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame;
+ ctx->params->sourceWidth = avctx->width;
+ ctx->params->sourceHeight = avctx->height;
+
+ if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
+ av_reduce(&sar_num, &sar_den,
+ avctx->sample_aspect_ratio.num,
+ avctx->sample_aspect_ratio.den, 65535);
+ snprintf(sar, sizeof(sar), "%d:%d", sar_num, sar_den);
+ if (x265_param_parse(ctx->params, "sar", sar) == X265_PARAM_BAD_VALUE) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid SAR: %d:%d.\n", sar_num, sar_den);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ if (x265_max_bit_depth == 8)
+ ctx->params->internalBitDepth = 8;
+ else if (x265_max_bit_depth == 12)
+ ctx->params->internalBitDepth = 10;
+
+ switch (avctx->pix_fmt) {
+ case AV_PIX_FMT_YUV420P:
+ case AV_PIX_FMT_YUV420P10:
+ ctx->params->internalCsp = X265_CSP_I420;
+ break;
+ case AV_PIX_FMT_YUV444P:
+ case AV_PIX_FMT_YUV444P10:
+ ctx->params->internalCsp = X265_CSP_I444;
+ break;
+ }
+
+ if (avctx->bit_rate > 0) {
+ ctx->params->rc.bitrate = avctx->bit_rate / 1000;
+ ctx->params->rc.rateControlMode = X265_RC_ABR;
+ }
+
+ if (!(avctx->flags & CODEC_FLAG_GLOBAL_HEADER))
+ ctx->params->bRepeatHeaders = 1;
+
+ if (ctx->x265_opts) {
+ AVDictionary *dict = NULL;
+ AVDictionaryEntry *en = NULL;
+
+ if (!av_dict_parse_string(&dict, ctx->x265_opts, "=", ":", 0)) {
+ while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
+ int parse_ret = x265_param_parse(ctx->params, en->key, en->value);
+
+ switch (parse_ret) {
+ case X265_PARAM_BAD_NAME:
+ av_log(avctx, AV_LOG_WARNING,
+ "Unknown option: %s.\n", en->key);
+ break;
+ case X265_PARAM_BAD_VALUE:
+ av_log(avctx, AV_LOG_WARNING,
+ "Invalid value for %s: %s.\n", en->key, en->value);
+ break;
+ default:
+ break;
+ }
+ }
+ av_dict_free(&dict);
+ }
+ }
+
+ ctx->encoder = x265_encoder_open(ctx->params);
+ if (!ctx->encoder) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot open libx265 encoder.\n");
+ libx265_encode_close(avctx);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
+ avctx->extradata_size = x265_encoder_headers(ctx->encoder, &nal, &nnal);
+ if (avctx->extradata_size <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot encode headers.\n");
+ libx265_encode_close(avctx);
+ return AVERROR_INVALIDDATA;
+ }
+
+ avctx->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Cannot allocate HEVC header of size %d.\n", avctx->extradata_size);
+ libx265_encode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
+ memcpy(avctx->extradata, nal[0].payload, avctx->extradata_size);
+ }
+
+ return 0;
+}
+
+static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pic, int *got_packet)
+{
+ libx265Context *ctx = avctx->priv_data;
+ x265_picture x265pic;
+ x265_picture x265pic_out = { { 0 } };
+ x265_nal *nal;
+ uint8_t *dst;
+ int payload = 0;
+ int nnal;
+ int ret;
+ int i;
+
+ x265_picture_init(ctx->params, &x265pic);
+
+ if (pic) {
+ for (i = 0; i < 3; i++) {
+ x265pic.planes[i] = pic->data[i];
+ x265pic.stride[i] = pic->linesize[i];
+ }
+
+ x265pic.pts = pic->pts;
+ x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1;
+ }
+
+ ret = x265_encoder_encode(ctx->encoder, &nal, &nnal,
+ pic ? &x265pic : NULL, &x265pic_out);
+ if (ret < 0)
+ return AVERROR_EXTERNAL;
+
+ if (!nnal)
+ return 0;
+
+ for (i = 0; i < nnal; i++)
+ payload += nal[i].sizeBytes;
+
+ ret = ff_alloc_packet(pkt, payload);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+ return ret;
+ }
+ dst = pkt->data;
+
+ for (i = 0; i < nnal; i++) {
+ memcpy(dst, nal[i].payload, nal[i].sizeBytes);
+ dst += nal[i].sizeBytes;
+
+ if (is_keyframe(nal[i].type))
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ }
+
+ pkt->pts = x265pic_out.pts;
+ pkt->dts = x265pic_out.dts;
+
+ *got_packet = 1;
+ return 0;
+}
+
+static const enum AVPixelFormat x265_csp_eight[] = {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_NONE
+};
+
+static const enum AVPixelFormat x265_csp_twelve[] = {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_YUV420P10,
+ AV_PIX_FMT_YUV444P10,
+ AV_PIX_FMT_NONE
+};
+
+static av_cold void libx265_encode_init_csp(AVCodec *codec)
+{
+ if (x265_max_bit_depth == 8)
+ codec->pix_fmts = x265_csp_eight;
+ else if (x265_max_bit_depth == 12)
+ codec->pix_fmts = x265_csp_twelve;
+}
+
+#define OFFSET(x) offsetof(libx265Context, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
+ { "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
+ { "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
+ { NULL }
+};
+
+static const AVClass class = {
+ .class_name = "libx265",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_libx265_encoder = {
+ .name = "libx265",
+ .long_name = NULL_IF_CONFIG_SMALL("libx265 H.265 / HEVC"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_HEVC,
+ .init = libx265_encode_init,
+ .init_static_data = libx265_encode_init_csp,
+ .encode2 = libx265_encode_frame,
+ .close = libx265_encode_close,
+ .priv_data_size = sizeof(libx265Context),
+ .priv_class = &class,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libxavs.c b/chromium/third_party/ffmpeg/libavcodec/libxavs.c
index ffe3411c960..92dceceac17 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libxavs.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libxavs.c
@@ -353,7 +353,7 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
if (!x4->enc)
return -1;
- if (!(x4->pts_buffer = av_mallocz((avctx->max_b_frames+1) * sizeof(*x4->pts_buffer))))
+ if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer))))
return AVERROR(ENOMEM);
avctx->coded_frame = av_frame_alloc();
diff --git a/chromium/third_party/ffmpeg/libavcodec/libxvid.c b/chromium/third_party/ffmpeg/libavcodec/libxvid.c
index 40b3bffacf1..88d748e8b89 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libxvid.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libxvid.c
@@ -48,6 +48,7 @@
* This stores all the private context for the codec.
*/
struct xvid_context {
+ AVClass *class;
void *encoder_handle; /**< Handle for Xvid encoder */
int xsize; /**< Frame x size */
int ysize; /**< Frame y size */
@@ -66,6 +67,7 @@ struct xvid_context {
int variance_aq; /**< Variance adaptive quantization */
int ssim; /**< SSIM information display mode */
int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */
+ int gmc;
};
/**
@@ -421,8 +423,13 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
}
/* Bring in VOL flags from ffmpeg command-line */
+#if FF_API_GMC
+ if (avctx->flags & CODEC_FLAG_GMC)
+ x->gmc = 1;
+#endif
+
x->vol_flags = 0;
- if( xvid_flags & CODEC_FLAG_GMC ) {
+ if (x->gmc) {
x->vol_flags |= XVID_VOL_GMC;
x->me_flags |= XVID_ME_GME_REFINE;
}
@@ -530,25 +537,26 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
xvid_enc_create.num_plugins++;
}
- if ( avctx->lumi_masking != 0.0)
+ if (avctx->lumi_masking != 0.0)
x->lumi_aq = 1;
/* Luminance Masking */
- if( x->lumi_aq ) {
+ if (x->lumi_aq) {
masking_l.method = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
/* The old behavior is that when avctx->lumi_masking is specified,
* plugins[...].param = NULL. Trying to keep the old behavior here. */
- plugins[xvid_enc_create.num_plugins].param = avctx->lumi_masking ? NULL : &masking_l ;
- xvid_enc_create.num_plugins++;
+ plugins[xvid_enc_create.num_plugins].param = avctx->lumi_masking ? NULL
+ : &masking_l;
+ xvid_enc_create.num_plugins++;
}
/* Variance AQ */
- if( x->variance_aq ) {
+ if (x->variance_aq) {
masking_v.method = 1;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
- plugins[xvid_enc_create.num_plugins].param = &masking_v ;
+ plugins[xvid_enc_create.num_plugins].param = &masking_v;
xvid_enc_create.num_plugins++;
}
@@ -558,9 +566,9 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
"will be the worse one of the two effects made by the AQ.\n");
/* SSIM */
- if( x->ssim ) {
+ if (x->ssim) {
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
- ssim.b_printstat = ( x->ssim == 2 );
+ ssim.b_printstat = x->ssim == 2;
ssim.acc = x->ssim_acc;
ssim.cpu_flags = xvid_gbl_init.cpu_flags;
ssim.b_visualize = 0;
@@ -687,7 +695,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* Initialize input image fields */
if( avctx->pix_fmt != AV_PIX_FMT_YUV420P ) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Color spaces other than 420p not supported\n");
- return -1;
+ return AVERROR(EINVAL);
}
xvid_enc_frame.input.csp = XVID_CSP_PLANAR; /* YUV420P */
@@ -774,7 +782,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (!xerr)
return 0;
av_log(avctx, AV_LOG_ERROR, "Xvid: Encoding Error Occurred: %i\n", xerr);
- return -1;
+ return AVERROR_EXTERNAL;
}
}
@@ -813,6 +821,7 @@ static const AVOption options[] = {
{ "avg", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "ssim" },
{ "frame", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" },
{ "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE },
+ { "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/libzvbi-teletextdec.c b/chromium/third_party/ffmpeg/libavcodec/libzvbi-teletextdec.c
index bf2dc063ab5..e65e3fb55f3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/libzvbi-teletextdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/libzvbi-teletextdec.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
@@ -23,6 +23,7 @@
#include "libavutil/opt.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/log.h"
#include <libzvbi.h>
@@ -34,6 +35,9 @@
#define VBI_B(rgba) (((rgba) >> 16) & 0xFF)
#define VBI_A(rgba) (((rgba) >> 24) & 0xFF)
#define MAX_BUFFERED_PAGES 25
+#define BITMAP_CHAR_WIDTH 12
+#define BITMAP_CHAR_HEIGHT 10
+#define MAX_SLICES 64
typedef struct TeletextPage
{
@@ -43,7 +47,6 @@ typedef struct TeletextPage
int64_t pts;
} TeletextPage;
-/* main data structure */
typedef struct TeletextContext
{
AVClass *class;
@@ -63,18 +66,13 @@ typedef struct TeletextContext
int handler_ret;
vbi_decoder * vbi;
- vbi_dvb_demux * dx;
#ifdef DEBUG
vbi_export * ex;
#endif
- /* Don't even _think_ about making sliced stack-local! */
- vbi_sliced sliced[64];
+ vbi_sliced sliced[MAX_SLICES];
} TeletextContext;
-/************************************************************************/
-
-static int
-chop_spaces_utf8(const unsigned char* t, int len)
+static int chop_spaces_utf8(const unsigned char* t, int len)
{
t += len;
while (len > 0) {
@@ -85,8 +83,7 @@ chop_spaces_utf8(const unsigned char* t, int len)
return len;
}
-static void
-subtitle_rect_free(AVSubtitleRect **sub_rect)
+static void subtitle_rect_free(AVSubtitleRect **sub_rect)
{
av_freep(&(*sub_rect)->pict.data[0]);
av_freep(&(*sub_rect)->pict.data[1]);
@@ -94,8 +91,7 @@ subtitle_rect_free(AVSubtitleRect **sub_rect)
av_freep(sub_rect);
}
-static int
-create_ass_text(TeletextContext *ctx, const char *text, char **ass)
+static int create_ass_text(TeletextContext *ctx, const char *text, char **ass)
{
int ret;
AVBPrint buf, buf2;
@@ -127,9 +123,8 @@ create_ass_text(TeletextContext *ctx, const char *text, char **ass)
return 0;
}
-// draw a page as text
-static int
-gen_sub_text(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
+/* Draw a page as text */
+static int gen_sub_text(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
{
const char *in;
AVBPrint buf;
@@ -195,21 +190,21 @@ gen_sub_text(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int
return 0;
}
-static void
-fix_transparency(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top, uint8_t transparent_color, int resx, int resy)
+static void fix_transparency(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page,
+ int chop_top, uint8_t transparent_color, int resx, int resy)
{
int iy;
// Hack for transparency, inspired by VLC code...
for (iy = 0; iy < resy; iy++) {
uint8_t *pixel = sub_rect->pict.data[0] + iy * sub_rect->pict.linesize[0];
- vbi_char *vc = page->text + (iy / 10 + chop_top) * page->columns;
+ vbi_char *vc = page->text + (iy / BITMAP_CHAR_HEIGHT + chop_top) * page->columns;
vbi_char *vcnext = vc + page->columns;
for (; vc < vcnext; vc++) {
- uint8_t *pixelnext = pixel + 12;
+ uint8_t *pixelnext = pixel + BITMAP_CHAR_WIDTH;
switch (vc->opacity) {
case VBI_TRANSPARENT_SPACE:
- memset(pixel, transparent_color, 12);
+ memset(pixel, transparent_color, BITMAP_CHAR_WIDTH);
break;
case VBI_OPAQUE:
case VBI_SEMI_TRANSPARENT:
@@ -226,12 +221,11 @@ fix_transparency(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page,
}
}
-// draw a page as bitmap
-static int
-gen_sub_bitmap(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
+/* Draw a page as bitmap */
+static int gen_sub_bitmap(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
{
- int resx = page->columns * 12;
- int resy = (page->rows - chop_top) * 10;
+ int resx = page->columns * BITMAP_CHAR_WIDTH;
+ int resy = (page->rows - chop_top) * BITMAP_CHAR_HEIGHT;
uint8_t ci, cmax = 0;
int ret;
vbi_char *vc = page->text + (chop_top * page->columns);
@@ -262,7 +256,7 @@ gen_sub_bitmap(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, i
fix_transparency(ctx, sub_rect, page, chop_top, cmax, resx, resy);
sub_rect->x = ctx->x_offset;
- sub_rect->y = ctx->y_offset;
+ sub_rect->y = ctx->y_offset + chop_top * BITMAP_CHAR_HEIGHT;
sub_rect->w = resx;
sub_rect->h = resy;
sub_rect->nb_colors = (int)cmax + 1;
@@ -279,18 +273,14 @@ gen_sub_bitmap(TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, i
b = VBI_B(page->color_map[ci]);
a = VBI_A(page->color_map[ci]);
((uint32_t *)sub_rect->pict.data[1])[ci] = RGBA(r, g, b, a);
-#ifdef DEBUG
- av_log(ctx, AV_LOG_DEBUG, "palette %0x\n",
- ((uint32_t *)sub_rect->pict.data[1])[ci]);
-#endif
+ av_dlog(ctx, "palette %0x\n", ((uint32_t *)sub_rect->pict.data[1])[ci]);
}
((uint32_t *)sub_rect->pict.data[1])[cmax] = RGBA(0, 0, 0, 0);
sub_rect->type = SUBTITLE_BITMAP;
return 0;
}
-static void
-handler(vbi_event *ev, void *user_data)
+static void handler(vbi_event *ev, void *user_data)
{
TeletextContext *ctx = user_data;
TeletextPage *new_pages;
@@ -311,7 +301,6 @@ handler(vbi_event *ev, void *user_data)
if (ctx->handler_ret < 0)
return;
- /* Fetch the page. */
res = vbi_fetch_vt_page(ctx->vbi, &page,
ev->ev.ttx_page.pgno,
ev->ev.ttx_page.subno,
@@ -369,18 +358,46 @@ handler(vbi_event *ev, void *user_data)
vbi_unref_page(&page);
}
-static int
-teletext_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *pkt)
+static inline int data_identifier_is_teletext(int data_identifier) {
+ /* See EN 301 775 section 4.4.2. */
+ return (data_identifier >= 0x10 && data_identifier <= 0x1F ||
+ data_identifier >= 0x99 && data_identifier <= 0x9B);
+}
+
+static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
+{
+ int lines = 0;
+ while (size >= 2 && lines < MAX_SLICES) {
+ int data_unit_id = buf[0];
+ int data_unit_length = buf[1];
+ if (data_unit_length + 2 > size)
+ return AVERROR_INVALIDDATA;
+ if (data_unit_id == 0x02 || data_unit_id == 0x03) {
+ if (data_unit_length != 0x2c)
+ return AVERROR_INVALIDDATA;
+ else {
+ int line_offset = buf[2] & 0x1f;
+ int field_parity = buf[2] & 0x20;
+ int i;
+ ctx->sliced[lines].id = VBI_SLICED_TELETEXT_B;
+ ctx->sliced[lines].line = (line_offset > 0 ? (line_offset + (field_parity ? 0 : 313)) : 0);
+ for (i = 0; i < 42; i++)
+ ctx->sliced[lines].data[i] = vbi_rev8(buf[4 + i]);
+ lines++;
+ }
+ }
+ size -= data_unit_length + 2;
+ buf += data_unit_length + 2;
+ }
+ if (size)
+ av_log(ctx, AV_LOG_WARNING, "%d bytes remained after slicing data\n", size);
+ return lines;
+}
+
+static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
{
TeletextContext *ctx = avctx->priv_data;
AVSubtitle *sub = data;
- const uint8_t *buf = pkt->data;
- int left = pkt->size;
- uint8_t pesheader[45] = {0x00, 0x00, 0x01, 0xbd, 0x00, 0x00, 0x85, 0x80, 0x24, 0x21, 0x00, 0x01, 0x00, 0x01};
- int pesheader_size = sizeof(pesheader);
- const uint8_t *pesheader_buf = pesheader;
int ret = 0;
if (!ctx->vbi) {
@@ -392,43 +409,34 @@ teletext_decode_frame(AVCodecContext *avctx,
return AVERROR(ENOMEM);
}
}
- if (!ctx->dx && (!(ctx->dx = vbi_dvb_pes_demux_new (/* callback */ NULL, NULL))))
- return AVERROR(ENOMEM);
if (avctx->pkt_timebase.den && pkt->pts != AV_NOPTS_VALUE)
ctx->pts = av_rescale_q(pkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
- if (left) {
+ if (pkt->size) {
+ int lines;
+ const int full_pes_size = pkt->size + 45; /* PES header is 45 bytes */
+
// We allow unreasonably big packets, even if the standard only allows a max size of 1472
- if ((pesheader_size + left) < 184 || (pesheader_size + left) > 65504 || (pesheader_size + left) % 184 != 0)
+ if (full_pes_size < 184 || full_pes_size > 65504 || full_pes_size % 184 != 0)
return AVERROR_INVALIDDATA;
- memset(pesheader + 14, 0xff, pesheader_size - 14);
- AV_WB16(pesheader + 4, left + pesheader_size - 6);
-
- /* PTS is deliberately left as 0 in the PES header, otherwise libzvbi uses
- * it to detect dropped frames. Unforunatey the guessed packet PTS values
- * (see mpegts demuxer) are not accurate enough to pass that test. */
- vbi_dvb_demux_cor(ctx->dx, ctx->sliced, 64, NULL, &pesheader_buf, &pesheader_size);
-
ctx->handler_ret = pkt->size;
- while (left > 0) {
- int64_t pts = 0;
- unsigned int lines = vbi_dvb_demux_cor(ctx->dx, ctx->sliced, 64, &pts, &buf, &left);
-#ifdef DEBUG
- av_log(avctx, AV_LOG_DEBUG,
- "ctx=%p buf_size=%d left=%u lines=%u pts=%f pkt_pts=%f\n",
- ctx, pkt->size, left, lines, (double)pts/90000.0, (double)pkt->pts/90000.0);
-#endif
+ if (data_identifier_is_teletext(*pkt->data)) {
+ if ((lines = slice_to_vbi_lines(ctx, pkt->data + 1, pkt->size - 1)) < 0)
+ return lines;
+ av_dlog(avctx, "ctx=%p buf_size=%d lines=%u pkt_pts=%7.3f\n",
+ ctx, pkt->size, lines, (double)pkt->pts/90000.0);
if (lines > 0) {
-#ifdef DEBUGx
+#ifdef DEBUG
int i;
- for(i=0; i<lines; ++i)
- av_log(avctx, AV_LOG_DEBUG,
- "lines=%d id=%x\n", i, ctx->sliced[i].id);
+ av_log(avctx, AV_LOG_DEBUG, "line numbers:");
+ for(i = 0; i < lines; i++)
+ av_log(avctx, AV_LOG_DEBUG, " %d", ctx->sliced[i].line);
+ av_log(avctx, AV_LOG_DEBUG, "\n");
#endif
- vbi_decode(ctx->vbi, ctx->sliced, lines, (double)pts/90000.0);
+ vbi_decode(ctx->vbi, ctx->sliced, lines, 0.0);
ctx->lines_processed += lines;
}
}
@@ -449,7 +457,7 @@ teletext_decode_frame(AVCodecContext *avctx,
sub->pts = ctx->pages->pts;
if (ctx->pages->sub_rect->type != SUBTITLE_NONE) {
- sub->rects = av_malloc(sizeof(*sub->rects) * 1);
+ sub->rects = av_malloc(sizeof(*sub->rects));
if (sub->rects) {
sub->num_rects = 1;
sub->rects[0] = ctx->pages->sub_rect;
@@ -486,7 +494,11 @@ static int teletext_init_decoder(AVCodecContext *avctx)
return AVERROR_EXTERNAL;
}
- ctx->dx = NULL;
+ if (ctx->format_id == 0) {
+ avctx->width = 41 * BITMAP_CHAR_WIDTH;
+ avctx->height = 25 * BITMAP_CHAR_HEIGHT;
+ }
+
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
@@ -504,16 +516,12 @@ static int teletext_close_decoder(AVCodecContext *avctx)
{
TeletextContext *ctx = avctx->priv_data;
-#ifdef DEBUG
- av_log(avctx, AV_LOG_DEBUG, "lines_total=%u\n", ctx->lines_processed);
-#endif
+ av_dlog(avctx, "lines_total=%u\n", ctx->lines_processed);
while (ctx->nb_pages)
subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);
av_freep(&ctx->pages);
- vbi_dvb_demux_delete(ctx->dx);
vbi_decoder_delete(ctx->vbi);
- ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ljpegenc.c b/chromium/third_party/ffmpeg/libavcodec/ljpegenc.c
index 35b82fdea2c..6fd86ff2276 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ljpegenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ljpegenc.c
@@ -233,7 +233,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&pb, pkt->data, pkt->size);
ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
- s->matrix);
+ s->matrix, s->matrix);
header_bits = put_bits_count(&pb);
@@ -275,7 +275,8 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
- avctx->pix_fmt == AV_PIX_FMT_YUV444P) &&
+ avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
+ avctx->color_range == AVCOL_RANGE_MPEG) &&
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
av_log(avctx, AV_LOG_ERROR,
"Limited range YUV is non-standard, set strict_std_compliance to "
diff --git a/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.c b/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.c
new file mode 100644
index 00000000000..ca55e6e7c61
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.c
@@ -0,0 +1,128 @@
+/*
+ * Lossless video DSP utils
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avcodec.h"
+#include "lossless_videodsp.h"
+#include "libavcodec/mathops.h"
+
+static void add_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, int w){
+ long i;
+ unsigned long pw_lsb = (mask >> 1) * 0x0001000100010001ULL;
+ unsigned long pw_msb = pw_lsb + 0x0001000100010001ULL;
+ for (i = 0; i <= w - (int)sizeof(long)/2; i += sizeof(long)/2) {
+ long a = *(long*)(src+i);
+ long b = *(long*)(dst+i);
+ *(long*)(dst+i) = ((a&pw_lsb) + (b&pw_lsb)) ^ ((a^b)&pw_msb);
+ }
+ for(; i<w; i++)
+ dst[i] = (dst[i] + src[i]) & mask;
+}
+
+static void diff_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w){
+ long i;
+#if !HAVE_FAST_UNALIGNED
+ if((long)src2 & (sizeof(long)-1)){
+ for(i=0; i+3<w; i+=4){
+ dst[i+0] = (src1[i+0]-src2[i+0]) & mask;
+ dst[i+1] = (src1[i+1]-src2[i+1]) & mask;
+ dst[i+2] = (src1[i+2]-src2[i+2]) & mask;
+ dst[i+3] = (src1[i+3]-src2[i+3]) & mask;
+ }
+ }else
+#endif
+ {
+ unsigned long pw_lsb = (mask >> 1) * 0x0001000100010001ULL;
+ unsigned long pw_msb = pw_lsb + 0x0001000100010001ULL;
+
+ for (i = 0; i <= w - (int)sizeof(long)/2; i += sizeof(long)/2) {
+ long a = *(long*)(src1+i);
+ long b = *(long*)(src2+i);
+ *(long*)(dst+i) = ((a|pw_msb) - (b&pw_lsb)) ^ ((a^b^pw_msb)&pw_msb);
+ }
+ }
+ for (; i<w; i++)
+ dst[i] = (src1[i] - src2[i]) & mask;
+}
+
+static void add_hfyu_median_prediction_int16_c(uint16_t *dst, const uint16_t *src, const uint16_t *diff, unsigned mask, int w, int *left, int *left_top){
+ int i;
+ uint16_t l, lt;
+
+ l = *left;
+ lt = *left_top;
+
+ for(i=0; i<w; i++){
+ l = (mid_pred(l, src[i], (l + src[i] - lt) & mask) + diff[i]) & mask;
+ lt = src[i];
+ dst[i] = l;
+ }
+
+ *left = l;
+ *left_top = lt;
+}
+
+static void sub_hfyu_median_prediction_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top){
+ int i;
+ uint16_t l, lt;
+
+ l = *left;
+ lt = *left_top;
+
+ for(i=0; i<w; i++){
+ const int pred = mid_pred(l, src1[i], (l + src1[i] - lt) & mask);
+ lt = src1[i];
+ l = src2[i];
+ dst[i] = (l - pred) & mask;
+ }
+
+ *left = l;
+ *left_top = lt;
+}
+
+static int add_hfyu_left_prediction_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, int w, unsigned acc){
+ int i;
+
+ for(i=0; i<w-1; i++){
+ acc+= src[i];
+ dst[i]= acc & mask;
+ i++;
+ acc+= src[i];
+ dst[i]= acc & mask;
+ }
+
+ for(; i<w; i++){
+ acc+= src[i];
+ dst[i]= acc & mask;
+ }
+
+ return acc;
+}
+
+
+void ff_llviddsp_init(LLVidDSPContext *c, AVCodecContext *avctx)
+{
+ c->add_int16 = add_int16_c;
+ c->diff_int16= diff_int16_c;
+ c->add_hfyu_left_prediction_int16 = add_hfyu_left_prediction_int16_c;
+ c->add_hfyu_median_prediction_int16 = add_hfyu_median_prediction_int16_c;
+ c->sub_hfyu_median_prediction_int16 = sub_hfyu_median_prediction_int16_c;
+
+ if (ARCH_X86)
+ ff_llviddsp_init_x86(c, avctx);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.h b/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.h
new file mode 100644
index 00000000000..6e82f64eeac
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/lossless_videodsp.h
@@ -0,0 +1,40 @@
+/*
+ * Lossless video DSP utils
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef AVCODEC_LOSSLESS_VIDEODSP_H
+#define AVCODEC_LOSSLESS_VIDEODSP_H
+
+#include "avcodec.h"
+#include "libavutil/cpu.h"
+
+typedef struct LLVidDSPContext {
+ void (*add_int16)(uint16_t *dst/*align 16*/, const uint16_t *src/*align 16*/, unsigned mask, int w);
+ void (*diff_int16)(uint16_t *dst/*align 16*/, const uint16_t *src1/*align 16*/, const uint16_t *src2/*align 1*/, unsigned mask, int w);
+
+ void (*sub_hfyu_median_prediction_int16)(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top);
+ void (*add_hfyu_median_prediction_int16)(uint16_t *dst, const uint16_t *top, const uint16_t *diff, unsigned mask, int w, int *left, int *left_top);
+ int (*add_hfyu_left_prediction_int16)(uint16_t *dst, const uint16_t *src, unsigned mask, int w, unsigned left);
+} LLVidDSPContext;
+
+void ff_llviddsp_init(LLVidDSPContext *llviddsp, AVCodecContext *avctx);
+void ff_llviddsp_init_x86(LLVidDSPContext *llviddsp, AVCodecContext *avctx);
+
+#endif //AVCODEC_LOSSLESS_VIDEODSP_H
diff --git a/chromium/third_party/ffmpeg/libavcodec/lzw.c b/chromium/third_party/ffmpeg/libavcodec/lzw.c
index 43e3e055c26..6832c122a28 100644
--- a/chromium/third_party/ffmpeg/libavcodec/lzw.c
+++ b/chromium/third_party/ffmpeg/libavcodec/lzw.c
@@ -28,6 +28,7 @@
*/
#include "avcodec.h"
+#include "bytestream.h"
#include "lzw.h"
#include "libavutil/mem.h"
@@ -43,7 +44,7 @@ static const uint16_t mask[17] =
};
struct LZWState {
- const uint8_t *pbuf, *ebuf;
+ GetByteContext gb;
int bbits;
unsigned int bbuf;
@@ -73,9 +74,9 @@ static int lzw_get_code(struct LZWState * s)
if(s->mode == FF_LZW_GIF) {
while (s->bbits < s->cursize) {
if (!s->bs) {
- s->bs = *s->pbuf++;
+ s->bs = bytestream2_get_byte(&s->gb);
}
- s->bbuf |= (*s->pbuf++) << s->bbits;
+ s->bbuf |= bytestream2_get_byte(&s->gb) << s->bbits;
s->bbits += 8;
s->bs--;
}
@@ -83,7 +84,7 @@ static int lzw_get_code(struct LZWState * s)
s->bbuf >>= s->cursize;
} else { // TIFF
while (s->bbits < s->cursize) {
- s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
+ s->bbuf = (s->bbuf << 8) | bytestream2_get_byte(&s->gb);
s->bbits += 8;
}
c = s->bbuf >> (s->bbits - s->cursize);
@@ -97,17 +98,12 @@ void ff_lzw_decode_tail(LZWState *p)
struct LZWState *s = (struct LZWState *)p;
if(s->mode == FF_LZW_GIF) {
- while (s->bs > 0) {
- if (s->bs >= s->ebuf - s->pbuf) {
- s->pbuf = s->ebuf;
- break;
- } else {
- s->pbuf += s->bs;
- s->bs = *s->pbuf++;
- }
+ while (s->bs > 0 && bytestream2_get_bytes_left(&s->gb)) {
+ bytestream2_skip(&s->gb, s->bs);
+ s->bs = bytestream2_get_byte(&s->gb);
}
}else
- s->pbuf= s->ebuf;
+ bytestream2_skip(&s->gb, bytestream2_get_bytes_left(&s->gb));
}
av_cold void ff_lzw_decode_open(LZWState **p)
@@ -135,8 +131,7 @@ int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size,
if(csize < 1 || csize >= LZW_MAXBITS)
return -1;
/* read buffer */
- s->pbuf = buf;
- s->ebuf = s->pbuf + buf_size;
+ bytestream2_init(&s->gb, buf, buf_size);
s->bbuf = 0;
s->bbits = 0;
s->bs = 0;
@@ -186,10 +181,6 @@ int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
if ((--l) == 0)
goto the_end;
}
- if (s->ebuf < s->pbuf) {
- av_log(NULL, AV_LOG_ERROR, "lzw overread\n");
- goto the_end;
- }
c = lzw_get_code(s);
if (c == s->end_code) {
break;
diff --git a/chromium/third_party/ffmpeg/libavcodec/lzwenc.c b/chromium/third_party/ffmpeg/libavcodec/lzwenc.c
index d5a07bc7ba5..03080ee5872 100644
--- a/chromium/third_party/ffmpeg/libavcodec/lzwenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/lzwenc.c
@@ -26,8 +26,9 @@
*/
#include "avcodec.h"
-#include "put_bits.h"
#include "lzw.h"
+#include "mathops.h"
+#include "put_bits.h"
#define LZW_MAXBITS 12
#define LZW_SIZTABLE (1<<LZW_MAXBITS)
diff --git a/chromium/third_party/ffmpeg/libavcodec/mace.c b/chromium/third_party/ffmpeg/libavcodec/mace.c
index fbd932e2034..6eaa2966880 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mace.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mace.c
@@ -244,6 +244,13 @@ static int mace_decode_frame(AVCodecContext *avctx, void *data,
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
+ if (buf_size % (avctx->channels << is_mace3)) {
+ av_log(avctx, AV_LOG_ERROR, "buffer size %d is odd\n", buf_size);
+ buf_size -= buf_size % (avctx->channels << is_mace3);
+ if (!buf_size)
+ return AVERROR_INVALIDDATA;
+ }
+
/* get output buffer */
frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/mathops.h b/chromium/third_party/ffmpeg/libavcodec/mathops.h
index bad25afd45b..b0e48d89198 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mathops.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mathops.h
@@ -27,9 +27,13 @@
#include "libavutil/common.h"
#include "config.h"
+#define MAX_NEG_CROP 1024
+
extern const uint32_t ff_inverse[257];
extern const uint8_t ff_reverse[256];
extern const uint8_t ff_sqrt_tab[256];
+extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];
+extern const uint8_t ff_zigzag_direct[64];
#if ARCH_ARM
# include "arm/mathops.h"
@@ -195,15 +199,6 @@ if ((y) < (x)) {\
# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
#endif /* FASTDIV */
-#ifndef MOD_UNLIKELY
-# define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \
- do { \
- if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \
- (modulus) = (dividend) % (divisor); \
- (prev_dividend) = (dividend); \
- } while (0)
-#endif
-
static inline av_const unsigned int ff_sqrt(unsigned int a)
{
unsigned int b;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mathtables.c b/chromium/third_party/ffmpeg/libavcodec/mathtables.c
index ec5ba794273..a07ac50c08b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mathtables.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mathtables.c
@@ -20,6 +20,8 @@
#include <stdint.h>
+#include "mathops.h"
+
/* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256
* for a>16909558, is an overestimate by less than 1 part in 1<<24 */
const uint32_t ff_inverse[257]={
@@ -91,7 +93,7 @@ const uint8_t ff_reverse[256] = {
#define times4(x) x, x, x, x
#define times256(x) times4(times4(times4(times4(times4(x)))))
-const uint8_t ff_cropTbl[256 + 2 * 1024] = {
+const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP] = {
times256(0x00),
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
diff --git a/chromium/third_party/ffmpeg/libavcodec/mdct_fixed.c b/chromium/third_party/ffmpeg/libavcodec/mdct_fixed.c
index 2ee29b609a3..a32cb00ca03 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mdct_fixed.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mdct_fixed.c
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
-#define CONFIG_FFT_FIXED_32 0
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 0
#include "mdct_template.c"
/* same as ff_mdct_calcw_c with double-width unscaled output */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mdct_fixed_32.c b/chromium/third_party/ffmpeg/libavcodec/mdct_fixed_32.c
index f1d6a2dc6bc..5a34dfe7607 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mdct_fixed_32.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mdct_fixed_32.c
@@ -47,6 +47,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 0
-#define CONFIG_FFT_FIXED_32 1
+#define FFT_FLOAT 0
+#define FFT_FIXED_32 1
#include "mdct_template.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/mdct_float.c b/chromium/third_party/ffmpeg/libavcodec/mdct_float.c
index 75b5f0d3a0a..cff2d211c4b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mdct_float.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mdct_float.c
@@ -16,6 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define CONFIG_FFT_FLOAT 1
-#define CONFIG_FFT_FIXED_32 0
+#define FFT_FLOAT 1
+#define FFT_FIXED_32 0
#include "mdct_template.c"
diff --git a/chromium/third_party/ffmpeg/libavcodec/mdct_template.c b/chromium/third_party/ffmpeg/libavcodec/mdct_template.c
index 922d577e3e3..7fa8bcce569 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mdct_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mdct_template.c
@@ -31,14 +31,14 @@
* MDCT/IMDCT transforms.
*/
-#if CONFIG_FFT_FLOAT
+#if FFT_FLOAT
# define RSCALE(x) (x)
#else
-#if CONFIG_FFT_FIXED_32
+#if FFT_FIXED_32
# define RSCALE(x) (((x) + 32) >> 6)
-#else /* CONFIG_FFT_FIXED_32 */
+#else /* FFT_FIXED_32 */
# define RSCALE(x) ((x) >> 1)
-#endif /* CONFIG_FFT_FIXED_32 */
+#endif /* FFT_FIXED_32 */
#endif
/**
@@ -60,7 +60,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
goto fail;
- s->tcos = av_malloc(n/2 * sizeof(FFTSample));
+ s->tcos = av_malloc_array(n/2, sizeof(FFTSample));
if (!s->tcos)
goto fail;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mdec.c b/chromium/third_party/ffmpeg/libavcodec/mdec.c
index 1567e14a1f6..d9bb64e31f5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mdec.c
@@ -215,6 +215,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_SIMPLE;
avctx->pix_fmt = AV_PIX_FMT_YUVJ420P;
+ avctx->color_range = AVCOL_RANGE_JPEG;
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/metasound.c b/chromium/third_party/ffmpeg/libavcodec/metasound.c
index 677e959d483..2dab135bdaa 100644
--- a/chromium/third_party/ffmpeg/libavcodec/metasound.c
+++ b/chromium/third_party/ffmpeg/libavcodec/metasound.c
@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
#include <math.h>
#include <stdint.h>
@@ -283,7 +284,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx)
for (;;) {
if (!props->tag) {
- av_log(avctx, AV_LOG_ERROR, "Could not find tag %08X\n", tag);
+ av_log(avctx, AV_LOG_ERROR, "Could not find tag %08"PRIX32"\n", tag);
return AVERROR_INVALIDDATA;
}
if (props->tag == tag) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpeg.h b/chromium/third_party/ffmpeg/libavcodec/mjpeg.h
index 96e18545a7f..73db1dd1eb5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpeg.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpeg.h
@@ -33,10 +33,11 @@
#ifndef AVCODEC_MJPEG_H
#define AVCODEC_MJPEG_H
+#include "libavutil/internal.h"
+
#include "avcodec.h"
#include "put_bits.h"
-
/* JPEG marker codes */
typedef enum {
/* start of frame */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c b/chromium/third_party/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c
index f3672881bc5..6adeaf0ac83 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c
@@ -25,6 +25,10 @@
*/
#include <string.h>
+
+#include "libavutil/error.h"
+#include "libavutil/mem.h"
+
#include "avcodec.h"
#include "mjpeg.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpegbdec.c b/chromium/third_party/ffmpeg/libavcodec/mjpegbdec.c
index f061f0bc260..f6ee7057fdb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpegbdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpegbdec.c
@@ -24,6 +24,8 @@
* Apple MJPEG-B decoder.
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "mjpeg.h"
#include "mjpegdec.h"
@@ -74,13 +76,14 @@ read_header:
}
field_size = get_bits_long(&hgb, 32); /* field size */
- av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
+ av_log(avctx, AV_LOG_DEBUG, "field size: 0x%"PRIx32"\n", field_size);
skip_bits(&hgb, 32); /* padded field size */
second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
+ av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%"PRIx32"\n",
+ second_field_offs);
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
+ av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%"PRIx32"\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
@@ -91,7 +94,7 @@ read_header:
}
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
+ av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%"PRIx32"\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
@@ -100,7 +103,7 @@ read_header:
}
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%"PRIx32"\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
@@ -110,16 +113,16 @@ read_header:
}
sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%"PRIx32"\n", sos_offs);
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
- av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%"PRIx32"\n", sod_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
- if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
+ if (ff_mjpeg_decode_sos(s, NULL, 0, NULL) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpegdec.c b/chromium/third_party/ffmpeg/libavcodec/mjpegdec.c
index 187f32595ad..7150d4a2451 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpegdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpegdec.c
@@ -83,6 +83,17 @@ static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
avpriv_mjpeg_val_ac_chrominance, 251, 0, 0);
}
+static void parse_avid(MJpegDecodeContext *s, uint8_t *buf, int len)
+{
+ s->buggy_avid = 1;
+ if (len > 14 && buf[12] == 1) /* 1 - NTSC */
+ s->interlace_polarity = 1;
+ if (len > 14 && buf[12] == 2) /* 2 - PAL */
+ s->interlace_polarity = 0;
+ if (s->avctx->debug & FF_DEBUG_PICT_INFO)
+ av_log(s->avctx, AV_LOG_INFO, "AVID: len:%d %d\n", len, len > 14 ? buf[12] : -1);
+}
+
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
@@ -120,7 +131,17 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */
s->interlace_polarity = 1; /* bottom field first */
av_log(avctx, AV_LOG_DEBUG, "bottom field first\n");
+ } else if (avctx->field_order == AV_FIELD_UNKNOWN) {
+ if (avctx->codec_tag == AV_RL32("MJPG"))
+ s->interlace_polarity = 1;
}
+
+ if ( avctx->extradata_size > 8
+ && AV_RL32(avctx->extradata) == 0x2C
+ && AV_RL32(avctx->extradata+4) == 0x18) {
+ parse_avid(s, avctx->extradata, avctx->extradata_size);
+ }
+
if (avctx->codec->id == AV_CODEC_ID_AMV)
s->flipped = 1;
@@ -336,7 +357,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->first_picture = 0;
}
- if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
+ if (s->got_picture && s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (s->progressive) {
avpriv_request_sample(s->avctx, "progressively coded interlaced picture");
return AVERROR_INVALIDDATA;
@@ -378,7 +399,30 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
if (s->rgb)
s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_ABGR : AV_PIX_FMT_RGBA64;
else {
- s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_YUVA444P : AV_PIX_FMT_YUVA444P16;
+ if (s->adobe_transform == 0 && s->bits <= 8) {
+ s->avctx->pix_fmt = AV_PIX_FMT_GBRAP;
+ } else {
+ s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_YUVA444P : AV_PIX_FMT_YUVA444P16;
+ s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
+ }
+ }
+ av_assert0(s->nb_components == 4);
+ break;
+ case 0x22111122:
+ if (s->adobe_transform == 0 && s->bits <= 8) {
+ s->avctx->pix_fmt = AV_PIX_FMT_GBRAP;
+ s->upscale_v = 6;
+ s->upscale_h = 6;
+ s->chroma_height = s->height;
+ } else if (s->adobe_transform == 2 && s->bits <= 8) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
+ s->upscale_v = 6;
+ s->upscale_h = 6;
+ s->chroma_height = s->height;
+ s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
+ } else {
+ if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
+ else s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P16;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
av_assert0(s->nb_components == 4);
@@ -389,8 +433,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 2;
- s->upscale_h = (pix_fmt_id == 0x22122100);
+ s->upscale_v = 4;
+ s->upscale_h = 2*(pix_fmt_id == 0x22122100);
s->chroma_height = s->height;
break;
case 0x21211100:
@@ -399,8 +443,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = (pix_fmt_id == 0x22211200);
- s->upscale_h = 2;
+ s->upscale_v = 2*(pix_fmt_id == 0x22211200);
+ s->upscale_h = 4;
s->chroma_height = s->height;
break;
case 0x22221100:
@@ -408,8 +452,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 2;
- s->upscale_h = 2;
+ s->upscale_v = 4;
+ s->upscale_h = 4;
s->chroma_height = s->height / 2;
break;
case 0x11000000:
@@ -433,7 +477,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_h = (pix_fmt_id == 0x22211100) * 2 + (pix_fmt_id == 0x22112100);
+ s->upscale_h = 4 * (pix_fmt_id == 0x22211100) + 2 * (pix_fmt_id == 0x22112100);
s->chroma_height = s->height / 2;
break;
case 0x21111100:
@@ -447,7 +491,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = (pix_fmt_id == 0x22121100) + 1;
+ s->upscale_v = 2 << (pix_fmt_id == 0x22121100);
break;
case 0x22111100:
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
@@ -473,12 +517,20 @@ unk_pixfmt:
s->upscale_h = s->upscale_v = 0;
if (s->nb_components > 1)
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
+ else if (s->palette_index && s->bits <= 8)
+ s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
else if (s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
+ s->pix_desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
+ if (!s->pix_desc) {
+ av_log(s->avctx, AV_LOG_ERROR, "Could not get a pixel format descriptor.\n");
+ return AVERROR_BUG;
+ }
+
av_frame_unref(s->picture_ptr);
if (ff_get_buffer(s->avctx, s->picture_ptr, AV_GET_BUFFER_FLAG_REF) < 0)
return -1;
@@ -486,7 +538,7 @@ unk_pixfmt:
s->picture_ptr->key_frame = 1;
s->got_picture = 1;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced;
av_dlog(s->avctx, "%d %d %d %d %d %d\n",
@@ -510,8 +562,8 @@ unk_pixfmt:
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
- s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
- s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz));
+ s->blocks[i] = av_mallocz_array(size, sizeof(**s->blocks));
+ s->last_nnz[i] = av_mallocz_array(size, sizeof(**s->last_nnz));
if (!s->blocks[i] || !s->last_nnz[i])
return AVERROR(ENOMEM);
s->block_stride[i] = bw * s->h_count[i];
@@ -1094,37 +1146,32 @@ static void shift_output(MJpegDecodeContext *s, uint8_t *ptr, int linesize)
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
int Al, const uint8_t *mb_bitmask,
+ int mb_bitmask_size,
const AVFrame *reference)
{
int i, mb_x, mb_y;
uint8_t *data[MAX_COMPONENTS];
const uint8_t *reference_data[MAX_COMPONENTS];
int linesize[MAX_COMPONENTS];
- GetBitContext mb_bitmask_gb;
+ GetBitContext mb_bitmask_gb = {0}; // initialize to silence gcc warning
int bytes_per_pixel = 1 + (s->bits > 8);
- if (mb_bitmask)
+ if (mb_bitmask) {
+ if (mb_bitmask_size != (s->mb_width * s->mb_height + 7)>>3) {
+ av_log(s->avctx, AV_LOG_ERROR, "mb_bitmask_size mismatches\n");
+ return AVERROR_INVALIDDATA;
+ }
init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width * s->mb_height);
-
- if (s->flipped && s->avctx->lowres) {
- av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with lowres\n");
- s->flipped = 0;
}
+
s->restart_count = 0;
+
for (i = 0; i < nb_components; i++) {
int c = s->comp_index[i];
data[c] = s->picture_ptr->data[c];
reference_data[c] = reference ? reference->data[c] : NULL;
linesize[c] = s->linesize[c];
s->coefs_finished[c] |= 1;
- if (s->flipped && !(s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
- // picture should be flipped upside-down for this codec
- int offset = (linesize[c] * (s->v_scount[i] *
- (8 * s->mb_height - ((s->height / s->v_max) & 7)) - 1));
- data[c] += offset;
- reference_data[c] += offset;
- linesize[c] *= -1;
- }
}
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
@@ -1225,7 +1272,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
}
if (!Al) {
- s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
+ s->coefs_finished[c] |= (2ULL << se) - (1ULL << ss);
last_scan = !~s->coefs_finished[c];
}
@@ -1270,7 +1317,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
}
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
- const AVFrame *reference)
+ int mb_bitmask_size, const AVFrame *reference)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id, ret;
@@ -1402,7 +1449,7 @@ next_field:
} else {
if ((ret = mjpeg_decode_scan(s, nb_components,
prev_shift, point_transform,
- mb_bitmask, reference)) < 0)
+ mb_bitmask, mb_bitmask_size, reference)) < 0)
return ret;
}
}
@@ -1454,8 +1501,11 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
id = get_bits_long(&s->gb, 32);
len -= 6;
- if (s->avctx->debug & FF_DEBUG_STARTCODE)
- av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X len=%d\n", id, len);
+ if (s->avctx->debug & FF_DEBUG_STARTCODE) {
+ char id_str[32];
+ av_get_codec_tag_string(id_str, sizeof(id_str), av_bswap32(id));
+ av_log(s->avctx, AV_LOG_DEBUG, "APPx (%s / %8X) len=%d\n", id_str, id, len);
+ }
/* Buggy AVID, it puts EOI only at every 10th frame. */
/* Also, this fourcc is used by non-avid files too, it holds some
@@ -1511,12 +1561,12 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
}
if (id == AV_RB32("Adob") && (get_bits(&s->gb, 8) == 'e')) {
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found\n");
skip_bits(&s->gb, 16); /* version */
skip_bits(&s->gb, 16); /* flags0 */
skip_bits(&s->gb, 16); /* flags1 */
- skip_bits(&s->gb, 8); /* transform */
+ s->adobe_transform = get_bits(&s->gb, 8);
+ if (s->avctx->debug & FF_DEBUG_PICT_INFO)
+ av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found, transform=%d\n", s->adobe_transform);
len -= 7;
goto out;
}
@@ -1559,6 +1609,45 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
goto out;
}
+ /* JPS extension by VRex */
+ if (s->start_code == APP3 && id == AV_RB32("_JPS") && len >= 10) {
+ int flags, layout, type;
+ if (s->avctx->debug & FF_DEBUG_PICT_INFO)
+ av_log(s->avctx, AV_LOG_INFO, "_JPSJPS_\n");
+
+ skip_bits(&s->gb, 32); len -= 4; /* JPS_ */
+ skip_bits(&s->gb, 16); len -= 2; /* block length */
+ skip_bits(&s->gb, 8); /* reserved */
+ flags = get_bits(&s->gb, 8);
+ layout = get_bits(&s->gb, 8);
+ type = get_bits(&s->gb, 8);
+ len -= 4;
+
+ s->stereo3d = av_stereo3d_alloc();
+ if (!s->stereo3d) {
+ goto out;
+ }
+ if (type == 0) {
+ s->stereo3d->type = AV_STEREO3D_2D;
+ } else if (type == 1) {
+ switch (layout) {
+ case 0x01:
+ s->stereo3d->type = AV_STEREO3D_LINES;
+ break;
+ case 0x02:
+ s->stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 0x03:
+ s->stereo3d->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ }
+ if (!(flags & 0x04)) {
+ s->stereo3d->flags = AV_STEREO3D_FLAG_INVERT;
+ }
+ }
+ goto out;
+ }
+
/* EXIF metadata */
if (s->start_code == APP1 && id == AV_RB32("Exif") && len >= 2) {
GetByteContext gbytes;
@@ -1576,17 +1665,15 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
ret = ff_tdecode_header(&gbytes, &le, &ifd_offset);
if (ret) {
av_log(s->avctx, AV_LOG_ERROR, "mjpeg: invalid TIFF header in EXIF data\n");
- return ret;
- }
-
- bytestream2_seek(&gbytes, ifd_offset, SEEK_SET);
+ } else {
+ bytestream2_seek(&gbytes, ifd_offset, SEEK_SET);
- // read 0th IFD and store the metadata
- // (return values > 0 indicate the presence of subimage metadata)
- ret = ff_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata);
- if (ret < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n");
- return ret;
+ // read 0th IFD and store the metadata
+ // (return values > 0 indicate the presence of subimage metadata)
+ ret = avpriv_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n");
+ }
}
bytes_read = bytestream2_tell(&gbytes);
@@ -1647,9 +1734,7 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
/* buggy avid, it puts EOI only at every 10th frame */
if (!strncmp(cbuf, "AVID", 4)) {
- s->buggy_avid = 1;
- if (len > 14 && cbuf[12] == 1) /* 1 - NTSC, 2 - PAL */
- s->interlace_polarity = 1;
+ parse_avid(s, cbuf, len);
} else if (!strcmp(cbuf, "CS=ITU601"))
s->cs_itu601 = 1;
else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
@@ -1728,7 +1813,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
memset(s->buffer + *unescaped_buf_size, 0,
FF_INPUT_BUFFER_PADDING_SIZE);
- av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %td bytes\n",
+ av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %"PTRDIFF_SPECIFIER" bytes\n",
(buf_end - *buf_ptr) - (dst - s->buffer));
} else if (start_code == SOS && s->ls) {
const uint8_t *src = *buf_ptr;
@@ -1737,8 +1822,6 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
int t = 0, b = 0;
PutBitContext pb;
- s->cur_scan++;
-
/* find marker */
while (src + t < buf_end) {
uint8_t x = src[t++];
@@ -1781,6 +1864,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
@@ -1793,6 +1877,8 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int ret = 0;
av_dict_free(&s->exif_metadata);
+ av_freep(&s->stereo3d);
+ s->adobe_transform = -1;
buf_ptr = buf;
buf_end = buf + buf_size;
@@ -1803,14 +1889,14 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
&unescaped_buf_size);
/* EOF */
if (start_code < 0) {
- goto the_end;
+ break;
} else if (unescaped_buf_size > INT_MAX / 8) {
av_log(avctx, AV_LOG_ERROR,
"MJPEG packet 0x%x too big (%d/%d), corrupt data?\n",
start_code, unescaped_buf_size, buf_size);
return AVERROR_INVALIDDATA;
}
- av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
+ av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%"PTRDIFF_SPECIFIER"\n",
start_code, buf_end - buf_ptr);
ret = init_get_bits8(&s->gb, unescaped_buf_ptr, unescaped_buf_size);
@@ -1906,7 +1992,7 @@ eoi_parser:
if (s->bottom_field == !s->interlace_polarity)
break;
}
- if ((ret = av_frame_ref(data, s->picture_ptr)) < 0)
+ if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
return ret;
*got_frame = 1;
s->got_picture = 0;
@@ -1928,7 +2014,8 @@ eoi_parser:
goto the_end;
case SOS:
- if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
+ s->cur_scan++;
+ if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
goto fail;
break;
@@ -1956,7 +2043,7 @@ eoi_parser:
"marker parser used %d bytes (%d bits)\n",
(get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
}
- if (s->got_picture) {
+ if (s->got_picture && s->cur_scan) {
av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
goto eoi_parser;
}
@@ -1967,65 +2054,134 @@ fail:
return ret;
the_end:
if (s->upscale_h) {
- uint8_t *line = s->picture_ptr->data[s->upscale_h];
+ int p;
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ440P ||
- avctx->pix_fmt == AV_PIX_FMT_YUV440P);
- for (i = 0; i < s->chroma_height; i++) {
- for (index = s->width - 1; index; index--)
- line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
- line += s->linesize[s->upscale_h];
+ avctx->pix_fmt == AV_PIX_FMT_YUV440P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||
+ avctx->pix_fmt == AV_PIX_FMT_GBRAP
+ );
+ for (p = 1; p<4; p++) {
+ uint8_t *line = s->picture_ptr->data[p];
+ if (!(s->upscale_h & (1<<p)))
+ continue;
+ for (i = 0; i < s->chroma_height; i++) {
+ for (index = s->width - 1; index; index--)
+ line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
+ line += s->linesize[p];
+ }
}
}
if (s->upscale_v) {
- uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
- int w;
- avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- w = s->width >> hshift;
+ int p;
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
- avctx->pix_fmt == AV_PIX_FMT_YUV422P);
- for (i = s->height - 1; i; i--) {
- uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]];
- uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]];
- if (src1 == src2) {
- memcpy(dst, src1, w);
- } else {
- for (index = 0; index < w; index++)
- dst[index] = (src1[index] + src2[index]) >> 1;
+ avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||
+ avctx->pix_fmt == AV_PIX_FMT_GBRAP
+ );
+ avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
+ for (p = 1; p < 4; p++) {
+ uint8_t *dst = &((uint8_t *)s->picture_ptr->data[p])[(s->height - 1) * s->linesize[p]];
+ int w;
+ if (!(s->upscale_v & (1<<p)))
+ continue;
+ w = s->width >> hshift;
+ for (i = s->height - 1; i; i--) {
+ uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i / 2 * s->linesize[p]];
+ uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) / 2 * s->linesize[p]];
+ if (src1 == src2) {
+ memcpy(dst, src1, w);
+ } else {
+ for (index = 0; index < w; index++)
+ dst[index] = (src1[index] + src2[index]) >> 1;
+ }
+ dst -= s->linesize[p];
}
- dst -= s->linesize[s->upscale_v];
}
}
- if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
+ if (s->flipped) {
int j;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
for (index=0; index<4; index++) {
uint8_t *dst = s->picture_ptr->data[index];
- int w = s->width;
- int h = s->height;
+ int w = s->picture_ptr->width;
+ int h = s->picture_ptr->height;
if(index && index<3){
w = FF_CEIL_RSHIFT(w, hshift);
h = FF_CEIL_RSHIFT(h, vshift);
}
if(dst){
- uint8_t *dst2 = dst + s->linesize[index]*(h-1);
+ uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1);
for (i=0; i<h/2; i++) {
for (j=0; j<w; j++)
FFSWAP(int, dst[j], dst2[j]);
- dst += s->linesize[index];
- dst2 -= s->linesize[index];
+ dst += s->picture_ptr->linesize[index];
+ dst2 -= s->picture_ptr->linesize[index];
}
}
}
}
+ if (s->adobe_transform == 0 && s->avctx->pix_fmt == AV_PIX_FMT_GBRAP) {
+ int w = s->picture_ptr->width;
+ int h = s->picture_ptr->height;
+ for (i=0; i<h; i++) {
+ int j;
+ uint8_t *dst[4];
+ for (index=0; index<4; index++) {
+ dst[index] = s->picture_ptr->data[index]
+ + s->picture_ptr->linesize[index]*i;
+ }
+ for (j=0; j<w; j++) {
+ int k = dst[3][j];
+ int r = dst[0][j] * k;
+ int g = dst[1][j] * k;
+ int b = dst[2][j] * k;
+ dst[0][j] = g*257 >> 16;
+ dst[1][j] = b*257 >> 16;
+ dst[2][j] = r*257 >> 16;
+ dst[3][j] = 255;
+ }
+ }
+ }
+ if (s->adobe_transform == 2 && s->avctx->pix_fmt == AV_PIX_FMT_YUVA444P) {
+ int w = s->picture_ptr->width;
+ int h = s->picture_ptr->height;
+ for (i=0; i<h; i++) {
+ int j;
+ uint8_t *dst[4];
+ for (index=0; index<4; index++) {
+ dst[index] = s->picture_ptr->data[index]
+ + s->picture_ptr->linesize[index]*i;
+ }
+ for (j=0; j<w; j++) {
+ int k = dst[3][j];
+ int r = (255 - dst[0][j]) * k;
+ int g = (128 - dst[1][j]) * k;
+ int b = (128 - dst[2][j]) * k;
+ dst[0][j] = r*257 >> 16;
+ dst[1][j] = (g*257 >> 16) + 128;
+ dst[2][j] = (b*257 >> 16) + 128;
+ dst[3][j] = 255;
+ }
+ }
+ }
+
+ if (s->stereo3d) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(data);
+ if (stereo) {
+ stereo->type = s->stereo3d->type;
+ stereo->flags = s->stereo3d->flags;
+ }
+ av_freep(&s->stereo3d);
+ }
av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0);
av_dict_free(&s->exif_metadata);
- av_log(avctx, AV_LOG_DEBUG, "decode frame unused %td bytes\n",
+ av_log(avctx, AV_LOG_DEBUG, "decode frame unused %"PTRDIFF_SPECIFIER" bytes\n",
buf_end - buf_ptr);
// return buf_end - buf_ptr;
return buf_ptr - buf;
@@ -2046,7 +2202,8 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
} else if (s->picture_ptr)
av_frame_unref(s->picture_ptr);
- av_free(s->buffer);
+ av_freep(&s->buffer);
+ av_freep(&s->stereo3d);
av_freep(&s->ljpeg_buffer);
s->ljpeg_buffer_size = 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpegdec.h b/chromium/third_party/ffmpeg/libavcodec/mjpegdec.h
index 1335c66b8dd..a94778846e9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpegdec.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpegdec.h
@@ -30,6 +30,8 @@
#define AVCODEC_MJPEGDEC_H
#include "libavutil/log.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "get_bits.h"
@@ -67,6 +69,7 @@ typedef struct MJpegDecodeContext {
int bits; /* bits per component */
int colr;
int xfrm;
+ int adobe_transform;
int maxval;
int near; ///< near lossless bound (si 0 for lossless)
@@ -99,6 +102,7 @@ typedef struct MJpegDecodeContext {
int16_t (*blocks[MAX_COMPONENTS])[64]; ///< intermediate sums (progressive mode)
uint8_t *last_nnz[MAX_COMPONENTS];
uint64_t coefs_finished[MAX_COMPONENTS]; ///< bitmask of which coefs have been completely decoded (progressive mode)
+ int palette_index;
ScanTable scantable;
DSPContext dsp;
HpelDSPContext hdsp;
@@ -120,6 +124,10 @@ typedef struct MJpegDecodeContext {
int extern_huff;
AVDictionary *exif_metadata;
+
+ AVStereo3D *stereo3d; ///!< stereoscopic information (cached, since it is read before frame allocation)
+
+ const AVPixFmtDescriptor *pix_desc;
} MJpegDecodeContext;
int ff_mjpeg_decode_init(AVCodecContext *avctx);
@@ -131,7 +139,8 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s);
int ff_mjpeg_decode_dht(MJpegDecodeContext *s);
int ff_mjpeg_decode_sof(MJpegDecodeContext *s);
int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
- const uint8_t *mb_bitmask, const AVFrame *reference);
+ const uint8_t *mb_bitmask,int mb_bitmask_size,
+ const AVFrame *reference);
int ff_mjpeg_find_marker(MJpegDecodeContext *s,
const uint8_t **buf_ptr, const uint8_t *buf_end,
const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size);
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpegenc.c b/chromium/third_party/ffmpeg/libavcodec/mjpegenc.c
index ffc29fd41f3..842528e5f18 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpegenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpegenc.c
@@ -37,23 +37,18 @@
#include "mjpeg.h"
#include "mjpegenc.h"
-/* use two quantizer tables (one for luminance and one for chrominance) */
-/* not yet working */
-#undef TWOMATRIXES
-
-
av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
{
MJpegContext *m;
if (s->width > 65500 || s->height > 65500) {
av_log(s, AV_LOG_ERROR, "JPEG does not support resolutions above 65500x65500\n");
- return -1;
+ return AVERROR(EINVAL);
}
m = av_malloc(sizeof(MJpegContext));
if (!m)
- return -1;
+ return AVERROR(ENOMEM);
s->min_qcoeff=-1023;
s->max_qcoeff= 1023;
@@ -108,34 +103,35 @@ static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
ScanTable *intra_scantable,
- uint16_t intra_matrix[64],
+ uint16_t luma_intra_matrix[64],
+ uint16_t chroma_intra_matrix[64],
int hsample[3])
{
int i, j, size;
uint8_t *ptr;
if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
+ int matrix_count = 1 + !!memcmp(luma_intra_matrix,
+ chroma_intra_matrix,
+ sizeof(luma_intra_matrix[0]) * 64);
/* quant matrixes */
put_marker(p, DQT);
-#ifdef TWOMATRIXES
- put_bits(p, 16, 2 + 2 * (1 + 64));
-#else
- put_bits(p, 16, 2 + 1 * (1 + 64));
-#endif
+ put_bits(p, 16, 2 + matrix_count * (1 + 64));
put_bits(p, 4, 0); /* 8 bit precision */
put_bits(p, 4, 0); /* table 0 */
for(i=0;i<64;i++) {
j = intra_scantable->permutated[i];
- put_bits(p, 8, intra_matrix[j]);
- }
-#ifdef TWOMATRIXES
- put_bits(p, 4, 0); /* 8 bit precision */
- put_bits(p, 4, 1); /* table 1 */
- for(i=0;i<64;i++) {
- j = s->intra_scantable.permutated[i];
- put_bits(p, 8, s->chroma_intra_matrix[j]);
+ put_bits(p, 8, luma_intra_matrix[j]);
}
-#endif
+
+ if (matrix_count > 1) {
+ put_bits(p, 4, 0); /* 8 bit precision */
+ put_bits(p, 4, 1); /* table 1 */
+ for(i=0;i<64;i++) {
+ j = intra_scantable->permutated[i];
+ put_bits(p, 8, chroma_intra_matrix[j]);
+ }
+ }
}
if(avctx->active_thread_type & FF_THREAD_SLICE){
@@ -232,11 +228,15 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
ScanTable *intra_scantable,
- uint16_t intra_matrix[64])
+ uint16_t luma_intra_matrix[64],
+ uint16_t chroma_intra_matrix[64])
{
const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG && avctx->codec_id != AV_CODEC_ID_AMV;
int hsample[3], vsample[3];
int i;
+ int chroma_matrix = !!memcmp(luma_intra_matrix,
+ chroma_intra_matrix,
+ sizeof(luma_intra_matrix[0])*64);
ff_mjpeg_init_hvsample(avctx, hsample, vsample);
@@ -247,7 +247,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
jpeg_put_comments(avctx, pb);
- jpeg_table_header(avctx, pb, intra_scantable, intra_matrix, hsample);
+ jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
switch (avctx->codec_id) {
case AV_CODEC_ID_MJPEG: put_marker(pb, SOF0 ); break;
@@ -276,21 +276,13 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
put_bits(pb, 8, 2); /* component number */
put_bits(pb, 4, hsample[1]); /* H factor */
put_bits(pb, 4, vsample[1]); /* V factor */
-#ifdef TWOMATRIXES
- put_bits(pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
- put_bits(pb, 8, 0); /* select matrix */
-#endif
+ put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
/* Cr component */
put_bits(pb, 8, 3); /* component number */
put_bits(pb, 4, hsample[2]); /* H factor */
put_bits(pb, 4, vsample[2]); /* V factor */
-#ifdef TWOMATRIXES
- put_bits(pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
- put_bits(pb, 8, 0); /* select matrix */
-#endif
+ put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
/* scan header */
put_marker(pb, SOS);
@@ -495,7 +487,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);
}
-void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64])
+void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
{
int i;
if (s->chroma_format == CHROMA_444) {
@@ -537,23 +529,28 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
{
MpegEncContext *s = avctx->priv_data;
- AVFrame pic = *pic_arg;
- int i;
+ AVFrame *pic;
+ int i, ret;
int chroma_h_shift, chroma_v_shift;
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
//CODEC_FLAG_EMU_EDGE have to be cleared
if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
- return -1;
+ return AVERROR(EINVAL);
+ pic = av_frame_clone(pic_arg);
+ if (!pic)
+ return AVERROR(ENOMEM);
//picture should be flipped upside-down
for(i=0; i < 3; i++) {
int vsample = i ? 2 >> chroma_v_shift : 2;
- pic.data[i] += (pic.linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
- pic.linesize[i] *= -1;
+ pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
+ pic->linesize[i] *= -1;
}
- return ff_MPV_encode_picture(avctx, pkt, &pic, got_packet);
+ ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);
+ av_frame_free(&pic);
+ return ret;
}
#if CONFIG_MJPEG_ENCODER
diff --git a/chromium/third_party/ffmpeg/libavcodec/mjpegenc.h b/chromium/third_party/ffmpeg/libavcodec/mjpegenc.h
index 4b19e214d88..94bb652fba3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mjpegenc.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mjpegenc.h
@@ -53,13 +53,14 @@ int ff_mjpeg_encode_init(MpegEncContext *s);
void ff_mjpeg_encode_close(MpegEncContext *s);
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
ScanTable *intra_scantable,
- uint16_t intra_matrix[64]);
+ uint16_t luma_intra_matrix[64],
+ uint16_t chroma_intra_matrix[64]);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
void ff_mjpeg_encode_stuffing(MpegEncContext *s);
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3]);
void ff_mjpeg_encode_dc(PutBitContext *pb, int val,
uint8_t *huff_size, uint16_t *huff_code);
-void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64]);
+void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
#endif /* AVCODEC_MJPEGENC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlp.h b/chromium/third_party/ffmpeg/libavcodec/mlp.h
index d8d12929037..bb9ca26aa8f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mlp.h
@@ -124,4 +124,14 @@ static inline uint8_t xor_32_to_8(uint32_t value)
return value;
}
+typedef enum THDChannelModifier {
+ THD_CH_MODIFIER_NOTINDICATED = 0x0,
+ THD_CH_MODIFIER_STEREO = 0x0, // Stereo (not Dolby Surround)
+ THD_CH_MODIFIER_LTRT = 0x1, // Dolby Surround
+ THD_CH_MODIFIER_LBINRBIN = 0x2, // Dolby Headphone
+ THD_CH_MODIFIER_MONO = 0x3, // Mono or Dual Mono
+ THD_CH_MODIFIER_NOTSURROUNDEX = 0x1, // Not Dolby Digital EX
+ THD_CH_MODIFIER_SURROUNDEX = 0x2, // Dolby Digital EX
+} THDChannelModifier;
+
#endif /* AVCODEC_MLP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlp_parser.c b/chromium/third_party/ffmpeg/libavcodec/mlp_parser.c
index fcd11680761..dae19e756b2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlp_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mlp_parser.c
@@ -170,14 +170,17 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
mh->group1_samplerate = mlp_samplerate(ratebits);
mh->group2_samplerate = 0;
- skip_bits(gb, 8);
+ skip_bits(gb, 4);
+
+ mh->channel_modifier_thd_stream0 = get_bits(gb, 2);
+ mh->channel_modifier_thd_stream1 = get_bits(gb, 2);
mh->channel_arrangement=
channel_arrangement = get_bits(gb, 5);
mh->channels_thd_stream1 = truehd_channels(channel_arrangement);
mh->channel_layout_thd_stream1 = ff_truehd_layout(channel_arrangement);
- skip_bits(gb, 2);
+ mh->channel_modifier_thd_stream2 = get_bits(gb, 2);
channel_arrangement = get_bits(gb, 13);
mh->channels_thd_stream2 = truehd_channels(channel_arrangement);
@@ -340,7 +343,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
- if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
+ if (avctx->request_channel_layout &&
+ (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
+ avctx->request_channel_layout &&
mh.num_substreams > 1) {
avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
@@ -363,12 +368,16 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
- if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
- mh.num_substreams > 1) {
+ if (avctx->request_channel_layout &&
+ (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
+ avctx->request_channel_layout &&
+ mh.num_substreams > 1) {
avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- } else if (avctx->request_channel_layout == mh.channel_layout_thd_stream1 ||
- !mh.channels_thd_stream2) {
+ } else if (!mh.channels_thd_stream2 ||
+ (avctx->request_channel_layout &&
+ (avctx->request_channel_layout & mh.channel_layout_thd_stream1) ==
+ avctx->request_channel_layout)) {
avctx->channels = mh.channels_thd_stream1;
avctx->channel_layout = mh.channel_layout_thd_stream1;
} else {
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlp_parser.h b/chromium/third_party/ffmpeg/libavcodec/mlp_parser.h
index 9967abbad20..5d1d2e7845c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlp_parser.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mlp_parser.h
@@ -40,6 +40,11 @@ typedef struct MLPHeaderInfo
int group2_samplerate; ///< Sample rate of second substream (MLP only)
int channel_arrangement;
+
+ int channel_modifier_thd_stream0; ///< Channel modifier for substream 0 of TrueHD sreams ("2-channel presentation")
+ int channel_modifier_thd_stream1; ///< Channel modifier for substream 1 of TrueHD sreams ("6-channel presentation")
+ int channel_modifier_thd_stream2; ///< Channel modifier for substream 2 of TrueHD sreams ("8-channel presentation")
+
int channels_mlp; ///< Channel count for MLP streams
int channels_thd_stream1; ///< Channel count for substream 1 of TrueHD streams ("6-channel presentation")
int channels_thd_stream2; ///< Channel count for substream 2 of TrueHD streams ("8-channel presentation")
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlpdec.c b/chromium/third_party/ffmpeg/libavcodec/mlpdec.c
index aab82939aba..d25e78bcf62 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlpdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mlpdec.c
@@ -37,9 +37,16 @@
#include "mlp_parser.h"
#include "mlpdsp.h"
#include "mlp.h"
+#include "config.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
+#if ARCH_ARM
+#define VLC_BITS 5
+#define VLC_STATIC_SIZE 64
+#else
#define VLC_BITS 9
+#define VLC_STATIC_SIZE 512
+#endif
typedef struct SubStream {
/// Set if a valid restart header has been read. Otherwise the substream cannot be decoded.
@@ -60,6 +67,8 @@ typedef struct SubStream {
uint8_t ch_assign[MAX_CHANNELS];
/// The channel layout for this substream
uint64_t ch_layout;
+ /// The matrix encoding mode for this substream
+ enum AVMatrixEncoding matrix_encoding;
/// Channel coding parameters for channels in the substream
ChannelParams channel_params[MAX_CHANNELS];
@@ -191,13 +200,13 @@ static av_cold void init_static(void)
if (!huff_vlc[0].bits) {
INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
&ff_mlp_huffman_tables[0][0][1], 2, 1,
- &ff_mlp_huffman_tables[0][0][0], 2, 1, 512);
+ &ff_mlp_huffman_tables[0][0][0], 2, 1, VLC_STATIC_SIZE);
INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
&ff_mlp_huffman_tables[1][0][1], 2, 1,
- &ff_mlp_huffman_tables[1][0][0], 2, 1, 512);
+ &ff_mlp_huffman_tables[1][0][0], 2, 1, VLC_STATIC_SIZE);
INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
&ff_mlp_huffman_tables[2][0][1], 2, 1,
- &ff_mlp_huffman_tables[2][0][0], 2, 1, 512);
+ &ff_mlp_huffman_tables[2][0][0], 2, 1, VLC_STATIC_SIZE);
}
ff_mlp_init_crc();
@@ -354,6 +363,10 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
else
m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(m->substream[m->max_decoded_substream].ch_assign,
+ m->substream[m->max_decoded_substream].output_shift,
+ m->substream[m->max_decoded_substream].max_matrix_channel,
+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
m->params_valid = 1;
for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@@ -363,10 +376,22 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
* substream is Stereo. Subsequent substreams' layouts are indicated in the
* major sync. */
if (m->avctx->codec_id == AV_CODEC_ID_MLP) {
+ if (mh.stream_type != 0xbb) {
+ avpriv_request_sample(m->avctx,
+ "unexpected stream_type %X in MLP",
+ mh.stream_type);
+ return AVERROR_PATCHWELCOME;
+ }
if ((substr = (mh.num_substreams > 1)))
m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO;
m->substream[substr].ch_layout = mh.channel_layout_mlp;
} else {
+ if (mh.stream_type != 0xba) {
+ avpriv_request_sample(m->avctx,
+ "unexpected stream_type %X in !MLP",
+ mh.stream_type);
+ return AVERROR_PATCHWELCOME;
+ }
if ((substr = (mh.num_substreams > 1)))
m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO;
if (mh.num_substreams > 2)
@@ -386,6 +411,46 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20;
+ /* Parse the TrueHD decoder channel modifiers and set each substream's
+ * AVMatrixEncoding accordingly.
+ *
+ * The meaning of the modifiers depends on the channel layout:
+ *
+ * - THD_CH_MODIFIER_LTRT, THD_CH_MODIFIER_LBINRBIN only apply to 2-channel
+ *
+ * - THD_CH_MODIFIER_MONO applies to 1-channel or 2-channel (dual mono)
+ *
+ * - THD_CH_MODIFIER_SURROUNDEX, THD_CH_MODIFIER_NOTSURROUNDEX only apply to
+ * layouts with an Ls/Rs channel pair
+ */
+ for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
+ m->substream[substr].matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {
+ if (mh.num_substreams > 2 &&
+ mh.channel_layout_thd_stream2 & AV_CH_SIDE_LEFT &&
+ mh.channel_layout_thd_stream2 & AV_CH_SIDE_RIGHT &&
+ mh.channel_modifier_thd_stream2 == THD_CH_MODIFIER_SURROUNDEX)
+ m->substream[2].matrix_encoding = AV_MATRIX_ENCODING_DOLBYEX;
+
+ if (mh.num_substreams > 1 &&
+ mh.channel_layout_thd_stream1 & AV_CH_SIDE_LEFT &&
+ mh.channel_layout_thd_stream1 & AV_CH_SIDE_RIGHT &&
+ mh.channel_modifier_thd_stream1 == THD_CH_MODIFIER_SURROUNDEX)
+ m->substream[1].matrix_encoding = AV_MATRIX_ENCODING_DOLBYEX;
+
+ if (mh.num_substreams > 0)
+ switch (mh.channel_modifier_thd_stream0) {
+ case THD_CH_MODIFIER_LTRT:
+ m->substream[0].matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
+ break;
+ case THD_CH_MODIFIER_LBINRBIN:
+ m->substream[0].matrix_encoding = AV_MATRIX_ENCODING_DOLBYHEADPHONE;
+ break;
+ default:
+ break;
+ }
+ }
+
return 0;
}
@@ -474,8 +539,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
} else
#endif
- if (m->avctx->request_channel_layout == s->ch_layout &&
- m->max_decoded_substream > substr) {
+ if (m->avctx->request_channel_layout && (s->ch_layout & m->avctx->request_channel_layout) ==
+ m->avctx->request_channel_layout && m->max_decoded_substream > substr) {
av_log(m->avctx, AV_LOG_DEBUG,
"Extracting %d-channel downmix (0x%"PRIx64") from substream %d. "
"Further substreams will be skipped.\n",
@@ -551,6 +616,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (substr == m->max_decoded_substream) {
m->avctx->channels = s->max_matrix_channel + 1;
m->avctx->channel_layout = s->ch_layout;
+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
+ s->output_shift,
+ s->max_matrix_channel,
+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
if (m->avctx->codec_id == AV_CODEC_ID_MLP && m->needs_reordering) {
if (m->avctx->channel_layout == (AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY) ||
@@ -796,9 +865,15 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,
return ret;
if (s->param_presence_flags & PARAM_OUTSHIFT)
- if (get_bits1(gbp))
+ if (get_bits1(gbp)) {
for (ch = 0; ch <= s->max_matrix_channel; ch++)
s->output_shift[ch] = get_sbits(gbp, 4);
+ if (substr == m->max_decoded_substream)
+ m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
+ s->output_shift,
+ s->max_matrix_channel,
+ m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
+ }
if (s->param_presence_flags & PARAM_QUANTSTEP)
if (get_bits1(gbp))
@@ -963,7 +1038,7 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
{
SubStream *s = &m->substream[substr];
- unsigned int mat, src_ch, i;
+ unsigned int mat;
unsigned int maxchan;
maxchan = s->max_matrix_channel;
@@ -975,31 +1050,18 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
}
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
- int matrix_noise_shift = s->matrix_noise_shift[mat];
unsigned int dest_ch = s->matrix_out_ch[mat];
- int32_t mask = MSB_MASK(s->quant_step_size[dest_ch]);
- int32_t *coeffs = s->matrix_coeff[mat];
- int index = s->num_primitive_matrices - mat;
- int index2 = 2 * index + 1;
-
- /* TODO: DSPContext? */
-
- for (i = 0; i < s->blockpos; i++) {
- int32_t bypassed_lsb = m->bypassed_lsbs[i][mat];
- int32_t *samples = m->sample_buffer[i];
- int64_t accum = 0;
-
- for (src_ch = 0; src_ch <= maxchan; src_ch++)
- accum += (int64_t) samples[src_ch] * coeffs[src_ch];
-
- if (matrix_noise_shift) {
- index &= m->access_unit_size_pow2 - 1;
- accum += m->noise_buffer[index] << (matrix_noise_shift + 7);
- index += index2;
- }
-
- samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb;
- }
+ m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0],
+ s->matrix_coeff[mat],
+ &m->bypassed_lsbs[0][mat],
+ m->noise_buffer,
+ s->num_primitive_matrices - mat,
+ dest_ch,
+ s->blockpos,
+ maxchan,
+ s->matrix_noise_shift[mat],
+ m->access_unit_size_pow2,
+ MSB_MASK(s->quant_step_size[dest_ch]));
}
}
@@ -1010,9 +1072,6 @@ static int output_data(MLPDecodeContext *m, unsigned int substr,
{
AVCodecContext *avctx = m->avctx;
SubStream *s = &m->substream[substr];
- unsigned int i, out_ch = 0;
- int32_t *data_32;
- int16_t *data_16;
int ret;
int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
@@ -1030,19 +1089,18 @@ static int output_data(MLPDecodeContext *m, unsigned int substr,
frame->nb_samples = s->blockpos;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
- data_32 = (int32_t *)frame->data[0];
- data_16 = (int16_t *)frame->data[0];
-
- for (i = 0; i < s->blockpos; i++) {
- for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
- int mat_ch = s->ch_assign[out_ch];
- int32_t sample = m->sample_buffer[i][mat_ch]
- << s->output_shift[mat_ch];
- s->lossless_check_data ^= (sample & 0xffffff) << mat_ch;
- if (is32) *data_32++ = sample << 8;
- else *data_16++ = sample >> 8;
- }
- }
+ s->lossless_check_data = m->dsp.mlp_pack_output(s->lossless_check_data,
+ s->blockpos,
+ m->sample_buffer,
+ frame->data[0],
+ s->ch_assign,
+ s->output_shift,
+ s->max_matrix_channel,
+ is32);
+
+ /* Update matrix encoding side data */
+ if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) < 0)
+ return ret;
*got_frame_ptr = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlpdsp.c b/chromium/third_party/ffmpeg/libavcodec/mlpdsp.c
index b413e86db5d..3ae8c377081 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlpdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mlpdsp.c
@@ -57,9 +57,82 @@ static void mlp_filter_channel(int32_t *state, const int32_t *coeff,
}
}
+void ff_mlp_rematrix_channel(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t mask)
+{
+ unsigned int src_ch, i;
+ int index2 = 2 * index + 1;
+ for (i = 0; i < blockpos; i++) {
+ int64_t accum = 0;
+
+ for (src_ch = 0; src_ch <= maxchan; src_ch++)
+ accum += (int64_t) samples[src_ch] * coeffs[src_ch];
+
+ if (matrix_noise_shift) {
+ index &= access_unit_size_pow2 - 1;
+ accum += noise_buffer[index] << (matrix_noise_shift + 7);
+ index += index2;
+ }
+
+ samples[dest_ch] = ((accum >> 14) & mask) + *bypassed_lsbs;
+ bypassed_lsbs += MAX_CHANNELS;
+ samples += MAX_CHANNELS;
+ }
+}
+
+static int32_t (*mlp_select_pack_output(uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int)
+{
+ return ff_mlp_pack_output;
+}
+
+int32_t ff_mlp_pack_output(int32_t lossless_check_data,
+ uint16_t blockpos,
+ int32_t (*sample_buffer)[MAX_CHANNELS],
+ void *data,
+ uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32)
+{
+ unsigned int i, out_ch = 0;
+ int32_t *data_32 = data;
+ int16_t *data_16 = data;
+
+ for (i = 0; i < blockpos; i++) {
+ for (out_ch = 0; out_ch <= max_matrix_channel; out_ch++) {
+ int mat_ch = ch_assign[out_ch];
+ int32_t sample = sample_buffer[i][mat_ch]
+ << output_shift[mat_ch];
+ lossless_check_data ^= (sample & 0xffffff) << mat_ch;
+ if (is32)
+ *data_32++ = sample << 8;
+ else
+ *data_16++ = sample >> 8;
+ }
+ }
+ return lossless_check_data;
+}
+
av_cold void ff_mlpdsp_init(MLPDSPContext *c)
{
c->mlp_filter_channel = mlp_filter_channel;
+ c->mlp_rematrix_channel = ff_mlp_rematrix_channel;
+ c->mlp_select_pack_output = mlp_select_pack_output;
+ c->mlp_pack_output = ff_mlp_pack_output;
+ if (ARCH_ARM)
+ ff_mlpdsp_init_arm(c);
if (ARCH_X86)
ff_mlpdsp_init_x86(c);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mlpdsp.h b/chromium/third_party/ffmpeg/libavcodec/mlpdsp.h
index 84a8aa3a3e1..a0edeb77629 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mlpdsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mlpdsp.h
@@ -23,15 +23,61 @@
#define AVCODEC_MLPDSP_H
#include <stdint.h>
+#include "mlp.h"
+
+void ff_mlp_rematrix_channel(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t mask);
+
+int32_t ff_mlp_pack_output(int32_t lossless_check_data,
+ uint16_t blockpos,
+ int32_t (*sample_buffer)[MAX_CHANNELS],
+ void *data,
+ uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32);
typedef struct MLPDSPContext {
void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
int firorder, int iirorder,
unsigned int filter_shift, int32_t mask,
int blocksize, int32_t *sample_buffer);
+ void (*mlp_rematrix_channel)(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t mask);
+ int32_t (*(*mlp_select_pack_output)(uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32))(int32_t, uint16_t, int32_t (*)[], void *, uint8_t*, int8_t *, uint8_t, int);
+ int32_t (*mlp_pack_output)(int32_t lossless_check_data,
+ uint16_t blockpos,
+ int32_t (*sample_buffer)[MAX_CHANNELS],
+ void *data,
+ uint8_t *ch_assign,
+ int8_t *output_shift,
+ uint8_t max_matrix_channel,
+ int is32);
} MLPDSPContext;
void ff_mlpdsp_init(MLPDSPContext *c);
+void ff_mlpdsp_init_arm(MLPDSPContext *c);
void ff_mlpdsp_init_x86(MLPDSPContext *c);
#endif /* AVCODEC_MLPDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/motion_est.c b/chromium/third_party/ffmpeg/libavcodec/motion_est.c
index f4d217bf30f..939dedf17d3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/motion_est.c
+++ b/chromium/third_party/ffmpeg/libavcodec/motion_est.c
@@ -33,6 +33,7 @@
#include "avcodec.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#undef NDEBUG
@@ -285,7 +286,9 @@ static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx,
#include "motion_est_template.c"
-static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
+static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
+ int stride, int h)
+{
return 0;
}
@@ -390,10 +393,9 @@ static int sad_hpel_motion_search(MpegEncContext * s,
int mx, my, dminh;
uint8_t *pix, *ptr;
int stride= c->stride;
- const int flags= c->sub_flags;
LOAD_COMMON
- av_assert2(flags == 0);
+ av_assert2(c->sub_flags == 0);
if(c->skip){
*mx_ptr = 0;
@@ -668,7 +670,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
return INT_MAX;
if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
- dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
+ dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
}
if(c->avctx->mb_cmp&FF_CMP_CHROMA){
@@ -683,15 +685,15 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
if(s->no_rounding){
- s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
- s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
+ s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.f->data[1] + offset, s->uvlinesize, 8);
+ s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8);
}else{
- s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
- s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
+ s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.f->data[1] + offset, s->uvlinesize, 8);
+ s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8);
}
- dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8);
- dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
+ dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8);
+ dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
}
c->pred_x= mx;
@@ -879,7 +881,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_type=0;
Picture * const pic= &s->current_picture;
- init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
+ init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0);
av_assert0(s->quarter_sample==0 || s->quarter_sample==1);
av_assert0(s->linesize == c->stride);
@@ -989,7 +991,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
// if (varc*2 + 200*256 + 50*(s->lambda2>>FF_LAMBDA_SHIFT) > vard){
mb_type|= CANDIDATE_MB_TYPE_INTER;
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
- if(s->flags&CODEC_FLAG_MV0)
+ if (s->mpv_flags & FF_MPV_FLAG_MV0)
if(mx || my)
mb_type |= CANDIDATE_MB_TYPE_SKIPPED; //FIXME check difference
}else{
@@ -1078,7 +1080,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
int P[10][2];
const int shift= 1+s->quarter_sample;
const int xy= mb_x + mb_y*s->mb_stride;
- init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
+ init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0);
av_assert0(s->quarter_sample==0 || s->quarter_sample==1);
@@ -1517,8 +1519,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
int fmin, bmin, dmin, fbmin, bimin, fimin;
int type=0;
const int xy = mb_y*s->mb_stride + mb_x;
- init_ref(c, s->new_picture.f.data, s->last_picture.f.data,
- s->next_picture.f.data, 16 * mb_x, 16 * mb_y, 2);
+ init_ref(c, s->new_picture.f->data, s->last_picture.f->data,
+ s->next_picture.f->data, 16 * mb_x, 16 * mb_y, 2);
get_limits(s, 16*mb_x, 16*mb_y);
@@ -1608,7 +1610,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
}
//FIXME something smarter
if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; //do not try direct mode if it is invalid for this MB
- if(s->codec_id == AV_CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy])
+ if (s->codec_id == AV_CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT &&
+ s->mpv_flags & FF_MPV_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy])
type |= CANDIDATE_MB_TYPE_DIRECT0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/motion_est_template.c b/chromium/third_party/ffmpeg/libavcodec/motion_est_template.c
index 3123edcf925..53a39c0cbee 100644
--- a/chromium/third_party/ffmpeg/libavcodec/motion_est_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/motion_est_template.c
@@ -24,6 +24,8 @@
* Motion estimation template.
*/
+#include "mpegvideo.h"
+
//Let us hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...)
#define LOAD_COMMON\
uint32_t av_unused * const score_map= c->score_map;\
@@ -892,7 +894,8 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int
score_map[0]= dmin;
//FIXME precalc first term below?
- if((s->pict_type == AV_PICTURE_TYPE_B && !(c->flags & FLAG_DIRECT)) || s->flags&CODEC_FLAG_MV0)
+ if ((s->pict_type == AV_PICTURE_TYPE_B && !(c->flags & FLAG_DIRECT)) ||
+ s->mpv_flags & FF_MPV_FLAG_MV0)
dmin += (mv_penalty[pred_x] + mv_penalty[pred_y])*penalty_factor;
/* first line */
diff --git a/chromium/third_party/ffmpeg/libavcodec/motionpixels.c b/chromium/third_party/ffmpeg/libavcodec/motionpixels.c
index 089909a4d8a..13d4759ae6b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/motionpixels.c
+++ b/chromium/third_party/ffmpeg/libavcodec/motionpixels.c
@@ -77,10 +77,10 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
motionpixels_tableinit();
mp->avctx = avctx;
ff_dsputil_init(&mp->dsp, avctx);
- mp->changes_map = av_mallocz(avctx->width * h4);
+ mp->changes_map = av_mallocz_array(avctx->width, h4);
mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
- mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel));
- mp->hpt = av_mallocz(h4 * w4 / 16 * sizeof(YuvPixel));
+ mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel));
+ mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel));
if (!mp->changes_map || !mp->vpt || !mp->hpt) {
av_freep(&mp->changes_map);
av_freep(&mp->vpt);
diff --git a/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.c b/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.c
index 31e5cdf710e..14b7b9bb8ca 100644
--- a/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.c
+++ b/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.c
@@ -23,7 +23,7 @@
#include <stdlib.h>
#define CONFIG_HARDCODED_TABLES 0
#define MAX_NEG_CROP 0
-#define ff_cropTbl ((uint8_t *)NULL)
+#define ff_crop_tab ((uint8_t *)NULL)
#include "motionpixels_tablegen.h"
#include "tableprint.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.h b/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.h
index b9802e589df..8fb840f0fad 100644
--- a/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.h
+++ b/chromium/third_party/ffmpeg/libavcodec/motionpixels_tablegen.h
@@ -30,7 +30,7 @@ typedef struct YuvPixel {
} YuvPixel;
static int mp_yuv_to_rgb(int y, int v, int u, int clip_rgb) {
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int r, g, b;
r = (1000 * y + 701 * v) / 1000;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpc8.c b/chromium/third_party/ffmpeg/libavcodec/mpc8.c
index 2f58805e188..29c65f9ef54 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpc8.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpc8.c
@@ -29,7 +29,6 @@
#include "libavutil/lfg.h"
#include "avcodec.h"
#include "get_bits.h"
-#include "dsputil.h"
#include "internal.h"
#include "mpegaudiodsp.h"
@@ -119,7 +118,6 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
}
memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
av_lfg_init(&c->rnd, 0xDEADBEEF);
- ff_dsputil_init(&c->dsp, avctx);
ff_mpadsp_init(&c->mpadsp);
ff_mpc_init();
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg12.c b/chromium/third_party/ffmpeg/libavcodec/mpeg12.c
index c391ffda0e5..f4786c0ce40 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg12.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg12.c
@@ -31,7 +31,6 @@
#include "internal.h"
#include "avcodec.h"
-#include "dsputil.h"
#include "mpegvideo.h"
#include "error_resilience.h"
#include "mpeg12.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg12dec.c b/chromium/third_party/ffmpeg/libavcodec/mpeg12dec.c
index 11048670af0..f77fc6e1a84 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg12dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg12dec.c
@@ -25,33 +25,41 @@
* MPEG-1/2 decoder
*/
+#define UNCHECKED_BITSTREAM_READER 1
+#include <inttypes.h>
+
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
-#include "internal.h"
+#include "libavutil/stereo3d.h"
+
#include "avcodec.h"
+#include "bytestream.h"
#include "dsputil.h"
-#include "mpegvideo.h"
#include "error_resilience.h"
+#include "internal.h"
#include "mpeg12.h"
#include "mpeg12data.h"
-#include "bytestream.h"
-#include "vdpau_internal.h"
-#include "xvmc_internal.h"
+#include "mpegutils.h"
+#include "mpegvideo.h"
#include "thread.h"
#include "version.h"
+#include "vdpau_internal.h"
+#include "xvmc_internal.h"
typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
- int repeat_field; /* true if we must repeat the field */
- AVPanScan pan_scan; /**< some temporary storage for the panscan */
+ int repeat_field; /* true if we must repeat the field */
+ AVPanScan pan_scan; /* some temporary storage for the panscan */
+ AVStereo3D stereo3d;
+ int has_stereo3d;
uint8_t *a53_caption;
int a53_caption_size;
int slice_count;
int save_aspect_info;
int save_width, save_height, save_progressive_seq;
- AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator
- int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame?
+ AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */
+ int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */
int tmpgexs;
int first_slice;
int extradata_decoded;
@@ -84,10 +92,10 @@ static const uint32_t btype2mb_type[11] = {
};
static const uint8_t non_linear_qscale[32] = {
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8,10,12,14,16,18,20,22,
- 24,28,32,36,40,44,48,52,
- 56,64,72,80,88,96,104,112,
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 10, 12, 14, 16, 18, 20, 22,
+ 24, 28, 32, 36, 40, 44, 48, 52,
+ 56, 64, 72, 80, 88, 96, 104, 112,
};
/* as H.263, but only 17 codes */
@@ -96,12 +104,10 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
int code, sign, val, shift;
code = get_vlc2(&s->gb, ff_mv_vlc.table, MV_VLC_BITS, 2);
- if (code == 0) {
+ if (code == 0)
return pred;
- }
- if (code < 0) {
+ if (code < 0)
return 0xffff;
- }
sign = get_bits1(&s->gb);
shift = fcode - 1;
@@ -119,12 +125,22 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
return sign_extend(val, 5 + shift);
}
-static inline int mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
+#define check_scantable_index(ctx, x) \
+ do { \
+ if ((x) > 63) { \
+ av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
+ ctx->mb_x, ctx->mb_y); \
+ return AVERROR_INVALIDDATA; \
+ } \
+ } while (0)
+
+static inline int mpeg1_decode_block_intra(MpegEncContext *s,
+ int16_t *block, int n)
{
int level, dc, diff, i, j, run;
int component;
- RLTable *rl = &ff_rl_mpeg1;
- uint8_t * const scantable = s->intra_scantable.permutated;
+ RLTable *rl = &ff_rl_mpeg1;
+ uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->intra_matrix;
const int qscale = s->qscale;
@@ -141,31 +157,40 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, in
i = 0;
{
OPEN_READER(re, &s->gb);
+ UPDATE_CACHE(re, &s->gb);
+ if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ goto end;
+
/* now quantify & encode AC coefficients */
for (;;) {
- UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
- if (level == 127) {
- break;
- } else if (level != 0) {
+ if (level != 0) {
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
level = (level - 1) | 1;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
+ SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_SBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
- level = SHOW_UBITS(re, &s->gb, 8) - 256; LAST_SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8) - 256;
+ SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
- level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
}
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
if (level < 0) {
level = -level;
@@ -177,17 +202,19 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, in
level = (level - 1) | 1;
}
}
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
block[j] = level;
+ if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ break;
+
+ UPDATE_CACHE(re, &s->gb);
}
+end:
+ LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = i;
- return 0;
+ return 0;
}
int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
@@ -195,11 +222,12 @@ int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
return mpeg1_decode_block_intra(s, block, n);
}
-static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
+static inline int mpeg1_decode_block_inter(MpegEncContext *s,
+ int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
- uint8_t * const scantable = s->intra_scantable.permutated;
+ RLTable *rl = &ff_rl_mpeg1;
+ uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
@@ -208,7 +236,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, in
i = -1;
// special case for first coefficient, no need to add second VLC table
UPDATE_CACHE(re, &s->gb);
- if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
+ if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale * quant_matrix[0]) >> 5;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
@@ -216,31 +244,39 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, in
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
goto end;
}
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_SBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
- level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8) - 256;
+ SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
- level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
}
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
if (level < 0) {
level = -level;
@@ -252,13 +288,9 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, in
level = (level - 1) | 1;
}
}
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
block[j] = level;
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
@@ -275,19 +307,20 @@ end:
* Changing this would eat up any speed benefits it has.
* Do not use "fast" flag if you need the code to be robust.
*/
-static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
+static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,
+ int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
- uint8_t * const scantable = s->intra_scantable.permutated;
- const int qscale = s->qscale;
+ RLTable *rl = &ff_rl_mpeg1;
+ uint8_t *const scantable = s->intra_scantable.permutated;
+ const int qscale = s->qscale;
{
OPEN_READER(re, &s->gb);
i = -1;
- // special case for first coefficient, no need to add second VLC table
+ // Special case for first coefficient, no need to add second VLC table.
UPDATE_CACHE(re, &s->gb);
- if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
+ if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale) >> 1;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
@@ -295,32 +328,40 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *bloc
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
goto end;
}
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_SBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
- level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8) - 256;
+ SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
- level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
+ level = SHOW_UBITS(re, &s->gb, 8);
+ SKIP_BITS(re, &s->gb, 8);
}
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
if (level < 0) {
level = -level;
@@ -334,7 +375,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *bloc
}
block[j] = level;
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
@@ -346,12 +387,12 @@ end:
return 0;
}
-
-static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n)
+static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
+ int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
- uint8_t * const scantable = s->intra_scantable.permutated;
+ uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
@@ -366,37 +407,43 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block
else
quant_matrix = s->chroma_inter_matrix;
- // special case for first coefficient, no need to add second VLC table
+ // Special case for first coefficient, no need to add second VLC table.
UPDATE_CACHE(re, &s->gb);
- if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
- level= (3 * qscale * quant_matrix[0]) >> 5;
+ if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
+ level = (3 * qscale * quant_matrix[0]) >> 5;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
mismatch ^= level;
i++;
SKIP_BITS(re, &s->gb, 2);
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
goto end;
}
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
+ level = SHOW_SBITS(re, &s->gb, 12);
+ SKIP_BITS(re, &s->gb, 12);
i += run;
+ check_scantable_index(s, i);
j = scantable[i];
if (level < 0) {
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
@@ -405,14 +452,10 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
}
}
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
mismatch ^= level;
block[j] = level;
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
@@ -435,22 +478,22 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
- uint8_t * const scantable = s->intra_scantable.permutated;
- const int qscale = s->qscale;
+ RLTable *rl = &ff_rl_mpeg1;
+ uint8_t *const scantable = s->intra_scantable.permutated;
+ const int qscale = s->qscale;
OPEN_READER(re, &s->gb);
i = -1;
// special case for first coefficient, no need to add second VLC table
UPDATE_CACHE(re, &s->gb);
- if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
+ if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale) >> 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF)
goto end;
}
@@ -460,18 +503,21 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
if (level != 0) {
i += run;
- j = scantable[i];
+ j = scantable[i];
level = ((level * 2 + 1) * qscale) >> 1;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
+ level = SHOW_SBITS(re, &s->gb, 12);
+ SKIP_BITS(re, &s->gb, 12);
i += run;
- j = scantable[i];
+ j = scantable[i];
if (level < 0) {
level = ((-level * 2 + 1) * qscale) >> 1;
level = -level;
@@ -481,8 +527,9 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
}
block[j] = level;
- if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
+ if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFFFFFF || i > 63)
break;
+
UPDATE_CACHE(re, &s->gb);
}
end:
@@ -492,13 +539,13 @@ end:
return 0;
}
-
-static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
+static inline int mpeg2_decode_block_intra(MpegEncContext *s,
+ int16_t *block, int n)
{
int level, dc, diff, i, j, run;
int component;
RLTable *rl;
- uint8_t * const scantable = s->intra_scantable.permutated;
+ uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
@@ -506,10 +553,10 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, in
/* DC coefficient */
if (n < 4) {
quant_matrix = s->intra_matrix;
- component = 0;
+ component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
- component = (n & 1) + 1;
+ component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
@@ -531,23 +578,29 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, in
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
- j = scantable[i];
+ check_scantable_index(s, i);
+ j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
+ level = SHOW_SBITS(re, &s->gb, 12);
+ SKIP_BITS(re, &s->gb, 12);
i += run;
- j = scantable[i];
+ check_scantable_index(s, i);
+ j = scantable[i];
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
@@ -555,10 +608,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, in
level = (level * qscale * quant_matrix[j]) >> 4;
}
}
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
mismatch ^= level;
block[j] = level;
@@ -576,22 +625,23 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, in
* Changing this would eat up any speed benefits it has.
* Do not use "fast" flag if you need the code to be robust.
*/
-static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
+static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
+ int16_t *block, int n)
{
- int level, dc, diff, j, run;
+ int level, dc, diff, i, j, run;
int component;
RLTable *rl;
- uint8_t * scantable = s->intra_scantable.permutated;
+ uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
/* DC coefficient */
if (n < 4) {
quant_matrix = s->intra_matrix;
- component = 0;
+ component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
- component = (n & 1) + 1;
+ component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
@@ -600,6 +650,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *bloc
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
+ i = 0;
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
@@ -610,23 +661,27 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *bloc
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ TEX_VLC_BITS, 2, 0);
- if (level == 127) {
+ if (level >= 64 || i > 63) {
break;
} else if (level != 0) {
- scantable += run;
- j = *scantable;
+ i += run;
+ j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
+ level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+ SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
- run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
+ run = SHOW_UBITS(re, &s->gb, 6) + 1;
+ LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
- scantable += run;
- j = *scantable;
+ level = SHOW_SBITS(re, &s->gb, 12);
+ SKIP_BITS(re, &s->gb, 12);
+ i += run;
+ j = scantable[i];
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
@@ -640,7 +695,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *bloc
CLOSE_READER(re, &s->gb);
}
- s->block_last_index[n] = scantable - s->intra_scantable.permutated;
+ s->block_last_index[n] = i;
return 0;
}
@@ -658,21 +713,12 @@ static inline int get_dmv(MpegEncContext *s)
static inline int get_qscale(MpegEncContext *s)
{
int qscale = get_bits(&s->gb, 5);
- if (s->q_scale_type) {
+ if (s->q_scale_type)
return non_linear_qscale[qscale];
- } else {
+ else
return qscale << 1;
- }
}
-static void exchange_uv(MpegEncContext *s)
-{
- int16_t (*tmp)[64];
-
- tmp = s->pblocks[4];
- s->pblocks[4] = s->pblocks[5];
- s->pblocks[5] = tmp;
-}
/* motion type (for MPEG-2) */
#define MT_FIELD 1
@@ -692,19 +738,21 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
if (s->mb_skip_run-- != 0) {
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->mb_skipped = 1;
- s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
+ s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
+ MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
int mb_type;
if (s->mb_x)
mb_type = s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
else
- mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all
+ // FIXME not sure if this is allowed in MPEG at all
+ mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1];
if (IS_INTRA(mb_type)) {
av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
return -1;
}
- s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
+ s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
mb_type | MB_TYPE_SKIP;
if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
@@ -719,7 +767,9 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
case AV_PICTURE_TYPE_I:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "invalid mb type in I Frame at %d %d\n",
+ s->mb_x, s->mb_y);
return -1;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
@@ -730,7 +780,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
case AV_PICTURE_TYPE_P:
mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = ptype2mb_type[mb_type];
@@ -738,7 +789,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
case AV_PICTURE_TYPE_B:
mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = btype2mb_type[mb_type];
@@ -749,15 +801,14 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
if (IS_INTRA(mb_type)) {
s->dsp.clear_blocks(s->block[0]);
- if (!s->chroma_y_shift) {
+ if (!s->chroma_y_shift)
s->dsp.clear_blocks(s->block[6]);
- }
/* compute DCT type */
- if (s->picture_structure == PICT_FRAME && // FIXME add an interlaced_dct coded var?
- !s->frame_pred_frame_dct) {
+ // FIXME: add an interlaced_dct coded var?
+ if (s->picture_structure == PICT_FRAME &&
+ !s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
- }
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
@@ -765,45 +816,40 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
if (s->concealment_motion_vectors) {
/* just parse them */
if (s->picture_structure != PICT_FRAME)
- skip_bits1(&s->gb); /* field select */
+ skip_bits1(&s->gb); /* field select */
- s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
- mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
- s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
- mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
+ s->mv[0][0][0] =
+ s->last_mv[0][0][0] =
+ s->last_mv[0][1][0] = mpeg_decode_motion(s, s->mpeg_f_code[0][0],
+ s->last_mv[0][0][0]);
+ s->mv[0][0][1] =
+ s->last_mv[0][0][1] =
+ s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1],
+ s->last_mv[0][0][1]);
skip_bits1(&s->gb); /* marker */
- } else
- memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
+ } else {
+ /* reset mv prediction */
+ memset(s->last_mv, 0, sizeof(s->last_mv));
+ }
s->mb_intra = 1;
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
// if 1, we memcpy blocks in xvmcvideo
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
+ if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
- if (s->swap_uv) {
- exchange_uv(s);
- }
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->flags2 & CODEC_FLAG2_FAST) {
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 6; i++)
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
- }
} else {
- for (i = 0; i < mb_block_count; i++) {
+ for (i = 0; i < mb_block_count; i++)
if (mpeg2_decode_block_intra(s, *s->pblocks[i], i) < 0)
return -1;
- }
}
} else {
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 6; i++)
if (mpeg1_decode_block_intra(s, *s->pblocks[i], i) < 0)
return -1;
- }
}
} else {
if (mb_type & MB_TYPE_ZERO_MV) {
@@ -816,8 +862,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->interlaced_dct = get_bits1(&s->gb);
s->mv_type = MV_TYPE_16X16;
} else {
- s->mv_type = MV_TYPE_FIELD;
- mb_type |= MB_TYPE_INTERLACED;
+ s->mv_type = MV_TYPE_FIELD;
+ mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0] = s->picture_structure - 1;
}
@@ -828,15 +874,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
+ s->mv[0][0][0] = 0;
+ s->mv[0][0][1] = 0;
} else {
av_assert2(mb_type & MB_TYPE_L0L1);
// FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED
/* get additional motion vector type */
- if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct)
+ if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {
motion_type = MT_FRAME;
- else {
+ } else {
motion_type = get_bits(&s->gb, 2);
if (s->picture_structure == PICT_FRAME && HAS_CBP(mb_type))
s->interlaced_dct = get_bits1(&s->gb);
@@ -851,15 +897,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
switch (motion_type) {
case MT_FRAME: /* or MT_16X8 */
if (s->picture_structure == PICT_FRAME) {
- mb_type |= MB_TYPE_16x16;
+ mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
/* MT_FRAME */
- s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] =
- mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
- s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] =
- mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
+ s->mv[i][0][0] =
+ s->last_mv[i][0][0] =
+ s->last_mv[i][1][0] =
+ mpeg_decode_motion(s, s->mpeg_f_code[i][0],
+ s->last_mv[i][0][0]);
+ s->mv[i][0][1] =
+ s->last_mv[i][0][1] =
+ s->last_mv[i][1][1] =
+ mpeg_decode_motion(s, s->mpeg_f_code[i][1],
+ s->last_mv[i][0][1]);
/* full_pel: only for MPEG-1 */
if (s->full_pel[i]) {
s->mv[i][0][0] <<= 1;
@@ -868,7 +920,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
} else {
- mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
+ mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
@@ -925,7 +977,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
break;
case MT_DMV:
- if(s->progressive_sequence){
+ if (s->progressive_sequence){
av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
return -1;
}
@@ -979,7 +1031,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
break;
default:
- av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
@@ -990,39 +1043,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
cbp = get_vlc2(&s->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (mb_block_count > 6) {
- cbp <<= mb_block_count - 6;
- cbp |= get_bits(&s->gb, mb_block_count - 6);
- s->dsp.clear_blocks(s->block[6]);
+ cbp <<= mb_block_count - 6;
+ cbp |= get_bits(&s->gb, mb_block_count - 6);
+ s->dsp.clear_blocks(s->block[6]);
}
if (cbp <= 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
}
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- //if 1, we memcpy blocks in xvmcvideo
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
+ // if 1, we memcpy blocks in xvmcvideo
+ if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, cbp);
- if (s->swap_uv) {
- exchange_uv(s);
- }
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->flags2 & CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
- if (cbp & 32) {
+ if (cbp & 32)
mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
- } else {
+ else
s->block_last_index[i] = -1;
- }
cbp += cbp;
}
} else {
- cbp <<= 12-mb_block_count;
+ cbp <<= 12 - mb_block_count;
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11)) {
@@ -1037,11 +1082,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
} else {
if (s->flags2 & CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
- if (cbp & 32) {
+ if (cbp & 32)
mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
- } else {
+ else
s->block_last_index[i] = -1;
- }
cbp += cbp;
}
} else {
@@ -1069,14 +1113,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
static av_cold int mpeg_decode_init(AVCodecContext *avctx)
{
- Mpeg1Context *s = avctx->priv_data;
+ Mpeg1Context *s = avctx->priv_data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
int i;
/* we need some permutation to store matrices,
* until MPV_common_init() sets the real permutation. */
for (i = 0; i < 64; i++)
- s2->dsp.idct_permutation[i]=i;
+ s2->dsp.idct_permutation[i] = i;
ff_MPV_decode_defaults(s2);
@@ -1090,7 +1134,7 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
s->mpeg_enc_ctx.picture_number = 0;
s->repeat_field = 0;
s->mpeg_enc_ctx.codec_id = avctx->codec->id;
- avctx->color_range = AVCOL_RANGE_MPEG;
+ avctx->color_range = AVCOL_RANGE_MPEG;
if (avctx->codec->id == AV_CODEC_ID_MPEG1VIDEO)
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
else
@@ -1098,17 +1142,21 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
return 0;
}
-static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from)
+static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
+ const AVCodecContext *avctx_from)
{
Mpeg1Context *ctx = avctx->priv_data, *ctx_from = avctx_from->priv_data;
MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx;
int err;
- if (avctx == avctx_from || !ctx_from->mpeg_enc_ctx_allocated || !s1->context_initialized)
+ if (avctx == avctx_from ||
+ !ctx_from->mpeg_enc_ctx_allocated ||
+ !s1->context_initialized)
return 0;
err = ff_mpeg_update_thread_context(avctx, avctx_from);
- if (err) return err;
+ if (err)
+ return err;
if (!ctx->mpeg_enc_ctx_allocated)
memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext));
@@ -1127,18 +1175,14 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
memcpy(temp_matrix, matrix, 64 * sizeof(uint16_t));
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < 64; i++)
matrix[new_perm[i]] = temp_matrix[old_perm[i]];
- }
}
static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
-#if FF_API_XVMC
-#if CONFIG_MPEG_XVMC_DECODER
- AV_PIX_FMT_XVMC_MPEG2_IDCT,
- AV_PIX_FMT_XVMC_MPEG2_MC,
+#if CONFIG_MPEG1_XVMC_HWACCEL
+ AV_PIX_FMT_XVMC,
#endif
-#endif /* FF_API_XVMC */
#if CONFIG_MPEG1_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU_MPEG1,
AV_PIX_FMT_VDPAU,
@@ -1148,12 +1192,9 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
};
static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
-#if FF_API_XVMC
-#if CONFIG_MPEG_XVMC_DECODER
- AV_PIX_FMT_XVMC_MPEG2_IDCT,
- AV_PIX_FMT_XVMC_MPEG2_MC,
+#if CONFIG_MPEG2_XVMC_HWACCEL
+ AV_PIX_FMT_XVMC,
#endif
-#endif /* FF_API_XVMC */
#if CONFIG_MPEG2_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU_MPEG2,
AV_PIX_FMT_VDPAU,
@@ -1174,15 +1215,15 @@ static inline int uses_vdpau(AVCodecContext *avctx) {
static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
- if(s->chroma_format < 2) {
+ if (s->chroma_format < 2)
return ff_thread_get_format(avctx,
avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO ?
mpeg1_hwaccel_pixfmt_list_420 :
mpeg2_hwaccel_pixfmt_list_420);
- } else if(s->chroma_format == 2)
+ else if (s->chroma_format == 2)
return AV_PIX_FMT_YUV422P;
else
return AV_PIX_FMT_YUV444P;
@@ -1190,46 +1231,39 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
{
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- if (avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_IDCT && avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_MC) {
- avctx->xvmc_acceleration = 0;
- } else if (!avctx->xvmc_acceleration) {
- avctx->xvmc_acceleration = 2;
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
- avctx->hwaccel = ff_find_hwaccel(avctx);
// until then pix_fmt may be changed right after codec init
-#if FF_API_XVMC
- if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
-#else
- if (
-#endif
- avctx->hwaccel || uses_vdpau(avctx))
+ if (avctx->hwaccel || uses_vdpau(avctx))
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_SIMPLE;
+
+ if (avctx->hwaccel && avctx->pix_fmt == AV_PIX_FMT_XVMC) {
+ Mpeg1Context *s1 = avctx->priv_data;
+ MpegEncContext *s = &s1->mpeg_enc_ctx;
+
+ s->pack_pblocks = 1;
+#if FF_API_XVMC
+ avctx->xvmc_acceleration = 2;
+#endif /* FF_API_XVMC */
+ }
}
/* Call this function when we know all parameters.
* It may be called in different places for MPEG-1 and MPEG-2. */
static int mpeg_decode_postinit(AVCodecContext *avctx)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
uint8_t old_permutation[64];
int ret;
- if ((s1->mpeg_enc_ctx_allocated == 0) ||
- avctx->coded_width != s->width ||
- avctx->coded_height != s->height ||
+ if ((s1->mpeg_enc_ctx_allocated == 0) ||
+ avctx->coded_width != s->width ||
+ avctx->coded_height != s->height ||
s1->save_width != s->width ||
s1->save_height != s->height ||
s1->save_aspect_info != s->aspect_ratio_info ||
(s1->save_progressive_seq != s->progressive_sequence && (s->height&31)) ||
- 0)
- {
-
+ 0) {
if (s1->mpeg_enc_ctx_allocated) {
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
@@ -1261,45 +1295,49 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
avctx->has_b_frames = !s->low_delay;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
- //MPEG-1 fps
+ // MPEG-1 fps
avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num;
avctx->time_base.num = ff_mpeg12_frame_rate_tab[s->frame_rate_index].den;
- //MPEG-1 aspect
- avctx->sample_aspect_ratio = av_d2q(1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255);
- avctx->ticks_per_frame=1;
- } else {//MPEG-2
- //MPEG-2 fps
+ // MPEG-1 aspect
+ avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
+ avctx->ticks_per_frame = 1;
+ } else { // MPEG-2
+ // MPEG-2 fps
av_reduce(&s->avctx->time_base.den,
&s->avctx->time_base.num,
- ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2,
+ ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
- //MPEG-2 aspect
+ // MPEG-2 aspect
if (s->aspect_ratio_info > 1) {
AVRational dar =
av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
- (AVRational) {s1->pan_scan.width, s1->pan_scan.height}),
- (AVRational) {s->width, s->height});
-
- // we ignore the spec here and guess a bit as reality does not match the spec, see for example
- // res_change_ffmpeg_aspect.ts and sequence-display-aspect.mpg
- // issue1613, 621, 562
+ (AVRational) { s1->pan_scan.width,
+ s1->pan_scan.height }),
+ (AVRational) { s->width, s->height });
+
+ /* We ignore the spec here and guess a bit as reality does not
+ * match the spec, see for example res_change_ffmpeg_aspect.ts
+ * and sequence-display-aspect.mpg.
+ * issue1613, 621, 562 */
if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
- (av_cmp_q(dar, (AVRational) {4, 3}) && av_cmp_q(dar, (AVRational) {16, 9}))) {
+ (av_cmp_q(dar, (AVRational) { 4, 3 }) &&
+ av_cmp_q(dar, (AVRational) { 16, 9 }))) {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
- (AVRational) {s->width, s->height});
+ (AVRational) { s->width, s->height });
} else {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
- (AVRational) {s1->pan_scan.width, s1->pan_scan.height});
-//issue1613 4/3 16/9 -> 16/9
-//res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
-//widescreen-issue562.mpg 4/3 16/9 -> 16/9
+ (AVRational) { s1->pan_scan.width, s1->pan_scan.height });
+// issue1613 4/3 16/9 -> 16/9
+// res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
+// widescreen-issue562.mpg 4/3 16/9 -> 16/9
// s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height});
av_dlog(avctx, "A %d/%d\n",
- ff_mpeg2_aspect[s->aspect_ratio_info].num, ff_mpeg2_aspect[s->aspect_ratio_info].den);
+ ff_mpeg2_aspect[s->aspect_ratio_info].num,
+ ff_mpeg2_aspect[s->aspect_ratio_info].den);
av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
}
@@ -1329,14 +1367,14 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
return 0;
}
-static int mpeg1_decode_picture(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
+static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
+ int buf_size)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ref, f_code, vbv_delay;
- init_get_bits(&s->gb, buf, buf_size*8);
+ init_get_bits(&s->gb, buf, buf_size * 8);
ref = get_bits(&s->gb, 10); /* temporal ref */
s->pict_type = get_bits(&s->gb, 3);
@@ -1345,7 +1383,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
vbv_delay = get_bits(&s->gb, 16);
s->vbv_delay = vbv_delay;
- if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) {
+ if (s->pict_type == AV_PICTURE_TYPE_P ||
+ s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
@@ -1363,11 +1402,12 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture.f->pict_type = s->pict_type;
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
+ av_log(avctx, AV_LOG_DEBUG,
+ "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
s->y_dc_scale = 8;
s->c_dc_scale = 8;
@@ -1376,14 +1416,14 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
{
- MpegEncContext *s= &s1->mpeg_enc_ctx;
+ MpegEncContext *s = &s1->mpeg_enc_ctx;
int horiz_size_ext, vert_size_ext;
int bit_rate_ext;
skip_bits(&s->gb, 1); /* profile and level esc*/
s->avctx->profile = get_bits(&s->gb, 3);
s->avctx->level = get_bits(&s->gb, 4);
- s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */
+ s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */
s->chroma_format = get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */
horiz_size_ext = get_bits(&s->gb, 2);
vert_size_ext = get_bits(&s->gb, 2);
@@ -1402,12 +1442,13 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1;
av_dlog(s->avctx, "sequence extension\n");
- s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
+ s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%d\n",
- s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, s->avctx->rc_buffer_size, s->bit_rate);
-
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%d\n",
+ s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format,
+ s->avctx->rc_buffer_size, s->bit_rate);
}
static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
@@ -1423,7 +1464,7 @@ static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
s->avctx->colorspace = get_bits(&s->gb, 8);
}
w = get_bits(&s->gb, 14);
- skip_bits(&s->gb, 1); //marker
+ skip_bits(&s->gb, 1); // marker
h = get_bits(&s->gb, 14);
// remaining 3 bits are zero padding
@@ -1461,13 +1502,15 @@ static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
}
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "pde (%d,%d) (%d,%d) (%d,%d)\n",
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "pde (%"PRId16",%"PRId16") (%"PRId16",%"PRId16") (%"PRId16",%"PRId16")\n",
s1->pan_scan.position[0][0], s1->pan_scan.position[0][1],
s1->pan_scan.position[1][0], s1->pan_scan.position[1][1],
s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]);
}
-static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra)
+static int load_matrix(MpegEncContext *s, uint16_t matrix0[64],
+ uint16_t matrix1[64], int intra)
{
int i;
@@ -1493,23 +1536,28 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
{
av_dlog(s->avctx, "matrix extension\n");
- if (get_bits1(&s->gb)) load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
- if (get_bits1(&s->gb)) load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
- if (get_bits1(&s->gb)) load_matrix(s, s->chroma_intra_matrix, NULL , 1);
- if (get_bits1(&s->gb)) load_matrix(s, s->chroma_inter_matrix, NULL , 0);
+ if (get_bits1(&s->gb))
+ load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
+ if (get_bits1(&s->gb))
+ load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
+ if (get_bits1(&s->gb))
+ load_matrix(s, s->chroma_intra_matrix, NULL, 1);
+ if (get_bits1(&s->gb))
+ load_matrix(s, s->chroma_inter_matrix, NULL, 0);
}
static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
{
MpegEncContext *s = &s1->mpeg_enc_ctx;
- s->full_pel[0] = s->full_pel[1] = 0;
+ s->full_pel[0] = s->full_pel[1] = 0;
s->mpeg_f_code[0][0] = get_bits(&s->gb, 4);
s->mpeg_f_code[0][1] = get_bits(&s->gb, 4);
s->mpeg_f_code[1][0] = get_bits(&s->gb, 4);
s->mpeg_f_code[1][1] = get_bits(&s->gb, 4);
if (!s->pict_type && s1->mpeg_enc_ctx_allocated) {
- av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code, guessing missing values\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Missing picture start code, guessing missing values\n");
if (s->mpeg_f_code[1][0] == 15 && s->mpeg_f_code[1][1] == 15) {
if (s->mpeg_f_code[0][0] == 15 && s->mpeg_f_code[0][1] == 15)
s->pict_type = AV_PICTURE_TYPE_I;
@@ -1517,8 +1565,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
s->pict_type = AV_PICTURE_TYPE_P;
} else
s->pict_type = AV_PICTURE_TYPE_B;
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture.f->pict_type = s->pict_type;
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
}
s->mpeg_f_code[0][0] += !s->mpeg_f_code[0][0];
s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1];
@@ -1537,7 +1585,6 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
s->chroma_420_type = get_bits1(&s->gb);
s->progressive_frame = get_bits1(&s->gb);
-
if (s->alternate_scan) {
ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);
ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);
@@ -1561,7 +1608,7 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
{
AVCodecContext *avctx = s->avctx;
- Mpeg1Context *s1 = (Mpeg1Context*)s;
+ Mpeg1Context *s1 = (Mpeg1Context *) s;
/* start frame decoding */
if (s->first_field || s->picture_structure == PICT_FRAME) {
@@ -1573,19 +1620,19 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
ff_mpeg_er_frame_start(s);
/* first check if we must repeat the frame */
- s->current_picture_ptr->f.repeat_pict = 0;
+ s->current_picture_ptr->f->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
- s->current_picture_ptr->f.repeat_pict = 4;
+ s->current_picture_ptr->f->repeat_pict = 4;
else
- s->current_picture_ptr->f.repeat_pict = 2;
+ s->current_picture_ptr->f->repeat_pict = 2;
} else if (s->progressive_frame) {
- s->current_picture_ptr->f.repeat_pict = 1;
+ s->current_picture_ptr->f->repeat_pict = 1;
}
}
- pan_scan = av_frame_new_side_data(&s->current_picture_ptr->f,
+ pan_scan = av_frame_new_side_data(s->current_picture_ptr->f,
AV_FRAME_DATA_PANSCAN,
sizeof(s1->pan_scan));
if (!pan_scan)
@@ -1594,12 +1641,21 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (s1->a53_caption) {
AVFrameSideData *sd = av_frame_new_side_data(
- &s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
+ s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
s1->a53_caption_size);
if (sd)
memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
av_freep(&s1->a53_caption);
}
+
+ if (s1->has_stereo3d) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(s->current_picture_ptr->f);
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ *stereo = s1->stereo3d;
+ s1->has_stereo3d = 0;
+ }
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_finish_setup(avctx);
} else { // second field
@@ -1613,14 +1669,15 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (s->avctx->hwaccel &&
(s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
if (s->avctx->hwaccel->end_frame(s->avctx) < 0)
- av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode first field\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "hardware accelerator failed to decode first field\n");
}
for (i = 0; i < 4; i++) {
- s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];
- if (s->picture_structure == PICT_BOTTOM_FIELD) {
- s->current_picture.f.data[i] += s->current_picture_ptr->f.linesize[i];
- }
+ s->current_picture.f->data[i] = s->current_picture_ptr->f->data[i];
+ if (s->picture_structure == PICT_BOTTOM_FIELD)
+ s->current_picture.f->data[i] +=
+ s->current_picture_ptr->f->linesize[i];
}
}
@@ -1629,16 +1686,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
return -1;
}
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
-// MPV_frame_start will call this function too,
-// but we need to call it on every field
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- if (ff_xvmc_field_start(s, avctx) < 0)
- return -1;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
-
return 0;
}
@@ -1664,7 +1711,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
av_assert0(mb_y < s->mb_height);
init_get_bits(&s->gb, *buf, buf_size * 8);
- if(s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16)
+ if (s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16)
skip_bits(&s->gb, 3);
ff_mpeg1_clean_buffers(s);
@@ -1694,9 +1741,8 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
return -1;
}
if (code >= 33) {
- if (code == 33) {
+ if (code == 33)
s->mb_x += 33;
- }
/* otherwise, stuffing, nothing to do */
} else {
s->mb_x += code;
@@ -1705,12 +1751,12 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
}
}
- if (s->mb_x >= (unsigned)s->mb_width) {
+ if (s->mb_x >= (unsigned) s->mb_width) {
av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
return -1;
}
- if (avctx->hwaccel) {
+ if (avctx->hwaccel && avctx->hwaccel->decode_slice) {
const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
int start_code = -1;
buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
@@ -1730,28 +1776,35 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
if (s->mb_y == 0 && s->mb_x == 0 && (s->first_field || s->picture_structure == PICT_FRAME)) {
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
- s->qscale, s->mpeg_f_code[0][0], s->mpeg_f_code[0][1], s->mpeg_f_code[1][0], s->mpeg_f_code[1][1],
- s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
- s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"",
- s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,
- s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :"");
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
+ s->qscale,
+ s->mpeg_f_code[0][0], s->mpeg_f_code[0][1],
+ s->mpeg_f_code[1][0], s->mpeg_f_code[1][1],
+ s->pict_type == AV_PICTURE_TYPE_I ? "I" :
+ (s->pict_type == AV_PICTURE_TYPE_P ? "P" :
+ (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
+ s->progressive_sequence ? "ps" : "",
+ s->progressive_frame ? "pf" : "",
+ s->alternate_scan ? "alt" : "",
+ s->top_field_first ? "top" : "",
+ s->intra_dc_precision, s->picture_structure,
+ s->frame_pred_frame_dct, s->concealment_motion_vectors,
+ s->q_scale_type, s->intra_vlc_format,
+ s->repeat_first_field, s->chroma_420_type ? "420" : "");
}
}
for (;;) {
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
// If 1, we memcpy blocks in xvmcvideo.
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
+ if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_init_block(s); // set s->block
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
if (mpeg_decode_mb(s, s->block) < 0)
return -1;
- if (s->current_picture.motion_val[0] && !s->encoding) { // note motion_val is normally NULL unless we want to extract the MVs
+ // Note motion_val is normally NULL unless we want to extract the MVs.
+ if (s->current_picture.motion_val[0] && !s->encoding) {
const int wrap = s->b8_stride;
int xy = s->mb_x * 2 + s->mb_y * 2 * wrap;
int b8_xy = 4 * (s->mb_x + s->mb_y * s->mb_stride);
@@ -1759,26 +1812,29 @@ FF_ENABLE_DEPRECATION_WARNINGS
for (i = 0; i < 2; i++) {
for (dir = 0; dir < 2; dir++) {
- if (s->mb_intra || (dir == 1 && s->pict_type != AV_PICTURE_TYPE_B)) {
+ if (s->mb_intra ||
+ (dir == 1 && s->pict_type != AV_PICTURE_TYPE_B)) {
motion_x = motion_y = 0;
- } else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)) {
+ } else if (s->mv_type == MV_TYPE_16X16 ||
+ (s->mv_type == MV_TYPE_FIELD && field_pic)) {
motion_x = s->mv[dir][0][0];
motion_y = s->mv[dir][0][1];
- } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ {
+ } else { /* if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8)) */
motion_x = s->mv[dir][i][0];
motion_y = s->mv[dir][i][1];
}
- s->current_picture.motion_val[dir][xy ][0] = motion_x;
- s->current_picture.motion_val[dir][xy ][1] = motion_y;
+ s->current_picture.motion_val[dir][xy][0] = motion_x;
+ s->current_picture.motion_val[dir][xy][1] = motion_y;
s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
- s->current_picture.ref_index [dir][b8_xy ] =
+ s->current_picture.ref_index [dir][b8_xy] =
s->current_picture.ref_index [dir][b8_xy + 1] = s->field_select[dir][i];
- av_assert2(s->field_select[dir][i] == 0 || s->field_select[dir][i] == 1);
+ av_assert2(s->field_select[dir][i] == 0 ||
+ s->field_select[dir][i] == 1);
}
- xy += wrap;
- b8_xy +=2;
+ xy += wrap;
+ b8_xy += 2;
}
}
@@ -1791,17 +1847,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (++s->mb_x >= s->mb_width) {
const int mb_size = 16 >> s->avctx->lowres;
- ff_mpeg_draw_horiz_band(s, mb_size*(s->mb_y >> field_pic), mb_size);
+ ff_mpeg_draw_horiz_band(s, mb_size * (s->mb_y >> field_pic), mb_size);
ff_MPV_report_decode_progress(s);
- s->mb_x = 0;
+ s->mb_x = 0;
s->mb_y += 1 << field_pic;
if (s->mb_y >= s->mb_height) {
int left = get_bits_left(&s->gb);
- int is_d10 = s->chroma_format == 2 && s->pict_type == AV_PICTURE_TYPE_I && avctx->profile == 0 && avctx->level == 5
- && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0
- && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/;
+ int is_d10 = s->chroma_format == 2 &&
+ s->pict_type == AV_PICTURE_TYPE_I &&
+ avctx->profile == 0 && avctx->level == 5 &&
+ s->intra_dc_precision == 2 &&
+ s->q_scale_type == 1 && s->alternate_scan == 0 &&
+ s->progressive_frame == 0
+ /* vbv_delay == 0xBBB || 0xE10 */;
if (left >= 32 && !is_d10) {
GetBitContext gb = s->gb;
@@ -1812,9 +1872,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
- if (left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10)
- || ((avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) && left > 8)) {
- av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23)));
+ if (left < 0 ||
+ (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
+ ((avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) && left > 8)) {
+ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n",
+ left, show_bits(&s->gb, FFMIN(left, 23)));
return -1;
} else
goto eos;
@@ -1853,7 +1915,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (s->mb_skip_run) {
int i;
if (s->pict_type == AV_PICTURE_TYPE_I) {
- av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
@@ -1883,14 +1946,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
eos: // end of slice
- *buf += (get_bits_count(&s->gb)-1)/8;
+ if (get_bits_left(&s->gb) < 0)
+ return AVERROR_INVALIDDATA;
+ *buf += (get_bits_count(&s->gb) - 1) / 8;
av_dlog(s, "y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
return 0;
}
static int slice_decode_thread(AVCodecContext *c, void *arg)
{
- MpegEncContext *s = *(void**)arg;
+ MpegEncContext *s = *(void **) arg;
const uint8_t *buf = s->gb.buffer;
int mb_y = s->start_mb_y;
const int field_pic = s->picture_structure != PICT_FRAME;
@@ -1910,18 +1975,22 @@ static int slice_decode_thread(AVCodecContext *c, void *arg)
if (c->err_recognition & AV_EF_EXPLODE)
return ret;
if (s->resync_mb_x >= 0 && s->resync_mb_y >= 0)
- ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
+ s->mb_x, s->mb_y,
+ ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
} else {
- ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
+ ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
+ s->mb_x - 1, s->mb_y,
+ ER_AC_END | ER_DC_END | ER_MV_END);
}
if (s->mb_y == s->end_mb_y)
return 0;
start_code = -1;
- buf = avpriv_find_start_code(buf, s->gb.buffer_end, &start_code);
- mb_y= start_code - SLICE_MIN_START_CODE;
- if(s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16)
+ buf = avpriv_find_start_code(buf, s->gb.buffer_end, &start_code);
+ mb_y = start_code - SLICE_MIN_START_CODE;
+ if (s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16)
mb_y += (*buf&0xE0)<<2;
mb_y <<= field_pic;
if (s->picture_structure == PICT_BOTTOM_FIELD)
@@ -1937,7 +2006,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg)
*/
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
@@ -1945,18 +2014,12 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
if (s->avctx->hwaccel) {
if (s->avctx->hwaccel->end_frame(s->avctx) < 0)
- av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "hardware accelerator failed to decode picture\n");
}
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- ff_xvmc_field_end(s);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
-
/* end of slice reached */
- if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field && !s1->first_slice) {
+ if (/* s->mb_y << field_pic == s->mb_height && */ !s->first_field && !s1->first_slice) {
/* end of image */
ff_er_frame_end(&s->er);
@@ -1964,7 +2027,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- int ret = av_frame_ref(pict, &s->current_picture_ptr->f);
+ int ret = av_frame_ref(pict, s->current_picture_ptr->f);
if (ret < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
@@ -1975,7 +2038,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* latency of 1 frame for I- and P-frames */
/* XXX: use another variable than picture_number */
if (s->last_picture_ptr != NULL) {
- int ret = av_frame_ref(pict, &s->last_picture_ptr->f);
+ int ret = av_frame_ref(pict, s->last_picture_ptr->f);
if (ret < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
@@ -1992,18 +2055,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int mpeg1_decode_sequence(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int width, height;
int i, v, j;
- init_get_bits(&s->gb, buf, buf_size*8);
+ init_get_bits(&s->gb, buf, buf_size * 8);
width = get_bits(&s->gb, 12);
height = get_bits(&s->gb, 12);
if (width == 0 || height == 0) {
- av_log(avctx, AV_LOG_WARNING, "Invalid horizontal or vertical size "
- "value.\n");
+ av_log(avctx, AV_LOG_WARNING,
+ "Invalid horizontal or vertical size value.\n");
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
}
@@ -2052,14 +2115,15 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
return -1;
}
- /* we set MPEG-2 parameters so that it emulates MPEG-1 */
+ /* We set MPEG-2 parameters so that it emulates MPEG-1. */
s->progressive_sequence = 1;
s->progressive_frame = 1;
s->picture_structure = PICT_FRAME;
s->first_field = 0;
s->frame_pred_frame_dct = 1;
s->chroma_format = 1;
- s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
+ s->codec_id =
+ s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
s->out_format = FMT_MPEG1;
s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER
if (s->flags & CODEC_FLAG_LOW_DELAY)
@@ -2074,7 +2138,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
static int vcr2_init_sequence(AVCodecContext *avctx)
{
- Mpeg1Context *s1 = avctx->priv_data;
+ Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int i, v;
@@ -2084,10 +2148,10 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
ff_MPV_common_end(s);
s1->mpeg_enc_ctx_allocated = 0;
}
- s->width = avctx->coded_width;
- s->height = avctx->coded_height;
+ s->width = avctx->coded_width;
+ s->height = avctx->coded_height;
avctx->has_b_frames = 0; // true?
- s->low_delay = 1;
+ s->low_delay = 1;
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
setup_hwaccel_for_pixfmt(avctx);
@@ -2125,7 +2189,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
return 0;
}
-
static int mpeg_decode_a53_cc(AVCodecContext *avctx,
const uint8_t *p, int buf_size)
{
@@ -2139,14 +2202,13 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
if (cc_count > 0 && buf_size >= 7 + cc_count * 3) {
av_freep(&s1->a53_caption);
s1->a53_caption_size = cc_count * 3;
- s1->a53_caption = av_malloc(s1->a53_caption_size);
- if (s1->a53_caption) {
+ s1->a53_caption = av_malloc(s1->a53_caption_size);
+ if (s1->a53_caption)
memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
- }
}
return 1;
} else if (buf_size >= 11 &&
- p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) {
+ p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) {
/* extract DVD CC data */
int cc_count = 0;
int i;
@@ -2158,7 +2220,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
if (cc_count > 0) {
av_freep(&s1->a53_caption);
s1->a53_caption_size = cc_count * 6;
- s1->a53_caption = av_malloc(s1->a53_caption_size);
+ s1->a53_caption = av_malloc(s1->a53_caption_size);
if (s1->a53_caption) {
uint8_t field1 = !!(p[4] & 0x80);
uint8_t *cap = s1->a53_caption;
@@ -2186,10 +2248,10 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
Mpeg1Context *s = avctx->priv_data;
const uint8_t *buf_end = p + buf_size;
- if(buf_size > 29){
+ if (buf_size > 29){
int i;
for(i=0; i<20; i++)
- if(!memcmp(p+i, "\0TMPGEXS\0", 9)){
+ if (!memcmp(p+i, "\0TMPGEXS\0", 9)){
s->tmpgexs= 1;
}
@@ -2213,6 +2275,35 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
return;
avctx->dtg_active_format = p[0] & 0x0f;
}
+ } else if (buf_end - p >= 6 &&
+ p[0] == 'J' && p[1] == 'P' && p[2] == '3' && p[3] == 'D' &&
+ p[4] == 0x03) { // S3D_video_format_length
+ // the 0x7F mask ignores the reserved_bit value
+ const uint8_t S3D_video_format_type = p[5] & 0x7F;
+
+ if (S3D_video_format_type == 0x03 ||
+ S3D_video_format_type == 0x04 ||
+ S3D_video_format_type == 0x08 ||
+ S3D_video_format_type == 0x23) {
+ Mpeg1Context *s1 = avctx->priv_data;
+
+ s1->has_stereo3d = 1;
+
+ switch (S3D_video_format_type) {
+ case 0x03:
+ s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case 0x04:
+ s1->stereo3d.type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case 0x08:
+ s1->stereo3d.type = AV_STEREO3D_2D;
+ break;
+ case 0x23:
+ s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ break;
+ }
+ }
} else if (mpeg_decode_a53_cc(avctx, p, buf_size)) {
return;
}
@@ -2226,14 +2317,14 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
int broken_link;
int64_t tc;
- init_get_bits(&s->gb, buf, buf_size*8);
+ init_get_bits(&s->gb, buf, buf_size * 8);
tc = avctx->timecode_frame_start = get_bits(&s->gb, 25);
s->closed_gop = get_bits1(&s->gb);
- /*broken_link indicate that after editing the
- reference frames of the first B-Frames after GOP I-Frame
- are missing (open gop)*/
+ /* broken_link indicate that after editing the
+ * reference frames of the first B-Frames after GOP I-Frame
+ * are missing (open gop) */
broken_link = get_bits1(&s->gb);
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
@@ -2245,9 +2336,8 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
}
}
-static int decode_chunks(AVCodecContext *avctx,
- AVFrame *picture, int *got_output,
- const uint8_t *buf, int buf_size)
+static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
+ int *got_output, const uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
@@ -2263,12 +2353,15 @@ static int decode_chunks(AVCodecContext *avctx,
buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &start_code);
if (start_code > 0x1ff) {
if (!skip_frame) {
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) &&
+ if (HAVE_THREADS &&
+ (avctx->active_thread_type & FF_THREAD_SLICE) &&
!avctx->hwaccel) {
int i;
av_assert0(avctx->thread_count > 1);
- avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*));
+ avctx->execute(avctx, slice_decode_thread,
+ &s2->thread_context[0], NULL,
+ s->slice_count, sizeof(void *));
for (i = 0; i < s->slice_count; i++)
s2->er.error_count += s2->thread_context[i]->er.error_count;
}
@@ -2281,7 +2374,8 @@ static int decode_chunks(AVCodecContext *avctx,
if (ret < 0)
return ret;
else if (ret) {
- if (s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
+ // FIXME: merge with the stuff in mpeg_decode_slice
+ if (s2->last_picture_ptr || s2->low_delay)
*got_output = 1;
}
}
@@ -2295,19 +2389,20 @@ static int decode_chunks(AVCodecContext *avctx,
input_size = buf_end - buf_ptr;
- if (avctx->debug & FF_DEBUG_STARTCODE) {
- av_log(avctx, AV_LOG_DEBUG, "%3X at %td left %d\n", start_code, buf_ptr-buf, input_size);
- }
+ if (avctx->debug & FF_DEBUG_STARTCODE)
+ av_log(avctx, AV_LOG_DEBUG, "%3"PRIX32" at %"PTRDIFF_SPECIFIER" left %d\n",
+ start_code, buf_ptr - buf, input_size);
/* prepare data for next start code */
switch (start_code) {
case SEQ_START_CODE:
if (last_code == 0) {
mpeg1_decode_sequence(avctx, buf_ptr, input_size);
- if(buf != avctx->extradata)
- s->sync=1;
+ if (buf != avctx->extradata)
+ s->sync = 1;
} else {
- av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code);
+ av_log(avctx, AV_LOG_ERROR,
+ "ignoring SEQ_START_CODE after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
@@ -2328,7 +2423,7 @@ static int decode_chunks(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
- if(s->tmpgexs){
+ if (s->tmpgexs){
s2->intra_dc_precision= 3;
s2->intra_matrix[0]= 1;
}
@@ -2338,7 +2433,7 @@ static int decode_chunks(AVCodecContext *avctx,
avctx->execute(avctx, slice_decode_thread,
s2->thread_context, NULL,
- s->slice_count, sizeof(void*));
+ s->slice_count, sizeof(void *));
for (i = 0; i < s->slice_count; i++)
s2->er.error_count += s2->thread_context[i]->er.error_count;
s->slice_count = 0;
@@ -2346,30 +2441,33 @@ static int decode_chunks(AVCodecContext *avctx,
if (last_code == 0 || last_code == SLICE_MIN_START_CODE) {
ret = mpeg_decode_postinit(avctx);
if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "mpeg_decode_postinit() failure\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "mpeg_decode_postinit() failure\n");
return ret;
}
- /* we have a complete image: we try to decompress it */
+ /* We have a complete image: we try to decompress it. */
if (mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0)
s2->pict_type = 0;
s->first_slice = 1;
- last_code = PICTURE_START_CODE;
+ last_code = PICTURE_START_CODE;
} else {
- av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code);
+ av_log(avctx, AV_LOG_ERROR,
+ "ignoring pic after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
case EXT_START_CODE:
- init_get_bits(&s2->gb, buf_ptr, input_size*8);
+ init_get_bits(&s2->gb, buf_ptr, input_size * 8);
switch (get_bits(&s2->gb, 4)) {
case 0x1:
if (last_code == 0) {
- mpeg_decode_sequence_extension(s);
+ mpeg_decode_sequence_extension(s);
} else {
- av_log(avctx, AV_LOG_ERROR, "ignoring seq ext after %X\n", last_code);
+ av_log(avctx, AV_LOG_ERROR,
+ "ignoring seq ext after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
@@ -2387,7 +2485,8 @@ static int decode_chunks(AVCodecContext *avctx,
if (last_code == PICTURE_START_CODE) {
mpeg_decode_picture_coding_extension(s);
} else {
- av_log(avctx, AV_LOG_ERROR, "ignoring pic cod ext after %X\n", last_code);
+ av_log(avctx, AV_LOG_ERROR,
+ "ignoring pic cod ext after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
@@ -2399,11 +2498,12 @@ static int decode_chunks(AVCodecContext *avctx,
break;
case GOP_START_CODE:
if (last_code == 0) {
- s2->first_field=0;
+ s2->first_field = 0;
mpeg_decode_gop(avctx, buf_ptr, input_size);
- s->sync=1;
+ s->sync = 1;
} else {
- av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code);
+ av_log(avctx, AV_LOG_ERROR,
+ "ignoring GOP_START_CODE after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
@@ -2411,20 +2511,22 @@ static int decode_chunks(AVCodecContext *avctx,
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE && last_code == PICTURE_START_CODE) {
-
if (s2->progressive_sequence && !s2->progressive_frame) {
s2->progressive_frame = 1;
- av_log(s2->avctx, AV_LOG_ERROR, "interlaced frame in progressive sequence, ignoring\n");
+ av_log(s2->avctx, AV_LOG_ERROR,
+ "interlaced frame in progressive sequence, ignoring\n");
}
- if (s2->picture_structure == 0 || (s2->progressive_frame && s2->picture_structure != PICT_FRAME)) {
- av_log(s2->avctx, AV_LOG_ERROR, "picture_structure %d invalid, ignoring\n", s2->picture_structure);
+ if (s2->picture_structure == 0 ||
+ (s2->progressive_frame && s2->picture_structure != PICT_FRAME)) {
+ av_log(s2->avctx, AV_LOG_ERROR,
+ "picture_structure %d invalid, ignoring\n",
+ s2->picture_structure);
s2->picture_structure = PICT_FRAME;
}
- if (s2->progressive_sequence && !s2->frame_pred_frame_dct) {
+ if (s2->progressive_sequence && !s2->frame_pred_frame_dct)
av_log(s2->avctx, AV_LOG_WARNING, "invalid frame_pred_frame_dct\n");
- }
if (s2->picture_structure == PICT_FRAME) {
s2->first_field = 0;
@@ -2440,7 +2542,7 @@ static int decode_chunks(AVCodecContext *avctx,
const int field_pic = s2->picture_structure != PICT_FRAME;
int mb_y = start_code - SLICE_MIN_START_CODE;
last_code = SLICE_MIN_START_CODE;
- if(s2->codec_id != AV_CODEC_ID_MPEG1VIDEO && s2->mb_height > 2800/16)
+ if (s2->codec_id != AV_CODEC_ID_MPEG1VIDEO && s2->mb_height > 2800/16)
mb_y += (*buf_ptr&0xE0)<<2;
mb_y <<= field_pic;
@@ -2453,12 +2555,14 @@ static int decode_chunks(AVCodecContext *avctx,
}
if (mb_y >= s2->mb_height) {
- av_log(s2->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s2->mb_height);
+ av_log(s2->avctx, AV_LOG_ERROR,
+ "slice below image (%d >= %d)\n", mb_y, s2->mb_height);
return -1;
}
if (s2->last_picture_ptr == NULL) {
- /* Skip B-frames if we do not have reference frames and gop is not closed */
+ /* Skip B-frames if we do not have reference frames and
+ * GOP is not closed. */
if (s2->pict_type == AV_PICTURE_TYPE_B) {
if (!s2->closed_gop) {
skip_frame = 1;
@@ -2467,17 +2571,20 @@ static int decode_chunks(AVCodecContext *avctx,
}
}
if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->flags2 & CODEC_FLAG2_SHOW_ALL))
- s->sync=1;
+ s->sync = 1;
if (s2->next_picture_ptr == NULL) {
- /* Skip P-frames if we do not have a reference frame or we have an invalid header. */
+ /* Skip P-frames if we do not have a reference frame or
+ * we have an invalid header. */
if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) {
skip_frame = 1;
break;
}
}
- if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type == AV_PICTURE_TYPE_B) ||
- (avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type != AV_PICTURE_TYPE_I) ||
- avctx->skip_frame >= AVDISCARD_ALL) {
+ if ((avctx->skip_frame >= AVDISCARD_NONREF &&
+ s2->pict_type == AV_PICTURE_TYPE_B) ||
+ (avctx->skip_frame >= AVDISCARD_NONKEY &&
+ s2->pict_type != AV_PICTURE_TYPE_I) ||
+ avctx->skip_frame >= AVDISCARD_ALL) {
skip_frame = 1;
break;
}
@@ -2486,7 +2593,8 @@ static int decode_chunks(AVCodecContext *avctx,
break;
if (s2->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom)
+ if (mb_y < avctx->skip_top ||
+ mb_y >= s2->mb_height - avctx->skip_bottom)
break;
}
@@ -2498,13 +2606,14 @@ static int decode_chunks(AVCodecContext *avctx,
}
if (s->first_slice) {
- skip_frame = 0;
+ skip_frame = 0;
s->first_slice = 0;
if (mpeg_field_start(s2, buf, buf_size) < 0)
return -1;
}
if (!s2->current_picture_ptr) {
- av_log(avctx, AV_LOG_ERROR, "current_picture not initialized\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "current_picture not initialized\n");
return AVERROR_INVALIDDATA;
}
@@ -2513,7 +2622,8 @@ static int decode_chunks(AVCodecContext *avctx,
break;
}
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) &&
+ if (HAVE_THREADS &&
+ (avctx->active_thread_type & FF_THREAD_SLICE) &&
!avctx->hwaccel) {
int threshold = (s2->mb_height * s->slice_count +
s2->slice_context_count / 2) /
@@ -2525,13 +2635,12 @@ static int decode_chunks(AVCodecContext *avctx,
thread_context->start_mb_y = mb_y;
thread_context->end_mb_y = s2->mb_height;
if (s->slice_count) {
- s2->thread_context[s->slice_count-1]->end_mb_y = mb_y;
- ret = ff_update_duplicate_context(thread_context,
- s2);
+ s2->thread_context[s->slice_count - 1]->end_mb_y = mb_y;
+ ret = ff_update_duplicate_context(thread_context, s2);
if (ret < 0)
return ret;
}
- init_get_bits(&thread_context->gb, buf_ptr, input_size*8);
+ init_get_bits(&thread_context->gb, buf_ptr, input_size * 8);
s->slice_count++;
}
buf_ptr += 2; // FIXME add minimum number of bytes per slice
@@ -2543,9 +2652,13 @@ static int decode_chunks(AVCodecContext *avctx,
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0)
- ff_er_add_slice(&s2->er, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
+ ff_er_add_slice(&s2->er, s2->resync_mb_x,
+ s2->resync_mb_y, s2->mb_x, s2->mb_y,
+ ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
} else {
- ff_er_add_slice(&s2->er, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
+ ff_er_add_slice(&s2->er, s2->resync_mb_x,
+ s2->resync_mb_y, s2->mb_x - 1, s2->mb_y,
+ ER_AC_END | ER_DC_END | ER_MV_END);
}
}
}
@@ -2554,9 +2667,8 @@ static int decode_chunks(AVCodecContext *avctx,
}
}
-static int mpeg_decode_frame(AVCodecContext *avctx,
- void *data, int *got_output,
- AVPacket *avpkt)
+static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_output, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int ret;
@@ -2564,12 +2676,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
Mpeg1Context *s = avctx->priv_data;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
- av_dlog(avctx, "fill_buffer\n");
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
/* special case for last picture */
if (s2->low_delay == 0 && s2->next_picture_ptr) {
- int ret = av_frame_ref(picture, &s2->next_picture_ptr->f);
+ int ret = av_frame_ref(picture, s2->next_picture_ptr->f);
if (ret < 0)
return ret;
@@ -2581,9 +2692,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
}
if (s2->flags & CODEC_FLAG_TRUNCATED) {
- int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
+ int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf,
+ buf_size, NULL);
- if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
+ if (ff_combine_frame(&s2->parse_context, next,
+ (const uint8_t **) &buf, &buf_size) < 0)
return buf_size;
}
@@ -2596,8 +2709,9 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
s->slice_count = 0;
if (avctx->extradata && !s->extradata_decoded) {
- ret = decode_chunks(avctx, picture, got_output, avctx->extradata, avctx->extradata_size);
- if(*got_output) {
+ ret = decode_chunks(avctx, picture, got_output,
+ avctx->extradata, avctx->extradata_size);
+ if (*got_output) {
av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
*got_output = 0;
}
@@ -2615,12 +2729,11 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
return ret;
}
-
static void flush(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
- s->sync=0;
+ s->sync = 0;
ff_mpeg_flush(avctx);
}
@@ -2644,10 +2757,9 @@ static const AVProfile mpeg2_video_profiles[] = {
{ FF_PROFILE_MPEG2_SIMPLE, "Simple" },
{ FF_PROFILE_RESERVED, "Reserved" },
{ FF_PROFILE_RESERVED, "Reserved" },
- { FF_PROFILE_UNKNOWN },
+ { FF_PROFILE_UNKNOWN },
};
-
AVCodec ff_mpeg1video_decoder = {
.name = "mpeg1video",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
@@ -2726,7 +2838,7 @@ AVCodec ff_mpeg_xvmc_decoder = {
.close = mpeg_decode_end,
.decode = mpeg_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
+ CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
.flush = flush,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg12enc.c b/chromium/third_party/ffmpeg/libavcodec/mpeg12enc.c
index a550379534d..0b20304517c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg12enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg12enc.c
@@ -32,11 +32,14 @@
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/timecode.h"
+#include "libavutil/stereo3d.h"
+
#include "avcodec.h"
#include "bytestream.h"
#include "mathops.h"
#include "mpeg12.h"
#include "mpeg12data.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
@@ -243,7 +246,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
if (aspect_ratio == 0.0)
aspect_ratio = 1.0; // pixel aspect 1.1 (VGA)
- if (s->current_picture.f.key_frame) {
+ if (s->current_picture.f->key_frame) {
AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
/* mpeg1 header repeated every gop */
@@ -333,10 +336,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* time code: we must convert from the real frame rate to a
* fake MPEG frame rate in case of low frame rate */
fps = (framerate.num + framerate.den / 2) / framerate.den;
- time_code = s->current_picture_ptr->f.coded_picture_number +
+ time_code = s->current_picture_ptr->f->coded_picture_number +
s->avctx->timecode_frame_start;
- s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
+ s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
av_assert0(s->drop_frame_timecode == !!(s->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
if (s->drop_frame_timecode)
@@ -347,7 +350,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
- put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP));
+ put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
put_bits(&s->pb, 1, 0); // broken link
}
}
@@ -388,6 +391,7 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s)
void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
{
+ AVFrameSideData *side_data;
mpeg1_encode_sequence_header(s);
/* mpeg1 picture header */
@@ -447,7 +451,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
if (s->progressive_sequence)
put_bits(&s->pb, 1, 0); /* no repeat */
else
- put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
+ put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
/* XXX: optimize the generation of this flag with entropy measures */
s->frame_pred_frame_dct = s->progressive_sequence;
@@ -471,6 +475,44 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
for (i = 0; i < sizeof(svcd_scan_offset_placeholder); i++)
put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]);
}
+ side_data = av_frame_get_side_data(s->current_picture_ptr->f,
+ AV_FRAME_DATA_STEREO3D);
+ if (side_data) {
+ AVStereo3D *stereo = (AVStereo3D *)side_data->data;
+ uint8_t fpa_type;
+
+ switch (stereo->type) {
+ case AV_STEREO3D_SIDEBYSIDE:
+ fpa_type = 0x03;
+ break;
+ case AV_STEREO3D_TOPBOTTOM:
+ fpa_type = 0x04;
+ break;
+ case AV_STEREO3D_2D:
+ fpa_type = 0x08;
+ break;
+ case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
+ fpa_type = 0x23;
+ break;
+ default:
+ fpa_type = 0;
+ break;
+ }
+
+ if (fpa_type != 0) {
+ put_header(s, USER_START_CODE);
+ put_bits(&s->pb, 8, 'J'); // S3D_video_format_signaling_identifier
+ put_bits(&s->pb, 8, 'P');
+ put_bits(&s->pb, 8, '3');
+ put_bits(&s->pb, 8, 'D');
+ put_bits(&s->pb, 8, 0x03); // S3D_video_format_length
+
+ put_bits(&s->pb, 1, 1); // reserved_bit
+ put_bits(&s->pb, 7, fpa_type); // S3D_video_format_type
+ put_bits(&s->pb, 8, 0x04); // reserved_data[0]
+ put_bits(&s->pb, 8, 0xFF); // reserved_data[1]
+ }
+ }
s->mb_y = 0;
ff_mpeg1_encode_slice_header(s);
@@ -641,7 +683,7 @@ next_coef:
}
static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
- int16_t block[6][64],
+ int16_t block[8][64],
int motion_x, int motion_y,
int mb_block_count)
{
@@ -918,7 +960,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
}
}
-void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[6][64],
+void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
int motion_x, int motion_y)
{
if (s->chroma_format == CHROMA_420)
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg4video.c b/chromium/third_party/ffmpeg/libavcodec/mpeg4video.c
index 3f92ba5a99f..38ed5af66f2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg4video.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg4video.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpeg4video.h"
#include "mpeg4data.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg4video_parser.c b/chromium/third_party/ffmpeg/libavcodec/mpeg4video_parser.c
index 1da96c0a75d..0990c5a2298 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg4video_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg4video_parser.c
@@ -71,9 +71,8 @@ int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
}
/* XXX: make it use less memory */
-static int av_mpeg4_decode_header(AVCodecParserContext *s1,
- AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
+static int mpeg4_decode_header(AVCodecParserContext *s1, AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
{
struct Mp4vParseContext *pc = s1->priv_data;
Mpeg4DecContext *dec_ctx = &pc->dec_ctx;
@@ -141,7 +140,7 @@ static int mpeg4video_parse(AVCodecParserContext *s,
return buf_size;
}
}
- av_mpeg4_decode_header(s, avctx, buf, buf_size);
+ mpeg4_decode_header(s, avctx, buf, buf_size);
*poutbuf = buf;
*poutbuf_size = buf_size;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg4videodec.c b/chromium/third_party/ffmpeg/libavcodec/mpeg4videodec.c
index 9b7799d6fd8..56795514002 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg4videodec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg4videodec.c
@@ -23,6 +23,7 @@
#include "libavutil/opt.h"
#include "error_resilience.h"
#include "internal.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpeg4video.h"
#include "h263.h"
@@ -611,7 +612,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
if (cbpc < 0) {
av_log(s->avctx, AV_LOG_ERROR,
- "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
+ "mcbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
} while (cbpc == 8);
@@ -683,7 +684,7 @@ try_again:
cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
if (cbpc < 0) {
av_log(s->avctx, AV_LOG_ERROR,
- "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
+ "mcbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if (cbpc == 20)
@@ -1081,7 +1082,8 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
if (SHOW_UBITS(re, &s->gb, 1) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"1. marker bit missing in 3. esc\n");
- return -1;
+ if (!(s->err_recognition & AV_EF_IGNORE_ERR))
+ return -1;
}
SKIP_CACHE(re, &s->gb, 1);
@@ -1091,7 +1093,8 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
if (SHOW_UBITS(re, &s->gb, 1) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"2. marker bit missing in 3. esc\n");
- return -1;
+ if (!(s->err_recognition & AV_EF_IGNORE_ERR))
+ return -1;
}
SKIP_COUNTER(re, &s->gb, 1 + 12 + 1);
@@ -1162,6 +1165,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
+ tprintf(s->avctx, "dct[%d][%d] = %- 4d end?:%d\n", scan_table[i&63]&7, scan_table[i&63] >> 3, level, i>62);
if (i > 62) {
i -= 192;
if (i & (~63)) {
@@ -1328,7 +1332,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
if (cbpc < 0) {
av_log(s->avctx, AV_LOG_ERROR,
- "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
+ "mcbpc damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
} while (cbpc == 20);
@@ -1737,7 +1741,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
}
} else {
/* is setting low delay flag only once the smartest thing to do?
- * low delay detection won't be overriden. */
+ * low delay detection won't be overridden. */
if (s->picture_number == 0)
s->low_delay = 0;
}
@@ -1914,6 +1918,11 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
else
s->quarter_sample = 0;
+ if (get_bits_left(gb) < 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
+ return AVERROR_INVALIDDATA;
+ }
+
if (!get_bits1(gb)) {
int pos = get_bits_count(gb);
int estimation_method = get_bits(gb, 2);
@@ -2295,8 +2304,10 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
ROUNDED_DIV(s->last_non_b_time - s->pp_time, ctx->t_frame)) * 2;
s->pb_field_time = (ROUNDED_DIV(s->time, ctx->t_frame) -
ROUNDED_DIV(s->last_non_b_time - s->pp_time, ctx->t_frame)) * 2;
- if (!s->progressive_sequence) {
- if (s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1)
+ if (s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1) {
+ s->pb_field_time = 2;
+ s->pp_field_time = 4;
+ if (!s->progressive_sequence)
return FRAME_SKIPPED;
}
}
@@ -2651,10 +2662,9 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
}
if (startcode_found) {
- av_fast_malloc(&s->bitstream_buffer,
+ av_fast_padded_malloc(&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
- buf_size - current_pos +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ buf_size - current_pos);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos,
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpeg4videoenc.c b/chromium/third_party/ffmpeg/libavcodec/mpeg4videoenc.c
index 14c6e8faeda..9865e1df731 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpeg4videoenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpeg4videoenc.c
@@ -23,6 +23,7 @@
#include "libavutil/attributes.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "mpeg4video.h"
@@ -277,19 +278,19 @@ static inline void mpeg4_encode_dc(PutBitContext *s, int level, int n)
if (n < 4) {
/* luminance */
- put_bits(&s->pb, ff_mpeg4_DCtab_lum[size][1], ff_mpeg4_DCtab_lum[size][0]);
+ put_bits(s, ff_mpeg4_DCtab_lum[size][1], ff_mpeg4_DCtab_lum[size][0]);
} else {
/* chrominance */
- put_bits(&s->pb, ff_mpeg4_DCtab_chrom[size][1], ff_mpeg4_DCtab_chrom[size][0]);
+ put_bits(s, ff_mpeg4_DCtab_chrom[size][1], ff_mpeg4_DCtab_chrom[size][0]);
}
/* encode remaining bits */
if (size > 0) {
if (level < 0)
level = (-level) ^ ((1 << size) - 1);
- put_bits(&s->pb, size, level);
+ put_bits(s, size, level);
if (size > 8)
- put_bits(&s->pb, 1, 1);
+ put_bits(s, 1, 1);
}
#endif
}
@@ -670,7 +671,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
y = s->mb_y * 16;
offset = x + y * s->linesize;
- p_pic = s->new_picture.f.data[0] + offset;
+ p_pic = s->new_picture.f->data[0] + offset;
s->mb_skipped = 1;
for (i = 0; i < s->max_b_frames; i++) {
@@ -678,10 +679,10 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
int diff;
Picture *pic = s->reordered_input_picture[i + 1];
- if (!pic || pic->f.pict_type != AV_PICTURE_TYPE_B)
+ if (!pic || pic->f->pict_type != AV_PICTURE_TYPE_B)
break;
- b_pic = pic->f.data[0] + offset;
+ b_pic = pic->f->data[0] + offset;
if (!pic->shared)
b_pic += INPLACE_OFFSET;
@@ -915,9 +916,9 @@ static void mpeg4_encode_gop_header(MpegEncContext *s)
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, GOP_STARTCODE);
- time = s->current_picture_ptr->f.pts;
+ time = s->current_picture_ptr->f->pts;
if (s->reordered_input_picture[1])
- time = FFMIN(time, s->reordered_input_picture[1]->f.pts);
+ time = FFMIN(time, s->reordered_input_picture[1]->f->pts);
time = time * s->avctx->time_base.num;
s->last_time_base = FFUDIV(time, s->avctx->time_base.den);
@@ -1125,7 +1126,7 @@ void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
}
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
if (!s->progressive_sequence) {
- put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
+ put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
put_bits(&s->pb, 1, s->alternate_scan);
}
// FIXME sprite stuff
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudio_parser.c b/chromium/third_party/ffmpeg/libavcodec/mpegaudio_parser.c
index 408193671fe..3d9e94688a7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudio_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudio_parser.c
@@ -64,10 +64,11 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
}else{
while(i<buf_size){
int ret, sr, channels, bit_rate, frame_size;
+ enum AVCodecID codec_id;
state= (state<<8) + buf[i++];
- ret = avpriv_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate);
+ ret = avpriv_mpa_decode_header2(state, &sr, &channels, &frame_size, &bit_rate, &codec_id);
if (ret < 4) {
if (i > 4)
s->header_count = -2;
@@ -78,10 +79,11 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
s->header_count++;
s->frame_size = ret-4;
- if (s->header_count > 0) {
+ if (s->header_count > 0 + (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec_id)) {
avctx->sample_rate= sr;
avctx->channels = channels;
s1->duration = frame_size;
+ avctx->codec_id = codec_id;
if (s->no_bitrate || !avctx->bit_rate) {
s->no_bitrate = 1;
avctx->bit_rate += (bit_rate - avctx->bit_rate) / s->header_count;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodec_template.c b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodec_template.c
index 1f29679d912..05237070ea7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodec_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodec_template.c
@@ -216,7 +216,7 @@ static inline int l1_unscale(int n, int mant, int scale_factor)
shift = scale_factor_modshift[scale_factor];
mod = shift & 3;
shift >>= 2;
- val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]);
+ val = MUL64((int)(mant + (-1U << n) + 1), scale_factor_mult[n-1][mod]);
shift += n;
/* NOTE: at this point, 1 <= shift >= 21 + 15 */
return (int)((val + (1LL << (shift - 1))) >> shift);
@@ -1705,7 +1705,9 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
static void mp_flush(MPADecodeContext *ctx)
{
memset(ctx->synth_buf, 0, sizeof(ctx->synth_buf));
+ memset(ctx->mdct_buf, 0, sizeof(ctx->mdct_buf));
ctx->last_buf_size = 0;
+ ctx->dither_state = 0;
}
static void flush(AVCodecContext *avctx)
@@ -1748,6 +1750,7 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data,
/* update codec info */
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
+ avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
if (!avctx->bit_rate)
avctx->bit_rate = s->bit_rate;
@@ -1933,8 +1936,10 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
}
header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header
- if (ff_mpa_check_header(header) < 0) // Bad header, discard block
- break;
+ if (ff_mpa_check_header(header) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Bad header, discard block\n");
+ return AVERROR_INVALIDDATA;
+ }
avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
@@ -1950,8 +1955,13 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
if (m->nb_channels > 1)
outptr[1] = out_samples[s->coff[fr] + 1];
- if ((ret = mp_decode_frame(m, outptr, buf, fsize)) < 0)
- return ret;
+ if ((ret = mp_decode_frame(m, outptr, buf, fsize)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "failed to decode channel %d\n", ch);
+ memset(outptr[0], 0, MPA_FRAME_SIZE*sizeof(OUT_INT));
+ if (m->nb_channels > 1)
+ memset(outptr[1], 0, MPA_FRAME_SIZE*sizeof(OUT_INT));
+ ret = m->nb_channels * MPA_FRAME_SIZE*sizeof(OUT_INT);
+ }
out_size += ret;
buf += fsize;
@@ -1959,6 +1969,10 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
avctx->bit_rate += m->bit_rate;
}
+ if (ch != avctx->channels) {
+ av_log(avctx, AV_LOG_ERROR, "failed to decode all channels\n");
+ return AVERROR_INVALIDDATA;
+ }
/* update codec info */
avctx->sample_rate = s->mp3decctx[0]->sample_rate;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.c b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.c
index 1772c2a3c4a..d337c458a0b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.c
@@ -108,7 +108,7 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
return 0;
}
-int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
+int avpriv_mpa_decode_header2(uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate, enum AVCodecID *codec_id)
{
MPADecodeHeader s1, *s = &s1;
@@ -121,16 +121,16 @@ int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_r
switch(s->layer) {
case 1:
- avctx->codec_id = AV_CODEC_ID_MP1;
+ *codec_id = AV_CODEC_ID_MP1;
*frame_size = 384;
break;
case 2:
- avctx->codec_id = AV_CODEC_ID_MP2;
+ *codec_id = AV_CODEC_ID_MP2;
*frame_size = 1152;
break;
default:
case 3:
- avctx->codec_id = AV_CODEC_ID_MP3;
+ *codec_id = AV_CODEC_ID_MP3;
if (s->lsf)
*frame_size = 576;
else
@@ -143,3 +143,8 @@ int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_r
*bit_rate = s->bit_rate;
return s->frame_size;
}
+
+int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
+{
+ return avpriv_mpa_decode_header2(head, sample_rate, channels, frame_size, bit_rate, &avctx->codec_id);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.h b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.h
index c434d004418..444b85f2657 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodecheader.h
@@ -56,6 +56,8 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header);
header, otherwise the coded frame size in bytes */
int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate);
+int avpriv_mpa_decode_header2(uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate, enum AVCodecID *codec_id);
+
/* fast header check for resync */
static inline int ff_mpa_check_header(uint32_t header){
/* header */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.c b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.c
index ddb74284581..5fe3444896f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.c
@@ -41,6 +41,7 @@ av_cold void ff_mpadsp_init(MPADSPContext *s)
s->imdct36_blocks_float = ff_imdct36_blocks_float;
s->imdct36_blocks_fixed = ff_imdct36_blocks_fixed;
+ if (ARCH_AARCH64) ff_mpadsp_init_aarch64(s);
if (ARCH_ARM) ff_mpadsp_init_arm(s);
if (ARCH_PPC) ff_mpadsp_init_ppc(s);
if (ARCH_X86) ff_mpadsp_init_x86(s);
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.h b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.h
index 38c75c7fe52..a722a2f36b5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudiodsp.h
@@ -55,6 +55,7 @@ void ff_mpa_synth_filter_float(MPADSPContext *s,
float *samples, int incr,
float *sb_samples);
+void ff_mpadsp_init_aarch64(MPADSPContext *s);
void ff_mpadsp_init_arm(MPADSPContext *s);
void ff_mpadsp_init_ppc(MPADSPContext *s);
void ff_mpadsp_init_x86(MPADSPContext *s);
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegaudioenc_template.c b/chromium/third_party/ffmpeg/libavcodec/mpegaudioenc_template.c
index b2dfe78254b..e9571d83c76 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegaudioenc_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegaudioenc_template.c
@@ -108,10 +108,15 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
s->freq_index = i;
/* encoding bitrate & frequency */
- for(i=0;i<15;i++) {
+ for(i=1;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
+ if (i == 15 && !avctx->bit_rate) {
+ i = 14;
+ bitrate = avpriv_mpa_bitrate_tab[s->lsf][1][i];
+ avctx->bit_rate = bitrate * 1000;
+ }
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
@@ -700,9 +705,10 @@ static void encode_frame(MpegAudioContext *s,
else
q1 = sample >> shift;
q1 = (q1 * mult) >> P;
- q[m] = ((q1 + (1 << P)) * steps) >> (P + 1);
- if (q[m] < 0)
- q[m] = 0;
+ q1 += 1 << P;
+ if (q1 < 0)
+ q1 = 0;
+ q[m] = (q1 * (unsigned)steps) >> (P + 1);
}
#endif
if (q[m] >= steps)
@@ -773,7 +779,7 @@ static int MPA_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
}
static const AVCodecDefault mp2_defaults[] = {
- { "b", "128k" },
+ { "b", "0" },
{ NULL },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegutils.c b/chromium/third_party/ffmpeg/libavcodec/mpegutils.c
new file mode 100644
index 00000000000..62cc36aa6e0
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegutils.c
@@ -0,0 +1,80 @@
+/*
+ * Mpeg video formats-related defines and utility functions
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/pixdesc.h"
+
+#include "avcodec.h"
+#include "mpegutils.h"
+
+void ff_draw_horiz_band(AVCodecContext *avctx,
+ AVFrame *cur, AVFrame *last,
+ int y, int h, int picture_structure,
+ int first_field, int low_delay)
+{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ int vshift = desc->log2_chroma_h;
+ const int field_pic = picture_structure != PICT_FRAME;
+ if (field_pic) {
+ h <<= 1;
+ y <<= 1;
+ }
+
+ h = FFMIN(h, avctx->height - y);
+
+ if (field_pic && first_field &&
+ !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
+ return;
+
+ if (avctx->draw_horiz_band) {
+ AVFrame *src;
+ int offset[AV_NUM_DATA_POINTERS];
+ int i;
+
+ if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
+ (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
+ src = cur;
+ else if (last)
+ src = last;
+ else
+ return;
+
+ if (cur->pict_type == AV_PICTURE_TYPE_B &&
+ picture_structure == PICT_FRAME &&
+ avctx->codec_id != AV_CODEC_ID_SVQ3) {
+ for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+ offset[i] = 0;
+ } else {
+ offset[0]= y * src->linesize[0];
+ offset[1]=
+ offset[2]= (y >> vshift) * src->linesize[1];
+ for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
+ offset[i] = 0;
+ }
+
+ emms_c();
+
+ avctx->draw_horiz_band(avctx, src, offset,
+ y, picture_structure, h);
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegutils.h b/chromium/third_party/ffmpeg/libavcodec/mpegutils.h
new file mode 100644
index 00000000000..6d59c224240
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegutils.h
@@ -0,0 +1,127 @@
+/*
+ * Mpeg video formats-related defines and utility functions
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_MPEGUTILS_H
+#define AVCODEC_MPEGUTILS_H
+
+#include <stdint.h>
+
+#include "libavutil/frame.h"
+
+#include "avcodec.h"
+#include "version.h"
+
+
+/* picture type */
+#define PICT_TOP_FIELD 1
+#define PICT_BOTTOM_FIELD 2
+#define PICT_FRAME 3
+
+/**
+ * Value of Picture.reference when Picture is not a reference picture, but
+ * is held for delayed output.
+ */
+#define DELAYED_PIC_REF 4
+
+
+/* MB types */
+#if !FF_API_MB_TYPE
+#define MB_TYPE_INTRA4x4 (1 << 0)
+#define MB_TYPE_INTRA16x16 (1 << 1) // FIXME H.264-specific
+#define MB_TYPE_INTRA_PCM (1 << 2) // FIXME H.264-specific
+#define MB_TYPE_16x16 (1 << 3)
+#define MB_TYPE_16x8 (1 << 4)
+#define MB_TYPE_8x16 (1 << 5)
+#define MB_TYPE_8x8 (1 << 6)
+#define MB_TYPE_INTERLACED (1 << 7)
+#define MB_TYPE_DIRECT2 (1 << 8) // FIXME
+#define MB_TYPE_ACPRED (1 << 9)
+#define MB_TYPE_GMC (1 << 10)
+#define MB_TYPE_SKIP (1 << 11)
+#define MB_TYPE_P0L0 (1 << 12)
+#define MB_TYPE_P1L0 (1 << 13)
+#define MB_TYPE_P0L1 (1 << 14)
+#define MB_TYPE_P1L1 (1 << 15)
+#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
+#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
+#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
+#define MB_TYPE_QUANT (1 << 16)
+#define MB_TYPE_CBP (1 << 17)
+#endif
+
+#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 // default mb_type if there is just one type
+
+#define IS_INTRA4x4(a) ((a) & MB_TYPE_INTRA4x4)
+#define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
+#define IS_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
+#define IS_INTRA(a) ((a) & 7)
+#define IS_INTER(a) ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \
+ MB_TYPE_8x16 | MB_TYPE_8x8))
+#define IS_SKIP(a) ((a) & MB_TYPE_SKIP)
+#define IS_INTRA_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
+#define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED)
+#define IS_DIRECT(a) ((a) & MB_TYPE_DIRECT2)
+#define IS_GMC(a) ((a) & MB_TYPE_GMC)
+#define IS_16X16(a) ((a) & MB_TYPE_16x16)
+#define IS_16X8(a) ((a) & MB_TYPE_16x8)
+#define IS_8X16(a) ((a) & MB_TYPE_8x16)
+#define IS_8X8(a) ((a) & MB_TYPE_8x8)
+#define IS_SUB_8X8(a) ((a) & MB_TYPE_16x16) // note reused
+#define IS_SUB_8X4(a) ((a) & MB_TYPE_16x8) // note reused
+#define IS_SUB_4X8(a) ((a) & MB_TYPE_8x16) // note reused
+#define IS_SUB_4X4(a) ((a) & MB_TYPE_8x8) // note reused
+#define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED)
+#define IS_QUANT(a) ((a) & MB_TYPE_QUANT)
+#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list))))
+
+// does this mb use listX, note does not work if subMBs
+#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
+
+#define HAS_CBP(a) ((a) & MB_TYPE_CBP)
+
+/* MB types for encoding */
+#define CANDIDATE_MB_TYPE_INTRA (1 << 0)
+#define CANDIDATE_MB_TYPE_INTER (1 << 1)
+#define CANDIDATE_MB_TYPE_INTER4V (1 << 2)
+#define CANDIDATE_MB_TYPE_SKIPPED (1 << 3)
+
+#define CANDIDATE_MB_TYPE_DIRECT (1 << 4)
+#define CANDIDATE_MB_TYPE_FORWARD (1 << 5)
+#define CANDIDATE_MB_TYPE_BACKWARD (1 << 6)
+#define CANDIDATE_MB_TYPE_BIDIR (1 << 7)
+
+#define CANDIDATE_MB_TYPE_INTER_I (1 << 8)
+#define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9)
+#define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
+#define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11)
+
+#define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12)
+
+
+/**
+ * Draw a horizontal band if supported.
+ *
+ * @param h is the normal height, this will be reduced automatically if needed
+ */
+void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last,
+ int y, int h, int picture_structure, int first_field,
+ int low_delay);
+
+#endif /* AVCODEC_PICTTYPE_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegvideo.c b/chromium/third_party/ffmpeg/libavcodec/mpegvideo.c
index 7380af05c96..e1d1efc50eb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegvideo.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegvideo.c
@@ -31,33 +31,19 @@
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
+#include "libavutil/timer.h"
#include "avcodec.h"
#include "dsputil.h"
#include "h264chroma.h"
#include "internal.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "mjpegenc.h"
#include "msmpeg4.h"
-#include "xvmc_internal.h"
#include "thread.h"
#include <limits.h>
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_h263_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_h263_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-
static const uint8_t ff_default_chroma_qscale_table[32] = {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
@@ -119,10 +105,212 @@ const uint8_t *const ff_mpeg2_dc_scale_table[4] = {
mpeg2_dc_scale_table3,
};
-const enum AVPixelFormat ff_pixfmt_list_420[] = {
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE
-};
+static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ nCoeffs= s->block_last_index[n];
+
+ block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+ /* XXX: only mpeg1 */
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = (level - 1) | 1;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = (level - 1) | 1;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ nCoeffs= s->block_last_index[n];
+
+ quant_matrix = s->inter_matrix;
+ for(i=0; i<=nCoeffs; i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = (level - 1) | 1;
+ level = -level;
+ } else {
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = (level - 1) | 1;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+ int sum=-1;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+ sum += block[0];
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ }
+ block[j] = level;
+ sum+=level;
+ }
+ }
+ block[63]^=sum&1;
+}
+
+static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+ int sum=-1;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ quant_matrix = s->inter_matrix;
+ for(i=0; i<=nCoeffs; i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = -level;
+ } else {
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ }
+ block[j] = level;
+ sum+=level;
+ }
+ }
+ block[63]^=sum&1;
+}
+
+static void dct_unquantize_h263_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
+
+ qmul = qscale << 1;
+
+ if (!s->h263_aic) {
+ block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+ qadd = (qscale - 1) | 1;
+ }else{
+ qadd = 0;
+ }
+ if(s->ac_pred)
+ nCoeffs=63;
+ else
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ for(i=1; i<=nCoeffs; i++) {
+ level = block[i];
+ if (level) {
+ if (level < 0) {
+ level = level * qmul - qadd;
+ } else {
+ level = level * qmul + qadd;
+ }
+ block[i] = level;
+ }
+ }
+}
+
+static void dct_unquantize_h263_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ av_assert2(s->block_last_index[n]>=0);
+
+ qadd = (qscale - 1) | 1;
+ qmul = qscale << 1;
+
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ for(i=0; i<=nCoeffs; i++) {
+ level = block[i];
+ if (level) {
+ if (level < 0) {
+ level = level * qmul - qadd;
+ } else {
+ level = level * qmul + qadd;
+ }
+ block[i] = level;
+ }
+ }
+}
static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
int (*mv)[2][4][2],
@@ -143,15 +331,27 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
s->dsp.clear_blocks(s->block[0]);
- s->dest[0] = s->current_picture.f.data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16;
- s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
- s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
+ s->dest[0] = s->current_picture.f->data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16;
+ s->dest[1] = s->current_picture.f->data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
+ s->dest[2] = s->current_picture.f->data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
if (ref)
av_log(s->avctx, AV_LOG_DEBUG, "Interlaced error concealment is not fully implemented\n");
ff_MPV_decode_mb(s, s->block);
}
+static void gray16(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h)
+{
+ while(h--)
+ memset(dst + h*linesize, 128, 16);
+}
+
+static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h)
+{
+ while(h--)
+ memset(dst + h*linesize, 128, 8);
+}
+
/* init common dct for both encoder and decoder */
av_cold int ff_dct_common_init(MpegEncContext *s)
{
@@ -160,6 +360,19 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
+ if (s->avctx->debug & FF_DEBUG_NOMC) {
+ int i;
+ for (i=0; i<4; i++) {
+ s->hdsp.avg_pixels_tab[0][i] = gray16;
+ s->hdsp.put_pixels_tab[0][i] = gray16;
+ s->hdsp.put_no_rnd_pixels_tab[0][i] = gray16;
+
+ s->hdsp.avg_pixels_tab[1][i] = gray8;
+ s->hdsp.put_pixels_tab[1][i] = gray8;
+ s->hdsp.put_no_rnd_pixels_tab[1][i] = gray8;
+ }
+ }
+
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;
s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c;
s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;
@@ -173,8 +386,6 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
ff_MPV_common_init_axp(s);
if (ARCH_ARM)
ff_MPV_common_init_arm(s);
- if (ARCH_BFIN)
- ff_MPV_common_init_bfin(s);
if (ARCH_PPC)
ff_MPV_common_init_ppc(s);
if (ARCH_X86)
@@ -226,31 +437,49 @@ fail:
*/
static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
{
+ int edges_needed = av_codec_is_encoder(s->avctx->codec);
int r, ret;
- pic->tf.f = &pic->f;
+ pic->tf.f = pic->f;
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
- s->codec_id != AV_CODEC_ID_MSS2)
+ s->codec_id != AV_CODEC_ID_MSS2) {
+ if (edges_needed) {
+ pic->f->width = s->avctx->width + 2 * EDGE_WIDTH;
+ pic->f->height = s->avctx->height + 2 * EDGE_WIDTH;
+ }
+
r = ff_thread_get_buffer(s->avctx, &pic->tf,
pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
- else {
- pic->f.width = s->avctx->width;
- pic->f.height = s->avctx->height;
- pic->f.format = s->avctx->pix_fmt;
- r = avcodec_default_get_buffer2(s->avctx, &pic->f, 0);
+ } else {
+ pic->f->width = s->avctx->width;
+ pic->f->height = s->avctx->height;
+ pic->f->format = s->avctx->pix_fmt;
+ r = avcodec_default_get_buffer2(s->avctx, pic->f, 0);
}
- if (r < 0 || !pic->f.buf[0]) {
+ if (r < 0 || !pic->f->buf[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
- r, pic->f.data[0]);
+ r, pic->f->data[0]);
return -1;
}
+ if (edges_needed) {
+ int i;
+ for (i = 0; pic->f->data[i]; i++) {
+ int offset = (EDGE_WIDTH >> (i ? s->chroma_y_shift : 0)) *
+ pic->f->linesize[i] +
+ (EDGE_WIDTH >> (i ? s->chroma_x_shift : 0));
+ pic->f->data[i] += offset;
+ }
+ pic->f->width = s->avctx->width;
+ pic->f->height = s->avctx->height;
+ }
+
if (s->avctx->hwaccel) {
assert(!pic->hwaccel_picture_private);
- if (s->avctx->hwaccel->priv_data_size) {
- pic->hwaccel_priv_buf = av_buffer_allocz(s->avctx->hwaccel->priv_data_size);
+ if (s->avctx->hwaccel->frame_priv_data_size) {
+ pic->hwaccel_priv_buf = av_buffer_allocz(s->avctx->hwaccel->frame_priv_data_size);
if (!pic->hwaccel_priv_buf) {
av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
@@ -259,15 +488,15 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
}
}
- if (s->linesize && (s->linesize != pic->f.linesize[0] ||
- s->uvlinesize != pic->f.linesize[1])) {
+ if (s->linesize && (s->linesize != pic->f->linesize[0] ||
+ s->uvlinesize != pic->f->linesize[1])) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
ff_mpeg_unref_picture(s, pic);
return -1;
}
- if (pic->f.linesize[1] != pic->f.linesize[2]) {
+ if (pic->f->linesize[1] != pic->f->linesize[2]) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
ff_mpeg_unref_picture(s, pic);
@@ -275,7 +504,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
}
if (!s->edge_emu_buffer &&
- (ret = frame_size_alloc(s, pic->f.linesize[0])) < 0) {
+ (ret = frame_size_alloc(s, pic->f->linesize[0])) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
ff_mpeg_unref_picture(s, pic);
@@ -385,16 +614,16 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
ff_free_picture_tables(pic);
if (shared) {
- av_assert0(pic->f.data[0]);
+ av_assert0(pic->f->data[0]);
pic->shared = 1;
} else {
- av_assert0(!pic->f.buf[0]);
+ av_assert0(!pic->f->buf[0]);
if (alloc_frame_buffer(s, pic) < 0)
return -1;
- s->linesize = pic->f.linesize[0];
- s->uvlinesize = pic->f.linesize[1];
+ s->linesize = pic->f->linesize[0];
+ s->uvlinesize = pic->f->linesize[1];
}
if (!pic->qscale_table_buf)
@@ -436,15 +665,15 @@ void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
{
int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
- pic->tf.f = &pic->f;
+ pic->tf.f = pic->f;
/* WM Image / Screen codecs allocate internal buffers with different
* dimensions / colorspaces; ignore user-defined callbacks for these. */
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
s->codec_id != AV_CODEC_ID_MSS2)
ff_thread_release_buffer(s->avctx, &pic->tf);
- else
- av_frame_unref(&pic->f);
+ else if (pic->f)
+ av_frame_unref(pic->f);
av_buffer_unref(&pic->hwaccel_priv_buf);
@@ -503,11 +732,11 @@ int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
{
int ret;
- av_assert0(!dst->f.buf[0]);
- av_assert0(src->f.buf[0]);
+ av_assert0(!dst->f->buf[0]);
+ av_assert0(src->f->buf[0]);
- src->tf.f = &src->f;
- dst->tf.f = &dst->f;
+ src->tf.f = src->f;
+ dst->tf.f = dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
@@ -553,6 +782,9 @@ static int init_duplicate_context(MpegEncContext *s)
int yc_size = y_size + 2 * c_size;
int i;
+ if (s->mb_height & 1)
+ yc_size += 2*s->b8_stride + 2*s->mb_stride;
+
s->edge_emu_buffer =
s->me.scratchpad =
s->me.temp =
@@ -716,7 +948,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
if(s->picture)
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
ff_mpeg_unref_picture(s, &s->picture[i]);
- if (s1->picture[i].f.buf[0] &&
+ if (s1->picture[i].f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0)
return ret;
}
@@ -724,7 +956,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
#define UPDATE_PICTURE(pic)\
do {\
ff_mpeg_unref_picture(s, &s->pic);\
- if (s1->pic.f.buf[0])\
+ if (s1->pic.f && s1->pic.f->buf[0])\
ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
else\
ret = update_picture_tables(&s->pic, &s1->pic);\
@@ -791,7 +1023,7 @@ do {\
if (!s1->first_field) {
s->last_pict_type = s1->pict_type;
if (s1->current_picture_ptr)
- s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->f.quality;
+ s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->f->quality;
}
return 0;
@@ -878,11 +1110,10 @@ static int init_context_frame(MpegEncContext *s)
s->mb_width = (s->width + 15) / 16;
s->mb_stride = s->mb_width + 1;
s->b8_stride = s->mb_width * 2 + 1;
- s->b4_stride = s->mb_width * 4 + 1;
mb_array_size = s->mb_height * s->mb_stride;
mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
- /* set default edge pos, will be overriden
+ /* set default edge pos, will be overridden
* in decode_header if needed */
s->h_edge_pos = s->mb_width * 16;
s->v_edge_pos = s->mb_height * 16;
@@ -900,6 +1131,9 @@ static int init_context_frame(MpegEncContext *s)
c_size = s->mb_stride * (s->mb_height + 1);
yc_size = y_size + 2 * c_size;
+ if (s->mb_height & 1)
+ yc_size += 2*s->b8_stride + 2*s->mb_stride;
+
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), fail); // error ressilience code looks cleaner with this
for (y = 0; y < s->mb_height; y++)
for (x = 0; x < s->mb_width; x++)
@@ -957,7 +1191,7 @@ static int init_context_frame(MpegEncContext *s)
}
if (s->out_format == FMT_H263) {
/* cbp values */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size + (s->mb_height&1)*2*s->b8_stride, fail);
s->coded_block = s->coded_block_base + s->b8_stride + 1;
/* cbp, ac_pred, pred_dir */
@@ -1047,14 +1281,26 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
MAX_PICTURE_COUNT * sizeof(Picture), fail);
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- avcodec_get_frame_defaults(&s->picture[i].f);
+ s->picture[i].f = av_frame_alloc();
+ if (!s->picture[i].f)
+ goto fail;
}
memset(&s->next_picture, 0, sizeof(s->next_picture));
memset(&s->last_picture, 0, sizeof(s->last_picture));
memset(&s->current_picture, 0, sizeof(s->current_picture));
- avcodec_get_frame_defaults(&s->next_picture.f);
- avcodec_get_frame_defaults(&s->last_picture.f);
- avcodec_get_frame_defaults(&s->current_picture.f);
+ memset(&s->new_picture, 0, sizeof(s->new_picture));
+ s->next_picture.f = av_frame_alloc();
+ if (!s->next_picture.f)
+ goto fail;
+ s->last_picture.f = av_frame_alloc();
+ if (!s->last_picture.f)
+ goto fail;
+ s->current_picture.f = av_frame_alloc();
+ if (!s->current_picture.f)
+ goto fail;
+ s->new_picture.f = av_frame_alloc();
+ if (!s->new_picture.f)
+ goto fail;
if (init_context_frame(s))
goto fail;
@@ -1248,15 +1494,22 @@ void ff_MPV_common_end(MpegEncContext *s)
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
ff_free_picture_tables(&s->picture[i]);
ff_mpeg_unref_picture(s, &s->picture[i]);
+ av_frame_free(&s->picture[i].f);
}
}
av_freep(&s->picture);
ff_free_picture_tables(&s->last_picture);
ff_mpeg_unref_picture(s, &s->last_picture);
+ av_frame_free(&s->last_picture.f);
ff_free_picture_tables(&s->current_picture);
ff_mpeg_unref_picture(s, &s->current_picture);
+ av_frame_free(&s->current_picture.f);
ff_free_picture_tables(&s->next_picture);
ff_mpeg_unref_picture(s, &s->next_picture);
+ av_frame_free(&s->next_picture.f);
+ ff_free_picture_tables(&s->new_picture);
+ ff_mpeg_unref_picture(s, &s->new_picture);
+ av_frame_free(&s->new_picture.f);
free_context_frame(s);
@@ -1374,7 +1627,7 @@ static inline int pic_is_unused(MpegEncContext *s, Picture *pic)
{
if (pic == s->last_picture_ptr)
return 0;
- if (pic->f.buf[0] == NULL)
+ if (pic->f->buf[0] == NULL)
return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1;
@@ -1387,7 +1640,7 @@ static int find_unused_picture(MpegEncContext *s, int shared)
if (shared) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (s->picture[i].f.buf[0] == NULL && &s->picture[i] != s->last_picture_ptr)
+ if (s->picture[i].f->buf[0] == NULL && &s->picture[i] != s->last_picture_ptr)
return i;
}
} else {
@@ -1423,36 +1676,30 @@ int ff_find_unused_picture(MpegEncContext *s, int shared)
s->picture[ret].needs_realloc = 0;
ff_free_picture_tables(&s->picture[ret]);
ff_mpeg_unref_picture(s, &s->picture[ret]);
- avcodec_get_frame_defaults(&s->picture[ret].f);
}
}
return ret;
}
-static void update_noise_reduction(MpegEncContext *s)
+static void gray_frame(AVFrame *frame)
{
- int intra, i;
+ int i, h_chroma_shift, v_chroma_shift;
- for (intra = 0; intra < 2; intra++) {
- if (s->dct_count[intra] > (1 << 16)) {
- for (i = 0; i < 64; i++) {
- s->dct_error_sum[intra][i] >>= 1;
- }
- s->dct_count[intra] >>= 1;
- }
+ av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
- for (i = 0; i < 64; i++) {
- s->dct_offset[intra][i] = (s->avctx->noise_reduction *
- s->dct_count[intra] +
- s->dct_error_sum[intra][i] / 2) /
- (s->dct_error_sum[intra][i] + 1);
- }
+ for(i=0; i<frame->height; i++)
+ memset(frame->data[0] + frame->linesize[0]*i, 0x80, frame->width);
+ for(i=0; i<FF_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) {
+ memset(frame->data[1] + frame->linesize[1]*i,
+ 0x80, FF_CEIL_RSHIFT(frame->width, h_chroma_shift));
+ memset(frame->data[2] + frame->linesize[2]*i,
+ 0x80, FF_CEIL_RSHIFT(frame->width, h_chroma_shift));
}
}
/**
- * generic function for encode/decode called after coding/decoding
- * the header and before a frame is coded/decoded.
+ * generic function called after decoding
+ * the header and before a frame is decoded.
*/
int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
@@ -1468,73 +1715,69 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
/* mark & release old frames */
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
- s->last_picture_ptr->f.buf[0]) {
+ s->last_picture_ptr->f->buf[0]) {
ff_mpeg_unref_picture(s, s->last_picture_ptr);
}
/* release forgotten pictures */
/* if (mpeg124/h263) */
- if (!s->encoding) {
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (&s->picture[i] != s->last_picture_ptr &&
- &s->picture[i] != s->next_picture_ptr &&
- s->picture[i].reference && !s->picture[i].needs_realloc) {
- if (!(avctx->active_thread_type & FF_THREAD_FRAME))
- av_log(avctx, AV_LOG_ERROR,
- "releasing zombie picture\n");
- ff_mpeg_unref_picture(s, &s->picture[i]);
- }
+ for (i = 0; i < MAX_PICTURE_COUNT; i++) {
+ if (&s->picture[i] != s->last_picture_ptr &&
+ &s->picture[i] != s->next_picture_ptr &&
+ s->picture[i].reference && !s->picture[i].needs_realloc) {
+ if (!(avctx->active_thread_type & FF_THREAD_FRAME))
+ av_log(avctx, AV_LOG_ERROR,
+ "releasing zombie picture\n");
+ ff_mpeg_unref_picture(s, &s->picture[i]);
}
}
ff_mpeg_unref_picture(s, &s->current_picture);
- if (!s->encoding) {
- release_unused_pictures(s);
+ release_unused_pictures(s);
- if (s->current_picture_ptr &&
- s->current_picture_ptr->f.buf[0] == NULL) {
- // we already have a unused image
- // (maybe it was set before reading the header)
- pic = s->current_picture_ptr;
- } else {
- i = ff_find_unused_picture(s, 0);
- if (i < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- pic = &s->picture[i];
+ if (s->current_picture_ptr &&
+ s->current_picture_ptr->f->buf[0] == NULL) {
+ // we already have a unused image
+ // (maybe it was set before reading the header)
+ pic = s->current_picture_ptr;
+ } else {
+ i = ff_find_unused_picture(s, 0);
+ if (i < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
+ return i;
}
+ pic = &s->picture[i];
+ }
- pic->reference = 0;
- if (!s->droppable) {
- if (s->pict_type != AV_PICTURE_TYPE_B)
- pic->reference = 3;
- }
+ pic->reference = 0;
+ if (!s->droppable) {
+ if (s->pict_type != AV_PICTURE_TYPE_B)
+ pic->reference = 3;
+ }
- pic->f.coded_picture_number = s->coded_picture_number++;
+ pic->f->coded_picture_number = s->coded_picture_number++;
- if (ff_alloc_picture(s, pic, 0) < 0)
- return -1;
+ if (ff_alloc_picture(s, pic, 0) < 0)
+ return -1;
- s->current_picture_ptr = pic;
- // FIXME use only the vars from current_pic
- s->current_picture_ptr->f.top_field_first = s->top_field_first;
- if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
- s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->picture_structure != PICT_FRAME)
- s->current_picture_ptr->f.top_field_first =
- (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
- }
- s->current_picture_ptr->f.interlaced_frame = !s->progressive_frame &&
- !s->progressive_sequence;
- s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
+ s->current_picture_ptr = pic;
+ // FIXME use only the vars from current_pic
+ s->current_picture_ptr->f->top_field_first = s->top_field_first;
+ if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
+ s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ if (s->picture_structure != PICT_FRAME)
+ s->current_picture_ptr->f->top_field_first =
+ (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
}
+ s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
+ !s->progressive_sequence;
+ s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
- s->current_picture_ptr->f.pict_type = s->pict_type;
+ s->current_picture_ptr->f->pict_type = s->pict_type;
// if (s->flags && CODEC_FLAG_QSCALE)
// s->current_picture_ptr->quality = s->new_picture_ptr->quality;
- s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,
s->current_picture_ptr)) < 0)
@@ -1547,19 +1790,19 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
av_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
- s->last_picture_ptr ? s->last_picture_ptr->f.data[0] : NULL,
- s->next_picture_ptr ? s->next_picture_ptr->f.data[0] : NULL,
- s->current_picture_ptr ? s->current_picture_ptr->f.data[0] : NULL,
+ s->last_picture_ptr ? s->last_picture_ptr->f->data[0] : NULL,
+ s->next_picture_ptr ? s->next_picture_ptr->f->data[0] : NULL,
+ s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
s->pict_type, s->droppable);
if ((s->last_picture_ptr == NULL ||
- s->last_picture_ptr->f.buf[0] == NULL) &&
+ s->last_picture_ptr->f->buf[0] == NULL) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
- if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f.buf[0])
+ if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f->buf[0])
av_log(avctx, AV_LOG_DEBUG,
"allocating dummy last picture for B frame\n");
else if (s->pict_type != AV_PICTURE_TYPE_I)
@@ -1576,31 +1819,38 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
return i;
}
s->last_picture_ptr = &s->picture[i];
- s->last_picture_ptr->f.key_frame = 0;
+
+ s->last_picture_ptr->reference = 3;
+ s->last_picture_ptr->f->key_frame = 0;
+ s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
+
if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
s->last_picture_ptr = NULL;
return -1;
}
- memset(s->last_picture_ptr->f.data[0], 0x80,
- avctx->height * s->last_picture_ptr->f.linesize[0]);
- memset(s->last_picture_ptr->f.data[1], 0x80,
- (avctx->height >> v_chroma_shift) *
- s->last_picture_ptr->f.linesize[1]);
- memset(s->last_picture_ptr->f.data[2], 0x80,
- (avctx->height >> v_chroma_shift) *
- s->last_picture_ptr->f.linesize[2]);
-
- if(s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263){
+ if (!avctx->hwaccel && !(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)) {
for(i=0; i<avctx->height; i++)
- memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i, 16, avctx->width);
+ memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i,
+ 0x80, avctx->width);
+ for(i=0; i<FF_CEIL_RSHIFT(avctx->height, v_chroma_shift); i++) {
+ memset(s->last_picture_ptr->f->data[1] + s->last_picture_ptr->f->linesize[1]*i,
+ 0x80, FF_CEIL_RSHIFT(avctx->width, h_chroma_shift));
+ memset(s->last_picture_ptr->f->data[2] + s->last_picture_ptr->f->linesize[2]*i,
+ 0x80, FF_CEIL_RSHIFT(avctx->width, h_chroma_shift));
+ }
+
+ if(s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263){
+ for(i=0; i<avctx->height; i++)
+ memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i, 16, avctx->width);
+ }
}
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
if ((s->next_picture_ptr == NULL ||
- s->next_picture_ptr->f.buf[0] == NULL) &&
+ s->next_picture_ptr->f->buf[0] == NULL) &&
s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */
i = ff_find_unused_picture(s, 0);
@@ -1609,7 +1859,11 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
return i;
}
s->next_picture_ptr = &s->picture[i];
- s->next_picture_ptr->f.key_frame = 0;
+
+ s->next_picture_ptr->reference = 3;
+ s->next_picture_ptr->f->key_frame = 0;
+ s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
+
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
s->next_picture_ptr = NULL;
return -1;
@@ -1619,37 +1873,37 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
#if 0 // BUFREF-FIXME
- memset(s->last_picture.f.data, 0, sizeof(s->last_picture.f.data));
- memset(s->next_picture.f.data, 0, sizeof(s->next_picture.f.data));
+ memset(s->last_picture.f->data, 0, sizeof(s->last_picture.f->data));
+ memset(s->next_picture.f->data, 0, sizeof(s->next_picture.f->data));
#endif
if (s->last_picture_ptr) {
ff_mpeg_unref_picture(s, &s->last_picture);
- if (s->last_picture_ptr->f.buf[0] &&
+ if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
ff_mpeg_unref_picture(s, &s->next_picture);
- if (s->next_picture_ptr->f.buf[0] &&
+ if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s, &s->next_picture,
s->next_picture_ptr)) < 0)
return ret;
}
av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
- s->last_picture_ptr->f.buf[0]));
+ s->last_picture_ptr->f->buf[0]));
if (s->picture_structure!= PICT_FRAME) {
int i;
for (i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
- s->current_picture.f.data[i] +=
- s->current_picture.f.linesize[i];
+ s->current_picture.f->data[i] +=
+ s->current_picture.f->linesize[i];
}
- s->current_picture.f.linesize[i] *= 2;
- s->last_picture.f.linesize[i] *= 2;
- s->next_picture.f.linesize[i] *= 2;
+ s->current_picture.f->linesize[i] *= 2;
+ s->last_picture.f->linesize[i] *= 2;
+ s->next_picture.f->linesize[i] *= 2;
}
}
@@ -1669,59 +1923,16 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
}
- if (s->dct_error_sum) {
- av_assert2(s->avctx->noise_reduction && s->encoding);
- update_noise_reduction(s);
+ if (s->avctx->debug & FF_DEBUG_NOMC) {
+ gray_frame(s->current_picture_ptr->f);
}
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- return ff_xvmc_field_start(s, avctx);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
-
return 0;
}
/* called after a frame has been decoded. */
void ff_MPV_frame_end(MpegEncContext *s)
{
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- /* redraw edges for the frame if decoding didn't complete */
- // just to make sure that all data is rendered.
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) {
- ff_xvmc_field_end(s);
- } else
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
- if ((s->er.error_count || !(s->avctx->codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)) &&
- !s->avctx->hwaccel &&
- !(s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) &&
- s->unrestricted_mv &&
- s->current_picture.reference &&
- !s->intra_only &&
- !(s->flags & CODEC_FLAG_EMU_EDGE) &&
- !s->avctx->lowres
- ) {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
- int hshift = desc->log2_chroma_w;
- int vshift = desc->log2_chroma_h;
- s->dsp.draw_edges(s->current_picture.f.data[0], s->current_picture.f.linesize[0],
- s->h_edge_pos, s->v_edge_pos,
- EDGE_WIDTH, EDGE_WIDTH,
- EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(s->current_picture.f.data[1], s->current_picture.f.linesize[1],
- s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
- EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
- EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(s->current_picture.f.data[2], s->current_picture.f.linesize[2],
- s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
- EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
- EDGE_TOP | EDGE_BOTTOM);
- }
-
emms_c();
if (s->current_picture.reference)
@@ -1819,11 +2030,12 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
/**
* Print debugging info for the given picture.
*/
-void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint8_t *mbskip_table,
+void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table,
+ uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
int *low_delay,
int mb_width, int mb_height, int mb_stride, int quarter_sample)
{
- if (avctx->hwaccel || !p || !p->mb_type
+ if (avctx->hwaccel || !mbtype_table
|| (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
return;
@@ -1843,10 +2055,10 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
}
if (avctx->debug & FF_DEBUG_QP) {
av_log(avctx, AV_LOG_DEBUG, "%2d",
- p->qscale_table[x + y * mb_stride]);
+ qscale_table[x + y * mb_stride]);
}
if (avctx->debug & FF_DEBUG_MB_TYPE) {
- int mb_type = p->mb_type[x + y * mb_stride];
+ int mb_type = mbtype_table[x + y * mb_stride];
// Type & MV direction
if (IS_PCM(mb_type))
av_log(avctx, AV_LOG_DEBUG, "P");
@@ -1925,7 +2137,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
int mb_x;
for (mb_x = 0; mb_x < mb_width; mb_x++) {
const int mb_index = mb_x + mb_y * mb_stride;
- if ((avctx->debug_mv) && p->motion_val[0]) {
+ if ((avctx->debug_mv) && motion_val[0]) {
int type;
for (type = 0; type < 3; type++) {
int direction = 0;
@@ -1949,46 +2161,46 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
direction = 1;
break;
}
- if (!USES_LIST(p->mb_type[mb_index], direction))
+ if (!USES_LIST(mbtype_table[mb_index], direction))
continue;
- if (IS_8X8(p->mb_type[mb_index])) {
+ if (IS_8X8(mbtype_table[mb_index])) {
int i;
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 4 + 8 * (i & 1);
int sy = mb_y * 16 + 4 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
- int mx = (p->motion_val[direction][xy][0] >> shift) + sx;
- int my = (p->motion_val[direction][xy][1] >> shift) + sy;
+ int mx = (motion_val[direction][xy][0] >> shift) + sx;
+ int my = (motion_val[direction][xy][1] >> shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width,
height, pict->linesize[0], 100);
}
- } else if (IS_16X8(p->mb_type[mb_index])) {
+ } else if (IS_16X8(mbtype_table[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 8;
int sy = mb_y * 16 + 4 + 8 * i;
int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
- int mx = (p->motion_val[direction][xy][0] >> shift);
- int my = (p->motion_val[direction][xy][1] >> shift);
+ int mx = (motion_val[direction][xy][0] >> shift);
+ int my = (motion_val[direction][xy][1] >> shift);
- if (IS_INTERLACED(p->mb_type[mb_index]))
+ if (IS_INTERLACED(mbtype_table[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, pict->linesize[0], 100);
}
- } else if (IS_8X16(p->mb_type[mb_index])) {
+ } else if (IS_8X16(mbtype_table[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 4 + 8 * i;
int sy = mb_y * 16 + 8;
int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
- int mx = p->motion_val[direction][xy][0] >> shift;
- int my = p->motion_val[direction][xy][1] >> shift;
+ int mx = motion_val[direction][xy][0] >> shift;
+ int my = motion_val[direction][xy][1] >> shift;
- if (IS_INTERLACED(p->mb_type[mb_index]))
+ if (IS_INTERLACED(mbtype_table[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
@@ -1998,14 +2210,14 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
int sx= mb_x * 16 + 8;
int sy= mb_y * 16 + 8;
int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
- int mx= (p->motion_val[direction][xy][0]>>shift) + sx;
- int my= (p->motion_val[direction][xy][1]>>shift) + sy;
+ int mx= (motion_val[direction][xy][0]>>shift) + sx;
+ int my= (motion_val[direction][xy][1]>>shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width, height, pict->linesize[0], 100);
}
}
}
if ((avctx->debug & FF_DEBUG_VIS_QP)) {
- uint64_t c = (p->qscale_table[mb_index] * 128 / 31) *
+ uint64_t c = (qscale_table[mb_index] * 128 / 31) *
0x0101010101010101ULL;
int y;
for (y = 0; y < block_height; y++) {
@@ -2018,8 +2230,8 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
}
}
if ((avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
- p->motion_val[0]) {
- int mb_type = p->mb_type[mb_index];
+ motion_val[0]) {
+ int mb_type = mbtype_table[mb_index];
uint64_t u,v;
int y;
#define COLOR(theta, r) \
@@ -2083,7 +2295,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
// FIXME bidir
- int32_t *mv = (int32_t *) &p->motion_val[0][xy];
+ int32_t *mv = (int32_t *) &motion_val[0][xy];
if (mv[0] != mv[dm] ||
mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
for (y = 0; y < 8; y++)
@@ -2107,7 +2319,8 @@ void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict)
{
- ff_print_debug_info2(s->avctx, p, pict, s->mbskip_table, &s->low_delay,
+ ff_print_debug_info2(s->avctx, pict, s->mbskip_table, p->mb_type,
+ p->qscale_table, p->motion_val, &s->low_delay,
s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample);
}
@@ -2191,8 +2404,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
const int s_mask = (2 << lowres) - 1;
const int h_edge_pos = s->h_edge_pos >> lowres;
const int v_edge_pos = s->v_edge_pos >> lowres;
- linesize = s->current_picture.f.linesize[0] << field_based;
- uvlinesize = s->current_picture.f.linesize[1] << field_based;
+ linesize = s->current_picture.f->linesize[0] << field_based;
+ uvlinesize = s->current_picture.f->linesize[1] << field_based;
// FIXME obviously not perfect but qpel will not work in lowres anyway
if (s->quarter_sample) {
@@ -2277,7 +2490,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
}
}
- // FIXME use this for field pix too instead of the obnoxious hack which changes picture.f.data
+ // FIXME use this for field pix too instead of the obnoxious hack which changes picture.f->data
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
@@ -2435,7 +2648,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
- ref_picture = s->current_picture_ptr->f.data;
+ ref_picture = s->current_picture_ptr->f->data;
}
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
@@ -2453,7 +2666,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
- ref2picture = s->current_picture_ptr->f.data;
+ ref2picture = s->current_picture_ptr->f->data;
}
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
@@ -2495,7 +2708,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
// opposite parity is always in the same
// frame if this is second field
if (!s->first_field) {
- ref_picture = s->current_picture_ptr->f.data;
+ ref_picture = s->current_picture_ptr->f->data;
}
}
}
@@ -2619,14 +2832,11 @@ void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64],
{
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
- ff_xvmc_decode_mb(s);//xvmc uses pblocks
+ if (CONFIG_XVMC &&
+ s->avctx->hwaccel && s->avctx->hwaccel->decode_mb) {
+ s->avctx->hwaccel->decode_mb(s);//xvmc uses pblocks
return;
}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
/* print DCT coefficients */
@@ -2656,13 +2866,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
else if (!is_mpeg12 && (s->h263_pred || s->h263_aic))
s->mbintra_table[mb_xy]=1;
- if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
+ if ( (s->flags&CODEC_FLAG_PSNR)
+ || s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor
+ || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
uint8_t *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
- const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
- const int uvlinesize = s->current_picture.f.linesize[1];
+ const int linesize = s->current_picture.f->linesize[0]; //not s->linesize as this would be wrong for field pics
+ const int uvlinesize = s->current_picture.f->linesize[1];
const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
@@ -2717,11 +2929,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
if (s->mv_dir & MV_DIR_FORWARD) {
- MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix);
+ MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix);
op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
- MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix);
+ MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f->data, op_pix);
}
}else{
op_qpix = s->me.qpel_put;
@@ -2731,12 +2943,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
op_pix = s->hdsp.put_no_rnd_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
- ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
+ ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix= s->me.qpel_avg;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
- ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
+ ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f->data, op_pix, op_qpix);
}
}
}
@@ -2871,96 +3083,16 @@ void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64]){
else MPV_decode_mb_internal(s, block, 0, 0);
}
-/**
- * @param h is the normal height, this will be reduced automatically if needed for the last row
- */
-void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
- Picture *last, int y, int h, int picture_structure,
- int first_field, int draw_edges, int low_delay,
- int v_edge_pos, int h_edge_pos)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
- int hshift = desc->log2_chroma_w;
- int vshift = desc->log2_chroma_h;
- const int field_pic = picture_structure != PICT_FRAME;
- if(field_pic){
- h <<= 1;
- y <<= 1;
- }
-
- if (!avctx->hwaccel &&
- !(avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) &&
- draw_edges &&
- cur->reference &&
- !(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
- int *linesize = cur->f.linesize;
- int sides = 0, edge_h;
- if (y==0) sides |= EDGE_TOP;
- if (y + h >= v_edge_pos)
- sides |= EDGE_BOTTOM;
-
- edge_h= FFMIN(h, v_edge_pos - y);
-
- dsp->draw_edges(cur->f.data[0] + y * linesize[0],
- linesize[0], h_edge_pos, edge_h,
- EDGE_WIDTH, EDGE_WIDTH, sides);
- dsp->draw_edges(cur->f.data[1] + (y >> vshift) * linesize[1],
- linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
- EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
- dsp->draw_edges(cur->f.data[2] + (y >> vshift) * linesize[2],
- linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
- EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
- }
-
- h = FFMIN(h, avctx->height - y);
-
- if(field_pic && first_field && !(avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
-
- if (avctx->draw_horiz_band) {
- AVFrame *src;
- int offset[AV_NUM_DATA_POINTERS];
- int i;
-
- if(cur->f.pict_type == AV_PICTURE_TYPE_B || low_delay ||
- (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
- src = &cur->f;
- else if (last)
- src = &last->f;
- else
- return;
-
- if (cur->f.pict_type == AV_PICTURE_TYPE_B &&
- picture_structure == PICT_FRAME &&
- avctx->codec_id != AV_CODEC_ID_SVQ3) {
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
- offset[i] = 0;
- }else{
- offset[0]= y * src->linesize[0];
- offset[1]=
- offset[2]= (y >> vshift) * src->linesize[1];
- for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
- offset[i] = 0;
- }
-
- emms_c();
-
- avctx->draw_horiz_band(avctx, src, offset,
- y, picture_structure, h);
- }
-}
-
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
{
- int draw_edges = s->unrestricted_mv && !s->intra_only;
- ff_draw_horiz_band(s->avctx, &s->dsp, s->current_picture_ptr,
- s->last_picture_ptr, y, h, s->picture_structure,
- s->first_field, draw_edges, s->low_delay,
- s->v_edge_pos, s->h_edge_pos);
+ ff_draw_horiz_band(s->avctx, s->current_picture_ptr->f,
+ s->last_picture_ptr ? s->last_picture_ptr->f : NULL, y, h, s->picture_structure,
+ s->first_field, s->low_delay);
}
void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
- const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
- const int uvlinesize = s->current_picture.f.linesize[1];
+ const int linesize = s->current_picture.f->linesize[0]; //not s->linesize as this would be wrong for field pics
+ const int uvlinesize = s->current_picture.f->linesize[1];
const int mb_size= 4 - s->avctx->lowres;
s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2;
@@ -2971,9 +3103,9 @@ void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
//block_index is not used by mpeg2, so it is not affected by chroma_format
- s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) << mb_size);
- s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
- s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
+ s->dest[0] = s->current_picture.f->data[0] + ((s->mb_x - 1) << mb_size);
+ s->dest[1] = s->current_picture.f->data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
+ s->dest[2] = s->current_picture.f->data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
{
@@ -3047,213 +3179,6 @@ void ff_mpeg_flush(AVCodecContext *avctx){
s->pp_time=0;
}
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- nCoeffs= s->block_last_index[n];
-
- block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
- /* XXX: only mpeg1 */
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = (level - 1) | 1;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- nCoeffs= s->block_last_index[n];
-
- quant_matrix = s->inter_matrix;
- for(i=0; i<=nCoeffs; i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = (level - 1) | 1;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
- int sum=-1;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
- sum += block[0];
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- }
- block[j] = level;
- sum+=level;
- }
- }
- block[63]^=sum&1;
-}
-
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
- int sum=-1;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- quant_matrix = s->inter_matrix;
- for(i=0; i<=nCoeffs; i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = -level;
- } else {
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- }
- block[j] = level;
- sum+=level;
- }
- }
- block[63]^=sum&1;
-}
-
-static void dct_unquantize_h263_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, qmul, qadd;
- int nCoeffs;
-
- av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
-
- qmul = qscale << 1;
-
- if (!s->h263_aic) {
- block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
- qadd = (qscale - 1) | 1;
- }else{
- qadd = 0;
- }
- if(s->ac_pred)
- nCoeffs=63;
- else
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
- for(i=1; i<=nCoeffs; i++) {
- level = block[i];
- if (level) {
- if (level < 0) {
- level = level * qmul - qadd;
- } else {
- level = level * qmul + qadd;
- }
- block[i] = level;
- }
- }
-}
-
-static void dct_unquantize_h263_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, qmul, qadd;
- int nCoeffs;
-
- av_assert2(s->block_last_index[n]>=0);
-
- qadd = (qscale - 1) | 1;
- qmul = qscale << 1;
-
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
- for(i=0; i<=nCoeffs; i++) {
- level = block[i];
- if (level) {
- if (level < 0) {
- level = level * qmul - qadd;
- } else {
- level = level * qmul + qadd;
- }
- block[i] = level;
- }
- }
-}
-
/**
* set qscale and update qscale dependent variables.
*/
@@ -3278,13 +3203,33 @@ void ff_MPV_report_decode_progress(MpegEncContext *s)
}
#if CONFIG_ERROR_RESILIENCE
+void ff_mpeg_set_erpic(ERPicture *dst, Picture *src)
+{
+ int i;
+
+ memset(dst, 0, sizeof(*dst));
+ if (!src)
+ return;
+
+ dst->f = src->f;
+ dst->tf = &src->tf;
+
+ for (i = 0; i < 2; i++) {
+ dst->motion_val[i] = src->motion_val[i];
+ dst->ref_index[i] = src->ref_index[i];
+ }
+
+ dst->mb_type = src->mb_type;
+ dst->field_picture = src->field_picture;
+}
+
void ff_mpeg_er_frame_start(MpegEncContext *s)
{
ERContext *er = &s->er;
- er->cur_pic = s->current_picture_ptr;
- er->last_pic = s->last_picture_ptr;
- er->next_pic = s->next_picture_ptr;
+ ff_mpeg_set_erpic(&er->cur_pic, s->current_picture_ptr);
+ ff_mpeg_set_erpic(&er->next_pic, s->next_picture_ptr);
+ ff_mpeg_set_erpic(&er->last_pic, s->last_picture_ptr);
er->pp_time = s->pp_time;
er->pb_time = s->pb_time;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegvideo.h b/chromium/third_party/ffmpeg/libavcodec/mpegvideo.h
index 65c4f9e0d5f..7a49d2ea1d0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegvideo.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegvideo.h
@@ -86,19 +86,13 @@ enum OutputFormat {
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
-/**
- * Value of Picture.reference when Picture is not a reference picture, but
- * is held for delayed output.
- */
-#define DELAYED_PIC_REF 4
-
struct MpegEncContext;
/**
* Picture.
*/
typedef struct Picture{
- struct AVFrame f;
+ struct AVFrame *f;
ThreadFrame tf;
AVBufferRef *qscale_table_buf;
@@ -108,31 +102,7 @@ typedef struct Picture{
int16_t (*motion_val[2])[2];
AVBufferRef *mb_type_buf;
- uint32_t *mb_type;
-
-#if !FF_API_MB_TYPE
-#define MB_TYPE_INTRA4x4 0x0001
-#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
-#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
-#define MB_TYPE_16x16 0x0008
-#define MB_TYPE_16x8 0x0010
-#define MB_TYPE_8x16 0x0020
-#define MB_TYPE_8x8 0x0040
-#define MB_TYPE_INTERLACED 0x0080
-#define MB_TYPE_DIRECT2 0x0100 //FIXME
-#define MB_TYPE_ACPRED 0x0200
-#define MB_TYPE_GMC 0x0400
-#define MB_TYPE_SKIP 0x0800
-#define MB_TYPE_P0L0 0x1000
-#define MB_TYPE_P1L0 0x2000
-#define MB_TYPE_P0L1 0x4000
-#define MB_TYPE_P1L1 0x8000
-#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
-#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
-#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
-#define MB_TYPE_QUANT 0x00010000
-#define MB_TYPE_CBP 0x00020000
-#endif
+ uint32_t *mb_type; ///< types and macros are defined in mpegutils.h
AVBufferRef *mbskip_table_buf;
uint8_t *mbskip_table;
@@ -158,56 +128,16 @@ typedef struct Picture{
*/
void *hwaccel_picture_private;
-#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type
-#define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4)
-#define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
-#define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
-#define IS_INTRA(a) ((a)&7)
-#define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
-#define IS_SKIP(a) ((a)&MB_TYPE_SKIP)
-#define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
-#define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
-#define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2)
-#define IS_GMC(a) ((a)&MB_TYPE_GMC)
-#define IS_16X16(a) ((a)&MB_TYPE_16x16)
-#define IS_16X8(a) ((a)&MB_TYPE_16x8)
-#define IS_8X16(a) ((a)&MB_TYPE_8x16)
-#define IS_8X8(a) ((a)&MB_TYPE_8x8)
-#define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused
-#define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused
-#define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused
-#define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused
-#define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED)
-#define IS_QUANT(a) ((a)&MB_TYPE_QUANT)
-#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
-#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note does not work if subMBs
-#define HAS_CBP(a) ((a)&MB_TYPE_CBP)
-
- int field_poc[2]; ///< h264 top/bottom POC
- int poc; ///< h264 frame POC
- int frame_num; ///< h264 frame_num (raw frame_num from slice header)
- int mmco_reset; ///< h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET.
- int pic_id; /**< h264 pic_num (short -> no wrap version of pic_num,
- pic_num & max_pic_num; long -> long_pic_num) */
- int long_ref; ///< 1->long term reference 0->short term reference
- int ref_poc[2][2][32]; ///< h264 POCs of the frames/fields used as reference (FIXME need per slice)
- int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice)
- int mbaff; ///< h264 1 -> MBAFF frame 0-> not MBAFF
int field_picture; ///< whether or not the picture was encoded in separate fields
- int mb_var_sum; ///< sum of MB variance for current frame
- int mc_mb_var_sum; ///< motion compensated MB variance for current frame
+ int64_t mb_var_sum; ///< sum of MB variance for current frame
+ int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame
int b_frame_score;
int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
int reference;
int shared;
- int recovered; ///< Picture at IDR or recovery point + recovery count
-
- int crop;
- int crop_left;
- int crop_top;
} Picture;
/**
@@ -250,8 +180,8 @@ typedef struct MotionEstContext{
int stride;
int uvstride;
/* temp variables for picture complexity calculation */
- int mc_mb_var_sum_temp;
- int mb_var_sum_temp;
+ int64_t mc_mb_var_sum_temp;
+ int64_t mb_var_sum_temp;
int scene_change_score;
/* cmp, chroma_cmp;*/
op_pixels_func (*hpel_put)[4];
@@ -271,6 +201,21 @@ typedef struct MotionEstContext{
*/
typedef struct MpegEncContext {
AVClass *class;
+
+ int y_dc_scale, c_dc_scale;
+ int ac_pred;
+ int block_last_index[12]; ///< last non zero coefficient in block
+ int h263_aic; ///< Advanded INTRA Coding (AIC)
+
+ /* scantables */
+ ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
+ ScanTable intra_scantable;
+ ScanTable intra_h_scantable;
+ ScanTable intra_v_scantable;
+
+ /* WARNING: changes above this line require updates to hardcoded
+ * offsets used in asm. */
+
struct AVCodecContext *avctx;
/* the following parameters must be initialized before encoding */
int width, height;///< picture size. must be a multiple of 16
@@ -308,7 +253,6 @@ typedef struct MpegEncContext {
int mb_width, mb_height; ///< number of MBs horizontally & vertically
int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
- int b4_stride; ///< 4*mb_width+1 used for some 4x4 block arrays to allow simple addressing
int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replication)
int mb_num; ///< number of MBs of a picture
ptrdiff_t linesize; ///< line size, in bytes, may be different from width
@@ -317,20 +261,6 @@ typedef struct MpegEncContext {
Picture **input_picture; ///< next pictures on display order for encoding
Picture **reordered_input_picture; ///< pointer to the next pictures in codedorder for encoding
- int y_dc_scale, c_dc_scale;
- int ac_pred;
- int block_last_index[12]; ///< last non zero coefficient in block
- int h263_aic; ///< Advanded INTRA Coding (AIC)
-
- /* scantables */
- ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
- ScanTable intra_scantable;
- ScanTable intra_h_scantable;
- ScanTable intra_v_scantable;
-
- /* WARNING: changes above this line require updates to hardcoded
- * offsets used in asm. */
-
int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_encode_video2()
/**
* pts difference between the first and second input frame, used for
@@ -475,24 +405,7 @@ typedef struct MpegEncContext {
int mb_x, mb_y;
int mb_skip_run;
int mb_intra;
- uint16_t *mb_type; ///< Table for candidate MB types for encoding
-#define CANDIDATE_MB_TYPE_INTRA 0x01
-#define CANDIDATE_MB_TYPE_INTER 0x02
-#define CANDIDATE_MB_TYPE_INTER4V 0x04
-#define CANDIDATE_MB_TYPE_SKIPPED 0x08
-//#define MB_TYPE_GMC 0x10
-
-#define CANDIDATE_MB_TYPE_DIRECT 0x10
-#define CANDIDATE_MB_TYPE_FORWARD 0x20
-#define CANDIDATE_MB_TYPE_BACKWARD 0x40
-#define CANDIDATE_MB_TYPE_BIDIR 0x80
-
-#define CANDIDATE_MB_TYPE_INTER_I 0x100
-#define CANDIDATE_MB_TYPE_FORWARD_I 0x200
-#define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
-#define CANDIDATE_MB_TYPE_BIDIR_I 0x800
-
-#define CANDIDATE_MB_TYPE_DIRECT0 0x1000
+ uint16_t *mb_type; ///< Table for candidate MB types for encoding (defines in mpegutils.h)
int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6];
@@ -656,11 +569,9 @@ typedef struct MpegEncContext {
/* MPEG-2-specific - I wished not to have to support this mess. */
int progressive_sequence;
int mpeg_f_code[2][2];
+
+ // picture structure defines are loaded from mpegutils.h
int picture_structure;
-/* picture type */
-#define PICT_TOP_FIELD 1
-#define PICT_BOTTOM_FIELD 2
-#define PICT_FRAME 3
int intra_dc_precision;
int frame_pred_frame_dct;
@@ -693,6 +604,7 @@ typedef struct MpegEncContext {
uint8_t *ptr_lastgob;
int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped
+ int pack_pblocks; //xvmc needs to keep blocks without gaps.
int16_t (*pblocks[12])[64];
int16_t (*block)[64]; ///< points to one of the following blocks
@@ -755,6 +667,8 @@ typedef struct MpegEncContext {
#define FF_MPV_FLAG_STRICT_GOP 0x0002
#define FF_MPV_FLAG_QP_RD 0x0004
#define FF_MPV_FLAG_CBP_RD 0x0008
+#define FF_MPV_FLAG_NAQ 0x0010
+#define FF_MPV_FLAG_MV0 0x0020
#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
@@ -764,6 +678,8 @@ typedef struct MpegEncContext {
{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
+{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
+{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\
FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\
@@ -799,23 +715,19 @@ void ff_MPV_frame_end(MpegEncContext *s);
int ff_MPV_encode_init(AVCodecContext *avctx);
int ff_MPV_encode_end(AVCodecContext *avctx);
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
- AVFrame *frame, int *got_packet);
+ const AVFrame *frame, int *got_packet);
void ff_dct_encode_init_x86(MpegEncContext *s);
void ff_MPV_common_init_x86(MpegEncContext *s);
void ff_MPV_common_init_axp(MpegEncContext *s);
void ff_MPV_common_init_arm(MpegEncContext *s);
-void ff_MPV_common_init_bfin(MpegEncContext *s);
void ff_MPV_common_init_ppc(MpegEncContext *s);
void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
- Picture *last, int y, int h, int picture_structure,
- int first_field, int draw_edges, int low_delay,
- int v_edge_pos, int h_edge_pos);
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_mpeg_flush(AVCodecContext *avctx);
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict);
-void ff_print_debug_info2(AVCodecContext *avctx, Picture *p, AVFrame *pict, uint8_t *mbskip_table,
+void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table,
+ uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
int *low_delay,
int mb_width, int mb_height, int mb_stride, int quarter_sample);
@@ -830,7 +742,9 @@ void ff_MPV_report_decode_progress(MpegEncContext *s);
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
void ff_set_qscale(MpegEncContext * s, int qscale);
+/* Error resilience */
void ff_mpeg_er_frame_start(MpegEncContext *s);
+void ff_mpeg_set_erpic(ERPicture *dst, Picture *src);
int ff_dct_common_init(MpegEncContext *s);
int ff_dct_encode_init(MpegEncContext *s);
@@ -853,8 +767,6 @@ void ff_MPV_motion(MpegEncContext *s,
*/
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared);
-extern const enum AVPixelFormat ff_pixfmt_list_420[];
-
/**
* permute block according to permuatation.
* @param last last non zero element in scantable order
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_enc.c b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_enc.c
index fb9f4519d63..99ab8856875 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_enc.c
@@ -34,6 +34,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
+#include "libavutil/timer.h"
#include "avcodec.h"
#include "dct.h"
#include "dsputil.h"
@@ -42,6 +43,7 @@
#include "h261.h"
#include "h263.h"
#include "mathops.h"
+#include "mpegutils.h"
#include "mjpegenc.h"
#include "msmpeg4.h"
#include "faandct.h"
@@ -226,7 +228,8 @@ av_cold int ff_dct_encode_init(MpegEncContext *s) {
if (ARCH_X86)
ff_dct_encode_init_x86(s);
- ff_h263dsp_init(&s->h263dsp);
+ if (CONFIG_H263_ENCODER)
+ ff_h263dsp_init(&s->h263dsp);
if (!s->dct_quantize)
s->dct_quantize = ff_dct_quantize_c;
if (!s->denoise_dct)
@@ -406,9 +409,9 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (!s->fixed_qscale &&
avctx->bit_rate * av_q2d(avctx->time_base) >
avctx->bit_rate_tolerance) {
- av_log(avctx, AV_LOG_ERROR,
- "bitrate tolerance too small for bitrate\n");
- return -1;
+ av_log(avctx, AV_LOG_WARNING,
+ "bitrate tolerance %d too small for bitrate %d, overriding\n", avctx->bit_rate_tolerance, avctx->bit_rate);
+ avctx->bit_rate_tolerance = 5 * avctx->bit_rate * av_q2d(avctx->time_base);
}
if (s->avctx->rc_max_rate &&
@@ -800,7 +803,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (ff_MPV_common_init(s) < 0)
return -1;
- s->avctx->coded_frame = &s->current_picture.f;
+ s->avctx->coded_frame = s->current_picture.f;
if (s->msmpeg4_version) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
@@ -887,6 +890,20 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
FF_ENABLE_DEPRECATION_WARNINGS;
#endif
+#if FF_API_NORMALIZE_AQP
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->flags & CODEC_FLAG_NORMALIZE_AQP)
+ s->mpv_flags |= FF_MPV_FLAG_NAQ;
+ FF_ENABLE_DEPRECATION_WARNINGS;
+#endif
+
+#if FF_API_MV0
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->flags & CODEC_FLAG_MV0)
+ s->mpv_flags |= FF_MPV_FLAG_MV0;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (avctx->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
@@ -1035,8 +1052,14 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
direct = 0;
if (pic_arg->linesize[2] != s->uvlinesize)
direct = 0;
+ if ((s->width & 15) || (s->height & 15))
+ direct = 0;
+ if (((intptr_t)(pic_arg->data[0])) & (STRIDE_ALIGN-1))
+ direct = 0;
+ if (s->linesize & (STRIDE_ALIGN-1))
+ direct = 0;
- av_dlog(s->avctx, "%d %d %td %td\n", pic_arg->linesize[0],
+ av_dlog(s->avctx, "%d %d %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"\n", pic_arg->linesize[0],
pic_arg->linesize[1], s->linesize, s->uvlinesize);
if (direct) {
@@ -1047,7 +1070,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
pic = &s->picture[i];
pic->reference = 3;
- if ((ret = av_frame_ref(&pic->f, pic_arg)) < 0)
+ if ((ret = av_frame_ref(pic->f, pic_arg)) < 0)
return ret;
if (ff_alloc_picture(s, pic, 1) < 0) {
return -1;
@@ -1064,9 +1087,9 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
return -1;
}
- if (pic->f.data[0] + INPLACE_OFFSET == pic_arg->data[0] &&
- pic->f.data[1] + INPLACE_OFFSET == pic_arg->data[1] &&
- pic->f.data[2] + INPLACE_OFFSET == pic_arg->data[2]) {
+ if (pic->f->data[0] + INPLACE_OFFSET == pic_arg->data[0] &&
+ pic->f->data[1] + INPLACE_OFFSET == pic_arg->data[1] &&
+ pic->f->data[2] + INPLACE_OFFSET == pic_arg->data[2]) {
// empty
} else {
int h_chroma_shift, v_chroma_shift;
@@ -1082,7 +1105,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
int w = s->width >> h_shift;
int h = s->height >> v_shift;
uint8_t *src = pic_arg->data[i];
- uint8_t *dst = pic->f.data[i];
+ uint8_t *dst = pic->f->data[i];
if (s->codec_id == AV_CODEC_ID_AMV && !(s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
h = ((s->height + 15)/16*16) >> v_shift;
@@ -1112,12 +1135,12 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
}
}
}
- ret = av_frame_copy_props(&pic->f, pic_arg);
+ ret = av_frame_copy_props(pic->f, pic_arg);
if (ret < 0)
return ret;
- pic->f.display_picture_number = display_picture_number;
- pic->f.pts = pts; // we set this here to avoid modifiying pic_arg
+ pic->f->display_picture_number = display_picture_number;
+ pic->f->pts = pts; // we set this here to avoid modifiying pic_arg
}
/* shift buffer entries */
@@ -1136,28 +1159,32 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
int64_t score64 = 0;
for (plane = 0; plane < 3; plane++) {
- const int stride = p->f.linesize[plane];
+ const int stride = p->f->linesize[plane];
const int bw = plane ? 1 : 2;
for (y = 0; y < s->mb_height * bw; y++) {
for (x = 0; x < s->mb_width * bw; x++) {
int off = p->shared ? 0 : 16;
- uint8_t *dptr = p->f.data[plane] + 8 * (x + y * stride) + off;
- uint8_t *rptr = ref->f.data[plane] + 8 * (x + y * stride);
+ uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
+ uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
int v = s->dsp.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
- switch (s->avctx->frame_skip_exp) {
+ switch (FFABS(s->avctx->frame_skip_exp)) {
case 0: score = FFMAX(score, v); break;
case 1: score += FFABS(v); break;
- case 2: score += v * v; break;
- case 3: score64 += FFABS(v * v * (int64_t)v); break;
- case 4: score64 += v * v * (int64_t)(v * v); break;
+ case 2: score64 += v * (int64_t)v; break;
+ case 3: score64 += FFABS(v * (int64_t)v * v); break;
+ case 4: score64 += (v * (int64_t)v) * (v * (int64_t)v); break;
}
}
}
}
+ emms_c();
if (score)
score64 = score;
+ if (s->avctx->frame_skip_exp < 0)
+ score64 = pow(score64 / (double)(s->mb_width * s->mb_height),
+ -1.0/s->avctx->frame_skip_exp);
if (score64 < s->avctx->frame_skip_threshold)
return 1;
@@ -1204,8 +1231,7 @@ static int estimate_best_b_count(MpegEncContext *s)
c->width = s->width >> scale;
c->height = s->height >> scale;
- c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |
- CODEC_FLAG_INPUT_PRESERVED /*| CODEC_FLAG_EMU_EDGE*/;
+ c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR;
c->flags |= s->avctx->flags & CODEC_FLAG_QPEL;
c->mb_decision = s->avctx->mb_decision;
c->me_cmp = s->avctx->me_cmp;
@@ -1226,19 +1252,19 @@ static int estimate_best_b_count(MpegEncContext *s)
pre_input = *pre_input_ptr;
if (!pre_input.shared && i) {
- pre_input.f.data[0] += INPLACE_OFFSET;
- pre_input.f.data[1] += INPLACE_OFFSET;
- pre_input.f.data[2] += INPLACE_OFFSET;
+ pre_input.f->data[0] += INPLACE_OFFSET;
+ pre_input.f->data[1] += INPLACE_OFFSET;
+ pre_input.f->data[2] += INPLACE_OFFSET;
}
s->dsp.shrink[scale](s->tmp_frames[i]->data[0], s->tmp_frames[i]->linesize[0],
- pre_input.f.data[0], pre_input.f.linesize[0],
+ pre_input.f->data[0], pre_input.f->linesize[0],
c->width, c->height);
s->dsp.shrink[scale](s->tmp_frames[i]->data[1], s->tmp_frames[i]->linesize[1],
- pre_input.f.data[1], pre_input.f.linesize[1],
+ pre_input.f->data[1], pre_input.f->linesize[1],
c->width >> 1, c->height >> 1);
s->dsp.shrink[scale](s->tmp_frames[i]->data[2], s->tmp_frames[i]->linesize[2],
- pre_input.f.data[2], pre_input.f.linesize[2],
+ pre_input.f->data[2], pre_input.f->linesize[2],
c->width >> 1, c->height >> 1);
}
}
@@ -1300,31 +1326,31 @@ static int select_input_picture(MpegEncContext *s)
/* set next picture type & ordering */
if (s->reordered_input_picture[0] == NULL && s->input_picture[0]) {
+ if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
+ if (s->picture_in_gop_number < s->gop_size &&
+ s->next_picture_ptr &&
+ skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
+ // FIXME check that te gop check above is +-1 correct
+ av_frame_unref(s->input_picture[0]->f);
+
+ ff_vbv_update(s, 0);
+
+ goto no_output_pic;
+ }
+ }
+
if (/*s->picture_in_gop_number >= s->gop_size ||*/
s->next_picture_ptr == NULL || s->intra_only) {
s->reordered_input_picture[0] = s->input_picture[0];
- s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_I;
- s->reordered_input_picture[0]->f.coded_picture_number =
+ s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
+ s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
int b_frames;
- if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
- if (s->picture_in_gop_number < s->gop_size &&
- skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
- // FIXME check that te gop check above is +-1 correct
- av_frame_unref(&s->input_picture[0]->f);
-
- emms_c();
- ff_vbv_update(s, 0);
-
- goto no_output_pic;
- }
- }
-
if (s->flags & CODEC_FLAG_PASS2) {
for (i = 0; i < s->max_b_frames + 1; i++) {
- int pict_num = s->input_picture[0]->f.display_picture_number + i;
+ int pict_num = s->input_picture[0]->f->display_picture_number + i;
if (pict_num >= s->rc_context.num_entries)
break;
@@ -1333,7 +1359,7 @@ static int select_input_picture(MpegEncContext *s)
break;
}
- s->input_picture[i]->f.pict_type =
+ s->input_picture[i]->f->pict_type =
s->rc_context.entry[pict_num].new_pict_type;
}
}
@@ -1348,8 +1374,8 @@ static int select_input_picture(MpegEncContext *s)
s->input_picture[i]->b_frame_score == 0) {
s->input_picture[i]->b_frame_score =
get_intra_count(s,
- s->input_picture[i ]->f.data[0],
- s->input_picture[i - 1]->f.data[0],
+ s->input_picture[i ]->f->data[0],
+ s->input_picture[i - 1]->f->data[0],
s->linesize) + 1;
}
}
@@ -1376,11 +1402,11 @@ static int select_input_picture(MpegEncContext *s)
emms_c();
for (i = b_frames - 1; i >= 0; i--) {
- int type = s->input_picture[i]->f.pict_type;
+ int type = s->input_picture[i]->f->pict_type;
if (type && type != AV_PICTURE_TYPE_B)
b_frames = i;
}
- if (s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_B &&
+ if (s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B &&
b_frames == s->max_b_frames) {
av_log(s->avctx, AV_LOG_ERROR,
"warning, too many b frames in a row\n");
@@ -1393,24 +1419,24 @@ static int select_input_picture(MpegEncContext *s)
} else {
if (s->flags & CODEC_FLAG_CLOSED_GOP)
b_frames = 0;
- s->input_picture[b_frames]->f.pict_type = AV_PICTURE_TYPE_I;
+ s->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I;
}
}
if ((s->flags & CODEC_FLAG_CLOSED_GOP) && b_frames &&
- s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_I)
+ s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I)
b_frames--;
s->reordered_input_picture[0] = s->input_picture[b_frames];
- if (s->reordered_input_picture[0]->f.pict_type != AV_PICTURE_TYPE_I)
- s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_P;
- s->reordered_input_picture[0]->f.coded_picture_number =
+ if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
+ s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
+ s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
for (i = 0; i < b_frames; i++) {
s->reordered_input_picture[i + 1] = s->input_picture[i];
- s->reordered_input_picture[i + 1]->f.pict_type =
+ s->reordered_input_picture[i + 1]->f->pict_type =
AV_PICTURE_TYPE_B;
- s->reordered_input_picture[i + 1]->f.coded_picture_number =
+ s->reordered_input_picture[i + 1]->f->coded_picture_number =
s->coded_picture_number++;
}
}
@@ -1418,7 +1444,7 @@ static int select_input_picture(MpegEncContext *s)
no_output_pic:
if (s->reordered_input_picture[0]) {
s->reordered_input_picture[0]->reference =
- s->reordered_input_picture[0]->f.pict_type !=
+ s->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
ff_mpeg_unref_picture(s, &s->new_picture);
@@ -1440,12 +1466,12 @@ no_output_pic:
return -1;
}
- ret = av_frame_copy_props(&pic->f, &s->reordered_input_picture[0]->f);
+ ret = av_frame_copy_props(pic->f, s->reordered_input_picture[0]->f);
if (ret < 0)
return ret;
/* mark us unused / free shared pic */
- av_frame_unref(&s->reordered_input_picture[0]->f);
+ av_frame_unref(s->reordered_input_picture[0]->f);
s->reordered_input_picture[0]->shared = 0;
s->current_picture_ptr = pic;
@@ -1453,7 +1479,7 @@ no_output_pic:
// input is not a shared pix -> reuse buffer for current_pix
s->current_picture_ptr = s->reordered_input_picture[0];
for (i = 0; i < 4; i++) {
- s->new_picture.f.data[i] += INPLACE_OFFSET;
+ s->new_picture.f->data[i] += INPLACE_OFFSET;
}
}
ff_mpeg_unref_picture(s, &s->current_picture);
@@ -1461,7 +1487,7 @@ no_output_pic:
s->current_picture_ptr)) < 0)
return ret;
- s->picture_number = s->new_picture.f.display_picture_number;
+ s->picture_number = s->new_picture.f->display_picture_number;
} else {
ff_mpeg_unref_picture(s, &s->new_picture);
}
@@ -1476,15 +1502,15 @@ static void frame_end(MpegEncContext *s)
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
- s->dsp.draw_edges(s->current_picture.f.data[0], s->current_picture.f.linesize[0],
+ s->dsp.draw_edges(s->current_picture.f->data[0], s->current_picture.f->linesize[0],
s->h_edge_pos, s->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(s->current_picture.f.data[1], s->current_picture.f.linesize[1],
+ s->dsp.draw_edges(s->current_picture.f->data[1], s->current_picture.f->linesize[1],
s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
- s->dsp.draw_edges(s->current_picture.f.data[2], s->current_picture.f.linesize[2],
+ s->dsp.draw_edges(s->current_picture.f->data[2], s->current_picture.f->linesize[2],
s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
@@ -1493,16 +1519,109 @@ static void frame_end(MpegEncContext *s)
emms_c();
s->last_pict_type = s->pict_type;
- s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f.quality;
+ s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality;
if (s->pict_type!= AV_PICTURE_TYPE_B)
s->last_non_b_pict_type = s->pict_type;
- s->avctx->coded_frame = &s->current_picture_ptr->f;
+ s->avctx->coded_frame = s->current_picture_ptr->f;
+
+}
+
+static void update_noise_reduction(MpegEncContext *s)
+{
+ int intra, i;
+
+ for (intra = 0; intra < 2; intra++) {
+ if (s->dct_count[intra] > (1 << 16)) {
+ for (i = 0; i < 64; i++) {
+ s->dct_error_sum[intra][i] >>= 1;
+ }
+ s->dct_count[intra] >>= 1;
+ }
+
+ for (i = 0; i < 64; i++) {
+ s->dct_offset[intra][i] = (s->avctx->noise_reduction *
+ s->dct_count[intra] +
+ s->dct_error_sum[intra][i] / 2) /
+ (s->dct_error_sum[intra][i] + 1);
+ }
+ }
+}
+
+static int frame_start(MpegEncContext *s)
+{
+ int ret;
+
+ /* mark & release old frames */
+ if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
+ s->last_picture_ptr != s->next_picture_ptr &&
+ s->last_picture_ptr->f->buf[0]) {
+ ff_mpeg_unref_picture(s, s->last_picture_ptr);
+ }
+
+ s->current_picture_ptr->f->pict_type = s->pict_type;
+ s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+
+ ff_mpeg_unref_picture(s, &s->current_picture);
+ if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,
+ s->current_picture_ptr)) < 0)
+ return ret;
+
+ if (s->pict_type != AV_PICTURE_TYPE_B) {
+ s->last_picture_ptr = s->next_picture_ptr;
+ if (!s->droppable)
+ s->next_picture_ptr = s->current_picture_ptr;
+ }
+
+ if (s->last_picture_ptr) {
+ ff_mpeg_unref_picture(s, &s->last_picture);
+ if (s->last_picture_ptr->f->buf[0] &&
+ (ret = ff_mpeg_ref_picture(s, &s->last_picture,
+ s->last_picture_ptr)) < 0)
+ return ret;
+ }
+ if (s->next_picture_ptr) {
+ ff_mpeg_unref_picture(s, &s->next_picture);
+ if (s->next_picture_ptr->f->buf[0] &&
+ (ret = ff_mpeg_ref_picture(s, &s->next_picture,
+ s->next_picture_ptr)) < 0)
+ return ret;
+ }
+
+ if (s->picture_structure!= PICT_FRAME) {
+ int i;
+ for (i = 0; i < 4; i++) {
+ if (s->picture_structure == PICT_BOTTOM_FIELD) {
+ s->current_picture.f->data[i] +=
+ s->current_picture.f->linesize[i];
+ }
+ s->current_picture.f->linesize[i] *= 2;
+ s->last_picture.f->linesize[i] *= 2;
+ s->next_picture.f->linesize[i] *= 2;
+ }
+ }
+
+ if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
+ s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
+ } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
+ s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
+ s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
+ } else {
+ s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
+ s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
+ }
+
+ if (s->dct_error_sum) {
+ av_assert2(s->avctx->noise_reduction && s->encoding);
+ update_noise_reduction(s);
+ }
+ return 0;
}
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
- AVFrame *pic_arg, int *got_packet)
+ const AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
int i, stuffing_count, ret;
@@ -1518,7 +1637,7 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
}
/* output? */
- if (s->new_picture.f.data[0]) {
+ if (s->new_picture.f->data[0]) {
if ((ret = ff_alloc_packet2(avctx, pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
return ret;
if (s->mb_info) {
@@ -1538,10 +1657,11 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&s->thread_context[i]->pb, start, end - start);
}
- s->pict_type = s->new_picture.f.pict_type;
+ s->pict_type = s->new_picture.f->pict_type;
//emms_c();
- if (ff_MPV_frame_start(s, avctx) < 0)
- return -1;
+ ret = frame_start(s);
+ if (ret < 0)
+ return ret;
vbv_retry:
if (encode_picture(s, s->picture_number) < 0)
return -1;
@@ -1577,7 +1697,7 @@ vbv_retry:
s->lambda_table[i] * (s->qscale + 1) /
s->qscale);
}
- s->mb_skipped = 0; // done in MPV_frame_start()
+ s->mb_skipped = 0; // done in frame_start()
// done in encode_picture() so we must undo it
if (s->pict_type == AV_PICTURE_TYPE_P) {
if (s->flipflop_rounding ||
@@ -1596,15 +1716,15 @@ vbv_retry:
goto vbv_retry;
}
- assert(s->avctx->rc_max_rate);
+ av_assert0(s->avctx->rc_max_rate);
}
if (s->flags & CODEC_FLAG_PASS1)
ff_write_pass1_stats(s);
for (i = 0; i < 4; i++) {
- s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i];
- avctx->error[i] += s->current_picture_ptr->f.error[i];
+ s->current_picture_ptr->f->error[i] = s->current_picture.f->error[i];
+ avctx->error[i] += s->current_picture_ptr->f->error[i];
}
if (s->flags & CODEC_FLAG_PASS1)
@@ -1682,16 +1802,16 @@ vbv_retry:
s->total_bits += s->frame_bits;
avctx->frame_bits = s->frame_bits;
- pkt->pts = s->current_picture.f.pts;
+ pkt->pts = s->current_picture.f->pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
- if (!s->current_picture.f.coded_picture_number)
+ if (!s->current_picture.f->coded_picture_number)
pkt->dts = pkt->pts - s->dts_delta;
else
pkt->dts = s->reordered_pts;
s->reordered_pts = pkt->pts;
} else
pkt->dts = pkt->pts;
- if (s->current_picture.f.key_frame)
+ if (s->current_picture.f->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
if (s->mb_info)
av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size);
@@ -1705,7 +1825,7 @@ vbv_retry:
ff_mpeg_unref_picture(s, &s->picture[i]);
}
- assert((s->frame_bits & 7) == 0);
+ av_assert1((s->frame_bits & 7) == 0);
pkt->size = s->frame_bits / 8;
*got_packet = !!pkt->size;
@@ -1878,11 +1998,11 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
wrap_y = s->linesize;
wrap_c = s->uvlinesize;
- ptr_y = s->new_picture.f.data[0] +
+ ptr_y = s->new_picture.f->data[0] +
(mb_y * 16 * wrap_y) + mb_x * 16;
- ptr_cb = s->new_picture.f.data[1] +
+ ptr_cb = s->new_picture.f->data[1] +
(mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width;
- ptr_cr = s->new_picture.f.data[2] +
+ ptr_cr = s->new_picture.f->data[2] +
(mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width;
if((mb_x * 16 + 16 > s->width || mb_y * 16 + 16 > s->height) && s->codec_id != AV_CODEC_ID_AMV){
@@ -1978,14 +2098,14 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
if (s->mv_dir & MV_DIR_FORWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0,
- s->last_picture.f.data,
+ s->last_picture.f->data,
op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix = s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1,
- s->next_picture.f.data,
+ s->next_picture.f->data,
op_pix, op_qpix);
}
@@ -2310,7 +2430,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
s->dest[0] = s->rd_scratchpad;
s->dest[1] = s->rd_scratchpad + 16*s->linesize;
s->dest[2] = s->rd_scratchpad + 16*s->linesize + 8;
- assert(s->linesize >= 32); //FIXME
+ av_assert0(s->linesize >= 32); //FIXME
}
encode_mb(s, motion_x, motion_y);
@@ -2341,7 +2461,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
}
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
- uint32_t *sq = ff_squareTbl + 256;
+ uint32_t *sq = ff_square_tab + 256;
int acc=0;
int x,y;
@@ -2370,18 +2490,18 @@ static int sse_mb(MpegEncContext *s){
if(w==16 && h==16)
if(s->avctx->mb_cmp == FF_CMP_NSSE){
- return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
- +s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
- +s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
+ return s->dsp.nsse[0](s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+ +s->dsp.nsse[1](s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+ +s->dsp.nsse[1](s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}else{
- return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
- +s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
- +s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
+ return s->dsp.sse[0](NULL, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+ +s->dsp.sse[1](NULL, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+ +s->dsp.sse[1](NULL, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}
else
- return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
- +sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
- +sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
+ return sse(s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
+ +sse(s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
+ +sse(s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
}
static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
@@ -2440,7 +2560,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xx = mb_x * 16;
int yy = mb_y * 16;
- uint8_t *pix = s->new_picture.f.data[0] + (yy * s->linesize) + xx;
+ uint8_t *pix = s->new_picture.f->data[0] + (yy * s->linesize) + xx;
int varc;
int sum = s->dsp.pix_sum(pix, s->linesize);
@@ -2549,7 +2669,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
/* note: quant matrix value (8) is implied here */
s->last_dc[i] = 128 << s->intra_dc_precision;
- s->current_picture.f.error[i] = 0;
+ s->current_picture.f->error[i] = 0;
}
if(s->codec_id==AV_CODEC_ID_AMV){
s->last_dc[0] = 128*8/13;
@@ -3116,14 +3236,14 @@ static int encode_thread(AVCodecContext *c, void *arg){
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
- s->current_picture.f.error[0] += sse(
- s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
+ s->current_picture.f->error[0] += sse(
+ s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->dest[0], w, h, s->linesize);
- s->current_picture.f.error[1] += sse(
- s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
+ s->current_picture.f->error[1] += sse(
+ s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
- s->current_picture.f.error[2] += sse(
- s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
+ s->current_picture.f->error[2] += sse(
+ s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
@@ -3175,9 +3295,9 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
MERGE(misc_bits);
MERGE(er.error_count);
MERGE(padding_bug_score);
- MERGE(current_picture.f.error[0]);
- MERGE(current_picture.f.error[1]);
- MERGE(current_picture.f.error[2]);
+ MERGE(current_picture.f->error[0]);
+ MERGE(current_picture.f->error[1]);
+ MERGE(current_picture.f->error[2]);
if(dst->avctx->noise_reduction){
for(i=0; i<64; i++){
@@ -3194,13 +3314,13 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
static int estimate_qp(MpegEncContext *s, int dry_run){
if (s->next_lambda){
- s->current_picture_ptr->f.quality =
- s->current_picture.f.quality = s->next_lambda;
+ s->current_picture_ptr->f->quality =
+ s->current_picture.f->quality = s->next_lambda;
if(!dry_run) s->next_lambda= 0;
} else if (!s->fixed_qscale) {
- s->current_picture_ptr->f.quality =
- s->current_picture.f.quality = ff_rate_estimate_qscale(s, dry_run);
- if (s->current_picture.f.quality < 0)
+ s->current_picture_ptr->f->quality =
+ s->current_picture.f->quality = ff_rate_estimate_qscale(s, dry_run);
+ if (s->current_picture.f->quality < 0)
return -1;
}
@@ -3223,15 +3343,15 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
s->lambda= s->lambda_table[0];
//FIXME broken
}else
- s->lambda = s->current_picture.f.quality;
+ s->lambda = s->current_picture.f->quality;
update_qscale(s);
return 0;
}
/* must be called before writing the header */
static void set_frame_distances(MpegEncContext * s){
- assert(s->current_picture_ptr->f.pts != AV_NOPTS_VALUE);
- s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num;
+ av_assert1(s->current_picture_ptr->f->pts != AV_NOPTS_VALUE);
+ s->time = s->current_picture_ptr->f->pts * s->avctx->time_base.num;
if(s->pict_type==AV_PICTURE_TYPE_B){
s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
@@ -3286,7 +3406,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
update_qscale(s);
}
- if(s->codec_id != AV_CODEC_ID_AMV){
+ if(s->codec_id != AV_CODEC_ID_AMV && s->codec_id != AV_CODEC_ID_MJPEG){
if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix);
if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16);
s->q_chroma_intra_matrix = s->q_intra_matrix;
@@ -3337,7 +3457,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(s->msmpeg4_version >= 3)
s->no_rounding=1;
- av_dlog(s, "Scene change detected, encoding as I Frame %d %d\n",
+ av_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
}
@@ -3402,17 +3522,31 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->qscale= 3; //reduce clipping problems
if (s->out_format == FMT_MJPEG) {
+ const uint16_t * luma_matrix = ff_mpeg1_default_intra_matrix;
+ const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
+
+ if (s->avctx->intra_matrix) {
+ chroma_matrix =
+ luma_matrix = s->avctx->intra_matrix;
+ }
+ if (s->avctx->chroma_intra_matrix)
+ chroma_matrix = s->avctx->chroma_intra_matrix;
+
/* for mjpeg, we do include qscale in the matrix */
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[i];
- s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
+ s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * s->qscale) >> 3);
+ s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3);
}
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision];
+ s->chroma_intra_matrix[0] =
s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8];
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
+ ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
+ s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
if(s->codec_id == AV_CODEC_ID_AMV){
@@ -3436,12 +3570,12 @@ static int encode_picture(MpegEncContext *s, int picture_number)
}
//FIXME var duplication
- s->current_picture_ptr->f.key_frame =
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
- s->current_picture_ptr->f.pict_type =
- s->current_picture.f.pict_type = s->pict_type;
+ s->current_picture_ptr->f->key_frame =
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
+ s->current_picture_ptr->f->pict_type =
+ s->current_picture.f->pict_type = s->pict_type;
- if (s->current_picture.f.key_frame)
+ if (s->current_picture.f->key_frame)
s->picture_in_gop_number=0;
s->mb_x = s->mb_y = 0;
@@ -3450,7 +3584,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
- s->intra_matrix);
+ s->intra_matrix, s->chroma_intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_motion.c b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_motion.c
index 9ec37890584..8a804e216e2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_motion.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_motion.c
@@ -28,6 +28,7 @@
#include "avcodec.h"
#include "dsputil.h"
#include "h261.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "mjpegenc.h"
#include "msmpeg4.h"
@@ -60,15 +61,15 @@ static void gmc1_motion(MpegEncContext *s,
ptr = ref_picture[0] + src_y * linesize + src_x;
- if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
- (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
- linesize, linesize,
- 17, 17,
- src_x, src_y,
- s->h_edge_pos, s->v_edge_pos);
- ptr = s->edge_emu_buffer;
- }
+ if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
+ (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
+ linesize, linesize,
+ 17, 17,
+ src_x, src_y,
+ s->h_edge_pos, s->v_edge_pos);
+ ptr = s->edge_emu_buffer;
+ }
if ((motion_x | motion_y) & 7) {
s->dsp.gmc1(dest_y, ptr, linesize, 16,
@@ -104,16 +105,16 @@ static void gmc1_motion(MpegEncContext *s,
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
- if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
- (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
- uvlinesize, uvlinesize,
- 9, 9,
- src_x, src_y,
- s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ptr = s->edge_emu_buffer;
- emu = 1;
- }
+ if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
+ (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
+ uvlinesize, uvlinesize,
+ 9, 9,
+ src_x, src_y,
+ s->h_edge_pos >> 1, s->v_edge_pos >> 1);
+ ptr = s->edge_emu_buffer;
+ emu = 1;
+ }
s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
@@ -209,7 +210,6 @@ static inline int hpel_motion(MpegEncContext *s,
dxy |= (motion_y & 1) << 1;
src += src_y * s->linesize + src_x;
- if (s->flags & CODEC_FLAG_EMU_EDGE) {
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src,
@@ -220,7 +220,6 @@ static inline int hpel_motion(MpegEncContext *s,
src = s->edge_emu_buffer;
emu = 1;
}
- }
pix_op[dxy](dest, src, s->linesize, 8);
return emu;
}
@@ -254,8 +253,8 @@ void mpeg_motion_internal(MpegEncContext *s,
#endif
v_edge_pos = s->v_edge_pos >> field_based;
- linesize = s->current_picture.f.linesize[0] << field_based;
- uvlinesize = s->current_picture.f.linesize[1] << field_based;
+ linesize = s->current_picture.f->linesize[0] << field_based;
+ uvlinesize = s->current_picture.f->linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
@@ -405,7 +404,7 @@ static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
motion_x, motion_y, h, 0, mb_y);
}
-// FIXME move to dsputil, avg variant, 16x16 version
+// FIXME: SIMDify, avg variant, 16x16 version
static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride)
{
int x;
@@ -619,16 +618,14 @@ static void chroma_4mv_motion(MpegEncContext *s,
offset = src_y * s->uvlinesize + src_x;
ptr = ref_picture[1] + offset;
- if (s->flags & CODEC_FLAG_EMU_EDGE) {
- if ((unsigned)src_x > FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
- (unsigned)src_y > FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 8, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
- s->uvlinesize, s->uvlinesize,
- 9, 9, src_x, src_y,
- s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ptr = s->edge_emu_buffer;
- emu = 1;
- }
+ if ((unsigned)src_x > FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 8, 0) ||
+ (unsigned)src_y > FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 8, 0)) {
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
+ s->uvlinesize, s->uvlinesize,
+ 9, 9, src_x, src_y,
+ s->h_edge_pos >> 1, s->v_edge_pos >> 1);
+ ptr = s->edge_emu_buffer;
+ emu = 1;
}
pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
@@ -779,17 +776,15 @@ static inline void apply_8x8(MpegEncContext *s,
dxy &= ~12;
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
- if (s->flags & CODEC_FLAG_EMU_EDGE) {
- if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 8, 0) ||
- (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 3) - 8, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
- s->linesize, s->linesize,
- 9, 9,
- src_x, src_y,
- s->h_edge_pos,
- s->v_edge_pos);
- ptr = s->edge_emu_buffer;
- }
+ if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 8, 0) ||
+ (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 3) - 8, 0)) {
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
+ s->linesize, s->linesize,
+ 9, 9,
+ src_x, src_y,
+ s->h_edge_pos,
+ s->v_edge_pos);
+ ptr = s->edge_emu_buffer;
}
dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
qpix_op[1][dxy](dest, ptr, s->linesize);
@@ -904,7 +899,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
} else {
if ( s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field
|| !ref_picture[0]) {
- ref_picture = s->current_picture_ptr->f.data;
+ ref_picture = s->current_picture_ptr->f->data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
@@ -921,7 +916,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && ref_picture[0]) {
ref2picture = ref_picture;
} else {
- ref2picture = s->current_picture_ptr->f.data;
+ ref2picture = s->current_picture_ptr->f->data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
@@ -948,7 +943,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
}
} else {
if (!ref_picture[0]) {
- ref_picture = s->current_picture_ptr->f.data;
+ ref_picture = s->current_picture_ptr->f->data;
}
for (i = 0; i < 2; i++) {
mpeg_motion(s, dest_y, dest_cb, dest_cr,
@@ -963,7 +958,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
/* opposite parity is always in the same frame if this is
* second field */
if (!s->first_field) {
- ref_picture = s->current_picture_ptr->f.data;
+ ref_picture = s->current_picture_ptr->f->data;
}
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_xvmc.c b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_xvmc.c
index 664c0089a17..6e8d7753075 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mpegvideo_xvmc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mpegvideo_xvmc.c
@@ -23,6 +23,7 @@
#include <X11/extensions/XvMC.h>
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#undef NDEBUG
@@ -32,8 +33,6 @@
#include "xvmc_internal.h"
#include "version.h"
-#if FF_API_XVMC
-
/**
* Initialize the block field of the MpegEncContext pointer passed as
* parameter after making sure that the data is not corrupted.
@@ -43,12 +42,21 @@
*/
void ff_xvmc_init_block(MpegEncContext *s)
{
- struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
+ struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render && render->xvmc_id == AV_XVMC_ID);
s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
}
+static void exchange_uv(MpegEncContext *s)
+{
+ int16_t (*tmp)[64];
+
+ tmp = s->pblocks[4];
+ s->pblocks[4] = s->pblocks[5];
+ s->pblocks[5] = tmp;
+}
+
/**
* Fill individual block pointers, so there are no gaps in the data_block array
* in case not all blocks in the macroblock are coded.
@@ -66,6 +74,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
s->pblocks[i] = NULL;
cbp += cbp;
}
+ if (s->swap_uv) {
+ exchange_uv(s);
+ }
}
/**
@@ -73,9 +84,10 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
* This function should be called for every new field and/or frame.
* It should be safe to call the function a few times for the same field.
*/
-int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
+static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
{
- struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
+ struct MpegEncContext *s = avctx->priv_data;
+ struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
const int mb_block_count = 4 + (1 << s->chroma_format);
assert(avctx);
@@ -115,7 +127,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
case AV_PICTURE_TYPE_I:
return 0; // no prediction from other frames
case AV_PICTURE_TYPE_B:
- next = (struct xvmc_pix_fmt*)s->next_picture.f.data[2];
+ next = (struct xvmc_pix_fmt*)s->next_picture.f->data[2];
if (!next)
return -1;
if (next->xvmc_id != AV_XVMC_ID)
@@ -123,7 +135,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
render->p_future_surface = next->p_surface;
// no return here, going to set forward prediction
case AV_PICTURE_TYPE_P:
- last = (struct xvmc_pix_fmt*)s->last_picture.f.data[2];
+ last = (struct xvmc_pix_fmt*)s->last_picture.f->data[2];
if (!last)
last = render; // predict second field from the first
if (last->xvmc_id != AV_XVMC_ID)
@@ -141,20 +153,22 @@ return -1;
* some leftover blocks, for example from error_resilience(), may remain.
* It should be safe to call the function a few times for the same field.
*/
-void ff_xvmc_field_end(MpegEncContext *s)
+static int ff_xvmc_field_end(AVCodecContext *avctx)
{
- struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
+ struct MpegEncContext *s = avctx->priv_data;
+ struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
if (render->filled_mv_blocks_num > 0)
ff_mpeg_draw_horiz_band(s, 0, 0);
+ return 0;
}
/**
* Synthesize the data needed by XvMC to render one macroblock of data.
* Fill all relevant fields, if necessary do IDCT.
*/
-void ff_xvmc_decode_mb(MpegEncContext *s)
+static void ff_xvmc_decode_mb(struct MpegEncContext *s)
{
XvMCMacroBlock *mv_block;
struct xvmc_pix_fmt *render;
@@ -184,7 +198,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
s->current_picture.qscale_table[mb_xy] = s->qscale;
// start of XVMC-specific code
- render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
+ render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
assert(render->xvmc_id == AV_XVMC_ID);
assert(render->mv_blocks);
@@ -313,7 +327,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
* slowdown. */
}
// copy blocks only if the codec doesn't support pblocks reordering
- if (s->avctx->xvmc_acceleration == 1) {
+ if (!s->pack_pblocks) {
memcpy(&render->data_blocks[render->next_free_data_block_num*64],
s->pblocks[i], sizeof(*s->pblocks[i]));
}
@@ -333,4 +347,30 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
ff_mpeg_draw_horiz_band(s, 0, 0);
}
-#endif /* FF_API_XVMC */
+#if CONFIG_MPEG1_XVMC_HWACCEL
+AVHWAccel ff_mpeg1_xvmc_hwaccel = {
+ .name = "mpeg1_xvmc",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_MPEG1VIDEO,
+ .pix_fmt = AV_PIX_FMT_XVMC,
+ .start_frame = ff_xvmc_field_start,
+ .end_frame = ff_xvmc_field_end,
+ .decode_slice = NULL,
+ .decode_mb = ff_xvmc_decode_mb,
+ .priv_data_size = 0,
+};
+#endif
+
+#if CONFIG_MPEG2_XVMC_HWACCEL
+AVHWAccel ff_mpeg2_xvmc_hwaccel = {
+ .name = "mpeg2_xvmc",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_MPEG2VIDEO,
+ .pix_fmt = AV_PIX_FMT_XVMC,
+ .start_frame = ff_xvmc_field_start,
+ .end_frame = ff_xvmc_field_end,
+ .decode_slice = NULL,
+ .decode_mb = ff_xvmc_decode_mb,
+ .priv_data_size = 0,
+};
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/msmpeg4.c b/chromium/third_party/ffmpeg/libavcodec/msmpeg4.c
index b071d74c920..70410767014 100644
--- a/chromium/third_party/ffmpeg/libavcodec/msmpeg4.c
+++ b/chromium/third_party/ffmpeg/libavcodec/msmpeg4.c
@@ -276,10 +276,10 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
int bs = 8 >> s->avctx->lowres;
if(n<4){
wrap= s->linesize;
- dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * bs* wrap ) + ((n & 1) + 2*s->mb_x) * bs;
+ dest= s->current_picture.f->data[0] + (((n >> 1) + 2*s->mb_y) * bs* wrap ) + ((n & 1) + 2*s->mb_x) * bs;
}else{
wrap= s->uvlinesize;
- dest= s->current_picture.f.data[n - 3] + (s->mb_y * bs * wrap) + s->mb_x * bs;
+ dest= s->current_picture.f->data[n - 3] + (s->mb_y * bs * wrap) + s->mb_x * bs;
}
if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
else a= get_dc(dest-bs, wrap, scale*8>>(2*s->avctx->lowres), bs);
diff --git a/chromium/third_party/ffmpeg/libavcodec/msmpeg4dec.c b/chromium/third_party/ffmpeg/libavcodec/msmpeg4dec.c
index 7c260fe50e1..2f96c34adb7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/msmpeg4dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/msmpeg4dec.c
@@ -23,7 +23,7 @@
*/
#include "avcodec.h"
-#include "dsputil.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "msmpeg4.h"
#include "libavutil/imgutils.h"
@@ -586,8 +586,11 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
} else {
level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
}
- if (level < 0)
+ if (level < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
+ *dir_ptr = 0;
return -1;
+ }
level-=256;
}else{ //FIXME optimize use unified tables & index
if (n < 4) {
@@ -597,6 +600,7 @@ static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
}
if (level < 0){
av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
+ *dir_ptr = 0;
return -1;
}
@@ -918,7 +922,10 @@ AVCodec ff_msmpeg4v1_decoder = {
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
AVCodec ff_msmpeg4v2_decoder = {
@@ -932,7 +939,10 @@ AVCodec ff_msmpeg4v2_decoder = {
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
AVCodec ff_msmpeg4v3_decoder = {
@@ -946,7 +956,10 @@ AVCodec ff_msmpeg4v3_decoder = {
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
AVCodec ff_wmv1_decoder = {
@@ -960,5 +973,8 @@ AVCodec ff_wmv1_decoder = {
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/msrle.c b/chromium/third_party/ffmpeg/libavcodec/msrle.c
index 2836fec2fd0..9f0cac61e3a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/msrle.c
+++ b/chromium/third_party/ffmpeg/libavcodec/msrle.c
@@ -35,6 +35,7 @@
#include "avcodec.h"
#include "internal.h"
#include "msrledec.h"
+#include "libavutil/imgutils.h"
typedef struct MsrleContext {
AVCodecContext *avctx;
@@ -110,11 +111,14 @@ static int msrle_decode_frame(AVCodecContext *avctx,
/* FIXME how to correctly detect RLE ??? */
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
- int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
+ int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
uint8_t *ptr = s->frame->data[0];
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
int i, j;
+ if (linesize < 0)
+ return linesize;
+
for (i = 0; i < avctx->height; i++) {
if (avctx->bits_per_coded_sample == 4) {
for (j = 0; j < avctx->width - 1; j += 2) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss1.c b/chromium/third_party/ffmpeg/libavcodec/mss1.c
index fc88eb0fd9c..6bb524bc482 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mss1.c
@@ -60,7 +60,7 @@ static void arith_normalise(ArithCoder *c)
}
}
-ARITH_GET_BIT()
+ARITH_GET_BIT(arith)
static int arith_get_bits(ArithCoder *c, int bits)
{
@@ -105,7 +105,7 @@ static int arith_get_prob(ArithCoder *c, int16_t *probs)
return sym;
}
-ARITH_GET_MODEL_SYM()
+ARITH_GET_MODEL_SYM(arith)
static void arith_init(ArithCoder *c, GetBitContext *gb)
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss12.c b/chromium/third_party/ffmpeg/libavcodec/mss12.c
index b522e4a4080..7d54d2917a8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss12.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mss12.c
@@ -23,6 +23,8 @@
* Common functions for Microsoft Screen 1 and 2
*/
+#include <inttypes.h>
+
#include "libavutil/intfloat.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
@@ -573,7 +575,7 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
if (AV_RB32(avctx->extradata) < avctx->extradata_size) {
av_log(avctx, AV_LOG_ERROR,
- "Insufficient extradata size: expected %d got %d\n",
+ "Insufficient extradata size: expected %"PRIu32" got %d\n",
AV_RB32(avctx->extradata),
avctx->extradata_size);
return AVERROR_INVALIDDATA;
@@ -592,7 +594,7 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
return AVERROR_INVALIDDATA;
}
- av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d\n",
+ av_log(avctx, AV_LOG_DEBUG, "Encoder version %"PRIu32".%"PRIu32"\n",
AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));
if (version != AV_RB32(avctx->extradata + 4) > 1) {
av_log(avctx, AV_LOG_ERROR,
@@ -609,13 +611,13 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
}
av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours);
- av_log(avctx, AV_LOG_DEBUG, "Display dimensions %dx%d\n",
+ av_log(avctx, AV_LOG_DEBUG, "Display dimensions %"PRIu32"x%"PRIu32"\n",
AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));
av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n",
avctx->coded_width, avctx->coded_height);
av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n",
av_int2float(AV_RB32(avctx->extradata + 28)));
- av_log(avctx, AV_LOG_DEBUG, "Bitrate %d bps\n",
+ av_log(avctx, AV_LOG_DEBUG, "Bitrate %"PRIu32" bps\n",
AV_RB32(avctx->extradata + 32));
av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 36)));
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss12.h b/chromium/third_party/ffmpeg/libavcodec/mss12.h
index a3f9a7ca70d..f9531673894 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss12.h
+++ b/chromium/third_party/ffmpeg/libavcodec/mss12.h
@@ -99,8 +99,8 @@ int ff_mss12_decode_init(MSS12Context *c, int version,
SliceContext *sc1, SliceContext *sc2);
int ff_mss12_decode_end(MSS12Context *ctx);
-#define ARITH_GET_BIT(VERSION) \
-static int arith ## VERSION ## _get_bit(ArithCoder *c) \
+#define ARITH_GET_BIT(prefix) \
+static int prefix ## _get_bit(ArithCoder *c) \
{ \
int range = c->high - c->low + 1; \
int bit = 2 * c->value - c->low >= c->high; \
@@ -110,22 +110,22 @@ static int arith ## VERSION ## _get_bit(ArithCoder *c) \
else \
c->high = c->low + (range >> 1) - 1; \
\
- arith ## VERSION ## _normalise(c); \
+ prefix ## _normalise(c); \
\
return bit; \
}
-#define ARITH_GET_MODEL_SYM(VERSION) \
-static int arith ## VERSION ## _get_model_sym(ArithCoder *c, Model *m) \
+#define ARITH_GET_MODEL_SYM(prefix) \
+static int prefix ## _get_model_sym(ArithCoder *c, Model *m) \
{ \
int idx, val; \
\
- idx = arith ## VERSION ## _get_prob(c, m->cum_prob); \
+ idx = prefix ## _get_prob(c, m->cum_prob); \
\
val = m->idx2sym[idx]; \
ff_mss12_model_update(m, idx); \
\
- arith ## VERSION ## _normalise(c); \
+ prefix ## _normalise(c); \
\
return val; \
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss2.c b/chromium/third_party/ffmpeg/libavcodec/mss2.c
index 99db046f033..64d6300aaa1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mss2.c
@@ -54,7 +54,7 @@ static void arith2_normalise(ArithCoder *c)
}
}
-ARITH_GET_BIT(2)
+ARITH_GET_BIT(arith2)
/* L. Stuiver and A. Moffat: "Piecewise Integer Mapping for Arithmetic Coding."
* In Proc. 8th Data Compression Conference (DCC '98), pp. 3-12, Mar. 1998 */
@@ -127,7 +127,7 @@ static int arith2_get_prob(ArithCoder *c, int16_t *probs)
return i;
}
-ARITH_GET_MODEL_SYM(2)
+ARITH_GET_MODEL_SYM(arith2)
static int arith2_get_consumed_bytes(ArithCoder *c)
{
@@ -417,12 +417,12 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
ff_MPV_frame_end(s);
- f = &s->current_picture.f;
+ f = s->current_picture.f;
if (v->respic == 3) {
ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h);
- ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w >> 1, h >> 1);
- ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w >> 1, h >> 1);
+ ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w+1 >> 1, h+1 >> 1);
+ ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w+1 >> 1, h+1 >> 1);
} else if (v->respic)
avpriv_request_sample(v->s.avctx,
"Asymmetric WMV9 rectangle subsampling");
@@ -739,8 +739,6 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
int ret;
v->s.avctx = avctx;
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
- v->s.flags |= CODEC_FLAG_EMU_EDGE;
if ((ret = ff_vc1_init_common(v)) < 0)
return ret;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss3.c b/chromium/third_party/ffmpeg/libavcodec/mss3.c
index c6bb838045d..075685b902d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss3.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mss3.c
@@ -26,8 +26,8 @@
#include "avcodec.h"
#include "bytestream.h"
-#include "dsputil.h"
#include "internal.h"
+#include "mathops.h"
#include "mss34dsp.h"
#define HEADER_SIZE 27
diff --git a/chromium/third_party/ffmpeg/libavcodec/mss4.c b/chromium/third_party/ffmpeg/libavcodec/mss4.c
index 662cf24df50..efa0372e549 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mss4.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mss4.c
@@ -27,7 +27,6 @@
#include "avcodec.h"
#include "bytestream.h"
-#include "dsputil.h"
#include "get_bits.h"
#include "internal.h"
#include "mss34dsp.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/msvideo1.c b/chromium/third_party/ffmpeg/libavcodec/msvideo1.c
index 970c67ce122..e60abeee27d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/msvideo1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/msvideo1.c
@@ -67,6 +67,8 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
if (s->avctx->bits_per_coded_sample == 8) {
s->mode_8bit = 1;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
+ if (avctx->extradata_size >= AVPALETTE_SIZE)
+ memcpy(s->pal, avctx->extradata, AVPALETTE_SIZE);
} else {
s->mode_8bit = 0;
avctx->pix_fmt = AV_PIX_FMT_RGB555;
diff --git a/chromium/third_party/ffmpeg/libavcodec/msvideo1enc.c b/chromium/third_party/ffmpeg/libavcodec/msvideo1enc.c
index 7844d57b70f..b27eadf06b2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/msvideo1enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/msvideo1enc.c
@@ -35,7 +35,6 @@
*/
typedef struct Msvideo1EncContext {
AVCodecContext *avctx;
- AVFrame pic;
AVLFG rnd;
uint8_t *prev;
@@ -58,7 +57,7 @@ enum MSV1Mode{
};
#define SKIP_PREFIX 0x8400
-#define SKIPS_MAX 0x0FFF
+#define SKIPS_MAX 0x03FF
#define MKRGB555(in, off) ((in[off] << 10) | (in[off + 1] << 5) | (in[off + 2]))
static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
@@ -67,7 +66,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
Msvideo1EncContext * const c = avctx->priv_data;
- AVFrame * const p = &c->pic;
+ const AVFrame *p = pict;
uint16_t *src;
uint8_t *prevptr;
uint8_t *dst, *buf;
@@ -75,12 +74,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int no_skips = 1;
int i, j, k, x, y, ret;
int skips = 0;
+ int quality = 24;
if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0)
return ret;
dst= buf= pkt->data;
- *p = *pict;
if(!c->prev)
c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
@@ -88,7 +87,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if(c->keyint >= avctx->keyint_min)
keyframe = 1;
- p->quality = 24;
for(y = 0; y < avctx->height; y += 4){
for(x = 0; x < avctx->width; x += 4){
@@ -114,7 +112,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bestscore += t*t;
}
}
- bestscore /= p->quality;
+ bestscore /= quality;
}
// try to find optimal value to fill whole 4x4 block
score = 0;
@@ -130,7 +128,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
}
- score /= p->quality;
+ score /= quality;
score += 2;
if(score < bestscore){
bestscore = score;
@@ -155,7 +153,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
}
- score /= p->quality;
+ score /= quality;
score += 6;
if(score < bestscore){
bestscore = score;
@@ -182,7 +180,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
}
- score /= p->quality;
+ score /= quality;
score += 18;
if(score < bestscore){
bestscore = score;
@@ -248,8 +246,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
c->keyint = 0;
else
c->keyint++;
- p->pict_type= keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
- p->key_frame= keyframe;
if (keyframe) pkt->flags |= AV_PKT_FLAG_KEY;
pkt->size = dst - buf;
*got_packet = 1;
@@ -274,8 +270,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return -1;
}
- avcodec_get_frame_defaults(&c->pic);
- avctx->coded_frame = (AVFrame*)&c->pic;
avctx->bits_per_coded_sample = 16;
c->keyint = avctx->keyint_min;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mvcdec.c b/chromium/third_party/ffmpeg/libavcodec/mvcdec.c
index 2cc7735cfbe..69f0ee259cf 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mvcdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mvcdec.c
@@ -25,6 +25,7 @@
*/
#include "libavutil/intreadwrite.h"
+
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
@@ -37,8 +38,8 @@ typedef struct MvcContext {
static av_cold int mvc_decode_init(AVCodecContext *avctx)
{
MvcContext *s = avctx->priv_data;
- int width = avctx->width;
- int height = avctx->height;
+ int width = avctx->width;
+ int height = avctx->height;
int ret;
if (avctx->codec_id == AV_CODEC_ID_MVC1) {
@@ -50,62 +51,60 @@ static av_cold int mvc_decode_init(AVCodecContext *avctx)
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
return ret;
- avctx->pix_fmt = (avctx->codec_id == AV_CODEC_ID_MVC1) ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_BGRA;
- s->frame = av_frame_alloc();
+ avctx->pix_fmt = (avctx->codec_id == AV_CODEC_ID_MVC1) ? AV_PIX_FMT_RGB555
+ : AV_PIX_FMT_RGB32;
+ s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
- s->vflip = avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9);
+ s->vflip = avctx->extradata_size >= 9 &&
+ !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9);
return 0;
}
-static int decode_mvc1(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_start, int width, int height, int linesize)
+static int decode_mvc1(AVCodecContext *avctx, GetByteContext *gb,
+ uint8_t *dst_start, int width, int height, int linesize)
{
uint8_t *dst;
uint16_t v[8];
int mask, x, y, i;
- x = y= 0;
- while (bytestream2_get_bytes_left(gb) >= 6) {
- mask = bytestream2_get_be16u(gb);
- v[0] = bytestream2_get_be16u(gb);
- v[1] = bytestream2_get_be16u(gb);
- if ((v[0] & 0x8000)) {
- if (bytestream2_get_bytes_left(gb) < 12) {
- av_log(avctx, AV_LOG_WARNING, "buffer overflow\n");
- return AVERROR_INVALIDDATA;
+ for (y = 0; y < height; y += 4) {
+ for (x = 0; x < width; x += 4) {
+ if (bytestream2_get_bytes_left(gb) < 6)
+ return 0;
+
+ mask = bytestream2_get_be16u(gb);
+ v[0] = bytestream2_get_be16u(gb);
+ v[1] = bytestream2_get_be16u(gb);
+ if ((v[0] & 0x8000)) {
+ if (bytestream2_get_bytes_left(gb) < 12) {
+ av_log(avctx, AV_LOG_WARNING, "buffer overflow\n");
+ return AVERROR_INVALIDDATA;
+ }
+ for (i = 2; i < 8; i++)
+ v[i] = bytestream2_get_be16u(gb);
+ } else {
+ v[2] = v[4] = v[6] = v[0];
+ v[3] = v[5] = v[7] = v[1];
}
- for (i = 2; i < 8; i++)
- v[i] = bytestream2_get_be16u(gb);
- } else {
- v[2] = v[4] = v[6] = v[0];
- v[3] = v[5] = v[7] = v[1];
- }
-
-#define PIX16(target, true, false) \
- i = (mask & target) ? true : false; \
- AV_WN16A(dst, (v[i] & 0x7C00) | (v[i] & 0x3E0) | (v[i] & 0x1F)); \
- dst += 2;
-#define ROW16(row, a1, a0, b1, b0) \
- dst = dst_start + (y + row) * linesize + x * 2; \
- PIX16(1 << (row * 4), a1, a0) \
- PIX16(1 << (row * 4 + 1), a1, a0) \
- PIX16(1 << (row * 4 + 2), b1, b0) \
- PIX16(1 << (row * 4 + 3), b1, b0)
-
- ROW16(0, 0, 1, 2, 3);
- ROW16(1, 0, 1, 2, 3);
- ROW16(2, 4, 5, 6, 7);
- ROW16(3, 4, 5, 6, 7);
-
- x += 4;
- if (x >= width) {
- y += 4;
- if (y >= height) {
- break;
- }
- x = 0;
+#define PIX16(target, true, false) \
+ i = (mask & target) ? true : false; \
+ AV_WN16A(dst, v[i] & 0x7FFF); \
+ dst += 2;
+
+#define ROW16(row, a1, a0, b1, b0) \
+ dst = dst_start + (y + row) * linesize + x * 2; \
+ PIX16(1 << (row * 4), a1, a0) \
+ PIX16(1 << (row * 4 + 1), a1, a0) \
+ PIX16(1 << (row * 4 + 2), b1, b0) \
+ PIX16(1 << (row * 4 + 3), b1, b0)
+
+ ROW16(0, 0, 1, 2, 3);
+ ROW16(1, 0, 1, 2, 3);
+ ROW16(2, 4, 5, 6, 7);
+ ROW16(3, 4, 5, 6, 7);
}
}
return 0;
@@ -119,24 +118,26 @@ static void set_4x4_block(uint8_t *dst, int linesize, uint32_t pixel)
AV_WN32A(dst + j * linesize + i * 4, pixel);
}
-#define PIX32(target, true, false) \
- AV_WN32A(dst, (mask & target) ? v[true] : v[false]); \
+#define PIX32(target, true, false) \
+ AV_WN32A(dst, (mask & target) ? v[true] : v[false]); \
dst += 4;
-#define ROW32(row, a1, a0, b1, b0) \
- dst = dst_start + (y + row) * linesize + x * 4; \
- PIX32(1 << (row * 4), a1, a0) \
- PIX32(1 << (row * 4 + 1), a1, a0) \
- PIX32(1 << (row * 4 + 2), b1, b0) \
+#define ROW32(row, a1, a0, b1, b0) \
+ dst = dst_start + (y + row) * linesize + x * 4; \
+ PIX32(1 << (row * 4), a1, a0) \
+ PIX32(1 << (row * 4 + 1), a1, a0) \
+ PIX32(1 << (row * 4 + 2), b1, b0) \
PIX32(1 << (row * 4 + 3), b1, b0)
-#define MVC2_BLOCK \
- ROW32(0, 1, 0, 3, 2); \
- ROW32(1, 1, 0, 3, 2); \
- ROW32(2, 5, 4, 7, 6); \
+#define MVC2_BLOCK \
+ ROW32(0, 1, 0, 3, 2); \
+ ROW32(1, 1, 0, 3, 2); \
+ ROW32(2, 5, 4, 7, 6); \
ROW32(3, 5, 4, 7, 6);
-static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_start, int width, int height, int linesize, int vflip)
+static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb,
+ uint8_t *dst_start, int width, int height,
+ int linesize, int vflip)
{
uint8_t *dst;
uint32_t color[128], v[8];
@@ -165,7 +166,7 @@ static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_s
if (vflip) {
dst_start += (height - 1) * linesize;
- linesize = -linesize;
+ linesize = -linesize;
}
x = y = 0;
while (bytestream2_get_bytes_left(gb) >= 1) {
@@ -173,17 +174,19 @@ static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_s
if ((p0 & 0x80)) {
if ((p0 & 0x40)) {
p0 &= 0x3F;
- p0 = (p0 << 2) | (p0 >> 4);
- set_4x4_block(dst_start + y * linesize + x * 4, linesize, 0xFF000000 | (p0 << 16) | (p0 << 8) | p0);
+ p0 = (p0 << 2) | (p0 >> 4);
+ set_4x4_block(dst_start + y * linesize + x * 4, linesize,
+ 0xFF000000 | (p0 << 16) | (p0 << 8) | p0);
} else {
int g, r;
p0 &= 0x3F;
- p0 = (p0 << 2) | (p0 >> 4);
+ p0 = (p0 << 2) | (p0 >> 4);
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
g = bytestream2_get_byteu(gb);
r = bytestream2_get_byteu(gb);
- set_4x4_block(dst_start + y * linesize + x * 4, linesize, 0xFF000000 | (r << 16) | (g << 8) | p0);
+ set_4x4_block(dst_start + y * linesize + x * 4, linesize,
+ 0xFF000000 | (r << 16) | (g << 8) | p0);
}
} else {
if (bytestream2_get_bytes_left(gb) < 1)
@@ -191,7 +194,8 @@ static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_s
p1 = bytestream2_get_byteu(gb);
if ((p1 & 0x80)) {
if ((p0 & 0x7F) == (p1 & 0x7F)) {
- set_4x4_block(dst_start + y * linesize + x * 4, linesize, color[p0 & 0x7F]);
+ set_4x4_block(dst_start + y * linesize + x * 4, linesize,
+ color[p0 & 0x7F]);
} else {
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
@@ -223,8 +227,7 @@ static int decode_mvc2(AVCodecContext *avctx, GetByteContext *gb, uint8_t *dst_s
return 0;
}
-static int mvc_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
+static int mvc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
MvcContext *s = avctx->priv_data;
@@ -236,9 +239,12 @@ static int mvc_decode_frame(AVCodecContext *avctx,
bytestream2_init(&gb, avpkt->data, avpkt->size);
if (avctx->codec_id == AV_CODEC_ID_MVC1)
- ret = decode_mvc1(avctx, &gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0]);
+ ret = decode_mvc1(avctx, &gb, s->frame->data[0],
+ avctx->width, avctx->height, s->frame->linesize[0]);
else
- ret = decode_mvc2(avctx, &gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0], s->vflip);
+ ret = decode_mvc2(avctx, &gb, s->frame->data[0],
+ avctx->width, avctx->height, s->frame->linesize[0],
+ s->vflip);
if (ret < 0)
return ret;
diff --git a/chromium/third_party/ffmpeg/libavcodec/mxpegdec.c b/chromium/third_party/ffmpeg/libavcodec/mxpegdec.c
index 8eee3b8e9e1..fbd4767db81 100644
--- a/chromium/third_party/ffmpeg/libavcodec/mxpegdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/mxpegdec.c
@@ -54,6 +54,7 @@ static av_cold int mxpeg_decode_end(AVCodecContext *avctx)
for (i = 0; i < 2; ++i)
av_frame_free(&s->picture[i]);
+ s->bitmask_size = 0;
av_freep(&s->mxm_bitmask);
av_freep(&s->completion_bitmask);
@@ -295,11 +296,11 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,
AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
- ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, reference_ptr);
+ ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, s->bitmask_size, reference_ptr);
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
- ret = ff_mjpeg_decode_sos(jpg, NULL, NULL);
+ ret = ff_mjpeg_decode_sos(jpg, NULL, 0, NULL);
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/nellymoserenc.c b/chromium/third_party/ffmpeg/libavcodec/nellymoserenc.c
index f9d1389a783..98e33f0e2e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/nellymoserenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/nellymoserenc.c
@@ -35,13 +35,15 @@
* http://wiki.multimedia.cx/index.php?title=Nellymoser
*/
+#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/mathematics.h"
-#include "nellymoser.h"
-#include "avcodec.h"
+
#include "audio_frame_queue.h"
+#include "avcodec.h"
#include "fft.h"
#include "internal.h"
+#include "nellymoser.h"
#include "sinewin.h"
#define BITSTREAM_WRITER_LE
diff --git a/chromium/third_party/ffmpeg/libavcodec/nuv.c b/chromium/third_party/ffmpeg/libavcodec/nuv.c
index d4d9318bf7a..31ab1a95e8f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/nuv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/nuv.c
@@ -25,6 +25,7 @@
#include "libavutil/bswap.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/lzo.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
@@ -40,7 +41,6 @@ typedef struct {
unsigned char *decomp_buf;
uint32_t lq[64], cq[64];
RTJpegContext rtj;
- DSPContext dsp;
} NuvContext;
static const uint8_t fallback_lquant[] = {
@@ -138,13 +138,11 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
"Can't allocate decompression buffer.\n");
return AVERROR(ENOMEM);
}
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height,
- c->lq, c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, c->width, c->height, c->lq, c->cq);
av_frame_unref(c->pic);
return 1;
} else if (quality != c->quality)
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height,
- c->lq, c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, c->width, c->height, c->lq, c->cq);
return 0;
}
@@ -183,8 +181,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
ret = get_quant(avctx, c, buf, buf_size);
if (ret < 0)
return ret;
- ff_rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq,
- c->cq);
+ ff_rtjpeg_decode_init(&c->rtj, c->width, c->height, c->lq, c->cq);
return orig_size;
}
@@ -218,6 +215,7 @@ retry:
}
buf = c->decomp_buf;
buf_size = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen;
+ memset(c->decomp_buf + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
if (c->codec_frameheader) {
int w, h, q;
@@ -321,7 +319,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->extradata_size)
get_quant(avctx, c, avctx->extradata, avctx->extradata_size);
- ff_dsputil_init(&c->dsp, avctx);
+ ff_rtjpeg_init(&c->rtj, avctx);
if ((ret = codec_reinit(avctx, avctx->width, avctx->height, -1)) < 0)
return ret;
diff --git a/chromium/third_party/ffmpeg/libavcodec/on2avc.c b/chromium/third_party/ffmpeg/libavcodec/on2avc.c
new file mode 100644
index 00000000000..ed212f118a8
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/on2avc.c
@@ -0,0 +1,1015 @@
+/*
+ * On2 Audio for Video Codec decoder
+ *
+ * Copyright (c) 2013 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/float_dsp.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "dsputil.h"
+#include "fft.h"
+#include "get_bits.h"
+#include "golomb.h"
+#include "internal.h"
+#include "unary.h"
+
+#include "on2avcdata.h"
+
+#define ON2AVC_SUBFRAME_SIZE 1024
+
+enum WindowTypes {
+ WINDOW_TYPE_LONG = 0,
+ WINDOW_TYPE_LONG_STOP,
+ WINDOW_TYPE_LONG_START,
+ WINDOW_TYPE_8SHORT = 3,
+ WINDOW_TYPE_EXT4,
+ WINDOW_TYPE_EXT5,
+ WINDOW_TYPE_EXT6,
+ WINDOW_TYPE_EXT7,
+};
+
+typedef struct On2AVCContext {
+ AVCodecContext *avctx;
+ AVFloatDSPContext fdsp;
+ FFTContext mdct, mdct_half, mdct_small;
+ FFTContext fft128, fft256, fft512, fft1024;
+ void (*wtf)(struct On2AVCContext *ctx, float *out, float *in, int size);
+
+ int is_av500;
+
+ const On2AVCMode *modes;
+ int window_type, prev_window_type;
+ int num_windows, num_bands;
+ int bits_per_section;
+ const int *band_start;
+
+ int grouping[8];
+ int ms_present;
+ int ms_info[ON2AVC_MAX_BANDS];
+
+ int is_long;
+
+ uint8_t band_type[ON2AVC_MAX_BANDS];
+ uint8_t band_run_end[ON2AVC_MAX_BANDS];
+ int num_sections;
+
+ float band_scales[ON2AVC_MAX_BANDS];
+
+ VLC scale_diff;
+ VLC cb_vlc[16];
+
+ float scale_tab[128];
+
+ DECLARE_ALIGNED(32, float, coeffs)[2][ON2AVC_SUBFRAME_SIZE];
+ DECLARE_ALIGNED(32, float, delay) [2][ON2AVC_SUBFRAME_SIZE];
+
+ DECLARE_ALIGNED(32, float, temp) [ON2AVC_SUBFRAME_SIZE * 2];
+ DECLARE_ALIGNED(32, float, mdct_buf) [ON2AVC_SUBFRAME_SIZE];
+ DECLARE_ALIGNED(32, float, long_win) [ON2AVC_SUBFRAME_SIZE];
+ DECLARE_ALIGNED(32, float, short_win)[ON2AVC_SUBFRAME_SIZE / 8];
+} On2AVCContext;
+
+static void on2avc_read_ms_info(On2AVCContext *c, GetBitContext *gb)
+{
+ int w, b, band_off = 0;
+
+ c->ms_present = get_bits1(gb);
+ if (!c->ms_present)
+ return;
+ for (w = 0; w < c->num_windows; w++) {
+ if (!c->grouping[w]) {
+ memcpy(c->ms_info + band_off,
+ c->ms_info + band_off - c->num_bands,
+ c->num_bands * sizeof(*c->ms_info));
+ band_off += c->num_bands;
+ continue;
+ }
+ for (b = 0; b < c->num_bands; b++)
+ c->ms_info[band_off++] = get_bits1(gb);
+ }
+}
+
+// do not see Table 17 in ISO/IEC 13818-7
+static int on2avc_decode_band_types(On2AVCContext *c, GetBitContext *gb)
+{
+ int bits_per_sect = c->is_long ? 5 : 3;
+ int esc_val = (1 << bits_per_sect) - 1;
+ int num_bands = c->num_bands * c->num_windows;
+ int band = 0, i, band_type, run_len, run;
+
+ while (band < num_bands) {
+ band_type = get_bits(gb, 4);
+ run_len = 1;
+ do {
+ run = get_bits(gb, bits_per_sect);
+ run_len += run;
+ } while (run == esc_val);
+ if (band + run_len > num_bands) {
+ av_log(c->avctx, AV_LOG_ERROR, "Invalid band type run\n");
+ return AVERROR_INVALIDDATA;
+ }
+ for (i = band; i < band + run_len; i++) {
+ c->band_type[i] = band_type;
+ c->band_run_end[i] = band + run_len;
+ }
+ band += run_len;
+ }
+
+ return 0;
+}
+
+// completely not like Table 18 in ISO/IEC 13818-7
+// (no intensity stereo, different coding for the first coefficient)
+static int on2avc_decode_band_scales(On2AVCContext *c, GetBitContext *gb)
+{
+ int w, w2, b, scale, first = 1;
+ int band_off = 0;
+
+ for (w = 0; w < c->num_windows; w++) {
+ if (!c->grouping[w]) {
+ memcpy(c->band_scales + band_off,
+ c->band_scales + band_off - c->num_bands,
+ c->num_bands * sizeof(*c->band_scales));
+ band_off += c->num_bands;
+ continue;
+ }
+ for (b = 0; b < c->num_bands; b++) {
+ if (!c->band_type[band_off]) {
+ int all_zero = 1;
+ for (w2 = w + 1; w2 < c->num_windows; w2++) {
+ if (c->grouping[w2])
+ break;
+ if (c->band_type[w2 * c->num_bands + b]) {
+ all_zero = 0;
+ break;
+ }
+ }
+ if (all_zero) {
+ c->band_scales[band_off++] = 0;
+ continue;
+ }
+ }
+ if (first) {
+ scale = get_bits(gb, 7);
+ first = 0;
+ } else {
+ scale += get_vlc2(gb, c->scale_diff.table, 9, 3) - 60;
+ }
+ if (scale < 0 || scale > 128) {
+ av_log(c->avctx, AV_LOG_ERROR, "Invalid scale value %d\n",
+ scale);
+ return AVERROR_INVALIDDATA;
+ }
+ c->band_scales[band_off++] = c->scale_tab[scale];
+ }
+ }
+
+ return 0;
+}
+
+static inline float on2avc_scale(int v, float scale)
+{
+ return v * sqrtf(fabsf(v)) * scale;
+}
+
+// spectral data is coded completely differently - there are no unsigned codebooks
+static int on2avc_decode_quads(On2AVCContext *c, GetBitContext *gb, float *dst,
+ int dst_size, int type, float band_scale)
+{
+ int i, j, val, val1;
+
+ for (i = 0; i < dst_size; i += 4) {
+ val = get_vlc2(gb, c->cb_vlc[type].table, 9, 3);
+
+ for (j = 0; j < 4; j++) {
+ val1 = sign_extend((val >> (12 - j * 4)) & 0xF, 4);
+ *dst++ = on2avc_scale(val1, band_scale);
+ }
+ }
+
+ return 0;
+}
+
+static inline int get_egolomb(GetBitContext *gb)
+{
+ int v = 4;
+
+ while (get_bits1(gb)) v++;
+
+ return (1 << v) + get_bits(gb, v);
+}
+
+static int on2avc_decode_pairs(On2AVCContext *c, GetBitContext *gb, float *dst,
+ int dst_size, int type, float band_scale)
+{
+ int i, val, val1, val2, sign;
+
+ for (i = 0; i < dst_size; i += 2) {
+ val = get_vlc2(gb, c->cb_vlc[type].table, 9, 3);
+
+ val1 = sign_extend(val >> 8, 8);
+ val2 = sign_extend(val & 0xFF, 8);
+ if (type == ON2AVC_ESC_CB) {
+ if (val1 <= -16 || val1 >= 16) {
+ sign = 1 - (val1 < 0) * 2;
+ val1 = sign * get_egolomb(gb);
+ }
+ if (val2 <= -16 || val2 >= 16) {
+ sign = 1 - (val2 < 0) * 2;
+ val2 = sign * get_egolomb(gb);
+ }
+ }
+
+ *dst++ = on2avc_scale(val1, band_scale);
+ *dst++ = on2avc_scale(val2, band_scale);
+ }
+
+ return 0;
+}
+
+static int on2avc_read_channel_data(On2AVCContext *c, GetBitContext *gb, int ch)
+{
+ int ret;
+ int w, b, band_idx;
+ float *coeff_ptr;
+
+ if ((ret = on2avc_decode_band_types(c, gb)) < 0)
+ return ret;
+ if ((ret = on2avc_decode_band_scales(c, gb)) < 0)
+ return ret;
+
+ coeff_ptr = c->coeffs[ch];
+ band_idx = 0;
+ memset(coeff_ptr, 0, ON2AVC_SUBFRAME_SIZE * sizeof(*coeff_ptr));
+ for (w = 0; w < c->num_windows; w++) {
+ for (b = 0; b < c->num_bands; b++) {
+ int band_size = c->band_start[b + 1] - c->band_start[b];
+ int band_type = c->band_type[band_idx + b];
+
+ if (!band_type) {
+ coeff_ptr += band_size;
+ continue;
+ }
+ if (band_type < 9)
+ on2avc_decode_quads(c, gb, coeff_ptr, band_size, band_type,
+ c->band_scales[band_idx + b]);
+ else
+ on2avc_decode_pairs(c, gb, coeff_ptr, band_size, band_type,
+ c->band_scales[band_idx + b]);
+ coeff_ptr += band_size;
+ }
+ band_idx += c->num_bands;
+ }
+
+ return 0;
+}
+
+static int on2avc_apply_ms(On2AVCContext *c)
+{
+ int w, b, i;
+ int band_off = 0;
+ float *ch0 = c->coeffs[0];
+ float *ch1 = c->coeffs[1];
+
+ for (w = 0; w < c->num_windows; w++) {
+ for (b = 0; b < c->num_bands; b++) {
+ if (c->ms_info[band_off + b]) {
+ for (i = c->band_start[b]; i < c->band_start[b + 1]; i++) {
+ float l = *ch0, r = *ch1;
+ *ch0++ = l + r;
+ *ch1++ = l - r;
+ }
+ } else {
+ ch0 += c->band_start[b + 1] - c->band_start[b];
+ ch1 += c->band_start[b + 1] - c->band_start[b];
+ }
+ }
+ band_off += c->num_bands;
+ }
+ return 0;
+}
+
+static void zero_head_and_tail(float *src, int len, int order0, int order1)
+{
+ memset(src, 0, sizeof(*src) * order0);
+ memset(src + len - order1, 0, sizeof(*src) * order1);
+}
+
+static void pretwiddle(float *src, float *dst, int dst_len, int tab_step,
+ int step, int order0, int order1, const double * const *tabs)
+{
+ float *src2, *out;
+ const double *tab;
+ int i, j;
+
+ out = dst;
+ tab = tabs[0];
+ for (i = 0; i < tab_step; i++) {
+ double sum = 0;
+ for (j = 0; j < order0; j++)
+ sum += src[j] * tab[j * tab_step + i];
+ out[i] += sum;
+ }
+
+ out = dst + dst_len - tab_step;
+ tab = tabs[order0];
+ src2 = src + (dst_len - tab_step) / step + 1 + order0;
+ for (i = 0; i < tab_step; i++) {
+ double sum = 0;
+ for (j = 0; j < order1; j++)
+ sum += src2[j] * tab[j * tab_step + i];
+ out[i] += sum;
+ }
+}
+
+static void twiddle(float *src1, float *src2, int src2_len,
+ const double *tab, int tab_len, int step,
+ int order0, int order1, const double * const *tabs)
+{
+ int steps;
+ int mask;
+ int i, j;
+
+ steps = (src2_len - tab_len) / step + 1;
+ pretwiddle(src1, src2, src2_len, tab_len, step, order0, order1, tabs);
+ mask = tab_len - 1;
+
+ for (i = 0; i < steps; i++) {
+ float in0 = src1[order0 + i];
+ int pos = (src2_len - 1) & mask;
+
+ if (pos < tab_len) {
+ const double *t = tab;
+ for (j = pos; j >= 0; j--)
+ src2[j] += in0 * *t++;
+ for (j = 0; j < tab_len - pos - 1; j++)
+ src2[src2_len - j - 1] += in0 * tab[pos + 1 + j];
+ } else {
+ for (j = 0; j < tab_len; j++)
+ src2[pos - j] += in0 * tab[j];
+ }
+ mask = pos + step;
+ }
+}
+
+#define CMUL1_R(s, t, is, it) \
+ s[is + 0] * t[it + 0] - s[is + 1] * t[it + 1]
+#define CMUL1_I(s, t, is, it) \
+ s[is + 0] * t[it + 1] + s[is + 1] * t[it + 0]
+#define CMUL2_R(s, t, is, it) \
+ s[is + 0] * t[it + 0] + s[is + 1] * t[it + 1]
+#define CMUL2_I(s, t, is, it) \
+ s[is + 0] * t[it + 1] - s[is + 1] * t[it + 0]
+
+#define CMUL0(dst, id, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
+ dst[id] = s0[is] * t0[it] + s1[is] * t1[it] \
+ + s2[is] * t2[it] + s3[is] * t3[it]; \
+ dst[id + 1] = s0[is] * t0[it + 1] + s1[is] * t1[it + 1] \
+ + s2[is] * t2[it + 1] + s3[is] * t3[it + 1];
+
+#define CMUL1(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
+ *dst++ = CMUL1_R(s0, t0, is, it) \
+ + CMUL1_R(s1, t1, is, it) \
+ + CMUL1_R(s2, t2, is, it) \
+ + CMUL1_R(s3, t3, is, it); \
+ *dst++ = CMUL1_I(s0, t0, is, it) \
+ + CMUL1_I(s1, t1, is, it) \
+ + CMUL1_I(s2, t2, is, it) \
+ + CMUL1_I(s3, t3, is, it);
+
+#define CMUL2(dst, s0, s1, s2, s3, t0, t1, t2, t3, is, it) \
+ *dst++ = CMUL2_R(s0, t0, is, it) \
+ + CMUL2_R(s1, t1, is, it) \
+ + CMUL2_R(s2, t2, is, it) \
+ + CMUL2_R(s3, t3, is, it); \
+ *dst++ = CMUL2_I(s0, t0, is, it) \
+ + CMUL2_I(s1, t1, is, it) \
+ + CMUL2_I(s2, t2, is, it) \
+ + CMUL2_I(s3, t3, is, it);
+
+static void combine_fft(float *s0, float *s1, float *s2, float *s3, float *dst,
+ const float *t0, const float *t1,
+ const float *t2, const float *t3, int len, int step)
+{
+ const float *h0, *h1, *h2, *h3;
+ float *d1, *d2;
+ int tmp, half;
+ int len2 = len >> 1, len4 = len >> 2;
+ int hoff;
+ int i, j, k;
+
+ tmp = step;
+ for (half = len2; tmp > 1; half <<= 1, tmp >>= 1);
+
+ h0 = t0 + half;
+ h1 = t1 + half;
+ h2 = t2 + half;
+ h3 = t3 + half;
+
+ CMUL0(dst, 0, s0, s1, s2, s3, t0, t1, t2, t3, 0, 0);
+
+ hoff = 2 * step * (len4 >> 1);
+
+ j = 2;
+ k = 2 * step;
+ d1 = dst + 2;
+ d2 = dst + 2 + (len >> 1);
+ for (i = 0; i < (len4 - 1) >> 1; i++) {
+ CMUL1(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
+ CMUL1(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
+ j += 2;
+ k += 2 * step;
+ }
+ CMUL0(dst, len4, s0, s1, s2, s3, t0, t1, t2, t3, 1, hoff);
+ CMUL0(dst, len4 + len2, s0, s1, s2, s3, h0, h1, h2, h3, 1, hoff);
+
+ j = len4;
+ k = hoff + 2 * step * len4;
+ d1 = dst + len4 + 2;
+ d2 = dst + len4 + 2 + len2;
+ for (i = 0; i < (len4 - 2) >> 1; i++) {
+ CMUL2(d1, s0, s1, s2, s3, t0, t1, t2, t3, j, k);
+ CMUL2(d2, s0, s1, s2, s3, h0, h1, h2, h3, j, k);
+ j -= 2;
+ k += 2 * step;
+ }
+ CMUL0(dst, len2 + 4, s0, s1, s2, s3, t0, t1, t2, t3, 0, k);
+}
+
+static void wtf_end_512(On2AVCContext *c, float *out, float *src,
+ float *tmp0, float *tmp1)
+{
+ memcpy(src, tmp0, 384 * sizeof(*tmp0));
+ memcpy(tmp0 + 384, src + 384, 128 * sizeof(*tmp0));
+
+ zero_head_and_tail(src, 128, 16, 4);
+ zero_head_and_tail(src + 128, 128, 16, 4);
+ zero_head_and_tail(src + 256, 128, 13, 7);
+ zero_head_and_tail(src + 384, 128, 15, 5);
+
+ c->fft128.fft_permute(&c->fft128, (FFTComplex*)src);
+ c->fft128.fft_permute(&c->fft128, (FFTComplex*)(src + 128));
+ c->fft128.fft_permute(&c->fft128, (FFTComplex*)(src + 256));
+ c->fft128.fft_permute(&c->fft128, (FFTComplex*)(src + 384));
+ c->fft128.fft_calc(&c->fft128, (FFTComplex*)src);
+ c->fft128.fft_calc(&c->fft128, (FFTComplex*)(src + 128));
+ c->fft128.fft_calc(&c->fft128, (FFTComplex*)(src + 256));
+ c->fft128.fft_calc(&c->fft128, (FFTComplex*)(src + 384));
+ combine_fft(src, src + 128, src + 256, src + 384, tmp1,
+ ff_on2avc_ctab_1, ff_on2avc_ctab_2,
+ ff_on2avc_ctab_3, ff_on2avc_ctab_4, 512, 2);
+ c->fft512.fft_permute(&c->fft512, (FFTComplex*)tmp1);
+ c->fft512.fft_calc(&c->fft512, (FFTComplex*)tmp1);
+
+ pretwiddle(&tmp0[ 0], tmp1, 512, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ pretwiddle(&tmp0[128], tmp1, 512, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ pretwiddle(&tmp0[256], tmp1, 512, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ pretwiddle(&tmp0[384], tmp1, 512, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+
+ memcpy(src, tmp1, 512 * sizeof(float));
+}
+
+static void wtf_end_1024(On2AVCContext *c, float *out, float *src,
+ float *tmp0, float *tmp1)
+{
+ memcpy(src, tmp0, 768 * sizeof(*tmp0));
+ memcpy(tmp0 + 768, src + 768, 256 * sizeof(*tmp0));
+
+ zero_head_and_tail(src, 256, 16, 4);
+ zero_head_and_tail(src + 256, 256, 16, 4);
+ zero_head_and_tail(src + 512, 256, 13, 7);
+ zero_head_and_tail(src + 768, 256, 15, 5);
+
+ c->fft256.fft_permute(&c->fft256, (FFTComplex*)src);
+ c->fft256.fft_permute(&c->fft256, (FFTComplex*)(src + 256));
+ c->fft256.fft_permute(&c->fft256, (FFTComplex*)(src + 512));
+ c->fft256.fft_permute(&c->fft256, (FFTComplex*)(src + 768));
+ c->fft256.fft_calc(&c->fft256, (FFTComplex*)src);
+ c->fft256.fft_calc(&c->fft256, (FFTComplex*)(src + 256));
+ c->fft256.fft_calc(&c->fft256, (FFTComplex*)(src + 512));
+ c->fft256.fft_calc(&c->fft256, (FFTComplex*)(src + 768));
+ combine_fft(src, src + 256, src + 512, src + 768, tmp1,
+ ff_on2avc_ctab_1, ff_on2avc_ctab_2,
+ ff_on2avc_ctab_3, ff_on2avc_ctab_4, 1024, 1);
+ c->fft1024.fft_permute(&c->fft1024, (FFTComplex*)tmp1);
+ c->fft1024.fft_calc(&c->fft1024, (FFTComplex*)tmp1);
+
+ pretwiddle(&tmp0[ 0], tmp1, 1024, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ pretwiddle(&tmp0[256], tmp1, 1024, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ pretwiddle(&tmp0[512], tmp1, 1024, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ pretwiddle(&tmp0[768], tmp1, 1024, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+
+ memcpy(src, tmp1, 1024 * sizeof(float));
+}
+
+static void wtf_40(On2AVCContext *c, float *out, float *src, int size)
+{
+ float *tmp0 = c->temp, *tmp1 = c->temp + 1024;
+
+ memset(tmp0, 0, sizeof(*tmp0) * 1024);
+ memset(tmp1, 0, sizeof(*tmp1) * 1024);
+
+ if (size == 512) {
+ twiddle(src, &tmp0[ 0], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 8, &tmp0[ 0], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 16, &tmp0[ 16], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 24, &tmp0[ 16], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 32, &tmp0[ 32], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 40, &tmp0[ 32], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 48, &tmp0[ 48], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 56, &tmp0[ 48], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(&tmp0[ 0], &tmp1[ 0], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(&tmp0[16], &tmp1[ 0], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(&tmp0[32], &tmp1[ 32], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(&tmp0[48], &tmp1[ 32], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 64, &tmp1[ 64], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 80, &tmp1[ 64], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 96, &tmp1[ 96], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 112, &tmp1[ 96], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 128, &tmp1[128], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 144, &tmp1[128], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 160, &tmp1[160], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 176, &tmp1[160], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+
+ memset(tmp0, 0, 64 * sizeof(*tmp0));
+
+ twiddle(&tmp1[ 0], &tmp0[ 0], 128, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(&tmp1[ 32], &tmp0[ 0], 128, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(&tmp1[ 64], &tmp0[ 0], 128, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(&tmp1[ 96], &tmp0[ 0], 128, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(&tmp1[128], &tmp0[128], 128, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(&tmp1[160], &tmp0[128], 128, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 192, &tmp0[128], 128, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 224, &tmp0[128], 128, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 256, &tmp0[256], 128, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 288, &tmp0[256], 128, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 320, &tmp0[256], 128, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 352, &tmp0[256], 128, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+
+ wtf_end_512(c, out, src, tmp0, tmp1);
+ } else {
+ twiddle(src, &tmp0[ 0], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 16, &tmp0[ 0], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 32, &tmp0[ 32], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 48, &tmp0[ 32], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 64, &tmp0[ 64], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 80, &tmp0[ 64], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 96, &tmp0[ 96], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 112, &tmp0[ 96], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(&tmp0[ 0], &tmp1[ 0], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(&tmp0[32], &tmp1[ 0], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(&tmp0[64], &tmp1[ 64], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(&tmp0[96], &tmp1[ 64], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 128, &tmp1[128], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 160, &tmp1[128], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 192, &tmp1[192], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 224, &tmp1[192], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 256, &tmp1[256], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 288, &tmp1[256], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 320, &tmp1[320], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 352, &tmp1[320], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+
+ memset(tmp0, 0, 128 * sizeof(*tmp0));
+
+ twiddle(&tmp1[ 0], &tmp0[ 0], 256, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(&tmp1[ 64], &tmp0[ 0], 256, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(&tmp1[128], &tmp0[ 0], 256, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(&tmp1[192], &tmp0[ 0], 256, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(&tmp1[256], &tmp0[256], 256, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(&tmp1[320], &tmp0[256], 256, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 384, &tmp0[256], 256, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 448, &tmp0[256], 256, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 512, &tmp0[512], 256, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 576, &tmp0[512], 256, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 640, &tmp0[512], 256, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 704, &tmp0[512], 256, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+
+ wtf_end_1024(c, out, src, tmp0, tmp1);
+ }
+}
+
+static void wtf_44(On2AVCContext *c, float *out, float *src, int size)
+{
+ float *tmp0 = c->temp, *tmp1 = c->temp + 1024;
+
+ memset(tmp0, 0, sizeof(*tmp0) * 1024);
+ memset(tmp1, 0, sizeof(*tmp1) * 1024);
+
+ if (size == 512) {
+ twiddle(src, &tmp0[ 0], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 8, &tmp0[ 0], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 16, &tmp0[16], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 24, &tmp0[16], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 32, &tmp0[32], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(src + 40, &tmp0[32], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 48, &tmp0[48], 16, ff_on2avc_tab_10_2, 10, 2, 3, 1, ff_on2avc_tabs_4_10_2);
+ twiddle(src + 56, &tmp0[48], 16, ff_on2avc_tab_10_1, 10, 2, 1, 3, ff_on2avc_tabs_4_10_1);
+ twiddle(&tmp0[ 0], &tmp1[ 0], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(&tmp0[16], &tmp1[ 0], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(&tmp0[32], &tmp1[32], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(&tmp0[48], &tmp1[32], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 64, &tmp1[64], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 80, &tmp1[64], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 96, &tmp1[96], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 112, &tmp1[96], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+
+ memset(tmp0, 0, 64 * sizeof(*tmp0));
+
+ twiddle(&tmp1[ 0], &tmp0[ 0], 128, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(&tmp1[32], &tmp0[ 0], 128, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(&tmp1[64], &tmp0[ 0], 128, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(&tmp1[96], &tmp0[ 0], 128, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(src + 128, &tmp0[128], 128, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(src + 160, &tmp0[128], 128, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 192, &tmp0[128], 128, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 224, &tmp0[128], 128, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 256, &tmp0[256], 128, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 320, &tmp0[256], 128, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+
+ wtf_end_512(c, out, src, tmp0, tmp1);
+ } else {
+ twiddle(src, &tmp0[ 0], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 16, &tmp0[ 0], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 32, &tmp0[ 32], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 48, &tmp0[ 32], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 64, &tmp0[ 64], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(src + 80, &tmp0[ 64], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 96, &tmp0[ 96], 32, ff_on2avc_tab_20_2, 20, 2, 4, 5, ff_on2avc_tabs_9_20_2);
+ twiddle(src + 112, &tmp0[ 96], 32, ff_on2avc_tab_20_1, 20, 2, 5, 4, ff_on2avc_tabs_9_20_1);
+ twiddle(&tmp0[ 0], &tmp1[ 0], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(&tmp0[32], &tmp1[ 0], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(&tmp0[64], &tmp1[ 64], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(&tmp0[96], &tmp1[ 64], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 128, &tmp1[128], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 160, &tmp1[128], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 192, &tmp1[192], 64, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+ twiddle(src + 224, &tmp1[192], 64, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+
+ memset(tmp0, 0, 128 * sizeof(*tmp0));
+
+ twiddle(&tmp1[ 0], &tmp0[ 0], 256, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(&tmp1[ 64], &tmp0[ 0], 256, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(&tmp1[128], &tmp0[ 0], 256, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(&tmp1[192], &tmp0[ 0], 256, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(src + 256, &tmp0[256], 256, ff_on2avc_tab_84_4, 84, 4, 15, 5, ff_on2avc_tabs_20_84_4);
+ twiddle(src + 320, &tmp0[256], 256, ff_on2avc_tab_84_3, 84, 4, 13, 7, ff_on2avc_tabs_20_84_3);
+ twiddle(src + 384, &tmp0[256], 256, ff_on2avc_tab_84_2, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
+ twiddle(src + 448, &tmp0[256], 256, ff_on2avc_tab_84_1, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
+ twiddle(src + 512, &tmp0[512], 256, ff_on2avc_tab_40_1, 40, 2, 11, 8, ff_on2avc_tabs_19_40_1);
+ twiddle(src + 640, &tmp0[512], 256, ff_on2avc_tab_40_2, 40, 2, 8, 11, ff_on2avc_tabs_19_40_2);
+
+ wtf_end_1024(c, out, src, tmp0, tmp1);
+ }
+}
+
+static int on2avc_reconstruct_stereo(On2AVCContext *c, AVFrame *dst, int offset)
+{
+ int ch, i;
+
+ for (ch = 0; ch < 2; ch++) {
+ float *out = (float*)dst->extended_data[ch] + offset;
+ float *in = c->coeffs[ch];
+ float *saved = c->delay[ch];
+ float *buf = c->mdct_buf;
+ float *wout = out + 448;
+
+ switch (c->window_type) {
+ case WINDOW_TYPE_EXT7:
+ c->mdct.imdct_half(&c->mdct, buf, in);
+ break;
+ case WINDOW_TYPE_EXT4:
+ c->wtf(c, buf, in, 1024);
+ break;
+ case WINDOW_TYPE_EXT5:
+ c->wtf(c, buf, in, 512);
+ c->mdct.imdct_half(&c->mdct_half, buf + 512, in + 512);
+ for (i = 0; i < 256; i++) {
+ FFSWAP(float, buf[i + 512], buf[1023 - i]);
+ }
+ break;
+ case WINDOW_TYPE_EXT6:
+ c->mdct.imdct_half(&c->mdct_half, buf, in);
+ for (i = 0; i < 256; i++) {
+ FFSWAP(float, buf[i], buf[511 - i]);
+ }
+ c->wtf(c, buf + 512, in + 512, 512);
+ break;
+ }
+
+ memcpy(out, saved, 448 * sizeof(float));
+ c->fdsp.vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
+ memcpy(wout + 128, buf + 64, 448 * sizeof(float));
+ memcpy(saved, buf + 512, 448 * sizeof(float));
+ memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
+ }
+
+ return 0;
+}
+
+// not borrowed from aacdec.c - the codec has original design after all
+static int on2avc_reconstruct_channel(On2AVCContext *c, int channel,
+ AVFrame *dst, int offset)
+{
+ int i;
+ float *out = (float*)dst->extended_data[channel] + offset;
+ float *in = c->coeffs[channel];
+ float *saved = c->delay[channel];
+ float *buf = c->mdct_buf;
+ float *temp = c->temp;
+
+ switch (c->window_type) {
+ case WINDOW_TYPE_LONG_START:
+ case WINDOW_TYPE_LONG_STOP:
+ case WINDOW_TYPE_LONG:
+ c->mdct.imdct_half(&c->mdct, buf, in);
+ break;
+ case WINDOW_TYPE_8SHORT:
+ for (i = 0; i < ON2AVC_SUBFRAME_SIZE; i += ON2AVC_SUBFRAME_SIZE / 8)
+ c->mdct_small.imdct_half(&c->mdct_small, buf + i, in + i);
+ break;
+ }
+
+ if ((c->prev_window_type == WINDOW_TYPE_LONG ||
+ c->prev_window_type == WINDOW_TYPE_LONG_STOP) &&
+ (c->window_type == WINDOW_TYPE_LONG ||
+ c->window_type == WINDOW_TYPE_LONG_START)) {
+ c->fdsp.vector_fmul_window(out, saved, buf, c->long_win, 512);
+ } else {
+ float *wout = out + 448;
+ memcpy(out, saved, 448 * sizeof(float));
+
+ if (c->window_type == WINDOW_TYPE_8SHORT) {
+ c->fdsp.vector_fmul_window(wout + 0*128, saved + 448, buf + 0*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, c->short_win, 64);
+ memcpy(wout + 4*128, temp, 64 * sizeof(float));
+ } else {
+ c->fdsp.vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
+ memcpy(wout + 128, buf + 64, 448 * sizeof(float));
+ }
+ }
+
+ // buffer update
+ switch (c->window_type) {
+ case WINDOW_TYPE_8SHORT:
+ memcpy(saved, temp + 64, 64 * sizeof(float));
+ c->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, c->short_win, 64);
+ c->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, c->short_win, 64);
+ memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
+ break;
+ case WINDOW_TYPE_LONG_START:
+ memcpy(saved, buf + 512, 448 * sizeof(float));
+ memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
+ break;
+ case WINDOW_TYPE_LONG_STOP:
+ case WINDOW_TYPE_LONG:
+ memcpy(saved, buf + 512, 512 * sizeof(float));
+ break;
+ }
+ return 0;
+}
+
+static int on2avc_decode_subframe(On2AVCContext *c, const uint8_t *buf,
+ int buf_size, AVFrame *dst, int offset)
+{
+ GetBitContext gb;
+ int i, ret;
+
+ init_get_bits(&gb, buf, buf_size * 8);
+ if (get_bits1(&gb)) {
+ av_log(c->avctx, AV_LOG_ERROR, "enh bit set\n");
+ return AVERROR_INVALIDDATA;
+ }
+ c->prev_window_type = c->window_type;
+ c->window_type = get_bits(&gb, 3);
+ if (c->window_type >= WINDOW_TYPE_EXT4 && c->avctx->channels == 1) {
+ av_log(c->avctx, AV_LOG_ERROR, "stereo mode window for mono audio\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ c->band_start = c->modes[c->window_type].band_start;
+ c->num_windows = c->modes[c->window_type].num_windows;
+ c->num_bands = c->modes[c->window_type].num_bands;
+ c->is_long = (c->window_type != WINDOW_TYPE_8SHORT);
+
+ c->grouping[0] = 1;
+ for (i = 1; i < c->num_windows; i++)
+ c->grouping[i] = !get_bits1(&gb);
+
+ on2avc_read_ms_info(c, &gb);
+ for (i = 0; i < c->avctx->channels; i++)
+ if ((ret = on2avc_read_channel_data(c, &gb, i)) < 0)
+ return AVERROR_INVALIDDATA;
+ if (c->avctx->channels == 2 && c->ms_present)
+ on2avc_apply_ms(c);
+ if (c->window_type < WINDOW_TYPE_EXT4) {
+ for (i = 0; i < c->avctx->channels; i++)
+ on2avc_reconstruct_channel(c, i, dst, offset);
+ } else {
+ on2avc_reconstruct_stereo(c, dst, offset);
+ }
+
+ return 0;
+}
+
+static int on2avc_decode_frame(AVCodecContext * avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
+{
+ AVFrame *frame = data;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ On2AVCContext *c = avctx->priv_data;
+ GetByteContext gb;
+ int num_frames = 0, frame_size, audio_off;
+ int ret;
+
+ if (c->is_av500) {
+ /* get output buffer */
+ frame->nb_samples = ON2AVC_SUBFRAME_SIZE;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+
+ if ((ret = on2avc_decode_subframe(c, buf, buf_size, frame, 0)) < 0)
+ return ret;
+ } else {
+ bytestream2_init(&gb, buf, buf_size);
+ while (bytestream2_get_bytes_left(&gb) > 2) {
+ frame_size = bytestream2_get_le16(&gb);
+ if (!frame_size || frame_size > bytestream2_get_bytes_left(&gb)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid subframe size %d\n",
+ frame_size);
+ return AVERROR_INVALIDDATA;
+ }
+ num_frames++;
+ bytestream2_skip(&gb, frame_size);
+ }
+ if (!num_frames) {
+ av_log(avctx, AV_LOG_ERROR, "No subframes present\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ /* get output buffer */
+ frame->nb_samples = ON2AVC_SUBFRAME_SIZE * num_frames;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+
+ audio_off = 0;
+ bytestream2_init(&gb, buf, buf_size);
+ while (bytestream2_get_bytes_left(&gb) > 2) {
+ frame_size = bytestream2_get_le16(&gb);
+ if ((ret = on2avc_decode_subframe(c, gb.buffer, frame_size,
+ frame, audio_off)) < 0)
+ return ret;
+ audio_off += ON2AVC_SUBFRAME_SIZE;
+ bytestream2_skip(&gb, frame_size);
+ }
+ }
+
+ *got_frame_ptr = 1;
+
+ return buf_size;
+}
+
+static av_cold void on2avc_free_vlcs(On2AVCContext *c)
+{
+ int i;
+
+ ff_free_vlc(&c->scale_diff);
+ for (i = 1; i < 16; i++)
+ ff_free_vlc(&c->cb_vlc[i]);
+}
+
+static av_cold int on2avc_decode_init(AVCodecContext *avctx)
+{
+ On2AVCContext *c = avctx->priv_data;
+ int i;
+
+ c->avctx = avctx;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+ avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
+ : AV_CH_LAYOUT_MONO;
+
+ c->is_av500 = (avctx->codec_tag == 0x500);
+ if (c->is_av500 && avctx->channels == 2) {
+ av_log(avctx, AV_LOG_ERROR, "0x500 version should be mono\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (avctx->channels == 2)
+ av_log(avctx, AV_LOG_WARNING,
+ "Stereo mode support is not good, patch is welcome\n");
+
+ for (i = 0; i < 20; i++)
+ c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 16) / 32;
+ for (; i < 128; i++)
+ c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 0.5);
+
+ if (avctx->sample_rate < 32000 || avctx->channels == 1)
+ memcpy(c->long_win, ff_on2avc_window_long_24000,
+ 1024 * sizeof(*c->long_win));
+ else
+ memcpy(c->long_win, ff_on2avc_window_long_32000,
+ 1024 * sizeof(*c->long_win));
+ memcpy(c->short_win, ff_on2avc_window_short, 128 * sizeof(*c->short_win));
+
+ c->modes = (avctx->sample_rate <= 40000) ? ff_on2avc_modes_40
+ : ff_on2avc_modes_44;
+ c->wtf = (avctx->sample_rate <= 40000) ? wtf_40
+ : wtf_44;
+
+ ff_mdct_init(&c->mdct, 11, 1, 1.0 / (32768.0 * 1024.0));
+ ff_mdct_init(&c->mdct_half, 10, 1, 1.0 / (32768.0 * 512.0));
+ ff_mdct_init(&c->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0));
+ ff_fft_init(&c->fft128, 6, 0);
+ ff_fft_init(&c->fft256, 7, 0);
+ ff_fft_init(&c->fft512, 8, 1);
+ ff_fft_init(&c->fft1024, 9, 1);
+ avpriv_float_dsp_init(&c->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
+
+ if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS,
+ ff_on2avc_scale_diff_bits, 1, 1,
+ ff_on2avc_scale_diff_codes, 4, 4, 0)) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n");
+ return AVERROR(ENOMEM);
+ }
+ for (i = 1; i < 9; i++) {
+ int idx = i - 1;
+ if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_quad_cb_elems[idx],
+ ff_on2avc_quad_cb_bits[idx], 1, 1,
+ ff_on2avc_quad_cb_codes[idx], 4, 4,
+ ff_on2avc_quad_cb_syms[idx], 2, 2, 0)) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n");
+ on2avc_free_vlcs(c);
+ return AVERROR(ENOMEM);
+ }
+ }
+ for (i = 9; i < 16; i++) {
+ int idx = i - 9;
+ if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_pair_cb_elems[idx],
+ ff_on2avc_pair_cb_bits[idx], 1, 1,
+ ff_on2avc_pair_cb_codes[idx], 2, 2,
+ ff_on2avc_pair_cb_syms[idx], 2, 2, 0)) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n");
+ on2avc_free_vlcs(c);
+ return AVERROR(ENOMEM);
+ }
+ }
+
+ return 0;
+}
+
+static av_cold int on2avc_decode_close(AVCodecContext *avctx)
+{
+ On2AVCContext *c = avctx->priv_data;
+
+ ff_mdct_end(&c->mdct);
+ ff_mdct_end(&c->mdct_half);
+ ff_mdct_end(&c->mdct_small);
+ ff_fft_end(&c->fft128);
+ ff_fft_end(&c->fft256);
+ ff_fft_end(&c->fft512);
+ ff_fft_end(&c->fft1024);
+
+ on2avc_free_vlcs(c);
+
+ return 0;
+}
+
+
+AVCodec ff_on2avc_decoder = {
+ .name = "on2avc",
+ .long_name = NULL_IF_CONFIG_SMALL("On2 Audio for Video Codec"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_ON2AVC,
+ .priv_data_size = sizeof(On2AVCContext),
+ .init = on2avc_decode_init,
+ .decode = on2avc_decode_frame,
+ .close = on2avc_decode_close,
+ .capabilities = CODEC_CAP_DR1,
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_NONE },
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/on2avcdata.c b/chromium/third_party/ffmpeg/libavcodec/on2avcdata.c
new file mode 100644
index 00000000000..abe598350b1
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/on2avcdata.c
@@ -0,0 +1,9383 @@
+/*
+ * On2 Audio for Video Codec decoder
+ *
+ * Copyright (c) 2013 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "on2avcdata.h"
+
+static const int on2avc_swb_start_long[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64,
+ 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 204, 224, 244,
+ 264, 288, 312, 340, 368, 400, 432, 464, 496, 528, 560, 592, 624, 656,
+ 688, 720, 752, 784, 816, 848, 880, 1024
+};
+
+static const int on2avc_swb_start_short[] = {
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 56, 68, 80, 108, 128
+};
+
+static const int on2avc_swb_start_mode_4_40[] = {
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104,
+ 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 264, 272, 280,
+ 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 400,
+ 416, 432, 448, 464, 480, 496, 512, 520, 528, 536, 544, 552, 560, 568,
+ 576, 584, 592, 600, 608, 616, 624, 632, 640, 648, 656, 664, 672, 680,
+ 688, 696, 704, 712, 720, 728, 736, 744, 752, 760, 768, 800, 832, 864,
+ 896, 928, 960, 992, 1024
+};
+
+static const int on2avc_swb_start_mode_5_40[] = {
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 136,
+ 144, 152, 160, 168, 176, 184, 192, 208, 224, 240, 256, 264, 272, 280,
+ 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 416,
+ 448, 480, 512, 516, 520, 524, 528, 532, 536, 540, 548, 556, 568, 580,
+ 592, 608, 624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800,
+ 816, 832, 848, 864, 880, 896, 912, 928, 944, 1024
+};
+
+static const int on2avc_swb_start_mode_6_40[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 56, 68, 80, 96,
+ 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320,
+ 336, 352, 368, 384, 400, 416, 432, 512, 520, 528, 536, 544, 552, 560,
+ 568, 576, 592, 608, 624, 640, 648, 656, 664, 672, 680, 688, 696, 704,
+ 720, 736, 752, 768, 776, 784, 792, 800, 808, 816, 824, 832, 840, 848,
+ 856, 864, 872, 880, 888, 896, 928, 960, 992, 1024
+};
+
+static const int on2avc_swb_start_mode_4_44[] = {
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104,
+ 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216,
+ 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328,
+ 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440,
+ 448, 456, 464, 472, 480, 488, 496, 504, 512, 528, 544, 560, 576, 592,
+ 608, 624, 640, 672, 704, 736, 768, 832, 896, 960, 1024
+};
+
+static const int on2avc_swb_start_mode_5_44[] = {
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104,
+ 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216,
+ 224, 232, 240, 248, 256, 272, 288, 304, 320, 352, 384, 448, 512, 516,
+ 520, 524, 528, 532, 536, 540, 548, 556, 568, 580, 592, 608, 624, 640,
+ 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816, 832, 848, 864,
+ 880, 896, 912, 928, 944, 1024
+};
+
+static const int on2avc_swb_start_mode_6_44[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 56, 68, 80, 96,
+ 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320,
+ 336, 352, 368, 384, 400, 416, 432, 512, 520, 528, 536, 544, 552, 560,
+ 568, 576, 584, 592, 600, 608, 616, 624, 632, 640, 648, 656, 664, 672,
+ 680, 688, 696, 704, 712, 720, 728, 736, 744, 752, 760, 768, 784, 800,
+ 816, 832, 864, 896, 960, 1024
+};
+
+const On2AVCMode ff_on2avc_modes_40[8] = {
+ { 1, 49, on2avc_swb_start_long },
+ { 1, 49, on2avc_swb_start_long },
+ { 1, 49, on2avc_swb_start_long },
+ { 8, 14, on2avc_swb_start_short },
+ { 1, 88, on2avc_swb_start_mode_4_40 },
+ { 1, 79, on2avc_swb_start_mode_5_40 },
+ { 1, 79, on2avc_swb_start_mode_6_40 },
+ { 1, 49, on2avc_swb_start_long },
+};
+
+const On2AVCMode ff_on2avc_modes_44[8] = {
+ { 1, 49, on2avc_swb_start_long },
+ { 1, 49, on2avc_swb_start_long },
+ { 1, 49, on2avc_swb_start_long },
+ { 8, 14, on2avc_swb_start_short },
+ { 1, 80, on2avc_swb_start_mode_4_44 },
+ { 1, 75, on2avc_swb_start_mode_5_44 },
+ { 1, 75, on2avc_swb_start_mode_6_44 },
+ { 1, 49, on2avc_swb_start_long },
+};
+
+const uint32_t ff_on2avc_scale_diff_codes[ON2AVC_SCALE_DIFFS] = {
+ 0x6FFFF, 0xBFFF2, 0xBFFF3, 0xBFFF4, 0xBFFF5, 0xBFFF6,
+ 0xBFFF7, 0xBFFF8, 0xBFFF9, 0xBFFFA, 0xBFFFB, 0xBFFFC,
+ 0xBFFFD, 0xBFFFE, 0xBFFFF, 0xDF9A0, 0xDF9A1, 0xDF9A2,
+ 0xDF9A3, 0xDF9A4, 0xDF9A5, 0xDF9A6, 0xDF9A7, 0xDF9A8,
+ 0xDF9A9, 0x37FFE, 0x6FCDE, 0x6FFFA, 0x0BFF7, 0x0B7FF,
+ 0x0DF9F, 0x05FF8, 0x0B7FE, 0x05FF9, 0x06FCE, 0x05BFE,
+ 0x037FE, 0x02DFE, 0x00DFA, 0x00DFE, 0x017FC, 0x00DBE,
+ 0x00B7E, 0x005FE, 0x0037D, 0x002DE, 0x0017E, 0x0016C,
+ 0x000DE, 0x000BE, 0x0006C, 0x0005A, 0x0003E, 0x00034,
+ 0x0002C, 0x0001F, 0x0000E, 0x0000E, 0x00006, 0x00002,
+ 0x00000, 0x00004, 0x0000A, 0x0000C, 0x0001E, 0x0001E,
+ 0x0002E, 0x00035, 0x0003F, 0x0005E, 0x0006E, 0x000DA,
+ 0x0016D, 0x0016E, 0x001B6, 0x002FE, 0x0036E, 0x0037C,
+ 0x005BE, 0x006DE, 0x006FE, 0x00DBF, 0x00DFB, 0x016FE,
+ 0x017FD, 0x01BFE, 0x01BF2, 0x02FFE, 0x06FCC, 0x05FFE,
+ 0x05FFA, 0x06FFE, 0x0BFF6, 0x0BFFE, 0x0DF9E, 0x00DF8,
+ 0x0DFFE, 0x37FFC, 0x6FFFB, 0x5FFF8, 0xDF9AA, 0xDF9AB,
+ 0xDF9AC, 0xDF9AD, 0xDF9AE, 0xDF9AF, 0xDF9B0, 0xDF9B1,
+ 0xDF9B2, 0xDF9B3, 0x6FFFE, 0xDF9B4, 0xDF9B5, 0xDF9B6,
+ 0xDF9B7, 0xDF9B8, 0xDF9B9, 0xDF9BA, 0xDF9BB, 0xDF9BE,
+ 0xDF9BF,
+};
+
+const uint8_t ff_on2avc_scale_diff_bits[ON2AVC_SCALE_DIFFS] = {
+ 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21,
+ 21, 19, 20, 20, 16, 16,
+ 17, 15, 16, 15, 16, 15,
+ 15, 14, 13, 13, 13, 13,
+ 12, 11, 11, 10, 9, 9,
+ 9, 8, 8, 7, 7, 7,
+ 6, 5, 5, 4, 3, 3,
+ 2, 3, 4, 5, 5, 6,
+ 6, 7, 7, 7, 8, 9,
+ 9, 9, 10, 10, 11, 11,
+ 11, 12, 12, 13, 13, 13,
+ 13, 14, 14, 14, 16, 15,
+ 15, 16, 16, 16, 17, 13,
+ 17, 19, 20, 19, 21, 21,
+ 21, 21, 21, 21, 21, 21,
+ 21, 21, 20, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21,
+ 21,
+};
+
+#define ON2AVC_CB1_CODES 41
+static const uint32_t on2avc_cb1_codes[ON2AVC_CB1_CODES] = {
+ 0x0000, 0x0022, 0x001C, 0x001B, 0x0024, 0x0030,
+ 0x0029, 0x0027, 0x0021, 0x002B, 0x002E, 0x0020,
+ 0x0026, 0x0033, 0x0031, 0x002C, 0x002A, 0x001E,
+ 0x0094, 0x01FF, 0x01F7, 0x012E, 0x001A, 0x01F5,
+ 0x007E, 0x012C, 0x01FC, 0x002D, 0x0032, 0x0028,
+ 0x002F, 0x001D, 0x01FD, 0x012D, 0x007C, 0x01F4,
+ 0x0023, 0x012F, 0x01F6, 0x01FE, 0x0095,
+};
+
+static const uint8_t on2avc_cb1_bits[ON2AVC_CB1_CODES] = {
+ 1, 6, 5, 5, 6, 6,
+ 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 5,
+ 8, 9, 9, 9, 5, 9,
+ 7, 9, 9, 6, 6, 6,
+ 6, 5, 9, 9, 7, 9,
+ 6, 9, 9, 9, 8,
+};
+
+static const uint16_t on2avc_cb1_syms[ON2AVC_CB1_CODES] = {
+ 0x0000, 0x0011, 0x001F, 0x00F1, 0x00FF, 0x0101,
+ 0x010F, 0x0110, 0x01F0, 0x0F01, 0x0F0F, 0x0F10,
+ 0x0FF0, 0x1001, 0x100F, 0x1010, 0x10F0, 0x1100,
+ 0x1111, 0x111F, 0x11F1, 0x11FF, 0x1F00, 0x1F11,
+ 0x1F1F, 0x1FF1, 0x1FFF, 0xF001, 0xF00F, 0xF010,
+ 0xF0F0, 0xF100, 0xF111, 0xF11F, 0xF1F1, 0xF1FF,
+ 0xFF00, 0xFF11, 0xFF1F, 0xFFF1, 0xFFFF,
+};
+
+#define ON2AVC_CB2_CODES 41
+static const uint32_t on2avc_cb2_codes[ON2AVC_CB2_CODES] = {
+ 0x0006, 0x0003, 0x001F, 0x001E, 0x0000, 0x0014,
+ 0x0009, 0x000E, 0x000D, 0x000C, 0x0015, 0x0008,
+ 0x0010, 0x000F, 0x0004, 0x0012, 0x0007, 0x0016,
+ 0x0005, 0x002F, 0x0017, 0x0006, 0x001D, 0x002C,
+ 0x005E, 0x0014, 0x0016, 0x0006, 0x0011, 0x000A,
+ 0x0013, 0x001C, 0x002D, 0x0015, 0x005F, 0x002E,
+ 0x0002, 0x0007, 0x005D, 0x005C, 0x0004,
+};
+
+static const uint8_t on2avc_cb2_bits[ON2AVC_CB2_CODES] = {
+ 3, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5,
+ 7, 7, 7, 7, 5, 7,
+ 7, 7, 7, 5, 5, 5,
+ 5, 5, 7, 7, 7, 7,
+ 5, 7, 7, 7, 7,
+};
+
+static const uint16_t on2avc_cb2_syms[ON2AVC_CB2_CODES] = {
+ 0x0000, 0x0011, 0x001F, 0x00F1, 0x00FF, 0x0101,
+ 0x010F, 0x0110, 0x01F0, 0x0F01, 0x0F0F, 0x0F10,
+ 0x0FF0, 0x1001, 0x100F, 0x1010, 0x10F0, 0x1100,
+ 0x1111, 0x111F, 0x11F1, 0x11FF, 0x1F00, 0x1F11,
+ 0x1F1F, 0x1FF1, 0x1FFF, 0xF001, 0xF00F, 0xF010,
+ 0xF0F0, 0xF100, 0xF111, 0xF11F, 0xF1F1, 0xF1FF,
+ 0xFF00, 0xFF11, 0xFF1F, 0xFFF1, 0xFFFF,
+};
+
+#define ON2AVC_CB3_CODES 313
+static const uint32_t on2avc_cb3_codes[ON2AVC_CB3_CODES] = {
+ 0x00000, 0x00044, 0x00042, 0x00034, 0x0002E, 0x000CD,
+ 0x002DF, 0x0024A, 0x000CC, 0x0022E, 0x002D6, 0x00031,
+ 0x0003B, 0x00048, 0x00052, 0x00056, 0x001B8, 0x00160,
+ 0x001FA, 0x0015E, 0x0015C, 0x0014E, 0x0003C, 0x0010C,
+ 0x00166, 0x000CA, 0x0324C, 0x00FDA, 0x003DE, 0x002DB,
+ 0x0057F, 0x02C9E, 0x008BF, 0x0037F, 0x021DC, 0x00B1E,
+ 0x002DE, 0x002D2, 0x000C8, 0x014D6, 0x03576, 0x002CA,
+ 0x002CF, 0x003DB, 0x007FE, 0x01F7E, 0x005A3, 0x008BE,
+ 0x02D7E, 0x002D3, 0x0037E, 0x0004D, 0x0004C, 0x00041,
+ 0x0016A, 0x0010D, 0x0015D, 0x0011F, 0x00162, 0x0021E,
+ 0x00055, 0x00161, 0x001BE, 0x0004E, 0x0004A, 0x0004B,
+ 0x003EE, 0x00352, 0x0043A, 0x0033E, 0x0035C, 0x0036C,
+ 0x00050, 0x0032F, 0x003D6, 0x00039, 0x0067E, 0x00536,
+ 0x000FE, 0x001F4, 0x0036D, 0x007EF, 0x00CFE, 0x002D0,
+ 0x00F8C, 0x00D96, 0x001E9, 0x001F6, 0x00476, 0x00367,
+ 0x001F2, 0x01FF6, 0x016BB, 0x007FC, 0x00D5C, 0x00B24,
+ 0x00C92, 0x0014F, 0x01EA6, 0x01936, 0x00366, 0x0035E,
+ 0x00116, 0x00FBE, 0x01B5E, 0x0092F, 0x007EE, 0x00CEE,
+ 0x00B26, 0x0011E, 0x014DF, 0x035DE, 0x00030, 0x00473,
+ 0x005A2, 0x001BC, 0x000D6, 0x002DA, 0x00B5E, 0x007AA,
+ 0x002C8, 0x00D94, 0x00D97, 0x001AA, 0x001EE, 0x0003A,
+ 0x035DF, 0x03D4F, 0x0064F, 0x0064A, 0x02D73, 0x1ABBE,
+ 0x0B1CF, 0x00F8E, 0x06AFF, 0x0475E, 0x00472, 0x00596,
+ 0x003E7, 0x0036E, 0x00196, 0x0357E, 0x03F6E, 0x0324E,
+ 0x0324F, 0x0163B, 0x0192F, 0x001B4, 0x0326A, 0x02C9F,
+ 0x0021F, 0x0F8FF, 0x064D6, 0x007BE, 0x00DDF, 0x033BC,
+ 0x033BD, 0x06AEE, 0x00876, 0x07C7E, 0x0B1CE, 0x00D76,
+ 0x00DDC, 0x001EC, 0x0649B, 0x0B1CD, 0x00F8D, 0x007D6,
+ 0x01AEE, 0x0163F, 0x03E3E, 0x00A6A, 0x06D7E, 0x0DDDF,
+ 0x00F7E, 0x00DAE, 0x0036F, 0x00338, 0x0016C, 0x033BF,
+ 0x036BE, 0x01FF7, 0x01937, 0x01ABA, 0x014D7, 0x0014C,
+ 0x01F7F, 0x0475F, 0x00040, 0x07FFC, 0x03F6F, 0x00477,
+ 0x00496, 0x014DE, 0x0649A, 0x064D7, 0x02C9C, 0x0B1CC,
+ 0x1ABBF, 0x00648, 0x006BA, 0x00364, 0x0032E, 0x00126,
+ 0x03D4E, 0x02C72, 0x011D6, 0x01638, 0x01934, 0x02C9D,
+ 0x0016E, 0x021DD, 0x03DFF, 0x001F0, 0x07FFE, 0x043BF,
+ 0x00D5E, 0x00FAE, 0x0092E, 0x07FFF, 0x0F8FE, 0x02D7F,
+ 0x043BE, 0x06D7F, 0x008E9, 0x00FFA, 0x0021C, 0x06EEE,
+ 0x0D5DE, 0x00F57, 0x00CFF, 0x016BA, 0x07FFD, 0x06AFE,
+ 0x021DE, 0x0DDDE, 0x023AE, 0x00FAF, 0x006D6, 0x0037B,
+ 0x003E6, 0x001B9, 0x01F1E, 0x033BE, 0x0192E, 0x016BE,
+ 0x01FB6, 0x01BBA, 0x0019E, 0x03776, 0x03DFE, 0x00046,
+ 0x00051, 0x0004F, 0x003D7, 0x0033A, 0x00376, 0x00353,
+ 0x00356, 0x003EA, 0x00054, 0x00339, 0x003E2, 0x0002F,
+ 0x0064C, 0x00534, 0x00238, 0x001A8, 0x002C6, 0x00D95,
+ 0x00F52, 0x002CE, 0x007DE, 0x00B2F, 0x000D8, 0x001BA,
+ 0x0036A, 0x0035F, 0x00127, 0x01EFE, 0x016B8, 0x008EA,
+ 0x00CEC, 0x007EC, 0x00A6E, 0x00114, 0x01ABE, 0x00FFE,
+ 0x0037A, 0x0045E, 0x00124, 0x0163E, 0x02D72, 0x00CED,
+ 0x00B2E, 0x00C96, 0x007A8, 0x001FE, 0x0163A, 0x01FFE,
+ 0x00038, 0x0057E, 0x0064E, 0x001F8, 0x001E8, 0x002BE,
+ 0x00DDE, 0x00F56, 0x003DA, 0x00B25, 0x008E8, 0x001F9,
+ 0x00115,
+};
+
+static const uint8_t on2avc_cb3_bits[ON2AVC_CB3_CODES] = {
+ 1, 7, 7, 6, 6, 8,
+ 10, 10, 8, 10, 10, 6,
+ 6, 7, 7, 7, 9, 9,
+ 9, 9, 9, 9, 6, 9,
+ 9, 8, 14, 12, 10, 10,
+ 11, 14, 12, 10, 14, 12,
+ 10, 10, 8, 13, 14, 10,
+ 10, 10, 11, 13, 11, 12,
+ 14, 10, 10, 7, 7, 7,
+ 9, 9, 9, 9, 9, 10,
+ 7, 9, 9, 7, 7, 7,
+ 10, 10, 11, 10, 10, 10,
+ 7, 10, 10, 6, 11, 11,
+ 8, 9, 10, 11, 12, 10,
+ 12, 12, 9, 9, 11, 10,
+ 9, 13, 13, 11, 12, 12,
+ 12, 9, 13, 13, 10, 10,
+ 9, 12, 13, 12, 11, 12,
+ 12, 9, 13, 14, 6, 11,
+ 11, 9, 8, 10, 12, 11,
+ 10, 12, 12, 9, 9, 6,
+ 14, 14, 11, 11, 14, 17,
+ 16, 12, 15, 15, 11, 11,
+ 10, 10, 9, 14, 14, 14,
+ 14, 13, 13, 9, 14, 14,
+ 10, 16, 15, 11, 12, 14,
+ 14, 15, 12, 15, 16, 12,
+ 12, 9, 15, 16, 12, 11,
+ 13, 13, 14, 12, 15, 16,
+ 12, 12, 10, 10, 9, 14,
+ 14, 13, 13, 13, 13, 9,
+ 13, 15, 7, 15, 14, 11,
+ 11, 13, 15, 15, 14, 16,
+ 17, 11, 11, 10, 10, 9,
+ 14, 14, 13, 13, 13, 14,
+ 9, 14, 14, 9, 15, 15,
+ 12, 12, 12, 15, 16, 14,
+ 15, 15, 12, 12, 10, 15,
+ 16, 12, 12, 13, 15, 15,
+ 14, 16, 14, 12, 11, 10,
+ 10, 9, 13, 14, 13, 13,
+ 13, 13, 9, 14, 14, 7,
+ 7, 7, 10, 10, 10, 10,
+ 10, 10, 7, 10, 10, 6,
+ 11, 11, 10, 9, 10, 12,
+ 12, 10, 11, 12, 8, 9,
+ 10, 10, 9, 13, 13, 12,
+ 12, 11, 12, 9, 13, 12,
+ 10, 11, 9, 13, 14, 12,
+ 12, 12, 11, 9, 13, 13,
+ 6, 11, 11, 9, 9, 10,
+ 12, 12, 10, 12, 12, 9,
+ 9,
+};
+
+static const uint16_t on2avc_cb3_syms[ON2AVC_CB3_CODES] = {
+ 0x0000, 0x0002, 0x000E, 0x0011, 0x001F, 0x0020,
+ 0x0022, 0x002E, 0x00E0, 0x00E2, 0x00EE, 0x00F1,
+ 0x00FF, 0x0101, 0x010F, 0x0110, 0x0112, 0x011E,
+ 0x0121, 0x012F, 0x01E1, 0x01EF, 0x01F0, 0x01F2,
+ 0x01FE, 0x0200, 0x0202, 0x020E, 0x0211, 0x021F,
+ 0x0220, 0x0222, 0x022E, 0x02E0, 0x02E2, 0x02EE,
+ 0x02F1, 0x02FF, 0x0E00, 0x0E02, 0x0E0E, 0x0E11,
+ 0x0E1F, 0x0E20, 0x0E22, 0x0E2E, 0x0EE0, 0x0EE2,
+ 0x0EEE, 0x0EF1, 0x0EFF, 0x0F01, 0x0F0F, 0x0F10,
+ 0x0F12, 0x0F1E, 0x0F21, 0x0F2F, 0x0FE1, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FFE, 0x1001, 0x100F, 0x1010,
+ 0x1012, 0x101E, 0x1021, 0x102F, 0x10E1, 0x10EF,
+ 0x10F0, 0x10F2, 0x10FE, 0x1100, 0x1102, 0x110E,
+ 0x1111, 0x111F, 0x1120, 0x1122, 0x112E, 0x11E0,
+ 0x11E2, 0x11EE, 0x11F1, 0x11FF, 0x1201, 0x120F,
+ 0x1210, 0x1212, 0x121E, 0x1221, 0x122F, 0x12E1,
+ 0x12EF, 0x12F0, 0x12F2, 0x12FE, 0x1E01, 0x1E0F,
+ 0x1E10, 0x1E12, 0x1E1E, 0x1E21, 0x1E2F, 0x1EE1,
+ 0x1EEF, 0x1EF0, 0x1EF2, 0x1EFE, 0x1F00, 0x1F02,
+ 0x1F0E, 0x1F11, 0x1F1F, 0x1F20, 0x1F22, 0x1F2E,
+ 0x1FE0, 0x1FE2, 0x1FEE, 0x1FF1, 0x1FFF, 0x2000,
+ 0x2002, 0x200E, 0x2011, 0x201F, 0x2020, 0x2022,
+ 0x202E, 0x20E0, 0x20E2, 0x20EE, 0x20F1, 0x20FF,
+ 0x2101, 0x210F, 0x2110, 0x2112, 0x211E, 0x2121,
+ 0x212F, 0x21E1, 0x21EF, 0x21F0, 0x21F2, 0x21FE,
+ 0x2200, 0x2202, 0x220E, 0x2211, 0x221F, 0x2220,
+ 0x2222, 0x222E, 0x22E0, 0x22E2, 0x22EE, 0x22F1,
+ 0x22FF, 0x2E00, 0x2E02, 0x2E0E, 0x2E11, 0x2E1F,
+ 0x2E20, 0x2E22, 0x2E2E, 0x2EE0, 0x2EE2, 0x2EEE,
+ 0x2EF1, 0x2EFF, 0x2F01, 0x2F0F, 0x2F10, 0x2F12,
+ 0x2F1E, 0x2F21, 0x2F2F, 0x2FE1, 0x2FEF, 0x2FF0,
+ 0x2FF2, 0x2FFE, 0xE000, 0xE002, 0xE00E, 0xE011,
+ 0xE01F, 0xE020, 0xE022, 0xE02E, 0xE0E0, 0xE0E2,
+ 0xE0EE, 0xE0F1, 0xE0FF, 0xE101, 0xE10F, 0xE110,
+ 0xE112, 0xE11E, 0xE121, 0xE12F, 0xE1E1, 0xE1EF,
+ 0xE1F0, 0xE1F2, 0xE1FE, 0xE200, 0xE202, 0xE20E,
+ 0xE211, 0xE21F, 0xE220, 0xE222, 0xE22E, 0xE2E0,
+ 0xE2E2, 0xE2EE, 0xE2F1, 0xE2FF, 0xEE00, 0xEE02,
+ 0xEE0E, 0xEE11, 0xEE1F, 0xEE20, 0xEE22, 0xEE2E,
+ 0xEEE0, 0xEEE2, 0xEEEE, 0xEEF1, 0xEEFF, 0xEF01,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF1E, 0xEF21, 0xEF2F,
+ 0xEFE1, 0xEFEF, 0xEFF0, 0xEFF2, 0xEFFE, 0xF001,
+ 0xF00F, 0xF010, 0xF012, 0xF01E, 0xF021, 0xF02F,
+ 0xF0E1, 0xF0EF, 0xF0F0, 0xF0F2, 0xF0FE, 0xF100,
+ 0xF102, 0xF10E, 0xF111, 0xF11F, 0xF120, 0xF122,
+ 0xF12E, 0xF1E0, 0xF1E2, 0xF1EE, 0xF1F1, 0xF1FF,
+ 0xF201, 0xF20F, 0xF210, 0xF212, 0xF21E, 0xF221,
+ 0xF22F, 0xF2E1, 0xF2EF, 0xF2F0, 0xF2F2, 0xF2FE,
+ 0xFE01, 0xFE0F, 0xFE10, 0xFE12, 0xFE1E, 0xFE21,
+ 0xFE2F, 0xFEE1, 0xFEEF, 0xFEF0, 0xFEF2, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF0E, 0xFF11, 0xFF1F, 0xFF20,
+ 0xFF22, 0xFF2E, 0xFFE0, 0xFFE2, 0xFFEE, 0xFFF1,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB4_CODES 313
+static const uint32_t on2avc_cb4_codes[ON2AVC_CB4_CODES] = {
+ 0x000A, 0x013B, 0x0127, 0x0004, 0x0015, 0x012C,
+ 0x065F, 0x08CD, 0x016A, 0x08E7, 0x06BA, 0x001B,
+ 0x001D, 0x0018, 0x000A, 0x0002, 0x00C0, 0x012B,
+ 0x00CE, 0x013C, 0x012A, 0x012D, 0x0020, 0x0128,
+ 0x0121, 0x00FC, 0x066B, 0x0472, 0x010A, 0x004E,
+ 0x06AE, 0x063F, 0x1ABF, 0x0B4E, 0x084E, 0x1ABE,
+ 0x010E, 0x0094, 0x00C8, 0x0464, 0x069A, 0x00C9,
+ 0x00FA, 0x041B, 0x2FDE, 0x08CB, 0x05B7, 0x1ABD,
+ 0x066A, 0x008D, 0x00F8, 0x0003, 0x001A, 0x001E,
+ 0x0120, 0x011E, 0x0138, 0x0125, 0x0170, 0x00C4,
+ 0x000B, 0x013E, 0x00C5, 0x000C, 0x000E, 0x001C,
+ 0x00FE, 0x009C, 0x010F, 0x0115, 0x009F, 0x008C,
+ 0x0008, 0x002E, 0x00CF, 0x001C, 0x0110, 0x002F,
+ 0x002C, 0x0002, 0x0116, 0x01FE, 0x032D, 0x00CB,
+ 0x030D, 0x02EC, 0x002E, 0x0037, 0x00CF, 0x0086,
+ 0x00C8, 0x032C, 0x031E, 0x01AC, 0x030C, 0x02ED,
+ 0x035C, 0x013A, 0x02FF, 0x02E2, 0x00BE, 0x00CE,
+ 0x0126, 0x0356, 0x034E, 0x0347, 0x025F, 0x0306,
+ 0x02DA, 0x0168, 0x02E7, 0x020F, 0x0016, 0x0081,
+ 0x0114, 0x0024, 0x001B, 0x010C, 0x03FE, 0x027F,
+ 0x0084, 0x02F9, 0x0237, 0x0000, 0x001A, 0x011A,
+ 0x05A6, 0x04A6, 0x00F9, 0x00CC, 0x05B6, 0x0BF6,
+ 0x0B96, 0x0446, 0x08CE, 0x007F, 0x002C, 0x000E,
+ 0x0080, 0x00C9, 0x00BA, 0x035E, 0x03EF, 0x0345,
+ 0x02FE, 0x02FB, 0x02E6, 0x00D2, 0x021C, 0x0238,
+ 0x06BB, 0x0B97, 0x007E, 0x01AA, 0x023A, 0x05BE,
+ 0x031D, 0x094E, 0x1ABC, 0x0948, 0x088E, 0x02E4,
+ 0x0273, 0x084C, 0x08CC, 0x094B, 0x02D2, 0x023B,
+ 0x043E, 0x2FDF, 0x063E, 0x109B, 0x08CA, 0x08E6,
+ 0x02DE, 0x02F4, 0x00D4, 0x002D, 0x00CA, 0x020E,
+ 0x0344, 0x02FD, 0x030F, 0x02EE, 0x02D6, 0x0123,
+ 0x02F7, 0x03ED, 0x009E, 0x05CA, 0x060E, 0x000D,
+ 0x004D, 0x0444, 0x043F, 0x094A, 0x05FA, 0x109A,
+ 0x0B4F, 0x00FD, 0x0117, 0x0096, 0x0082, 0x0122,
+ 0x025D, 0x0304, 0x034C, 0x027B, 0x035B, 0x02FC,
+ 0x00FC, 0x035F, 0x03EE, 0x088B, 0x0C1E, 0x088A,
+ 0x02F5, 0x0272, 0x17EE, 0x0C1F, 0x084F, 0x088F,
+ 0x069B, 0x0949, 0x023F, 0x02E3, 0x07FE, 0x041A,
+ 0x0B7E, 0x027A, 0x0336, 0x07FF, 0x08CF, 0x094F,
+ 0x065E, 0x0B7F, 0x02DD, 0x0212, 0x01FB, 0x00C6,
+ 0x0095, 0x00D0, 0x023E, 0x025C, 0x02FC, 0x032E,
+ 0x025E, 0x021E, 0x00BC, 0x021D, 0x035A, 0x0007,
+ 0x000F, 0x0006, 0x00C2, 0x000C, 0x00BD, 0x00CD,
+ 0x0113, 0x0118, 0x001D, 0x00CA, 0x008E, 0x0014,
+ 0x010D, 0x0085, 0x0001, 0x003E, 0x008F, 0x0236,
+ 0x030E, 0x00FF, 0x025E, 0x0337, 0x000A, 0x0026,
+ 0x010B, 0x009D, 0x012E, 0x025F, 0x02EF, 0x0305,
+ 0x02DC, 0x027E, 0x02FE, 0x0124, 0x034F, 0x003E,
+ 0x004F, 0x00BC, 0x016C, 0x02D7, 0x03EC, 0x02FA,
+ 0x02F8, 0x02F6, 0x01FA, 0x00CC, 0x02FF, 0x0334,
+ 0x001E, 0x004C, 0x0112, 0x0036, 0x0022, 0x00FE,
+ 0x031C, 0x0346, 0x0108, 0x020C, 0x001E, 0x0012,
+ 0x0026,
+};
+
+static const uint8_t on2avc_cb4_bits[ON2AVC_CB4_CODES] = {
+ 4, 9, 9, 6, 6, 9,
+ 11, 12, 9, 12, 11, 6,
+ 5, 6, 6, 6, 8, 9,
+ 8, 9, 9, 9, 6, 9,
+ 9, 9, 11, 11, 9, 9,
+ 11, 11, 13, 12, 12, 13,
+ 9, 9, 9, 11, 11, 9,
+ 9, 12, 14, 12, 11, 13,
+ 11, 9, 9, 6, 6, 6,
+ 9, 9, 9, 9, 9, 8,
+ 6, 9, 8, 6, 6, 6,
+ 8, 9, 9, 9, 9, 9,
+ 6, 9, 8, 5, 9, 9,
+ 6, 7, 9, 9, 10, 9,
+ 10, 10, 7, 6, 9, 9,
+ 8, 10, 10, 9, 10, 10,
+ 10, 9, 11, 10, 9, 9,
+ 9, 10, 10, 10, 10, 10,
+ 10, 9, 10, 11, 6, 9,
+ 9, 7, 7, 9, 10, 10,
+ 9, 10, 10, 7, 7, 9,
+ 11, 11, 9, 9, 11, 12,
+ 12, 11, 12, 12, 9, 9,
+ 9, 8, 8, 10, 11, 10,
+ 11, 10, 10, 8, 11, 10,
+ 11, 12, 12, 9, 10, 11,
+ 10, 12, 13, 12, 12, 10,
+ 10, 12, 12, 12, 10, 10,
+ 12, 14, 11, 13, 12, 12,
+ 10, 10, 8, 9, 8, 11,
+ 10, 11, 10, 10, 10, 9,
+ 10, 11, 9, 11, 11, 9,
+ 9, 11, 12, 12, 11, 13,
+ 12, 9, 9, 9, 9, 9,
+ 11, 10, 10, 10, 10, 11,
+ 8, 10, 11, 12, 12, 12,
+ 10, 10, 13, 12, 12, 12,
+ 11, 12, 10, 10, 11, 12,
+ 12, 10, 10, 11, 12, 12,
+ 11, 12, 10, 10, 9, 8,
+ 9, 8, 10, 11, 10, 10,
+ 11, 11, 8, 11, 10, 6,
+ 6, 6, 8, 9, 9, 9,
+ 9, 9, 6, 9, 9, 6,
+ 9, 9, 7, 6, 9, 10,
+ 10, 9, 10, 10, 7, 7,
+ 9, 9, 9, 11, 10, 10,
+ 10, 10, 10, 9, 10, 11,
+ 9, 9, 9, 10, 11, 10,
+ 10, 10, 9, 8, 10, 10,
+ 5, 9, 9, 6, 7, 9,
+ 10, 10, 9, 11, 10, 7,
+ 6,
+};
+
+static const uint16_t on2avc_cb4_syms[ON2AVC_CB4_CODES] = {
+ 0x0000, 0x0002, 0x000E, 0x0011, 0x001F, 0x0020,
+ 0x0022, 0x002E, 0x00E0, 0x00E2, 0x00EE, 0x00F1,
+ 0x00FF, 0x0101, 0x010F, 0x0110, 0x0112, 0x011E,
+ 0x0121, 0x012F, 0x01E1, 0x01EF, 0x01F0, 0x01F2,
+ 0x01FE, 0x0200, 0x0202, 0x020E, 0x0211, 0x021F,
+ 0x0220, 0x0222, 0x022E, 0x02E0, 0x02E2, 0x02EE,
+ 0x02F1, 0x02FF, 0x0E00, 0x0E02, 0x0E0E, 0x0E11,
+ 0x0E1F, 0x0E20, 0x0E22, 0x0E2E, 0x0EE0, 0x0EE2,
+ 0x0EEE, 0x0EF1, 0x0EFF, 0x0F01, 0x0F0F, 0x0F10,
+ 0x0F12, 0x0F1E, 0x0F21, 0x0F2F, 0x0FE1, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FFE, 0x1001, 0x100F, 0x1010,
+ 0x1012, 0x101E, 0x1021, 0x102F, 0x10E1, 0x10EF,
+ 0x10F0, 0x10F2, 0x10FE, 0x1100, 0x1102, 0x110E,
+ 0x1111, 0x111F, 0x1120, 0x1122, 0x112E, 0x11E0,
+ 0x11E2, 0x11EE, 0x11F1, 0x11FF, 0x1201, 0x120F,
+ 0x1210, 0x1212, 0x121E, 0x1221, 0x122F, 0x12E1,
+ 0x12EF, 0x12F0, 0x12F2, 0x12FE, 0x1E01, 0x1E0F,
+ 0x1E10, 0x1E12, 0x1E1E, 0x1E21, 0x1E2F, 0x1EE1,
+ 0x1EEF, 0x1EF0, 0x1EF2, 0x1EFE, 0x1F00, 0x1F02,
+ 0x1F0E, 0x1F11, 0x1F1F, 0x1F20, 0x1F22, 0x1F2E,
+ 0x1FE0, 0x1FE2, 0x1FEE, 0x1FF1, 0x1FFF, 0x2000,
+ 0x2002, 0x200E, 0x2011, 0x201F, 0x2020, 0x2022,
+ 0x202E, 0x20E0, 0x20E2, 0x20EE, 0x20F1, 0x20FF,
+ 0x2101, 0x210F, 0x2110, 0x2112, 0x211E, 0x2121,
+ 0x212F, 0x21E1, 0x21EF, 0x21F0, 0x21F2, 0x21FE,
+ 0x2200, 0x2202, 0x220E, 0x2211, 0x221F, 0x2220,
+ 0x2222, 0x222E, 0x22E0, 0x22E2, 0x22EE, 0x22F1,
+ 0x22FF, 0x2E00, 0x2E02, 0x2E0E, 0x2E11, 0x2E1F,
+ 0x2E20, 0x2E22, 0x2E2E, 0x2EE0, 0x2EE2, 0x2EEE,
+ 0x2EF1, 0x2EFF, 0x2F01, 0x2F0F, 0x2F10, 0x2F12,
+ 0x2F1E, 0x2F21, 0x2F2F, 0x2FE1, 0x2FEF, 0x2FF0,
+ 0x2FF2, 0x2FFE, 0xE000, 0xE002, 0xE00E, 0xE011,
+ 0xE01F, 0xE020, 0xE022, 0xE02E, 0xE0E0, 0xE0E2,
+ 0xE0EE, 0xE0F1, 0xE0FF, 0xE101, 0xE10F, 0xE110,
+ 0xE112, 0xE11E, 0xE121, 0xE12F, 0xE1E1, 0xE1EF,
+ 0xE1F0, 0xE1F2, 0xE1FE, 0xE200, 0xE202, 0xE20E,
+ 0xE211, 0xE21F, 0xE220, 0xE222, 0xE22E, 0xE2E0,
+ 0xE2E2, 0xE2EE, 0xE2F1, 0xE2FF, 0xEE00, 0xEE02,
+ 0xEE0E, 0xEE11, 0xEE1F, 0xEE20, 0xEE22, 0xEE2E,
+ 0xEEE0, 0xEEE2, 0xEEEE, 0xEEF1, 0xEEFF, 0xEF01,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF1E, 0xEF21, 0xEF2F,
+ 0xEFE1, 0xEFEF, 0xEFF0, 0xEFF2, 0xEFFE, 0xF001,
+ 0xF00F, 0xF010, 0xF012, 0xF01E, 0xF021, 0xF02F,
+ 0xF0E1, 0xF0EF, 0xF0F0, 0xF0F2, 0xF0FE, 0xF100,
+ 0xF102, 0xF10E, 0xF111, 0xF11F, 0xF120, 0xF122,
+ 0xF12E, 0xF1E0, 0xF1E2, 0xF1EE, 0xF1F1, 0xF1FF,
+ 0xF201, 0xF20F, 0xF210, 0xF212, 0xF21E, 0xF221,
+ 0xF22F, 0xF2E1, 0xF2EF, 0xF2F0, 0xF2F2, 0xF2FE,
+ 0xFE01, 0xFE0F, 0xFE10, 0xFE12, 0xFE1E, 0xFE21,
+ 0xFE2F, 0xFEE1, 0xFEEF, 0xFEF0, 0xFEF2, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF0E, 0xFF11, 0xFF1F, 0xFF20,
+ 0xFF22, 0xFF2E, 0xFFE0, 0xFFE2, 0xFFEE, 0xFFF1,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB5_CODES 1201
+static const uint32_t on2avc_cb5_codes[ON2AVC_CB5_CODES] = {
+ 0x00000, 0x000D6, 0x000E2, 0x00044, 0x0009E, 0x0009A,
+ 0x0003A, 0x004E6, 0x00A29, 0x007FE, 0x0024A, 0x004EE,
+ 0x00496, 0x001EE, 0x001C8, 0x008FA, 0x0050F, 0x001EF,
+ 0x00486, 0x00906, 0x00904, 0x0003E, 0x00094, 0x000A6,
+ 0x00046, 0x00061, 0x0012A, 0x0020D, 0x00060, 0x00066,
+ 0x00452, 0x00692, 0x0087E, 0x00242, 0x0050C, 0x008BE,
+ 0x0024C, 0x0045A, 0x0025A, 0x001C6, 0x002EE, 0x00294,
+ 0x006CE, 0x001EC, 0x00492, 0x00690, 0x00055, 0x00474,
+ 0x0063E, 0x00524, 0x04802, 0x04DC5, 0x00DEF, 0x01A62,
+ 0x00E6A, 0x00A7F, 0x027FB, 0x034B5, 0x036C5, 0x00A3A,
+ 0x036C6, 0x0219B, 0x00296, 0x0090F, 0x027FA, 0x028C8,
+ 0x0052A, 0x0127E, 0x0598E, 0x034B4, 0x00C78, 0x0146E,
+ 0x00F5F, 0x00BAA, 0x00432, 0x0FF63, 0x0598F, 0x0091C,
+ 0x00257, 0x0240B, 0x014E6, 0x00E6B, 0x05173, 0x01647,
+ 0x007F9, 0x022F3, 0x04DC6, 0x022F2, 0x0087F, 0x036C7,
+ 0x01AB9, 0x00C79, 0x06944, 0x043C6, 0x0043E, 0x00218,
+ 0x031C4, 0x014E5, 0x0093E, 0x0FF62, 0x3FAE0, 0x00328,
+ 0x00228, 0x01428, 0x03FEA, 0x007A3, 0x034B3, 0x0D23B,
+ 0x00B29, 0x01AB8, 0x028C7, 0x0598D, 0x00B28, 0x0149B,
+ 0x0149A, 0x008EE, 0x027F9, 0x07FC0, 0x00CFE, 0x0025E,
+ 0x01CBB, 0x026EF, 0x00512, 0x0297B, 0x05172, 0x00D36,
+ 0x00FCA, 0x01EA5, 0x00D86, 0x01FC5, 0x031C3, 0x02CD6,
+ 0x00276, 0x01F8A, 0x04801, 0x00B2A, 0x00329, 0x00FC9,
+ 0x03F0C, 0x00D35, 0x01971, 0x04DC4, 0x036C4, 0x00A4F,
+ 0x00FEA, 0x01FC4, 0x0122A, 0x00058, 0x001CA, 0x0013A,
+ 0x0005E, 0x00054, 0x0053E, 0x0039E, 0x006C6, 0x00284,
+ 0x001C2, 0x0087A, 0x0020E, 0x0050E, 0x006F2, 0x00288,
+ 0x0029E, 0x00457, 0x006F9, 0x005D3, 0x00248, 0x008F7,
+ 0x00068, 0x0069D, 0x00497, 0x0005F, 0x0091D, 0x00738,
+ 0x00057, 0x0005A, 0x00A3E, 0x009CF, 0x00D3E, 0x00D87,
+ 0x00C6B, 0x00CBD, 0x003F6, 0x00A74, 0x00C6E, 0x0049C,
+ 0x012FE, 0x0137F, 0x00DBB, 0x010DA, 0x00CAB, 0x0127F,
+ 0x00056, 0x00A2A, 0x0083E, 0x00040, 0x00BAE, 0x00BA2,
+ 0x0012E, 0x006F0, 0x0096E, 0x0022C, 0x00FDE, 0x011EB,
+ 0x01ABE, 0x007EA, 0x014E7, 0x011F2, 0x00256, 0x009FC,
+ 0x0297C, 0x01C13, 0x006F4, 0x00B26, 0x0144E, 0x021EE,
+ 0x001C0, 0x00707, 0x00B3F, 0x00244, 0x00E0B, 0x02CD8,
+ 0x034B6, 0x00B2B, 0x00914, 0x027FD, 0x028CA, 0x01396,
+ 0x014EB, 0x01972, 0x01B71, 0x013BE, 0x00D9A, 0x00D3F,
+ 0x009C9, 0x014EA, 0x031C6, 0x022F5, 0x027FC, 0x0240D,
+ 0x0297D, 0x006F5, 0x02CD7, 0x0396A, 0x0018C, 0x04DC7,
+ 0x028CB, 0x007E7, 0x0D23C, 0x043C8, 0x008FC, 0x00C7A,
+ 0x031C7, 0x018EB, 0x0396B, 0x0D23D, 0x036C9, 0x01973,
+ 0x018EA, 0x07FC1, 0x08FD8, 0x01673, 0x0067C, 0x027FE,
+ 0x036C8, 0x004BE, 0x08FD9, 0x07FC2, 0x009B6, 0x00148,
+ 0x026F0, 0x05174, 0x0071C, 0x07279, 0x08FD7, 0x005D4,
+ 0x00E0A, 0x01A63, 0x01F8B, 0x0114E, 0x01ABA, 0x05990,
+ 0x043C7, 0x01BEE, 0x3FAE1, 0x1FE94, 0x01CBE, 0x006F3,
+ 0x018E7, 0x0240C, 0x006FA, 0x03967, 0x08FD6, 0x0045B,
+ 0x00DBA, 0x01A65, 0x03969, 0x00CFF, 0x0067E, 0x026F1,
+ 0x028C9, 0x022F4, 0x018D2, 0x01B70, 0x011EA, 0x00BBF,
+ 0x00B3E, 0x0144D, 0x00D3D, 0x0146F, 0x01A64, 0x01FFF,
+ 0x01B6F, 0x03968, 0x024EB, 0x00656, 0x031C5, 0x0727A,
+ 0x0003C, 0x00D22, 0x00D99, 0x0021A, 0x00706, 0x007EE,
+ 0x0013E, 0x00CBC, 0x01C12, 0x01A66, 0x0022E, 0x00E77,
+ 0x01672, 0x004D8, 0x006D3, 0x01CBF, 0x01ABB, 0x008BF,
+ 0x00E76, 0x01BEF, 0x01FC6, 0x001B2, 0x00736, 0x008FB,
+ 0x0021D, 0x000D7, 0x04804, 0x06948, 0x00D37, 0x0396E,
+ 0x06949, 0x0120A, 0x03F0F, 0x1437E, 0x043CB, 0x028D0,
+ 0x0A2BE, 0x08FDD, 0x05996, 0x022F6, 0x1FE96, 0x0FF64,
+ 0x026F2, 0x028CF, 0x04DCB, 0x03F0E, 0x00A3F, 0x05178,
+ 0x05995, 0x00BA3, 0x00A4A, 0x07FC8, 0x0727E, 0x007AA,
+ 0x003D0, 0x0599A, 0x02CDB, 0x034BB, 0x07FC9, 0x0D261,
+ 0x04805, 0x04806, 0x0727F, 0x022F7, 0x018FE, 0x0240F,
+ 0x02CDA, 0x031CB, 0x04DCC, 0x034BA, 0x036CB, 0x0052B,
+ 0x05997, 0x036CE, 0x00907, 0x08FDF, 0x043CD, 0x00E7E,
+ 0x0517A, 0x04DCD, 0x0197E, 0x0A2BF, 0x028D1, 0x04807,
+ 0x028D2, 0x04808, 0x0D262, 0x024ED, 0x01ABF, 0x072C0,
+ 0x1437F, 0x034BE, 0x05179, 0x144F0, 0x072C1, 0x029C1,
+ 0x08FDE, 0x043CC, 0x023AE, 0x00A3B, 0x1FE97, 0x08FE1,
+ 0x0142A, 0x006AC, 0x04809, 0x024EE, 0x00C7B, 0x3FAE3,
+ 0x08FE2, 0x01F8F, 0x0A2C0, 0x023AF, 0x08FE3, 0x02416,
+ 0x072C2, 0x0FF65, 0x00FCB, 0x08FE0, 0x144F1, 0x01EA6,
+ 0x00590, 0x04DCE, 0x0396F, 0x01FC7, 0x05991, 0x3FAE2,
+ 0x0096C, 0x00657, 0x034B8, 0x05992, 0x0240E, 0x0A2BC,
+ 0x08FDA, 0x0114F, 0x0727C, 0x06945, 0x05175, 0x01B72,
+ 0x0727B, 0x07FC3, 0x01472, 0x0A2BB, 0x0D23E, 0x00CBE,
+ 0x00636, 0x034B7, 0x043C9, 0x008AA, 0x08FDB, 0x0D23F,
+ 0x02852, 0x0727D, 0x05994, 0x00E3E, 0x031CA, 0x06947,
+ 0x04DC8, 0x02CD9, 0x1FE95, 0x0D260, 0x028CD, 0x024EC,
+ 0x04803, 0x07FC4, 0x01976, 0x028CC, 0x05993, 0x07FC5,
+ 0x027FF, 0x06946, 0x03FEB, 0x03F0D, 0x0096D, 0x08FDC,
+ 0x04DC9, 0x0097E, 0x003D3, 0x0A2BD, 0x0286E, 0x07FC6,
+ 0x07FC7, 0x034B9, 0x029C0, 0x01F8E, 0x04DCA, 0x05177,
+ 0x01977, 0x03FEE, 0x0297E, 0x028CE, 0x036CA, 0x05176,
+ 0x0297F, 0x00596, 0x02853, 0x043CA, 0x0090E, 0x144FA,
+ 0x0D26A, 0x008AB, 0x000CE, 0x072C3, 0x034BF, 0x02417,
+ 0x3FAF0, 0x3FAEF, 0x026F3, 0x1FEA0, 0x3FAF1, 0x1FE9F,
+ 0x0D269, 0x0FF6A, 0x1FE9D, 0x029C6, 0x3FAEE, 0x1FE9E,
+ 0x036CF, 0x001AA, 0x0480E, 0x0A2C7, 0x000A0, 0x07FCE,
+ 0x3FAF4, 0x008F8, 0x3FAF5, 0x144FB, 0x00A16, 0x024EF,
+ 0x04DD3, 0x0694E, 0x1FEA2, 0x3FAF7, 0x3FAF6, 0x0D26B,
+ 0x04DD2, 0x3FAF2, 0x1FEA1, 0x08FE6, 0x0122B, 0x08FE7,
+ 0x0480F, 0x00C6F, 0x0FF6B, 0x3FAF3, 0x008EF, 0x00C7E,
+ 0x3FAF8, 0x1FEA4, 0x00DF6, 0x00362, 0x0694F, 0x0599B,
+ 0x0142B, 0x1FEA6, 0x1FEA5, 0x03FEF, 0x07FCF, 0x1FEA7,
+ 0x3FAF9, 0x029C7, 0x0D26E, 0x144FE, 0x01C3E, 0x1FEA3,
+ 0x0A2CA, 0x01CE6, 0x0049E, 0x043CF, 0x04EFE, 0x0036B,
+ 0x3FAFE, 0x11F32, 0x01EAE, 0x1FEAA, 0x0D26F, 0x049D2,
+ 0x02EAE, 0x0356A, 0x08FEA, 0x07ABE, 0x08FEB, 0x3FAFF,
+ 0x1FEAB, 0x0292E, 0x144FF, 0x3FAFA, 0x08FE8, 0x01EA7,
+ 0x0B27A, 0x0A2CB, 0x0164E, 0x3FAFB, 0x08FE9, 0x021EF,
+ 0x00A76, 0x1FE9A, 0x144F2, 0x029C3, 0x3FAE8, 0x3FAE7,
+ 0x014EE, 0x03F12, 0x0D264, 0x08FE4, 0x0FF67, 0x1FE9B,
+ 0x144F3, 0x0FF66, 0x0D263, 0x3FAE5, 0x3FAE4, 0x029C2,
+ 0x031FE, 0x0A2C1, 0x1FE98, 0x01FD6, 0x3FAE6, 0x1FE99,
+ 0x01473, 0x00D9B, 0x144F5, 0x144F4, 0x00FD2, 0x0036A,
+ 0x043CE, 0x03F13, 0x0517B, 0x0D267, 0x144F6, 0x01756,
+ 0x0A2C2, 0x144F8, 0x144F7, 0x0480A, 0x0FF68, 0x0D265,
+ 0x01B73, 0x0D266, 0x3FAE9, 0x01A67, 0x00493, 0x0694B,
+ 0x0694A, 0x00082, 0x03F7E, 0x04DCF, 0x009B7, 0x3FAEB,
+ 0x1FE9C, 0x0071D, 0x028D3, 0x0D268, 0x0A2C5, 0x0A2C6,
+ 0x3FAED, 0x3FAEC, 0x08FE5, 0x07FCA, 0x3FAEA, 0x144F9,
+ 0x0A2C3, 0x00D3C, 0x07FCB, 0x0480B, 0x009CA, 0x0FF69,
+ 0x0A2C4, 0x0091E, 0x007EB, 0x1FE85, 0x0FF56, 0x0091F,
+ 0x0019E, 0x0693A, 0x0593E, 0x020FC, 0x1FE86, 0x0FF57,
+ 0x027F4, 0x0146A, 0x04BFC, 0x0CBF9, 0x0CBF8, 0x1FE83,
+ 0x3F7F5, 0x08F9E, 0x3F7F6, 0x1FE84, 0x036C0, 0x00098,
+ 0x0593C, 0x071F9, 0x0006E, 0x0593F, 0x03963, 0x00A3C,
+ 0x13BFD, 0x1FE89, 0x007F2, 0x00FD3, 0x03F08, 0x03D5E,
+ 0x034A9, 0x13BFF, 0x13BFE, 0x071FA, 0x011E8, 0x1FE87,
+ 0x3F7F7, 0x0FF58, 0x01B66, 0x07FB8, 0x05168, 0x0070E,
+ 0x0FF59, 0x1FE88, 0x009B3, 0x00BBC, 0x1FE8B, 0x3F7F8,
+ 0x00FE6, 0x004FC, 0x0CBFC, 0x03FE6, 0x022F0, 0x1FE8C,
+ 0x0CBFD, 0x01CE7, 0x08F9F, 0x0FF5A, 0x071FD, 0x1FE8A,
+ 0x071FB, 0x14378, 0x01AB4, 0x0CBFB, 0x0CBFA, 0x036C1,
+ 0x0037E, 0x05980, 0x071FC, 0x00D5E, 0x3F7FC, 0x08FD0,
+ 0x014EF, 0x3F7FE, 0x3F7FD, 0x01CFE, 0x01FBE, 0x05982,
+ 0x1437A, 0x04BFD, 0x1FE8E, 0x3F7FF, 0x071FF, 0x0FF5B,
+ 0x1FE8D, 0x3F7F9, 0x14379, 0x047F7, 0x05981, 0x071FE,
+ 0x014E2, 0x3F7FB, 0x3F7FA, 0x02CCE, 0x0037F, 0x0A27E,
+ 0x3D5FA, 0x02CCC, 0x1FE80, 0x1FD7E, 0x01496, 0x018E4,
+ 0x3D5FB, 0x05164, 0x070FD, 0x3D5FC, 0x11F33, 0x0277E,
+ 0x0FF54, 0x08F98, 0x07FB6, 0x070FC, 0x026E8, 0x07FB7,
+ 0x034A6, 0x0356B, 0x3D5F9, 0x3D5F8, 0x034A8, 0x0114C,
+ 0x3F7F0, 0x3D5FF, 0x00C74, 0x0024D, 0x05167, 0x049D3,
+ 0x0292F, 0x08F9C, 0x3F7F1, 0x01CB6, 0x03962, 0x070FF,
+ 0x08F9D, 0x08F9A, 0x3D5FD, 0x0A2B0, 0x024E8, 0x070FE,
+ 0x3D5FE, 0x01A5E, 0x00392, 0x08F9B, 0x05166, 0x00099,
+ 0x06939, 0x06938, 0x009B2, 0x0C7FE, 0x3F7F4, 0x007F7,
+ 0x011D6, 0x02EAF, 0x028BE, 0x071F8, 0x0C7FF, 0x1FE82,
+ 0x047F6, 0x06936, 0x3F7F3, 0x3F7F2, 0x1FE81, 0x026EA,
+ 0x0C7FC, 0x0B27B, 0x009FA, 0x0C7FD, 0x13BFC, 0x007A8,
+ 0x000D4, 0x08FD1, 0x0D234, 0x00D34, 0x07274, 0x05988,
+ 0x00F5C, 0x0516D, 0x0516E, 0x0516C, 0x036C3, 0x0A2B4,
+ 0x0D235, 0x036C2, 0x034AC, 0x0D233, 0x07FBA, 0x034AB,
+ 0x0A2B3, 0x1437D, 0x1437C, 0x00B3B, 0x07273, 0x0516B,
+ 0x00D84, 0x009FB, 0x0693F, 0x0598A, 0x007F8, 0x005D6,
+ 0x047FB, 0x024EA, 0x026EC, 0x0516F, 0x047FC, 0x031A7,
+ 0x01397, 0x026ED, 0x02975, 0x02CD1, 0x034AD, 0x07275,
+ 0x027F6, 0x05989, 0x043C1, 0x0693E, 0x00454, 0x034AE,
+ 0x043C2, 0x007F6, 0x0A2B7, 0x07FBB, 0x02408, 0x0598B,
+ 0x047FD, 0x01B6A, 0x04DC1, 0x0FF5F, 0x07FBC, 0x01B6B,
+ 0x07277, 0x0D236, 0x020FD, 0x01B68, 0x0A2B5, 0x0FF5E,
+ 0x02976, 0x043C3, 0x02977, 0x0A2B6, 0x012DE, 0x07276,
+ 0x03FE9, 0x01B69, 0x00A4C, 0x0FF60, 0x1FE93, 0x013BC,
+ 0x00592, 0x02978, 0x02CD3, 0x00D8E, 0x0D237, 0x05170,
+ 0x01FC1, 0x028C2, 0x06941, 0x0D238, 0x07278, 0x034AF,
+ 0x06940, 0x00E5E, 0x08FD2, 0x07FBD, 0x020FE, 0x007E6,
+ 0x043C4, 0x02CD2, 0x0166E, 0x0CBFF, 0x0CBFE, 0x00A5C,
+ 0x005D0, 0x026EB, 0x047F8, 0x01F88, 0x1FE90, 0x1FE8F,
+ 0x00C68, 0x021EC, 0x0A2B1, 0x0D230, 0x04BFE, 0x0693B,
+ 0x028BF, 0x028C0, 0x07270, 0x0FF5C, 0x00E08, 0x00360,
+ 0x0436C, 0x05983, 0x009BE, 0x0FF5D, 0x1FE91, 0x01A60,
+ 0x04BFF, 0x0A2B2, 0x0436E, 0x03F0A, 0x07FB9, 0x05984,
+ 0x01FC0, 0x1FE92, 0x1437B, 0x01646, 0x03F09, 0x0693C,
+ 0x027F5, 0x047F9, 0x034AA, 0x0D231, 0x0436D, 0x01AB6,
+ 0x047FA, 0x07271, 0x00CFA, 0x006CF, 0x07272, 0x05986,
+ 0x00B3A, 0x00654, 0x028C1, 0x0436F, 0x02CD0, 0x03FE8,
+ 0x05987, 0x043C0, 0x0146B, 0x02974, 0x031A6, 0x02CCF,
+ 0x03964, 0x04DC0, 0x0516A, 0x05985, 0x05169, 0x02406,
+ 0x003D6, 0x0D232, 0x0693D, 0x0005C, 0x006F6, 0x0086E,
+ 0x00062, 0x0005B, 0x006F1, 0x007E0, 0x00D98, 0x00BBE,
+ 0x00E72, 0x00D8F, 0x004DA, 0x0137B, 0x0137A, 0x00386,
+ 0x00A7E, 0x00C6A, 0x00CBA, 0x00F5E, 0x00F5D, 0x013BD,
+ 0x00064, 0x009CE, 0x008EC, 0x0003B, 0x00F56, 0x00CAA,
+ 0x00246, 0x008ED, 0x0086C, 0x001ED, 0x00C77, 0x0240A,
+ 0x01B6D, 0x0086F, 0x02CD5, 0x01FC3, 0x0073E, 0x005D2,
+ 0x01970, 0x014E4, 0x00456, 0x00B22, 0x0114D, 0x02198,
+ 0x00138, 0x0069C, 0x00737, 0x0020C, 0x00A4E, 0x04DC2,
+ 0x018E6, 0x00E1E, 0x006D2, 0x047FF, 0x02979, 0x01FFE,
+ 0x04800, 0x021ED, 0x028C6, 0x00917, 0x01671, 0x01CFF,
+ 0x00CFB, 0x00FE7, 0x00A1A, 0x0146D, 0x01670, 0x01B6E,
+ 0x0137E, 0x006D1, 0x01FFD, 0x028C5, 0x00176, 0x05171,
+ 0x0219A, 0x0023C, 0x0A2BA, 0x043C5, 0x006F8, 0x006DF,
+ 0x01EA4, 0x01CBA, 0x027F8, 0x0FF61, 0x08FD5, 0x0177B,
+ 0x02199, 0x0D23A, 0x03966, 0x0297A, 0x00A38, 0x0177A,
+ 0x01A61, 0x00597, 0x07FBF, 0x04DC3, 0x007F4, 0x00196,
+ 0x034B0, 0x03F0B, 0x008F6, 0x0598C, 0x08FD3, 0x003D2,
+ 0x006D0, 0x01FC2, 0x031C1, 0x026EE, 0x0A2B9, 0x0D239,
+ 0x0175F, 0x0175E, 0x031C0, 0x06942, 0x01FF6, 0x00A3D,
+ 0x0166F, 0x027F7, 0x009C8, 0x0A2B8, 0x07FBE, 0x00734,
+ 0x00FC6, 0x03965, 0x06943, 0x010CF, 0x006DE, 0x02CD4,
+ 0x08FD4, 0x034B2, 0x01CB8, 0x028C3, 0x01FFC, 0x0041E,
+ 0x0146C, 0x01B6C, 0x00C76, 0x00B3C, 0x010CE, 0x022F1,
+ 0x0144C, 0x012DF, 0x01436, 0x0073A, 0x034B1, 0x031C2,
+ 0x00042, 0x00DEE, 0x00B3D, 0x001CC, 0x00A17, 0x007E8,
+ 0x0021C, 0x00A28, 0x01CB9, 0x02409, 0x00916, 0x020FF,
+ 0x047FE, 0x00726, 0x00238, 0x011E9, 0x01AB7, 0x0071E,
+ 0x00FC8, 0x028C4, 0x00D85, 0x00239, 0x008EA, 0x007A2,
+ 0x0012C,
+};
+
+static const uint8_t on2avc_cb5_bits[ON2AVC_CB5_CODES] = {
+ 1, 8, 8, 7, 8, 8,
+ 6, 11, 12, 11, 10, 11,
+ 11, 9, 9, 12, 11, 9,
+ 11, 12, 12, 6, 8, 8,
+ 7, 7, 9, 10, 7, 7,
+ 11, 11, 12, 10, 11, 12,
+ 10, 11, 10, 9, 10, 10,
+ 11, 9, 11, 11, 7, 11,
+ 11, 11, 15, 15, 12, 13,
+ 12, 12, 14, 14, 14, 12,
+ 14, 14, 10, 12, 14, 14,
+ 11, 13, 15, 14, 12, 13,
+ 12, 12, 11, 16, 15, 12,
+ 10, 14, 13, 12, 15, 13,
+ 11, 14, 15, 14, 12, 14,
+ 13, 12, 15, 15, 11, 10,
+ 14, 13, 12, 16, 18, 10,
+ 10, 13, 14, 11, 14, 16,
+ 12, 13, 14, 15, 12, 13,
+ 13, 12, 14, 15, 12, 10,
+ 13, 14, 11, 14, 15, 12,
+ 12, 13, 12, 13, 14, 14,
+ 10, 13, 15, 12, 10, 12,
+ 14, 12, 13, 15, 14, 12,
+ 12, 13, 13, 7, 9, 9,
+ 7, 7, 11, 10, 11, 10,
+ 9, 12, 10, 11, 11, 10,
+ 10, 11, 11, 11, 10, 12,
+ 7, 11, 11, 7, 12, 11,
+ 7, 7, 12, 12, 12, 12,
+ 12, 12, 10, 12, 12, 11,
+ 13, 13, 12, 13, 12, 13,
+ 7, 12, 12, 7, 12, 12,
+ 9, 11, 12, 10, 12, 13,
+ 13, 11, 13, 13, 10, 12,
+ 14, 13, 11, 12, 13, 14,
+ 9, 11, 12, 10, 12, 14,
+ 14, 12, 12, 14, 14, 13,
+ 13, 13, 13, 13, 12, 12,
+ 12, 13, 14, 14, 14, 14,
+ 14, 11, 14, 14, 9, 15,
+ 14, 11, 16, 15, 12, 12,
+ 14, 13, 14, 16, 14, 13,
+ 13, 15, 16, 13, 11, 14,
+ 14, 11, 16, 15, 12, 9,
+ 14, 15, 11, 15, 16, 11,
+ 12, 13, 13, 13, 13, 15,
+ 15, 13, 18, 17, 13, 11,
+ 13, 14, 11, 14, 16, 11,
+ 12, 13, 14, 12, 11, 14,
+ 14, 14, 13, 13, 13, 12,
+ 12, 13, 12, 13, 13, 13,
+ 13, 14, 14, 11, 14, 15,
+ 6, 12, 12, 10, 11, 11,
+ 9, 12, 13, 13, 10, 12,
+ 13, 11, 11, 13, 13, 12,
+ 12, 13, 13, 9, 11, 12,
+ 10, 8, 15, 15, 12, 14,
+ 15, 13, 14, 17, 15, 14,
+ 16, 16, 15, 14, 17, 16,
+ 14, 14, 15, 14, 12, 15,
+ 15, 12, 12, 15, 15, 11,
+ 10, 15, 14, 14, 15, 16,
+ 15, 15, 15, 14, 13, 14,
+ 14, 14, 15, 14, 14, 11,
+ 15, 14, 12, 16, 15, 12,
+ 15, 15, 13, 16, 14, 15,
+ 14, 15, 16, 14, 13, 15,
+ 17, 14, 15, 17, 15, 14,
+ 16, 15, 14, 12, 17, 16,
+ 13, 11, 15, 14, 12, 18,
+ 16, 13, 16, 14, 16, 14,
+ 15, 16, 12, 16, 17, 13,
+ 11, 15, 14, 13, 15, 18,
+ 12, 11, 14, 15, 14, 16,
+ 16, 13, 15, 15, 15, 13,
+ 15, 15, 13, 16, 16, 12,
+ 11, 14, 15, 12, 16, 16,
+ 14, 15, 15, 12, 14, 15,
+ 15, 14, 17, 16, 14, 14,
+ 15, 15, 13, 14, 15, 15,
+ 14, 15, 14, 14, 12, 16,
+ 15, 12, 10, 16, 14, 15,
+ 15, 14, 14, 13, 15, 15,
+ 13, 14, 14, 14, 14, 15,
+ 14, 11, 14, 15, 12, 17,
+ 16, 12, 8, 15, 14, 14,
+ 18, 18, 14, 17, 18, 17,
+ 16, 16, 17, 14, 18, 17,
+ 14, 9, 15, 16, 8, 15,
+ 18, 12, 18, 17, 12, 14,
+ 15, 15, 17, 18, 18, 16,
+ 15, 18, 17, 16, 13, 16,
+ 15, 12, 16, 18, 12, 12,
+ 18, 17, 12, 10, 15, 15,
+ 13, 17, 17, 14, 15, 17,
+ 18, 14, 16, 17, 13, 17,
+ 16, 13, 11, 15, 15, 10,
+ 18, 17, 13, 17, 16, 15,
+ 14, 14, 16, 15, 16, 18,
+ 17, 14, 17, 18, 16, 13,
+ 16, 16, 13, 18, 16, 14,
+ 12, 17, 17, 14, 18, 18,
+ 13, 14, 16, 16, 16, 17,
+ 17, 16, 16, 18, 18, 14,
+ 14, 16, 17, 13, 18, 17,
+ 13, 12, 17, 17, 12, 10,
+ 15, 14, 15, 16, 17, 13,
+ 16, 17, 17, 15, 16, 16,
+ 13, 16, 18, 13, 11, 15,
+ 15, 8, 14, 15, 12, 18,
+ 17, 11, 14, 16, 16, 16,
+ 18, 18, 16, 15, 18, 17,
+ 16, 12, 15, 15, 12, 16,
+ 16, 12, 11, 17, 16, 12,
+ 9, 15, 15, 14, 17, 16,
+ 14, 13, 15, 16, 16, 17,
+ 18, 16, 18, 17, 14, 8,
+ 15, 15, 7, 15, 14, 12,
+ 17, 17, 11, 12, 14, 14,
+ 14, 17, 17, 15, 13, 17,
+ 18, 16, 13, 15, 15, 11,
+ 16, 17, 12, 12, 17, 18,
+ 12, 11, 16, 14, 14, 17,
+ 16, 13, 16, 16, 15, 17,
+ 15, 17, 13, 16, 16, 14,
+ 10, 15, 15, 12, 18, 16,
+ 13, 18, 18, 13, 13, 15,
+ 17, 15, 17, 18, 15, 16,
+ 17, 18, 17, 15, 15, 15,
+ 13, 18, 18, 14, 10, 16,
+ 18, 14, 17, 17, 13, 13,
+ 18, 15, 15, 18, 17, 14,
+ 16, 16, 15, 15, 14, 15,
+ 14, 14, 18, 18, 14, 13,
+ 18, 18, 12, 10, 15, 15,
+ 14, 16, 18, 13, 14, 15,
+ 16, 16, 18, 16, 14, 15,
+ 18, 13, 10, 16, 15, 8,
+ 15, 15, 12, 16, 18, 11,
+ 13, 14, 14, 15, 16, 17,
+ 15, 15, 18, 18, 17, 14,
+ 16, 16, 12, 16, 17, 11,
+ 8, 16, 16, 12, 15, 15,
+ 12, 15, 15, 15, 14, 16,
+ 16, 14, 14, 16, 15, 14,
+ 16, 17, 17, 12, 15, 15,
+ 12, 12, 15, 15, 11, 11,
+ 15, 14, 14, 15, 15, 14,
+ 13, 14, 14, 14, 14, 15,
+ 14, 15, 15, 15, 11, 14,
+ 15, 11, 16, 15, 14, 15,
+ 15, 13, 15, 16, 15, 13,
+ 15, 16, 14, 13, 16, 16,
+ 14, 15, 14, 16, 13, 15,
+ 14, 13, 12, 16, 17, 13,
+ 11, 14, 14, 12, 16, 15,
+ 13, 14, 15, 16, 15, 14,
+ 15, 12, 16, 15, 14, 11,
+ 15, 14, 13, 16, 16, 12,
+ 11, 14, 15, 13, 17, 17,
+ 12, 14, 16, 16, 15, 15,
+ 14, 14, 15, 16, 12, 10,
+ 15, 15, 12, 16, 17, 13,
+ 15, 16, 15, 14, 15, 15,
+ 13, 17, 17, 13, 14, 15,
+ 14, 15, 14, 16, 15, 13,
+ 15, 15, 12, 11, 15, 15,
+ 12, 11, 14, 15, 14, 14,
+ 15, 15, 13, 14, 14, 14,
+ 14, 15, 15, 15, 15, 14,
+ 10, 16, 15, 7, 11, 12,
+ 7, 7, 11, 11, 12, 12,
+ 12, 12, 11, 13, 13, 10,
+ 12, 12, 12, 12, 12, 13,
+ 7, 12, 12, 6, 12, 12,
+ 10, 12, 12, 9, 12, 14,
+ 13, 12, 14, 13, 11, 11,
+ 13, 13, 11, 12, 13, 14,
+ 9, 11, 11, 10, 12, 15,
+ 13, 12, 11, 15, 14, 13,
+ 15, 14, 14, 12, 13, 13,
+ 12, 12, 12, 13, 13, 13,
+ 13, 11, 13, 14, 9, 15,
+ 14, 10, 16, 15, 11, 11,
+ 13, 13, 14, 16, 16, 13,
+ 14, 16, 14, 14, 12, 13,
+ 13, 11, 15, 15, 11, 9,
+ 14, 14, 12, 15, 16, 10,
+ 11, 13, 14, 14, 16, 16,
+ 13, 13, 14, 15, 13, 12,
+ 13, 14, 12, 16, 15, 11,
+ 12, 14, 15, 13, 11, 14,
+ 16, 14, 13, 14, 13, 11,
+ 13, 13, 12, 12, 13, 14,
+ 13, 13, 13, 11, 14, 14,
+ 7, 12, 12, 9, 12, 11,
+ 10, 12, 13, 14, 12, 14,
+ 15, 11, 10, 13, 13, 11,
+ 12, 14, 12, 10, 12, 11,
+ 9,
+};
+
+static const uint16_t on2avc_cb5_syms[ON2AVC_CB5_CODES] = {
+ 0x0000, 0x0002, 0x000E, 0x0011, 0x0013, 0x001D,
+ 0x001F, 0x0020, 0x0022, 0x002E, 0x0031, 0x0033,
+ 0x003D, 0x003F, 0x00D1, 0x00D3, 0x00DD, 0x00DF,
+ 0x00E0, 0x00E2, 0x00EE, 0x00F1, 0x00F3, 0x00FD,
+ 0x00FF, 0x0101, 0x0103, 0x010D, 0x010F, 0x0110,
+ 0x0112, 0x011E, 0x0121, 0x0123, 0x012D, 0x012F,
+ 0x0130, 0x0132, 0x013E, 0x01D0, 0x01D2, 0x01DE,
+ 0x01E1, 0x01E3, 0x01ED, 0x01EF, 0x01F0, 0x01F2,
+ 0x01FE, 0x0200, 0x0202, 0x020E, 0x0211, 0x0213,
+ 0x021D, 0x021F, 0x0220, 0x0222, 0x022E, 0x0231,
+ 0x0233, 0x023D, 0x023F, 0x02D1, 0x02D3, 0x02DD,
+ 0x02DF, 0x02E0, 0x02E2, 0x02EE, 0x02F1, 0x02F3,
+ 0x02FD, 0x02FF, 0x0301, 0x0303, 0x030D, 0x030F,
+ 0x0310, 0x0312, 0x031E, 0x0321, 0x0323, 0x032D,
+ 0x032F, 0x0330, 0x0332, 0x033E, 0x03D0, 0x03D2,
+ 0x03DE, 0x03E1, 0x03E3, 0x03ED, 0x03EF, 0x03F0,
+ 0x03F2, 0x03FE, 0x0D01, 0x0D03, 0x0D0D, 0x0D0F,
+ 0x0D10, 0x0D12, 0x0D1E, 0x0D21, 0x0D23, 0x0D2D,
+ 0x0D2F, 0x0D30, 0x0D32, 0x0D3E, 0x0DD0, 0x0DD2,
+ 0x0DDE, 0x0DE1, 0x0DE3, 0x0DED, 0x0DEF, 0x0DF0,
+ 0x0DF2, 0x0DFE, 0x0E00, 0x0E02, 0x0E0E, 0x0E11,
+ 0x0E13, 0x0E1D, 0x0E1F, 0x0E20, 0x0E22, 0x0E2E,
+ 0x0E31, 0x0E33, 0x0E3D, 0x0E3F, 0x0ED1, 0x0ED3,
+ 0x0EDD, 0x0EDF, 0x0EE0, 0x0EE2, 0x0EEE, 0x0EF1,
+ 0x0EF3, 0x0EFD, 0x0EFF, 0x0F01, 0x0F03, 0x0F0D,
+ 0x0F0F, 0x0F10, 0x0F12, 0x0F1E, 0x0F21, 0x0F23,
+ 0x0F2D, 0x0F2F, 0x0F30, 0x0F32, 0x0F3E, 0x0FD0,
+ 0x0FD2, 0x0FDE, 0x0FE1, 0x0FE3, 0x0FED, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FFE, 0x1001, 0x1003, 0x100D,
+ 0x100F, 0x1010, 0x1012, 0x101E, 0x1021, 0x1023,
+ 0x102D, 0x102F, 0x1030, 0x1032, 0x103E, 0x10D0,
+ 0x10D2, 0x10DE, 0x10E1, 0x10E3, 0x10ED, 0x10EF,
+ 0x10F0, 0x10F2, 0x10FE, 0x1100, 0x1102, 0x110E,
+ 0x1111, 0x1113, 0x111D, 0x111F, 0x1120, 0x1122,
+ 0x112E, 0x1131, 0x1133, 0x113D, 0x113F, 0x11D1,
+ 0x11D3, 0x11DD, 0x11DF, 0x11E0, 0x11E2, 0x11EE,
+ 0x11F1, 0x11F3, 0x11FD, 0x11FF, 0x1201, 0x1203,
+ 0x120D, 0x120F, 0x1210, 0x1212, 0x121E, 0x1221,
+ 0x1223, 0x122D, 0x122F, 0x1230, 0x1232, 0x123E,
+ 0x12D0, 0x12D2, 0x12DE, 0x12E1, 0x12E3, 0x12ED,
+ 0x12EF, 0x12F0, 0x12F2, 0x12FE, 0x1300, 0x1302,
+ 0x130E, 0x1311, 0x1313, 0x131D, 0x131F, 0x1320,
+ 0x1322, 0x132E, 0x1331, 0x1333, 0x133D, 0x133F,
+ 0x13D1, 0x13D3, 0x13DD, 0x13DF, 0x13E0, 0x13E2,
+ 0x13EE, 0x13F1, 0x13F3, 0x13FD, 0x13FF, 0x1D00,
+ 0x1D02, 0x1D0E, 0x1D11, 0x1D13, 0x1D1D, 0x1D1F,
+ 0x1D20, 0x1D22, 0x1D2E, 0x1D31, 0x1D33, 0x1D3D,
+ 0x1D3F, 0x1DD1, 0x1DD3, 0x1DDD, 0x1DDF, 0x1DE0,
+ 0x1DE2, 0x1DEE, 0x1DF1, 0x1DF3, 0x1DFD, 0x1DFF,
+ 0x1E01, 0x1E03, 0x1E0D, 0x1E0F, 0x1E10, 0x1E12,
+ 0x1E1E, 0x1E21, 0x1E23, 0x1E2D, 0x1E2F, 0x1E30,
+ 0x1E32, 0x1E3E, 0x1ED0, 0x1ED2, 0x1EDE, 0x1EE1,
+ 0x1EE3, 0x1EED, 0x1EEF, 0x1EF0, 0x1EF2, 0x1EFE,
+ 0x1F00, 0x1F02, 0x1F0E, 0x1F11, 0x1F13, 0x1F1D,
+ 0x1F1F, 0x1F20, 0x1F22, 0x1F2E, 0x1F31, 0x1F33,
+ 0x1F3D, 0x1F3F, 0x1FD1, 0x1FD3, 0x1FDD, 0x1FDF,
+ 0x1FE0, 0x1FE2, 0x1FEE, 0x1FF1, 0x1FF3, 0x1FFD,
+ 0x1FFF, 0x2000, 0x2002, 0x200E, 0x2011, 0x2013,
+ 0x201D, 0x201F, 0x2020, 0x2022, 0x202E, 0x2031,
+ 0x2033, 0x203D, 0x203F, 0x20D1, 0x20D3, 0x20DD,
+ 0x20DF, 0x20E0, 0x20E2, 0x20EE, 0x20F1, 0x20F3,
+ 0x20FD, 0x20FF, 0x2101, 0x2103, 0x210D, 0x210F,
+ 0x2110, 0x2112, 0x211E, 0x2121, 0x2123, 0x212D,
+ 0x212F, 0x2130, 0x2132, 0x213E, 0x21D0, 0x21D2,
+ 0x21DE, 0x21E1, 0x21E3, 0x21ED, 0x21EF, 0x21F0,
+ 0x21F2, 0x21FE, 0x2200, 0x2202, 0x220E, 0x2211,
+ 0x2213, 0x221D, 0x221F, 0x2220, 0x2222, 0x222E,
+ 0x2231, 0x2233, 0x223D, 0x223F, 0x22D1, 0x22D3,
+ 0x22DD, 0x22DF, 0x22E0, 0x22E2, 0x22EE, 0x22F1,
+ 0x22F3, 0x22FD, 0x22FF, 0x2301, 0x2303, 0x230D,
+ 0x230F, 0x2310, 0x2312, 0x231E, 0x2321, 0x2323,
+ 0x232D, 0x232F, 0x2330, 0x2332, 0x233E, 0x23D0,
+ 0x23D2, 0x23DE, 0x23E1, 0x23E3, 0x23ED, 0x23EF,
+ 0x23F0, 0x23F2, 0x23FE, 0x2D01, 0x2D03, 0x2D0D,
+ 0x2D0F, 0x2D10, 0x2D12, 0x2D1E, 0x2D21, 0x2D23,
+ 0x2D2D, 0x2D2F, 0x2D30, 0x2D32, 0x2D3E, 0x2DD0,
+ 0x2DD2, 0x2DDE, 0x2DE1, 0x2DE3, 0x2DED, 0x2DEF,
+ 0x2DF0, 0x2DF2, 0x2DFE, 0x2E00, 0x2E02, 0x2E0E,
+ 0x2E11, 0x2E13, 0x2E1D, 0x2E1F, 0x2E20, 0x2E22,
+ 0x2E2E, 0x2E31, 0x2E33, 0x2E3D, 0x2E3F, 0x2ED1,
+ 0x2ED3, 0x2EDD, 0x2EDF, 0x2EE0, 0x2EE2, 0x2EEE,
+ 0x2EF1, 0x2EF3, 0x2EFD, 0x2EFF, 0x2F01, 0x2F03,
+ 0x2F0D, 0x2F0F, 0x2F10, 0x2F12, 0x2F1E, 0x2F21,
+ 0x2F23, 0x2F2D, 0x2F2F, 0x2F30, 0x2F32, 0x2F3E,
+ 0x2FD0, 0x2FD2, 0x2FDE, 0x2FE1, 0x2FE3, 0x2FED,
+ 0x2FEF, 0x2FF0, 0x2FF2, 0x2FFE, 0x3001, 0x3003,
+ 0x300D, 0x300F, 0x3010, 0x3012, 0x301E, 0x3021,
+ 0x3023, 0x302D, 0x302F, 0x3030, 0x3032, 0x303E,
+ 0x30D0, 0x30D2, 0x30DE, 0x30E1, 0x30E3, 0x30ED,
+ 0x30EF, 0x30F0, 0x30F2, 0x30FE, 0x3100, 0x3102,
+ 0x310E, 0x3111, 0x3113, 0x311D, 0x311F, 0x3120,
+ 0x3122, 0x312E, 0x3131, 0x3133, 0x313D, 0x313F,
+ 0x31D1, 0x31D3, 0x31DD, 0x31DF, 0x31E0, 0x31E2,
+ 0x31EE, 0x31F1, 0x31F3, 0x31FD, 0x31FF, 0x3201,
+ 0x3203, 0x320D, 0x320F, 0x3210, 0x3212, 0x321E,
+ 0x3221, 0x3223, 0x322D, 0x322F, 0x3230, 0x3232,
+ 0x323E, 0x32D0, 0x32D2, 0x32DE, 0x32E1, 0x32E3,
+ 0x32ED, 0x32EF, 0x32F0, 0x32F2, 0x32FE, 0x3300,
+ 0x3302, 0x330E, 0x3311, 0x3313, 0x331D, 0x331F,
+ 0x3320, 0x3322, 0x332E, 0x3331, 0x3333, 0x333D,
+ 0x333F, 0x33D1, 0x33D3, 0x33DD, 0x33DF, 0x33E0,
+ 0x33E2, 0x33EE, 0x33F1, 0x33F3, 0x33FD, 0x33FF,
+ 0x3D00, 0x3D02, 0x3D0E, 0x3D11, 0x3D13, 0x3D1D,
+ 0x3D1F, 0x3D20, 0x3D22, 0x3D2E, 0x3D31, 0x3D33,
+ 0x3D3D, 0x3D3F, 0x3DD1, 0x3DD3, 0x3DDD, 0x3DDF,
+ 0x3DE0, 0x3DE2, 0x3DEE, 0x3DF1, 0x3DF3, 0x3DFD,
+ 0x3DFF, 0x3E01, 0x3E03, 0x3E0D, 0x3E0F, 0x3E10,
+ 0x3E12, 0x3E1E, 0x3E21, 0x3E23, 0x3E2D, 0x3E2F,
+ 0x3E30, 0x3E32, 0x3E3E, 0x3ED0, 0x3ED2, 0x3EDE,
+ 0x3EE1, 0x3EE3, 0x3EED, 0x3EEF, 0x3EF0, 0x3EF2,
+ 0x3EFE, 0x3F00, 0x3F02, 0x3F0E, 0x3F11, 0x3F13,
+ 0x3F1D, 0x3F1F, 0x3F20, 0x3F22, 0x3F2E, 0x3F31,
+ 0x3F33, 0x3F3D, 0x3F3F, 0x3FD1, 0x3FD3, 0x3FDD,
+ 0x3FDF, 0x3FE0, 0x3FE2, 0x3FEE, 0x3FF1, 0x3FF3,
+ 0x3FFD, 0x3FFF, 0xD001, 0xD003, 0xD00D, 0xD00F,
+ 0xD010, 0xD012, 0xD01E, 0xD021, 0xD023, 0xD02D,
+ 0xD02F, 0xD030, 0xD032, 0xD03E, 0xD0D0, 0xD0D2,
+ 0xD0DE, 0xD0E1, 0xD0E3, 0xD0ED, 0xD0EF, 0xD0F0,
+ 0xD0F2, 0xD0FE, 0xD100, 0xD102, 0xD10E, 0xD111,
+ 0xD113, 0xD11D, 0xD11F, 0xD120, 0xD122, 0xD12E,
+ 0xD131, 0xD133, 0xD13D, 0xD13F, 0xD1D1, 0xD1D3,
+ 0xD1DD, 0xD1DF, 0xD1E0, 0xD1E2, 0xD1EE, 0xD1F1,
+ 0xD1F3, 0xD1FD, 0xD1FF, 0xD201, 0xD203, 0xD20D,
+ 0xD20F, 0xD210, 0xD212, 0xD21E, 0xD221, 0xD223,
+ 0xD22D, 0xD22F, 0xD230, 0xD232, 0xD23E, 0xD2D0,
+ 0xD2D2, 0xD2DE, 0xD2E1, 0xD2E3, 0xD2ED, 0xD2EF,
+ 0xD2F0, 0xD2F2, 0xD2FE, 0xD300, 0xD302, 0xD30E,
+ 0xD311, 0xD313, 0xD31D, 0xD31F, 0xD320, 0xD322,
+ 0xD32E, 0xD331, 0xD333, 0xD33D, 0xD33F, 0xD3D1,
+ 0xD3D3, 0xD3DD, 0xD3DF, 0xD3E0, 0xD3E2, 0xD3EE,
+ 0xD3F1, 0xD3F3, 0xD3FD, 0xD3FF, 0xDD00, 0xDD02,
+ 0xDD0E, 0xDD11, 0xDD13, 0xDD1D, 0xDD1F, 0xDD20,
+ 0xDD22, 0xDD2E, 0xDD31, 0xDD33, 0xDD3D, 0xDD3F,
+ 0xDDD1, 0xDDD3, 0xDDDD, 0xDDDF, 0xDDE0, 0xDDE2,
+ 0xDDEE, 0xDDF1, 0xDDF3, 0xDDFD, 0xDDFF, 0xDE01,
+ 0xDE03, 0xDE0D, 0xDE0F, 0xDE10, 0xDE12, 0xDE1E,
+ 0xDE21, 0xDE23, 0xDE2D, 0xDE2F, 0xDE30, 0xDE32,
+ 0xDE3E, 0xDED0, 0xDED2, 0xDEDE, 0xDEE1, 0xDEE3,
+ 0xDEED, 0xDEEF, 0xDEF0, 0xDEF2, 0xDEFE, 0xDF00,
+ 0xDF02, 0xDF0E, 0xDF11, 0xDF13, 0xDF1D, 0xDF1F,
+ 0xDF20, 0xDF22, 0xDF2E, 0xDF31, 0xDF33, 0xDF3D,
+ 0xDF3F, 0xDFD1, 0xDFD3, 0xDFDD, 0xDFDF, 0xDFE0,
+ 0xDFE2, 0xDFEE, 0xDFF1, 0xDFF3, 0xDFFD, 0xDFFF,
+ 0xE000, 0xE002, 0xE00E, 0xE011, 0xE013, 0xE01D,
+ 0xE01F, 0xE020, 0xE022, 0xE02E, 0xE031, 0xE033,
+ 0xE03D, 0xE03F, 0xE0D1, 0xE0D3, 0xE0DD, 0xE0DF,
+ 0xE0E0, 0xE0E2, 0xE0EE, 0xE0F1, 0xE0F3, 0xE0FD,
+ 0xE0FF, 0xE101, 0xE103, 0xE10D, 0xE10F, 0xE110,
+ 0xE112, 0xE11E, 0xE121, 0xE123, 0xE12D, 0xE12F,
+ 0xE130, 0xE132, 0xE13E, 0xE1D0, 0xE1D2, 0xE1DE,
+ 0xE1E1, 0xE1E3, 0xE1ED, 0xE1EF, 0xE1F0, 0xE1F2,
+ 0xE1FE, 0xE200, 0xE202, 0xE20E, 0xE211, 0xE213,
+ 0xE21D, 0xE21F, 0xE220, 0xE222, 0xE22E, 0xE231,
+ 0xE233, 0xE23D, 0xE23F, 0xE2D1, 0xE2D3, 0xE2DD,
+ 0xE2DF, 0xE2E0, 0xE2E2, 0xE2EE, 0xE2F1, 0xE2F3,
+ 0xE2FD, 0xE2FF, 0xE301, 0xE303, 0xE30D, 0xE30F,
+ 0xE310, 0xE312, 0xE31E, 0xE321, 0xE323, 0xE32D,
+ 0xE32F, 0xE330, 0xE332, 0xE33E, 0xE3D0, 0xE3D2,
+ 0xE3DE, 0xE3E1, 0xE3E3, 0xE3ED, 0xE3EF, 0xE3F0,
+ 0xE3F2, 0xE3FE, 0xED01, 0xED03, 0xED0D, 0xED0F,
+ 0xED10, 0xED12, 0xED1E, 0xED21, 0xED23, 0xED2D,
+ 0xED2F, 0xED30, 0xED32, 0xED3E, 0xEDD0, 0xEDD2,
+ 0xEDDE, 0xEDE1, 0xEDE3, 0xEDED, 0xEDEF, 0xEDF0,
+ 0xEDF2, 0xEDFE, 0xEE00, 0xEE02, 0xEE0E, 0xEE11,
+ 0xEE13, 0xEE1D, 0xEE1F, 0xEE20, 0xEE22, 0xEE2E,
+ 0xEE31, 0xEE33, 0xEE3D, 0xEE3F, 0xEED1, 0xEED3,
+ 0xEEDD, 0xEEDF, 0xEEE0, 0xEEE2, 0xEEEE, 0xEEF1,
+ 0xEEF3, 0xEEFD, 0xEEFF, 0xEF01, 0xEF03, 0xEF0D,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF1E, 0xEF21, 0xEF23,
+ 0xEF2D, 0xEF2F, 0xEF30, 0xEF32, 0xEF3E, 0xEFD0,
+ 0xEFD2, 0xEFDE, 0xEFE1, 0xEFE3, 0xEFED, 0xEFEF,
+ 0xEFF0, 0xEFF2, 0xEFFE, 0xF001, 0xF003, 0xF00D,
+ 0xF00F, 0xF010, 0xF012, 0xF01E, 0xF021, 0xF023,
+ 0xF02D, 0xF02F, 0xF030, 0xF032, 0xF03E, 0xF0D0,
+ 0xF0D2, 0xF0DE, 0xF0E1, 0xF0E3, 0xF0ED, 0xF0EF,
+ 0xF0F0, 0xF0F2, 0xF0FE, 0xF100, 0xF102, 0xF10E,
+ 0xF111, 0xF113, 0xF11D, 0xF11F, 0xF120, 0xF122,
+ 0xF12E, 0xF131, 0xF133, 0xF13D, 0xF13F, 0xF1D1,
+ 0xF1D3, 0xF1DD, 0xF1DF, 0xF1E0, 0xF1E2, 0xF1EE,
+ 0xF1F1, 0xF1F3, 0xF1FD, 0xF1FF, 0xF201, 0xF203,
+ 0xF20D, 0xF20F, 0xF210, 0xF212, 0xF21E, 0xF221,
+ 0xF223, 0xF22D, 0xF22F, 0xF230, 0xF232, 0xF23E,
+ 0xF2D0, 0xF2D2, 0xF2DE, 0xF2E1, 0xF2E3, 0xF2ED,
+ 0xF2EF, 0xF2F0, 0xF2F2, 0xF2FE, 0xF300, 0xF302,
+ 0xF30E, 0xF311, 0xF313, 0xF31D, 0xF31F, 0xF320,
+ 0xF322, 0xF32E, 0xF331, 0xF333, 0xF33D, 0xF33F,
+ 0xF3D1, 0xF3D3, 0xF3DD, 0xF3DF, 0xF3E0, 0xF3E2,
+ 0xF3EE, 0xF3F1, 0xF3F3, 0xF3FD, 0xF3FF, 0xFD00,
+ 0xFD02, 0xFD0E, 0xFD11, 0xFD13, 0xFD1D, 0xFD1F,
+ 0xFD20, 0xFD22, 0xFD2E, 0xFD31, 0xFD33, 0xFD3D,
+ 0xFD3F, 0xFDD1, 0xFDD3, 0xFDDD, 0xFDDF, 0xFDE0,
+ 0xFDE2, 0xFDEE, 0xFDF1, 0xFDF3, 0xFDFD, 0xFDFF,
+ 0xFE01, 0xFE03, 0xFE0D, 0xFE0F, 0xFE10, 0xFE12,
+ 0xFE1E, 0xFE21, 0xFE23, 0xFE2D, 0xFE2F, 0xFE30,
+ 0xFE32, 0xFE3E, 0xFED0, 0xFED2, 0xFEDE, 0xFEE1,
+ 0xFEE3, 0xFEED, 0xFEEF, 0xFEF0, 0xFEF2, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF0E, 0xFF11, 0xFF13, 0xFF1D,
+ 0xFF1F, 0xFF20, 0xFF22, 0xFF2E, 0xFF31, 0xFF33,
+ 0xFF3D, 0xFF3F, 0xFFD1, 0xFFD3, 0xFFDD, 0xFFDF,
+ 0xFFE0, 0xFFE2, 0xFFEE, 0xFFF1, 0xFFF3, 0xFFFD,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB6_CODES 1201
+static const uint32_t on2avc_cb6_codes[ON2AVC_CB6_CODES] = {
+ 0x0018, 0x0088, 0x0082, 0x0024, 0x05B4, 0x08DF,
+ 0x0044, 0x0197, 0x01DE, 0x021F, 0x0D77, 0x0A72,
+ 0x7E77, 0x0B8B, 0x03F1, 0x0433, 0x073F, 0x1E5C,
+ 0x016A, 0x01C5, 0x00D2, 0x0062, 0x0CE4, 0x0096,
+ 0x0020, 0x0052, 0x00B7, 0x0127, 0x003A, 0x0041,
+ 0x00CC, 0x01B6, 0x0124, 0x07D3, 0x01AE, 0x01C4,
+ 0x00DA, 0x03D8, 0x03F3, 0x1638, 0x03F2, 0x12FC,
+ 0x01E2, 0x0DBC, 0x026C, 0x008A, 0x0054, 0x01A6,
+ 0x0195, 0x0164, 0x01E2, 0x026D, 0x0051, 0x049F,
+ 0x01B3, 0x01E0, 0x01B4, 0x026E, 0x07DE, 0x0129,
+ 0x0292, 0x0DBD, 0x013E, 0x00F3, 0x05B5, 0x09A6,
+ 0x01FB, 0x02CF, 0x01FF, 0x037C, 0x004A, 0x067E,
+ 0x016B, 0x002A, 0x09A7, 0x10EE, 0x1639, 0x0135,
+ 0x0CCA, 0x016A, 0x011B, 0x03EE, 0x07A2, 0x0D7E,
+ 0x028F, 0x0FE2, 0x07DA, 0x0357, 0x92F6, 0x0F31,
+ 0x0217, 0x036A, 0x0CE5, 0x07A1, 0x0229, 0x03D9,
+ 0x0377, 0x00B7, 0x01A6, 0x0655, 0x012E, 0x002B,
+ 0x002E, 0x00F2, 0x06F2, 0x02D0, 0x0F98, 0x07A0,
+ 0x009C, 0x0332, 0x0014, 0x01BD, 0x017E, 0x0331,
+ 0x0371, 0x025B, 0x0498, 0x161F, 0x039E, 0x0654,
+ 0x00C2, 0x06BA, 0x0140, 0x021E, 0x02F8, 0x01B4,
+ 0x0134, 0x03FF, 0x0066, 0x0477, 0x01DF, 0x01FE,
+ 0x0A14, 0x029E, 0x0356, 0x038F, 0x035A, 0x3CB3,
+ 0x01B2, 0x016A, 0x011A, 0x00B6, 0x02DE, 0x01DD,
+ 0x017C, 0x0376, 0x002F, 0x0039, 0x03D7, 0x01BE,
+ 0x0056, 0x0050, 0x017C, 0x01CC, 0x0034, 0x0B3E,
+ 0x0499, 0x0014, 0x08DE, 0x037B, 0x03EB, 0x08BF,
+ 0x186E, 0x050F, 0x0030, 0x0169, 0x07F2, 0x00F6,
+ 0x0042, 0x0198, 0x00BC, 0x002E, 0x023A, 0x01E3,
+ 0x0036, 0x004C, 0x012E, 0x01A1, 0x007D, 0x00C3,
+ 0x0392, 0x0063, 0x0F33, 0x016C, 0x01A7, 0x0E77,
+ 0x01DF, 0x0177, 0x0032, 0x03FE, 0x0322, 0x01AC,
+ 0x0030, 0x017E, 0x011E, 0x0022, 0x01FB, 0x012A,
+ 0x002B, 0x0068, 0x00D4, 0x006E, 0x0015, 0x001C,
+ 0x00E5, 0x01A9, 0x0436, 0x053F, 0x05AE, 0x00B2,
+ 0x072A, 0x02EA, 0x008E, 0x0175, 0x02BE, 0x018E,
+ 0x0002, 0x005E, 0x01D6, 0x0055, 0x006A, 0x07F3,
+ 0x02F9, 0x01D4, 0x016E, 0x03AB, 0x00FF, 0x003C,
+ 0x0192, 0x01D6, 0x0256, 0x0137, 0x0148, 0x022A,
+ 0x039C, 0x016D, 0x0116, 0x038A, 0x033E, 0x0156,
+ 0x03CF, 0x004B, 0x00E6, 0x018F, 0x1E5D, 0x03DA,
+ 0x0292, 0x0108, 0x06F5, 0x03DB, 0x0092, 0x0178,
+ 0x014A, 0x03FF, 0x03EE, 0x0A79, 0x0A16, 0x00F7,
+ 0x01B5, 0x0A15, 0x0D7F, 0x02FA, 0x01E4, 0x0157,
+ 0x01E2, 0x0185, 0x057E, 0x07DB, 0x0098, 0x0DBE,
+ 0x019A, 0x05FE, 0x003B, 0x03F5, 0x01BF, 0x01E4,
+ 0x011E, 0x001B, 0x03AA, 0x0337, 0x1F9C, 0x0942,
+ 0x05AB, 0x0430, 0x24BF, 0x163A, 0x037E, 0x014E,
+ 0x00F4, 0x0217, 0x0059, 0x0F32, 0x03F4, 0x01F2,
+ 0x0031, 0x0136, 0x05C6, 0x0076, 0x0006, 0x02FE,
+ 0x03FB, 0x009D, 0x013F, 0x002E, 0x02E6, 0x00AD,
+ 0x0234, 0x021E, 0x0253, 0x012A, 0x0346, 0x029A,
+ 0x012B, 0x021C, 0x02DA, 0x0004, 0x013C, 0x00F5,
+ 0x004E, 0x017D, 0x01F8, 0x0006, 0x01FA, 0x01F9,
+ 0x007A, 0x0067, 0x033B, 0x033A, 0x0586, 0x05C7,
+ 0x05FF, 0x00C8, 0x014B, 0x024F, 0x02C5, 0x00E7,
+ 0x014C, 0x035C, 0x00A2, 0x006A, 0x01F3, 0x0071,
+ 0x005E, 0x0084, 0x063A, 0x03EF, 0x0064, 0x02FE,
+ 0x0255, 0x003A, 0x061A, 0x0333, 0x037F, 0x00FE,
+ 0x115B, 0x0F9A, 0x00A6, 0x027D, 0x0B5F, 0x013F,
+ 0x029E, 0x0293, 0x07B6, 0x000F, 0x0196, 0x02FB,
+ 0x033F, 0x01FE, 0x019E, 0x01B3, 0x037F, 0x00C4,
+ 0x00DE, 0x02D2, 0x007A, 0x03CA, 0x01E3, 0x02F7,
+ 0x00AE, 0x05AF, 0x02FF, 0x026F, 0x00CA, 0x0356,
+ 0x02C7, 0x02D1, 0x0256, 0x006B, 0x0141, 0x012C,
+ 0x03BE, 0x0026, 0x00F0, 0x03A3, 0x02D6, 0x005F,
+ 0x00FF, 0x03F2, 0x00AE, 0x0257, 0x01FE, 0x035E,
+ 0x01B6, 0x00EE, 0x0658, 0x008F, 0x0232, 0x0657,
+ 0x12FD, 0x00AF, 0x00E6, 0x0426, 0x0666, 0x009E,
+ 0x0467, 0x003F, 0x014A, 0x02D3, 0x12FE, 0x099A,
+ 0x03BF, 0x00DD, 0x04DF, 0x009F, 0x00B8, 0x0863,
+ 0x06F7, 0x01B8, 0x0346, 0x0179, 0x0FE3, 0x0667,
+ 0x0659, 0x01CE, 0x00B3, 0x0372, 0x065A, 0x025E,
+ 0x01AA, 0x0276, 0x027E, 0x02DB, 0x0CE6, 0x115A,
+ 0x02E7, 0x0139, 0x03DA, 0x01FA, 0x021C, 0x0943,
+ 0x0862, 0x011F, 0x08B6, 0x07E6, 0x029F, 0x00E5,
+ 0x0656, 0x049A, 0x000E, 0x0F99, 0x06F6, 0x00DC,
+ 0x00EC, 0x014B, 0x0230, 0x04A2, 0x0016, 0x02EB,
+ 0x03AE, 0x02DF, 0x01AA, 0x033E, 0x0196, 0x092E,
+ 0x06F3, 0x00E7, 0x0B5E, 0x03F2, 0x0086, 0x0347,
+ 0x022A, 0x0A17, 0x01EF, 0x067F, 0x004A, 0x037E,
+ 0x02EE, 0x015E, 0x0696, 0x006A, 0x01CD, 0x0077,
+ 0x073F, 0x0016, 0x01E3, 0x012E, 0x00DB, 0x03BD,
+ 0x0496, 0x01C6, 0x0323, 0x005E, 0x02F6, 0x027C,
+ 0x0235, 0x0231, 0x00DA, 0x01EB, 0x0232, 0x02C6,
+ 0x01F2, 0x016F, 0x02C6, 0x036B, 0x0050, 0x0AFE,
+ 0x0F9B, 0x00C6, 0x014E, 0x02BC, 0x01CA, 0x027F,
+ 0x07A5, 0x0DE1, 0x01F1, 0x039E, 0x0DE2, 0x1E5E,
+ 0x065E, 0x0DE0, 0x115F, 0x00F7, 0x02AB, 0x116E,
+ 0x019B, 0x04CE, 0x00D3, 0x01C7, 0x02D6, 0x01F3,
+ 0x016F, 0x014E, 0x05B7, 0x0FA3, 0x0118, 0x025F,
+ 0x017E, 0x0437, 0x049B, 0x05AE, 0x497A, 0x0D2E,
+ 0x05B6, 0x1E5F, 0x0DE3, 0x0512, 0x031A, 0x01F2,
+ 0x007E, 0x015C, 0x035E, 0x04CF, 0x01C8, 0x0194,
+ 0x12FF, 0x1F7F, 0x00E0, 0x01A2, 0x012F, 0x0087,
+ 0x014C, 0x0643, 0x0D5E, 0x017F, 0x07A6, 0x0513,
+ 0x0D5F, 0x022B, 0x065F, 0x03F6, 0x022E, 0x03F7,
+ 0x0642, 0x036E, 0x00D0, 0x01CB, 0x0378, 0x125EE,
+ 0x035F, 0x014F, 0x035F, 0x116F, 0x0A4F, 0x0102,
+ 0x032A, 0x0173, 0x0536, 0x03A7, 0x075E, 0x1F9F,
+ 0x163B, 0x14DA, 0x526E, 0x165F, 0x0A6E, 0x0596,
+ 0x07A7, 0x042A, 0x0172, 0x19C2, 0x07E6, 0x04A3,
+ 0x0327, 0x02A8, 0x07A3, 0x046E, 0x012F, 0x2EFF,
+ 0x01D7, 0x0266, 0x0BBE, 0x066E, 0x186F, 0x0A73,
+ 0x1336, 0x02A9, 0x0373, 0x017F, 0x1F9E, 0x0B62,
+ 0x03A6, 0x0DBF, 0x035B, 0x063B, 0x053B, 0x10EF,
+ 0x016E, 0x011B, 0x115D, 0x115C, 0x00F2, 0x0176,
+ 0x0393, 0x034A, 0x0107, 0x115E, 0x0B63, 0x023F,
+ 0x002A, 0x0CE7, 0x0A7A, 0x06FA, 0x06FB, 0x02AA,
+ 0x02C2, 0x065B, 0x07A4, 0x02D4, 0x0130, 0x0106,
+ 0x01FB, 0x0B3F, 0x01B7, 0x00F6, 0x0056, 0x053F,
+ 0x0126, 0x0048, 0x0233, 0x017D, 0x00A4, 0x08BE,
+ 0x165E, 0x165D, 0x0A7B, 0x0427, 0x078F, 0x1F7E,
+ 0x0641, 0x02E4, 0x01E6, 0x01DA, 0x00F8, 0x043A,
+ 0x02BE, 0x011C, 0x006F, 0x036D, 0x19C3, 0x0020,
+ 0x06AE, 0x0372, 0x0288, 0x00C0, 0x079D, 0x036E,
+ 0x0117, 0x02FB, 0x0538, 0x06F2, 0x12F9, 0x1337,
+ 0x1E58, 0x0214, 0x005E, 0x0CE0, 0x01EE, 0x0A6E,
+ 0x0215, 0x01C2, 0x12FA, 0x033A, 0x009A, 0x0174,
+ 0x0CE2, 0x09A1, 0x00FE, 0x0250, 0x02CA, 0x035E,
+ 0x03A2, 0x0D7D, 0x2EFE, 0x02E8, 0x24BE, 0x1F7C,
+ 0x10EC, 0x04A2, 0x0052, 0x010D, 0x0277, 0x003A,
+ 0x0CDE, 0x0A6F, 0x0086, 0x00E4, 0x12FB, 0x14DE,
+ 0x009E, 0x0062, 0x03CA, 0x03BC, 0x02CA, 0x14DF,
+ 0x0FE0, 0x030C, 0x03F0, 0x06F3, 0x0796, 0x0B1E,
+ 0x05B0, 0x15FE, 0x013A, 0x0CDF, 0x079E, 0x01E2,
+ 0x0166, 0x02BD, 0x0151, 0x0153, 0x0650, 0x0940,
+ 0x010F, 0x3CB2, 0x10ED, 0x057E, 0x03D4, 0x029E,
+ 0x0358, 0x06F4, 0x7E76, 0x017C, 0x15FF, 0x047D,
+ 0x1158, 0x3F3A, 0x0CE3, 0x005F, 0x043A, 0x032F,
+ 0x010E, 0x1E5A, 0x0A4C, 0x0152, 0x125EF, 0x0B88,
+ 0x057F, 0x059E, 0x042B, 0x2936, 0x0138, 0x03A1,
+ 0x03C6, 0x0E56, 0x12F8, 0x149A, 0x526F, 0x0F2E,
+ 0x079C, 0x02FA, 0x0476, 0x0267, 0x0636, 0x03A0,
+ 0x014E, 0x0092, 0x0D7C, 0x05AF, 0x010C, 0x011C,
+ 0x0A10, 0x177E, 0x0131, 0x09A0, 0x03EA, 0x02C2,
+ 0x02D6, 0x0B89, 0x032E, 0x01E8, 0x0F30, 0x01BA,
+ 0x0532, 0x0A6C, 0x0F6E, 0x04CC, 0x008E, 0x036C,
+ 0x0E57, 0x00D6, 0x0162, 0x0024, 0x0252, 0x0F6F,
+ 0x01AE, 0x0150, 0x0038, 0x07CE, 0x01BB, 0x01F6,
+ 0x026A, 0x038B, 0x01DB, 0x07CF, 0x14DB, 0x24BC,
+ 0x0272, 0x053E, 0x073E, 0x078E, 0x0C36, 0x0176,
+ 0x032B, 0x017A, 0x0190, 0x0CCB, 0x047C, 0x0170,
+ 0x0054, 0x03EC, 0x049D, 0x0197, 0x043B, 0x0432,
+ 0x0192, 0x026A, 0x01F0, 0x0076, 0x0216, 0x0A11,
+ 0x1F7D, 0x02C4, 0x0298, 0x1159, 0x0A4E, 0x0116,
+ 0x00E4, 0x0216, 0x029A, 0x000F, 0x04DA, 0x04D2,
+ 0x002B, 0x0011, 0x049E, 0x045A, 0x01BF, 0x01EF,
+ 0x03CE, 0x01F8, 0x026E, 0x0466, 0x02DC, 0x0168,
+ 0x030E, 0x00B4, 0x01C3, 0x03CC, 0x028D, 0x01AE,
+ 0x038E, 0x01B0, 0x0664, 0x0119, 0x01BE, 0x035B,
+ 0x035F, 0x028E, 0x0A78, 0x01DE, 0x0397, 0x03FE,
+ 0x01B1, 0x028E, 0x07D2, 0x09A2, 0x033C, 0x02C1,
+ 0x0FA0, 0x0359, 0x031E, 0x00C1, 0x03D6, 0x0A12,
+ 0x01C4, 0x0330, 0x075F, 0x0B1F, 0x025A, 0x027B,
+ 0x04DB, 0x02E5, 0x01FA, 0x036F, 0x0A13, 0x02BB,
+ 0x00FA, 0x01D4, 0x01F8, 0x018A, 0x161E, 0x0E75,
+ 0x026B, 0x05B3, 0x01BC, 0x05B2, 0x09A3, 0x0424,
+ 0x047E, 0x01EE, 0x0FE1, 0x161D, 0x024C, 0x017E,
+ 0x026B, 0x01DC, 0x00A5, 0x0F2F, 0x161C, 0x028B,
+ 0x0196, 0x0168, 0x01EF, 0x0394, 0x0E74, 0x013C,
+ 0x00C9, 0x032E, 0x0941, 0x0D76, 0x050C, 0x0228,
+ 0x006C, 0x0236, 0x0D2F, 0x0156, 0x00D2, 0x0B8A,
+ 0x0148, 0x028A, 0x028B, 0x033B, 0x0214, 0x01E9,
+ 0x03C2, 0x049C, 0x02BA, 0x02E9, 0x028C, 0x01FC,
+ 0x0103, 0x0B5C, 0x050D, 0x031C, 0x0268, 0x0651,
+ 0x013A, 0x013B, 0x0118, 0x03D5, 0x0252, 0x0044,
+ 0x0637, 0x01D2, 0x000E, 0x00F0, 0x0323, 0x02C3,
+ 0x019A, 0x016C, 0x0046, 0x03E3, 0x024A, 0x00AC,
+ 0x0269, 0x02C0, 0x0396, 0x027A, 0x0253, 0x0273,
+ 0x073E, 0x0322, 0x003A, 0x025E, 0x0336, 0x0257,
+ 0x00D6, 0x0026, 0x03C3, 0x0034, 0x019A, 0x00FB,
+ 0x0038, 0x0040, 0x0096, 0x01F0, 0x0184, 0x021A,
+ 0x003E, 0x0042, 0x050E, 0x03CE, 0x035E, 0x0FA1,
+ 0x017B, 0x02CD, 0x0058, 0x0326, 0x00E4, 0x002E,
+ 0x004F, 0x000C, 0x0164, 0x0048, 0x0048, 0x0194,
+ 0x0074, 0x006E, 0x0070, 0x006C, 0x01A4, 0x00A3,
+ 0x034F, 0x011E, 0x0374, 0x0157, 0x0138, 0x011D,
+ 0x03CF, 0x033D, 0x0132, 0x0050, 0x023E, 0x005A,
+ 0x0076, 0x01EC, 0x005D, 0x0008, 0x004C, 0x024E,
+ 0x0154, 0x001E, 0x01C6, 0x0027, 0x00FE, 0x01EA,
+ 0x02CE, 0x01DD, 0x02CB, 0x035A, 0x0318, 0x013E,
+ 0x009B, 0x0288, 0x0339, 0x024D, 0x031F, 0x0128,
+ 0x00B6, 0x0028, 0x028A, 0x0289, 0x029F, 0x01FD,
+ 0x029A, 0x00F6, 0x0FA2, 0x0347, 0x0080, 0x01A8,
+ 0x028F, 0x0326, 0x0327, 0x0370, 0x165C, 0x043F,
+ 0x0375, 0x013D, 0x1E5B, 0x04DE, 0x0155, 0x00D8,
+ 0x0319, 0x0096, 0x0640, 0x07E7, 0x007C, 0x0652,
+ 0x0373, 0x05DE, 0x00CF, 0x0E76, 0x0653, 0x01A0,
+ 0x0160, 0x0169, 0x01D5, 0x05AA, 0x053A, 0x0B5D,
+ 0x0254, 0x079A, 0x0533, 0x0425, 0x053E, 0x00A6,
+ 0x030F, 0x01A2, 0x00B0, 0x04A3, 0x079F, 0x011A,
+ 0x01EE, 0x02CC, 0x045E, 0x005C, 0x0024, 0x022C,
+ 0x001A, 0x0338, 0x0132, 0x026C, 0x004E, 0x047F,
+ 0x01B2, 0x0113, 0x043E, 0x0336, 0x00F0, 0x02CE,
+ 0x0112, 0x018B, 0x0010, 0x0114, 0x01BE, 0x03FA,
+ 0x002A, 0x00FA, 0x0033, 0x0060, 0x0146, 0x01DC,
+ 0x0000, 0x0025, 0x037A, 0x034E, 0x012E, 0x029B,
+ 0x079B, 0x00E6, 0x03CD, 0x02DD, 0x0117, 0x017A,
+ 0x002C, 0x03E2, 0x003E, 0x0070, 0x00CE, 0x00B1,
+ 0x003B,
+};
+
+static const uint8_t on2avc_cb6_bits[ON2AVC_CB6_CODES] = {
+ 7, 10, 10, 7, 12, 12,
+ 7, 10, 11, 11, 12, 15,
+ 17, 12, 13, 11, 15, 13,
+ 10, 11, 11, 7, 13, 13,
+ 7, 7, 12, 12, 7, 7,
+ 9, 9, 9, 11, 10, 9,
+ 12, 12, 13, 13, 13, 13,
+ 9, 12, 10, 10, 7, 9,
+ 9, 10, 12, 11, 10, 11,
+ 11, 9, 11, 11, 11, 11,
+ 12, 12, 13, 11, 12, 12,
+ 10, 11, 12, 12, 10, 11,
+ 11, 10, 12, 14, 13, 11,
+ 12, 12, 11, 10, 13, 14,
+ 10, 12, 12, 12, 16, 12,
+ 12, 10, 13, 13, 13, 12,
+ 11, 11, 11, 13, 14, 13,
+ 13, 11, 11, 10, 13, 13,
+ 11, 12, 12, 13, 16, 12,
+ 14, 10, 13, 13, 10, 13,
+ 11, 11, 10, 11, 11, 9,
+ 11, 11, 10, 11, 12, 12,
+ 13, 12, 12, 10, 13, 14,
+ 12, 11, 11, 12, 11, 9,
+ 11, 11, 10, 7, 12, 13,
+ 7, 7, 9, 9, 10, 12,
+ 13, 10, 12, 10, 10, 12,
+ 13, 12, 10, 10, 11, 9,
+ 7, 9, 9, 7, 10, 10,
+ 7, 7, 9, 9, 10, 11,
+ 10, 10, 12, 11, 11, 12,
+ 11, 11, 10, 10, 10, 9,
+ 7, 9, 9, 7, 9, 9,
+ 7, 10, 10, 7, 10, 10,
+ 11, 10, 11, 11, 11, 10,
+ 11, 12, 10, 9, 10, 10,
+ 8, 10, 9, 7, 10, 11,
+ 11, 9, 9, 10, 10, 10,
+ 10, 11, 10, 11, 10, 10,
+ 10, 11, 11, 10, 11, 11,
+ 10, 10, 11, 10, 13, 12,
+ 11, 10, 13, 12, 10, 11,
+ 11, 10, 11, 12, 13, 12,
+ 11, 13, 14, 11, 10, 11,
+ 11, 9, 13, 12, 10, 12,
+ 11, 11, 10, 13, 13, 9,
+ 11, 11, 10, 11, 15, 13,
+ 11, 11, 14, 13, 11, 10,
+ 11, 11, 10, 12, 13, 9,
+ 10, 11, 11, 10, 10, 10,
+ 10, 11, 11, 11, 10, 11,
+ 10, 10, 10, 11, 10, 10,
+ 11, 11, 10, 10, 10, 11,
+ 7, 9, 9, 8, 9, 9,
+ 7, 10, 10, 10, 11, 11,
+ 11, 10, 10, 12, 11, 10,
+ 9, 10, 10, 7, 9, 10,
+ 7, 10, 11, 11, 10, 11,
+ 11, 10, 11, 12, 12, 12,
+ 13, 13, 12, 11, 13, 13,
+ 11, 11, 11, 11, 9, 11,
+ 11, 9, 9, 12, 11, 9,
+ 9, 10, 11, 10, 11, 11,
+ 11, 11, 11, 11, 11, 11,
+ 11, 10, 11, 11, 10, 9,
+ 10, 10, 11, 12, 11, 10,
+ 12, 11, 10, 11, 10, 12,
+ 11, 11, 13, 11, 10, 13,
+ 13, 11, 12, 12, 11, 11,
+ 11, 11, 10, 10, 13, 13,
+ 10, 10, 11, 11, 10, 12,
+ 13, 10, 12, 11, 12, 11,
+ 13, 13, 10, 14, 13, 10,
+ 10, 11, 11, 10, 13, 13,
+ 10, 10, 10, 11, 10, 13,
+ 12, 10, 12, 12, 12, 12,
+ 13, 13, 11, 13, 13, 10,
+ 10, 11, 11, 11, 12, 12,
+ 10, 11, 11, 10, 12, 12,
+ 11, 11, 13, 12, 11, 10,
+ 13, 13, 10, 11, 12, 12,
+ 10, 11, 11, 11, 9, 12,
+ 11, 10, 9, 11, 11, 10,
+ 11, 11, 10, 12, 11, 11,
+ 10, 11, 11, 10, 11, 11,
+ 10, 9, 10, 10, 9, 12,
+ 13, 9, 13, 10, 11, 11,
+ 13, 14, 11, 14, 14, 13,
+ 13, 14, 13, 11, 13, 13,
+ 11, 12, 11, 11, 13, 11,
+ 11, 9, 12, 12, 9, 11,
+ 11, 11, 13, 14, 15, 12,
+ 12, 13, 14, 12, 10, 11,
+ 11, 9, 13, 12, 9, 10,
+ 13, 13, 10, 9, 11, 11,
+ 10, 12, 13, 11, 13, 12,
+ 13, 13, 13, 13, 10, 13,
+ 12, 10, 10, 11, 10, 17,
+ 13, 13, 11, 13, 14, 11,
+ 11, 11, 12, 12, 11, 15,
+ 13, 13, 17, 14, 13, 12,
+ 13, 13, 11, 14, 13, 11,
+ 10, 13, 13, 11, 14, 14,
+ 11, 12, 12, 11, 13, 15,
+ 14, 13, 14, 16, 15, 13,
+ 12, 12, 13, 11, 14, 14,
+ 11, 10, 13, 13, 10, 9,
+ 10, 10, 11, 13, 13, 10,
+ 13, 13, 12, 13, 13, 13,
+ 10, 13, 13, 10, 10, 11,
+ 11, 12, 11, 11, 9, 12,
+ 12, 9, 11, 11, 11, 12,
+ 14, 14, 12, 12, 14, 13,
+ 12, 10, 11, 11, 9, 12,
+ 12, 9, 10, 14, 14, 9,
+ 12, 11, 11, 11, 13, 14,
+ 11, 17, 14, 13, 13, 14,
+ 13, 11, 14, 13, 11, 12,
+ 11, 11, 13, 11, 11, 9,
+ 13, 12, 9, 10, 11, 10,
+ 12, 14, 14, 12, 14, 13,
+ 14, 12, 11, 11, 11, 9,
+ 12, 12, 9, 10, 13, 14,
+ 10, 10, 11, 10, 10, 14,
+ 12, 10, 13, 13, 12, 12,
+ 12, 13, 10, 12, 13, 10,
+ 9, 10, 11, 11, 13, 13,
+ 11, 14, 14, 11, 12, 13,
+ 13, 13, 17, 16, 13, 13,
+ 13, 16, 13, 12, 11, 13,
+ 11, 13, 14, 11, 17, 12,
+ 13, 11, 13, 16, 11, 12,
+ 13, 12, 13, 15, 17, 13,
+ 13, 17, 11, 12, 11, 12,
+ 11, 11, 14, 14, 11, 10,
+ 13, 13, 10, 12, 10, 11,
+ 10, 12, 13, 10, 12, 13,
+ 13, 12, 12, 12, 11, 14,
+ 12, 10, 9, 11, 11, 12,
+ 11, 11, 10, 12, 13, 9,
+ 10, 10, 11, 12, 13, 14,
+ 12, 12, 15, 14, 12, 11,
+ 11, 11, 9, 12, 13, 9,
+ 10, 11, 11, 9, 11, 11,
+ 9, 11, 11, 12, 11, 13,
+ 13, 11, 12, 13, 14, 12,
+ 12, 12, 12, 10, 11, 11,
+ 10, 10, 11, 11, 9, 9,
+ 10, 10, 10, 11, 11, 10,
+ 10, 11, 11, 11, 11, 12,
+ 10, 11, 11, 11, 9, 10,
+ 10, 11, 12, 12, 10, 11,
+ 11, 10, 11, 12, 11, 10,
+ 12, 13, 10, 11, 12, 13,
+ 11, 12, 11, 12, 10, 11,
+ 11, 10, 10, 14, 13, 10,
+ 10, 11, 11, 10, 13, 12,
+ 10, 12, 13, 12, 12, 12,
+ 13, 10, 12, 13, 10, 10,
+ 11, 11, 11, 13, 13, 10,
+ 10, 11, 11, 10, 12, 13,
+ 10, 12, 13, 12, 12, 13,
+ 11, 10, 12, 12, 10, 12,
+ 11, 11, 11, 11, 12, 10,
+ 10, 11, 10, 12, 11, 12,
+ 11, 13, 12, 10, 11, 13,
+ 11, 11, 11, 12, 10, 10,
+ 11, 11, 10, 9, 11, 11,
+ 9, 9, 10, 10, 10, 11,
+ 11, 10, 10, 11, 11, 12,
+ 11, 11, 11, 11, 11, 10,
+ 9, 11, 10, 7, 10, 10,
+ 7, 7, 9, 9, 9, 10,
+ 11, 10, 12, 11, 11, 12,
+ 11, 11, 10, 10, 11, 10,
+ 7, 10, 9, 7, 10, 9,
+ 7, 10, 10, 7, 9, 10,
+ 10, 10, 11, 12, 10, 10,
+ 11, 11, 10, 10, 10, 11,
+ 7, 9, 10, 8, 10, 12,
+ 11, 10, 9, 11, 10, 10,
+ 11, 11, 10, 10, 10, 11,
+ 11, 10, 10, 10, 10, 11,
+ 11, 10, 10, 10, 13, 12,
+ 11, 12, 12, 12, 10, 10,
+ 11, 11, 11, 14, 14, 11,
+ 11, 13, 13, 11, 11, 11,
+ 10, 10, 12, 12, 10, 13,
+ 11, 11, 10, 12, 13, 9,
+ 10, 11, 11, 11, 14, 13,
+ 11, 11, 13, 12, 11, 11,
+ 10, 11, 10, 12, 13, 10,
+ 9, 11, 11, 10, 10, 10,
+ 11, 10, 11, 11, 11, 13,
+ 11, 11, 11, 10, 10, 10,
+ 11, 10, 10, 9, 10, 10,
+ 7, 9, 10, 7, 9, 9,
+ 8, 10, 10, 10, 10, 12,
+ 11, 10, 11, 11, 12, 10,
+ 10, 10, 10, 7, 10, 10,
+ 7,
+};
+
+static const uint16_t on2avc_cb6_syms[ON2AVC_CB6_CODES] = {
+ 0x0000, 0x0002, 0x000E, 0x0011, 0x0013, 0x001D,
+ 0x001F, 0x0020, 0x0022, 0x002E, 0x0031, 0x0033,
+ 0x003D, 0x003F, 0x00D1, 0x00D3, 0x00DD, 0x00DF,
+ 0x00E0, 0x00E2, 0x00EE, 0x00F1, 0x00F3, 0x00FD,
+ 0x00FF, 0x0101, 0x0103, 0x010D, 0x010F, 0x0110,
+ 0x0112, 0x011E, 0x0121, 0x0123, 0x012D, 0x012F,
+ 0x0130, 0x0132, 0x013E, 0x01D0, 0x01D2, 0x01DE,
+ 0x01E1, 0x01E3, 0x01ED, 0x01EF, 0x01F0, 0x01F2,
+ 0x01FE, 0x0200, 0x0202, 0x020E, 0x0211, 0x0213,
+ 0x021D, 0x021F, 0x0220, 0x0222, 0x022E, 0x0231,
+ 0x0233, 0x023D, 0x023F, 0x02D1, 0x02D3, 0x02DD,
+ 0x02DF, 0x02E0, 0x02E2, 0x02EE, 0x02F1, 0x02F3,
+ 0x02FD, 0x02FF, 0x0301, 0x0303, 0x030D, 0x030F,
+ 0x0310, 0x0312, 0x031E, 0x0321, 0x0323, 0x032D,
+ 0x032F, 0x0330, 0x0332, 0x033E, 0x03D0, 0x03D2,
+ 0x03DE, 0x03E1, 0x03E3, 0x03ED, 0x03EF, 0x03F0,
+ 0x03F2, 0x03FE, 0x0D01, 0x0D03, 0x0D0D, 0x0D0F,
+ 0x0D10, 0x0D12, 0x0D1E, 0x0D21, 0x0D23, 0x0D2D,
+ 0x0D2F, 0x0D30, 0x0D32, 0x0D3E, 0x0DD0, 0x0DD2,
+ 0x0DDE, 0x0DE1, 0x0DE3, 0x0DED, 0x0DEF, 0x0DF0,
+ 0x0DF2, 0x0DFE, 0x0E00, 0x0E02, 0x0E0E, 0x0E11,
+ 0x0E13, 0x0E1D, 0x0E1F, 0x0E20, 0x0E22, 0x0E2E,
+ 0x0E31, 0x0E33, 0x0E3D, 0x0E3F, 0x0ED1, 0x0ED3,
+ 0x0EDD, 0x0EDF, 0x0EE0, 0x0EE2, 0x0EEE, 0x0EF1,
+ 0x0EF3, 0x0EFD, 0x0EFF, 0x0F01, 0x0F03, 0x0F0D,
+ 0x0F0F, 0x0F10, 0x0F12, 0x0F1E, 0x0F21, 0x0F23,
+ 0x0F2D, 0x0F2F, 0x0F30, 0x0F32, 0x0F3E, 0x0FD0,
+ 0x0FD2, 0x0FDE, 0x0FE1, 0x0FE3, 0x0FED, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FFE, 0x1001, 0x1003, 0x100D,
+ 0x100F, 0x1010, 0x1012, 0x101E, 0x1021, 0x1023,
+ 0x102D, 0x102F, 0x1030, 0x1032, 0x103E, 0x10D0,
+ 0x10D2, 0x10DE, 0x10E1, 0x10E3, 0x10ED, 0x10EF,
+ 0x10F0, 0x10F2, 0x10FE, 0x1100, 0x1102, 0x110E,
+ 0x1111, 0x1113, 0x111D, 0x111F, 0x1120, 0x1122,
+ 0x112E, 0x1131, 0x1133, 0x113D, 0x113F, 0x11D1,
+ 0x11D3, 0x11DD, 0x11DF, 0x11E0, 0x11E2, 0x11EE,
+ 0x11F1, 0x11F3, 0x11FD, 0x11FF, 0x1201, 0x1203,
+ 0x120D, 0x120F, 0x1210, 0x1212, 0x121E, 0x1221,
+ 0x1223, 0x122D, 0x122F, 0x1230, 0x1232, 0x123E,
+ 0x12D0, 0x12D2, 0x12DE, 0x12E1, 0x12E3, 0x12ED,
+ 0x12EF, 0x12F0, 0x12F2, 0x12FE, 0x1300, 0x1302,
+ 0x130E, 0x1311, 0x1313, 0x131D, 0x131F, 0x1320,
+ 0x1322, 0x132E, 0x1331, 0x1333, 0x133D, 0x133F,
+ 0x13D1, 0x13D3, 0x13DD, 0x13DF, 0x13E0, 0x13E2,
+ 0x13EE, 0x13F1, 0x13F3, 0x13FD, 0x13FF, 0x1D00,
+ 0x1D02, 0x1D0E, 0x1D11, 0x1D13, 0x1D1D, 0x1D1F,
+ 0x1D20, 0x1D22, 0x1D2E, 0x1D31, 0x1D33, 0x1D3D,
+ 0x1D3F, 0x1DD1, 0x1DD3, 0x1DDD, 0x1DDF, 0x1DE0,
+ 0x1DE2, 0x1DEE, 0x1DF1, 0x1DF3, 0x1DFD, 0x1DFF,
+ 0x1E01, 0x1E03, 0x1E0D, 0x1E0F, 0x1E10, 0x1E12,
+ 0x1E1E, 0x1E21, 0x1E23, 0x1E2D, 0x1E2F, 0x1E30,
+ 0x1E32, 0x1E3E, 0x1ED0, 0x1ED2, 0x1EDE, 0x1EE1,
+ 0x1EE3, 0x1EED, 0x1EEF, 0x1EF0, 0x1EF2, 0x1EFE,
+ 0x1F00, 0x1F02, 0x1F0E, 0x1F11, 0x1F13, 0x1F1D,
+ 0x1F1F, 0x1F20, 0x1F22, 0x1F2E, 0x1F31, 0x1F33,
+ 0x1F3D, 0x1F3F, 0x1FD1, 0x1FD3, 0x1FDD, 0x1FDF,
+ 0x1FE0, 0x1FE2, 0x1FEE, 0x1FF1, 0x1FF3, 0x1FFD,
+ 0x1FFF, 0x2000, 0x2002, 0x200E, 0x2011, 0x2013,
+ 0x201D, 0x201F, 0x2020, 0x2022, 0x202E, 0x2031,
+ 0x2033, 0x203D, 0x203F, 0x20D1, 0x20D3, 0x20DD,
+ 0x20DF, 0x20E0, 0x20E2, 0x20EE, 0x20F1, 0x20F3,
+ 0x20FD, 0x20FF, 0x2101, 0x2103, 0x210D, 0x210F,
+ 0x2110, 0x2112, 0x211E, 0x2121, 0x2123, 0x212D,
+ 0x212F, 0x2130, 0x2132, 0x213E, 0x21D0, 0x21D2,
+ 0x21DE, 0x21E1, 0x21E3, 0x21ED, 0x21EF, 0x21F0,
+ 0x21F2, 0x21FE, 0x2200, 0x2202, 0x220E, 0x2211,
+ 0x2213, 0x221D, 0x221F, 0x2220, 0x2222, 0x222E,
+ 0x2231, 0x2233, 0x223D, 0x223F, 0x22D1, 0x22D3,
+ 0x22DD, 0x22DF, 0x22E0, 0x22E2, 0x22EE, 0x22F1,
+ 0x22F3, 0x22FD, 0x22FF, 0x2301, 0x2303, 0x230D,
+ 0x230F, 0x2310, 0x2312, 0x231E, 0x2321, 0x2323,
+ 0x232D, 0x232F, 0x2330, 0x2332, 0x233E, 0x23D0,
+ 0x23D2, 0x23DE, 0x23E1, 0x23E3, 0x23ED, 0x23EF,
+ 0x23F0, 0x23F2, 0x23FE, 0x2D01, 0x2D03, 0x2D0D,
+ 0x2D0F, 0x2D10, 0x2D12, 0x2D1E, 0x2D21, 0x2D23,
+ 0x2D2D, 0x2D2F, 0x2D30, 0x2D32, 0x2D3E, 0x2DD0,
+ 0x2DD2, 0x2DDE, 0x2DE1, 0x2DE3, 0x2DED, 0x2DEF,
+ 0x2DF0, 0x2DF2, 0x2DFE, 0x2E00, 0x2E02, 0x2E0E,
+ 0x2E11, 0x2E13, 0x2E1D, 0x2E1F, 0x2E20, 0x2E22,
+ 0x2E2E, 0x2E31, 0x2E33, 0x2E3D, 0x2E3F, 0x2ED1,
+ 0x2ED3, 0x2EDD, 0x2EDF, 0x2EE0, 0x2EE2, 0x2EEE,
+ 0x2EF1, 0x2EF3, 0x2EFD, 0x2EFF, 0x2F01, 0x2F03,
+ 0x2F0D, 0x2F0F, 0x2F10, 0x2F12, 0x2F1E, 0x2F21,
+ 0x2F23, 0x2F2D, 0x2F2F, 0x2F30, 0x2F32, 0x2F3E,
+ 0x2FD0, 0x2FD2, 0x2FDE, 0x2FE1, 0x2FE3, 0x2FED,
+ 0x2FEF, 0x2FF0, 0x2FF2, 0x2FFE, 0x3001, 0x3003,
+ 0x300D, 0x300F, 0x3010, 0x3012, 0x301E, 0x3021,
+ 0x3023, 0x302D, 0x302F, 0x3030, 0x3032, 0x303E,
+ 0x30D0, 0x30D2, 0x30DE, 0x30E1, 0x30E3, 0x30ED,
+ 0x30EF, 0x30F0, 0x30F2, 0x30FE, 0x3100, 0x3102,
+ 0x310E, 0x3111, 0x3113, 0x311D, 0x311F, 0x3120,
+ 0x3122, 0x312E, 0x3131, 0x3133, 0x313D, 0x313F,
+ 0x31D1, 0x31D3, 0x31DD, 0x31DF, 0x31E0, 0x31E2,
+ 0x31EE, 0x31F1, 0x31F3, 0x31FD, 0x31FF, 0x3201,
+ 0x3203, 0x320D, 0x320F, 0x3210, 0x3212, 0x321E,
+ 0x3221, 0x3223, 0x322D, 0x322F, 0x3230, 0x3232,
+ 0x323E, 0x32D0, 0x32D2, 0x32DE, 0x32E1, 0x32E3,
+ 0x32ED, 0x32EF, 0x32F0, 0x32F2, 0x32FE, 0x3300,
+ 0x3302, 0x330E, 0x3311, 0x3313, 0x331D, 0x331F,
+ 0x3320, 0x3322, 0x332E, 0x3331, 0x3333, 0x333D,
+ 0x333F, 0x33D1, 0x33D3, 0x33DD, 0x33DF, 0x33E0,
+ 0x33E2, 0x33EE, 0x33F1, 0x33F3, 0x33FD, 0x33FF,
+ 0x3D00, 0x3D02, 0x3D0E, 0x3D11, 0x3D13, 0x3D1D,
+ 0x3D1F, 0x3D20, 0x3D22, 0x3D2E, 0x3D31, 0x3D33,
+ 0x3D3D, 0x3D3F, 0x3DD1, 0x3DD3, 0x3DDD, 0x3DDF,
+ 0x3DE0, 0x3DE2, 0x3DEE, 0x3DF1, 0x3DF3, 0x3DFD,
+ 0x3DFF, 0x3E01, 0x3E03, 0x3E0D, 0x3E0F, 0x3E10,
+ 0x3E12, 0x3E1E, 0x3E21, 0x3E23, 0x3E2D, 0x3E2F,
+ 0x3E30, 0x3E32, 0x3E3E, 0x3ED0, 0x3ED2, 0x3EDE,
+ 0x3EE1, 0x3EE3, 0x3EED, 0x3EEF, 0x3EF0, 0x3EF2,
+ 0x3EFE, 0x3F00, 0x3F02, 0x3F0E, 0x3F11, 0x3F13,
+ 0x3F1D, 0x3F1F, 0x3F20, 0x3F22, 0x3F2E, 0x3F31,
+ 0x3F33, 0x3F3D, 0x3F3F, 0x3FD1, 0x3FD3, 0x3FDD,
+ 0x3FDF, 0x3FE0, 0x3FE2, 0x3FEE, 0x3FF1, 0x3FF3,
+ 0x3FFD, 0x3FFF, 0xD001, 0xD003, 0xD00D, 0xD00F,
+ 0xD010, 0xD012, 0xD01E, 0xD021, 0xD023, 0xD02D,
+ 0xD02F, 0xD030, 0xD032, 0xD03E, 0xD0D0, 0xD0D2,
+ 0xD0DE, 0xD0E1, 0xD0E3, 0xD0ED, 0xD0EF, 0xD0F0,
+ 0xD0F2, 0xD0FE, 0xD100, 0xD102, 0xD10E, 0xD111,
+ 0xD113, 0xD11D, 0xD11F, 0xD120, 0xD122, 0xD12E,
+ 0xD131, 0xD133, 0xD13D, 0xD13F, 0xD1D1, 0xD1D3,
+ 0xD1DD, 0xD1DF, 0xD1E0, 0xD1E2, 0xD1EE, 0xD1F1,
+ 0xD1F3, 0xD1FD, 0xD1FF, 0xD201, 0xD203, 0xD20D,
+ 0xD20F, 0xD210, 0xD212, 0xD21E, 0xD221, 0xD223,
+ 0xD22D, 0xD22F, 0xD230, 0xD232, 0xD23E, 0xD2D0,
+ 0xD2D2, 0xD2DE, 0xD2E1, 0xD2E3, 0xD2ED, 0xD2EF,
+ 0xD2F0, 0xD2F2, 0xD2FE, 0xD300, 0xD302, 0xD30E,
+ 0xD311, 0xD313, 0xD31D, 0xD31F, 0xD320, 0xD322,
+ 0xD32E, 0xD331, 0xD333, 0xD33D, 0xD33F, 0xD3D1,
+ 0xD3D3, 0xD3DD, 0xD3DF, 0xD3E0, 0xD3E2, 0xD3EE,
+ 0xD3F1, 0xD3F3, 0xD3FD, 0xD3FF, 0xDD00, 0xDD02,
+ 0xDD0E, 0xDD11, 0xDD13, 0xDD1D, 0xDD1F, 0xDD20,
+ 0xDD22, 0xDD2E, 0xDD31, 0xDD33, 0xDD3D, 0xDD3F,
+ 0xDDD1, 0xDDD3, 0xDDDD, 0xDDDF, 0xDDE0, 0xDDE2,
+ 0xDDEE, 0xDDF1, 0xDDF3, 0xDDFD, 0xDDFF, 0xDE01,
+ 0xDE03, 0xDE0D, 0xDE0F, 0xDE10, 0xDE12, 0xDE1E,
+ 0xDE21, 0xDE23, 0xDE2D, 0xDE2F, 0xDE30, 0xDE32,
+ 0xDE3E, 0xDED0, 0xDED2, 0xDEDE, 0xDEE1, 0xDEE3,
+ 0xDEED, 0xDEEF, 0xDEF0, 0xDEF2, 0xDEFE, 0xDF00,
+ 0xDF02, 0xDF0E, 0xDF11, 0xDF13, 0xDF1D, 0xDF1F,
+ 0xDF20, 0xDF22, 0xDF2E, 0xDF31, 0xDF33, 0xDF3D,
+ 0xDF3F, 0xDFD1, 0xDFD3, 0xDFDD, 0xDFDF, 0xDFE0,
+ 0xDFE2, 0xDFEE, 0xDFF1, 0xDFF3, 0xDFFD, 0xDFFF,
+ 0xE000, 0xE002, 0xE00E, 0xE011, 0xE013, 0xE01D,
+ 0xE01F, 0xE020, 0xE022, 0xE02E, 0xE031, 0xE033,
+ 0xE03D, 0xE03F, 0xE0D1, 0xE0D3, 0xE0DD, 0xE0DF,
+ 0xE0E0, 0xE0E2, 0xE0EE, 0xE0F1, 0xE0F3, 0xE0FD,
+ 0xE0FF, 0xE101, 0xE103, 0xE10D, 0xE10F, 0xE110,
+ 0xE112, 0xE11E, 0xE121, 0xE123, 0xE12D, 0xE12F,
+ 0xE130, 0xE132, 0xE13E, 0xE1D0, 0xE1D2, 0xE1DE,
+ 0xE1E1, 0xE1E3, 0xE1ED, 0xE1EF, 0xE1F0, 0xE1F2,
+ 0xE1FE, 0xE200, 0xE202, 0xE20E, 0xE211, 0xE213,
+ 0xE21D, 0xE21F, 0xE220, 0xE222, 0xE22E, 0xE231,
+ 0xE233, 0xE23D, 0xE23F, 0xE2D1, 0xE2D3, 0xE2DD,
+ 0xE2DF, 0xE2E0, 0xE2E2, 0xE2EE, 0xE2F1, 0xE2F3,
+ 0xE2FD, 0xE2FF, 0xE301, 0xE303, 0xE30D, 0xE30F,
+ 0xE310, 0xE312, 0xE31E, 0xE321, 0xE323, 0xE32D,
+ 0xE32F, 0xE330, 0xE332, 0xE33E, 0xE3D0, 0xE3D2,
+ 0xE3DE, 0xE3E1, 0xE3E3, 0xE3ED, 0xE3EF, 0xE3F0,
+ 0xE3F2, 0xE3FE, 0xED01, 0xED03, 0xED0D, 0xED0F,
+ 0xED10, 0xED12, 0xED1E, 0xED21, 0xED23, 0xED2D,
+ 0xED2F, 0xED30, 0xED32, 0xED3E, 0xEDD0, 0xEDD2,
+ 0xEDDE, 0xEDE1, 0xEDE3, 0xEDED, 0xEDEF, 0xEDF0,
+ 0xEDF2, 0xEDFE, 0xEE00, 0xEE02, 0xEE0E, 0xEE11,
+ 0xEE13, 0xEE1D, 0xEE1F, 0xEE20, 0xEE22, 0xEE2E,
+ 0xEE31, 0xEE33, 0xEE3D, 0xEE3F, 0xEED1, 0xEED3,
+ 0xEEDD, 0xEEDF, 0xEEE0, 0xEEE2, 0xEEEE, 0xEEF1,
+ 0xEEF3, 0xEEFD, 0xEEFF, 0xEF01, 0xEF03, 0xEF0D,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF1E, 0xEF21, 0xEF23,
+ 0xEF2D, 0xEF2F, 0xEF30, 0xEF32, 0xEF3E, 0xEFD0,
+ 0xEFD2, 0xEFDE, 0xEFE1, 0xEFE3, 0xEFED, 0xEFEF,
+ 0xEFF0, 0xEFF2, 0xEFFE, 0xF001, 0xF003, 0xF00D,
+ 0xF00F, 0xF010, 0xF012, 0xF01E, 0xF021, 0xF023,
+ 0xF02D, 0xF02F, 0xF030, 0xF032, 0xF03E, 0xF0D0,
+ 0xF0D2, 0xF0DE, 0xF0E1, 0xF0E3, 0xF0ED, 0xF0EF,
+ 0xF0F0, 0xF0F2, 0xF0FE, 0xF100, 0xF102, 0xF10E,
+ 0xF111, 0xF113, 0xF11D, 0xF11F, 0xF120, 0xF122,
+ 0xF12E, 0xF131, 0xF133, 0xF13D, 0xF13F, 0xF1D1,
+ 0xF1D3, 0xF1DD, 0xF1DF, 0xF1E0, 0xF1E2, 0xF1EE,
+ 0xF1F1, 0xF1F3, 0xF1FD, 0xF1FF, 0xF201, 0xF203,
+ 0xF20D, 0xF20F, 0xF210, 0xF212, 0xF21E, 0xF221,
+ 0xF223, 0xF22D, 0xF22F, 0xF230, 0xF232, 0xF23E,
+ 0xF2D0, 0xF2D2, 0xF2DE, 0xF2E1, 0xF2E3, 0xF2ED,
+ 0xF2EF, 0xF2F0, 0xF2F2, 0xF2FE, 0xF300, 0xF302,
+ 0xF30E, 0xF311, 0xF313, 0xF31D, 0xF31F, 0xF320,
+ 0xF322, 0xF32E, 0xF331, 0xF333, 0xF33D, 0xF33F,
+ 0xF3D1, 0xF3D3, 0xF3DD, 0xF3DF, 0xF3E0, 0xF3E2,
+ 0xF3EE, 0xF3F1, 0xF3F3, 0xF3FD, 0xF3FF, 0xFD00,
+ 0xFD02, 0xFD0E, 0xFD11, 0xFD13, 0xFD1D, 0xFD1F,
+ 0xFD20, 0xFD22, 0xFD2E, 0xFD31, 0xFD33, 0xFD3D,
+ 0xFD3F, 0xFDD1, 0xFDD3, 0xFDDD, 0xFDDF, 0xFDE0,
+ 0xFDE2, 0xFDEE, 0xFDF1, 0xFDF3, 0xFDFD, 0xFDFF,
+ 0xFE01, 0xFE03, 0xFE0D, 0xFE0F, 0xFE10, 0xFE12,
+ 0xFE1E, 0xFE21, 0xFE23, 0xFE2D, 0xFE2F, 0xFE30,
+ 0xFE32, 0xFE3E, 0xFED0, 0xFED2, 0xFEDE, 0xFEE1,
+ 0xFEE3, 0xFEED, 0xFEEF, 0xFEF0, 0xFEF2, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF0E, 0xFF11, 0xFF13, 0xFF1D,
+ 0xFF1F, 0xFF20, 0xFF22, 0xFF2E, 0xFF31, 0xFF33,
+ 0xFF3D, 0xFF3F, 0xFFD1, 0xFFD3, 0xFFDD, 0xFFDF,
+ 0xFFE0, 0xFFE2, 0xFFEE, 0xFFF1, 0xFFF3, 0xFFFD,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB7_CODES 3281
+static const uint32_t on2avc_cb7_codes[ON2AVC_CB7_CODES] = {
+ 0x00000, 0x000EA, 0x000E6, 0x000F4, 0x000F6, 0x00047,
+ 0x003E2, 0x004A7, 0x00044, 0x004D3, 0x0082A, 0x0026E,
+ 0x0020E, 0x008A5, 0x02603, 0x02895, 0x049B0, 0x02894,
+ 0x007BE, 0x0069E, 0x01154, 0x01153, 0x0095F, 0x0038E,
+ 0x004AC, 0x0128E, 0x00E5E, 0x00992, 0x02A84, 0x0386A,
+ 0x03F6F, 0x01C54, 0x005D4, 0x00AFB, 0x001BE, 0x00258,
+ 0x00A59, 0x00043, 0x004A6, 0x004D7, 0x00040, 0x0006C,
+ 0x007FF, 0x00D39, 0x0005B, 0x00066, 0x0034A, 0x00124,
+ 0x004B6, 0x00626, 0x0071F, 0x014A3, 0x014A2, 0x0083E,
+ 0x032D4, 0x049B3, 0x0045E, 0x00ED5, 0x02896, 0x00ABA,
+ 0x0107B, 0x009EC, 0x0082C, 0x0082B, 0x00D38, 0x0072B,
+ 0x004FC, 0x049B2, 0x050B1, 0x003FE, 0x009EB, 0x049B1,
+ 0x00966, 0x00F75, 0x03F70, 0x007BC, 0x00054, 0x00394,
+ 0x000E8, 0x0052F, 0x0057A, 0x00458, 0x0FB4B, 0x01C55,
+ 0x00948, 0x032D6, 0x00ED6, 0x0A05F, 0x050B3, 0x00BBD,
+ 0x0197E, 0x024FC, 0x020C6, 0x0094A, 0x0386B, 0x1F2FF,
+ 0x050B4, 0x0A060, 0x0FB4C, 0x009ED, 0x02A85, 0x0FB4D,
+ 0x02605, 0x00ABB, 0x009A2, 0x0145B, 0x0A05D, 0x03F71,
+ 0x00BFF, 0x1F2FE, 0x0FB49, 0x0FB48, 0x050B2, 0x01155,
+ 0x01FD6, 0x032D5, 0x00976, 0x02604, 0x00A5A, 0x0A05E,
+ 0x0FB4A, 0x00DB9, 0x0A063, 0x1F307, 0x0FB4F, 0x1F306,
+ 0x049B4, 0x0FB50, 0x0FB51, 0x050B6, 0x1F308, 0x050B7,
+ 0x1F30A, 0x1F309, 0x0A064, 0x1F30B, 0x0A066, 0x06535,
+ 0x020C7, 0x0A065, 0x032D7, 0x0FB52, 0x02897, 0x0077A,
+ 0x03F72, 0x0FB4E, 0x050B5, 0x0076E, 0x1F301, 0x1F302,
+ 0x06533, 0x01FD7, 0x1F300, 0x0A061, 0x1F304, 0x1F303,
+ 0x07E54, 0x024FD, 0x1F305, 0x06534, 0x02606, 0x0A062,
+ 0x007C0, 0x0A06A, 0x1F30F, 0x0FB54, 0x0386D, 0x009E6,
+ 0x1F310, 0x06538, 0x00DBA, 0x014A4, 0x050B9, 0x1F311,
+ 0x0A06B, 0x0128F, 0x07E55, 0x1F312, 0x0FB55, 0x01C56,
+ 0x07E56, 0x0FB56, 0x1F313, 0x050BA, 0x01C57, 0x02608,
+ 0x0A067, 0x1F30D, 0x1F30C, 0x02607, 0x0386C, 0x0A069,
+ 0x0A068, 0x01557, 0x00ED7, 0x06536, 0x1F30E, 0x0FB53,
+ 0x02609, 0x007BF, 0x050B8, 0x06537, 0x00DE5, 0x00392,
+ 0x03F69, 0x0A055, 0x0FB3C, 0x0A054, 0x00AB7, 0x050AB,
+ 0x0FB3D, 0x00CE6, 0x009E8, 0x014A1, 0x049A8, 0x1F2ED,
+ 0x02890, 0x009E9, 0x049A9, 0x1F2EE, 0x032D1, 0x020C4,
+ 0x049AA, 0x0A056, 0x0FB3E, 0x0FB3F, 0x0A051, 0x0A052,
+ 0x0A053, 0x0FB39, 0x0A050, 0x0096E, 0x0FB3A, 0x1F2EB,
+ 0x029FE, 0x007FE, 0x0128D, 0x049A7, 0x1F2EC, 0x07E50,
+ 0x00E36, 0x03867, 0x0FB3B, 0x006EA, 0x03F6B, 0x1F2F4,
+ 0x1F2F3, 0x03868, 0x049AB, 0x1F2F6, 0x029FF, 0x1F2F5,
+ 0x0A05A, 0x07E52, 0x1F2F7, 0x07E51, 0x03F6C, 0x1F2FA,
+ 0x07E53, 0x025FF, 0x1F2F8, 0x1F2F9, 0x009A0, 0x06532,
+ 0x0FB45, 0x024FB, 0x008B9, 0x01D7D, 0x0FB40, 0x01FD3,
+ 0x0FB42, 0x0A058, 0x050AC, 0x0A057, 0x0FB41, 0x0A059,
+ 0x1F2F0, 0x1F2EF, 0x0FB43, 0x03F6A, 0x0FB44, 0x020C5,
+ 0x1F2F1, 0x1F2F2, 0x004FE, 0x02601, 0x00A58, 0x01FD5,
+ 0x049AD, 0x00A46, 0x02A80, 0x050AD, 0x009E5, 0x01B56,
+ 0x02A81, 0x00A36, 0x01556, 0x032D3, 0x02A82, 0x0FB47,
+ 0x1F2FD, 0x050AE, 0x004BA, 0x00A6B, 0x03F6D, 0x049AE,
+ 0x01317, 0x009A1, 0x00AB8, 0x02891, 0x03869, 0x01FD4,
+ 0x049AC, 0x1F2FB, 0x0FB46, 0x0A05B, 0x02600, 0x032D2,
+ 0x0137E, 0x01C53, 0x02892, 0x00BFE, 0x0A05C, 0x1F2FC,
+ 0x00CE7, 0x00058, 0x00FF7, 0x009EA, 0x00068, 0x00060,
+ 0x004D2, 0x004BD, 0x000EE, 0x003A4, 0x006E2, 0x0137F,
+ 0x0197D, 0x006EB, 0x050B0, 0x03F6E, 0x00E37, 0x00316,
+ 0x02893, 0x004CB, 0x006EE, 0x01152, 0x008AE, 0x0067E,
+ 0x00991, 0x0145A, 0x00AB9, 0x049AF, 0x02A83, 0x00A6C,
+ 0x0045F, 0x02602, 0x006E1, 0x050AF, 0x012D2, 0x0073F,
+ 0x00061, 0x00526, 0x004D6, 0x0013E, 0x003AE, 0x0005E,
+ 0x01D7E, 0x0289F, 0x00059, 0x0006A, 0x0082D, 0x00F77,
+ 0x009EE, 0x006E3, 0x00D3F, 0x1F32B, 0x02A8B, 0x00D3E,
+ 0x032DE, 0x0FB60, 0x02A8C, 0x020CC, 0x03874, 0x0045B,
+ 0x00DE8, 0x0082E, 0x00636, 0x012D6, 0x049B9, 0x0260C,
+ 0x01157, 0x06540, 0x0A073, 0x02504, 0x0289D, 0x050C2,
+ 0x00AFE, 0x0260D, 0x0289E, 0x00A6F, 0x0004E, 0x006EF,
+ 0x0099C, 0x00EDA, 0x0062E, 0x00048, 0x00A3A, 0x01292,
+ 0x013C2, 0x00A72, 0x0012A, 0x028A0, 0x02507, 0x00174,
+ 0x00DE9, 0x00ABF, 0x00EDE, 0x01146, 0x013C3, 0x032E1,
+ 0x049BA, 0x03875, 0x03876, 0x00824, 0x0077B, 0x032E2,
+ 0x01050, 0x00677, 0x00EDB, 0x0145C, 0x02505, 0x032DF,
+ 0x019C0, 0x050C3, 0x06541, 0x0A074, 0x032E0, 0x00A37,
+ 0x02506, 0x00ABE, 0x00E78, 0x02A8D, 0x001B4, 0x02A8E,
+ 0x01D7F, 0x001A4, 0x00DEA, 0x1F32F, 0x050C5, 0x009EF,
+ 0x00977, 0x020CD, 0x01B60, 0x019C3, 0x017DE, 0x0131A,
+ 0x0260F, 0x0A075, 0x01C5C, 0x0FB61, 0x07E62, 0x00E79,
+ 0x02610, 0x0A076, 0x014A7, 0x02611, 0x009FA, 0x007C1,
+ 0x0145D, 0x1F32C, 0x049BB, 0x019C1, 0x06543, 0x1F32D,
+ 0x06544, 0x01FD8, 0x06542, 0x01B5E, 0x06545, 0x1F32E,
+ 0x019C2, 0x005F4, 0x0260E, 0x050C4, 0x01B5F, 0x01C5B,
+ 0x032E3, 0x1F339, 0x1F33A, 0x1F338, 0x0FB63, 0x028A1,
+ 0x1F33B, 0x0FB64, 0x049BC, 0x0A07A, 0x1F33C, 0x0A07B,
+ 0x032E4, 0x07E63, 0x1F33E, 0x07E64, 0x1F33D, 0x0FB65,
+ 0x028A2, 0x02612, 0x02613, 0x050C6, 0x00967, 0x0155A,
+ 0x03F78, 0x1F330, 0x0A077, 0x03877, 0x0A078, 0x1F333,
+ 0x1F331, 0x1F332, 0x03878, 0x1F335, 0x1F336, 0x06546,
+ 0x1F334, 0x06547, 0x1F337, 0x0A079, 0x0FB62, 0x006FE,
+ 0x1F342, 0x0FB69, 0x008A7, 0x009FB, 0x1F343, 0x1F344,
+ 0x050C7, 0x0654A, 0x020CF, 0x1F345, 0x020CE, 0x01FD9,
+ 0x028A5, 0x0A07C, 0x0A07D, 0x050C8, 0x013C6, 0x03F7A,
+ 0x0A07E, 0x0387B, 0x01C5D, 0x03879, 0x06548, 0x1F33F,
+ 0x028A3, 0x00DBE, 0x03F79, 0x1F340, 0x0FB66, 0x028A4,
+ 0x008B2, 0x0FB67, 0x0387A, 0x0131B, 0x005D5, 0x06549,
+ 0x1F341, 0x0FB68, 0x0155B, 0x00DE6, 0x07E59, 0x1F318,
+ 0x00266, 0x00823, 0x01B57, 0x0FB58, 0x1F319, 0x0386F,
+ 0x01B58, 0x02899, 0x050BB, 0x00DBB, 0x01B59, 0x032D9,
+ 0x050BC, 0x1F31A, 0x03F74, 0x032DA, 0x0A06D, 0x06539,
+ 0x03870, 0x0386E, 0x1F315, 0x1F314, 0x024FE, 0x0176A,
+ 0x032D8, 0x0A06C, 0x1F316, 0x07E57, 0x014A5, 0x049B5,
+ 0x07E58, 0x00D3A, 0x0075B, 0x02898, 0x1F317, 0x0FB57,
+ 0x03F73, 0x01B5A, 0x0FB5B, 0x050BE, 0x1F31F, 0x0FB5A,
+ 0x0653B, 0x1F320, 0x0FB5C, 0x07E5C, 0x07E5D, 0x1F322,
+ 0x050BF, 0x0A06F, 0x1F321, 0x0FB5D, 0x1F325, 0x1F323,
+ 0x1F324, 0x01C58, 0x00ED8, 0x0289A, 0x1F326, 0x03F77,
+ 0x013C0, 0x0653A, 0x03F75, 0x1F31B, 0x024FF, 0x03F76,
+ 0x0FB59, 0x07E5A, 0x0A06E, 0x02500, 0x07E5B, 0x02A86,
+ 0x050BD, 0x1F31C, 0x032DB, 0x1F31E, 0x1F31D, 0x049B6,
+ 0x00C49, 0x1F329, 0x1F328, 0x00BBE, 0x008A6, 0x03871,
+ 0x01B5B, 0x02A88, 0x01558, 0x020C9, 0x0FB5F, 0x049B7,
+ 0x014A6, 0x07E5F, 0x1F32A, 0x0197F, 0x01B5C, 0x03872,
+ 0x00726, 0x01156, 0x02501, 0x0104F, 0x00C48, 0x032DC,
+ 0x0653C, 0x0176B, 0x1F327, 0x0653D, 0x0289B, 0x07E5E,
+ 0x0FB5E, 0x0176E, 0x0A071, 0x0A070, 0x0260A, 0x00993,
+ 0x020C8, 0x0176F, 0x02A87, 0x0289C, 0x00042, 0x00CE8,
+ 0x01C5A, 0x00F76, 0x008BA, 0x001C8, 0x02A8A, 0x02503,
+ 0x00136, 0x00A6E, 0x020CB, 0x00A5B, 0x008AF, 0x00ED9,
+ 0x03873, 0x0653F, 0x07E61, 0x050C1, 0x007A9, 0x0067F,
+ 0x013C1, 0x01559, 0x00D3B, 0x00DE7, 0x01B5D, 0x050C0,
+ 0x0260B, 0x02A89, 0x0653E, 0x0A072, 0x07E60, 0x049B8,
+ 0x00A6D, 0x02502, 0x00E5F, 0x012D3, 0x020CA, 0x0015D,
+ 0x032DD, 0x01C59, 0x0018E, 0x000E0, 0x07E77, 0x07E78,
+ 0x07E76, 0x049C5, 0x00BEA, 0x0A090, 0x0A08F, 0x00A3B,
+ 0x03F80, 0x0655A, 0x0655B, 0x050D1, 0x0A091, 0x1F37E,
+ 0x1F37F, 0x1F37C, 0x1F37D, 0x0FB77, 0x0655D, 0x050D2,
+ 0x1F380, 0x0655C, 0x02618, 0x049C3, 0x1F379, 0x0A08D,
+ 0x07E72, 0x07E73, 0x1F37B, 0x1F37A, 0x0A08E, 0x0145E,
+ 0x06558, 0x06559, 0x07E74, 0x049C4, 0x0083F, 0x07E75,
+ 0x0FB76, 0x007AA, 0x008A8, 0x1F382, 0x0FB7B, 0x007AB,
+ 0x004B2, 0x050D5, 0x07E7C, 0x07E7B, 0x032E8, 0x0261A,
+ 0x07E7D, 0x1F383, 0x03F81, 0x1F384, 0x0655F, 0x0FB7C,
+ 0x0A094, 0x0A095, 0x020D3, 0x1F385, 0x050D6, 0x050D7,
+ 0x01B61, 0x0FB78, 0x07E79, 0x028A7, 0x07E7A, 0x0A092,
+ 0x1F381, 0x050D3, 0x0FB79, 0x032E7, 0x0655E, 0x0A093,
+ 0x01DA2, 0x0053B, 0x02619, 0x050D4, 0x0FB7A, 0x020D2,
+ 0x0094B, 0x0A09A, 0x0FB7F, 0x0FB7E, 0x03884, 0x00C4A,
+ 0x0FB80, 0x1F38B, 0x019C6, 0x032E9, 0x01C5F, 0x0FB82,
+ 0x1F38C, 0x0FB81, 0x050D9, 0x07E7E, 0x1F38D, 0x1F38E,
+ 0x03885, 0x050DB, 0x07E7F, 0x06562, 0x050DA, 0x00E7A,
+ 0x02A92, 0x1F386, 0x0A096, 0x06560, 0x06561, 0x1F389,
+ 0x1F387, 0x1F388, 0x050D8, 0x0A098, 0x0FB7D, 0x02A93,
+ 0x0A097, 0x01FDC, 0x1F38A, 0x0A099, 0x020D4, 0x07E82,
+ 0x0FB89, 0x1F394, 0x07E81, 0x0A09E, 0x0FB8B, 0x1F395,
+ 0x07E83, 0x0FB8A, 0x028A8, 0x1F397, 0x1F396, 0x0A09F,
+ 0x0FB8C, 0x03F82, 0x049C6, 0x1F398, 0x1F399, 0x06563,
+ 0x02508, 0x03886, 0x07E84, 0x012E6, 0x0A09B, 0x1F38F,
+ 0x032EA, 0x0FB85, 0x1F390, 0x0FB86, 0x0FB83, 0x0FB84,
+ 0x0A09C, 0x1F392, 0x1F391, 0x0FB87, 0x02A94, 0x1F393,
+ 0x0A09D, 0x07E80, 0x0FB88, 0x006B6, 0x1F39D, 0x1F39E,
+ 0x0A0A1, 0x0A0A2, 0x0155E, 0x1F39F, 0x0A0A3, 0x02509,
+ 0x020D5, 0x0A0A4, 0x1F3A0, 0x07E86, 0x06564, 0x01FDE,
+ 0x0FB90, 0x049C8, 0x06565, 0x050DE, 0x0A0A6, 0x07E87,
+ 0x0A0A5, 0x06566, 0x00E7B, 0x049C7, 0x1F39A, 0x0A0A0,
+ 0x050DC, 0x00DEC, 0x07E85, 0x0FB8D, 0x01FDD, 0x00CE9,
+ 0x050DD, 0x0FB8E, 0x1F39B, 0x03F83, 0x0051F, 0x1F39C,
+ 0x0FB8F, 0x01293, 0x009A3, 0x049BE, 0x1F34E, 0x1F34D,
+ 0x0654B, 0x0115A, 0x0A07F, 0x0654C, 0x00A47, 0x01C5E,
+ 0x049BF, 0x1F350, 0x1F34F, 0x0387C, 0x07E67, 0x1F351,
+ 0x07E66, 0x02A8F, 0x1F353, 0x07E68, 0x1F354, 0x1F352,
+ 0x0A080, 0x00BBF, 0x1F347, 0x1F348, 0x1F346, 0x0FB6A,
+ 0x032E5, 0x07E65, 0x1F349, 0x006E4, 0x012D7, 0x049BD,
+ 0x1F34A, 0x0FB6B, 0x050C9, 0x00DEB, 0x1F34C, 0x1F34B,
+ 0x0052E, 0x07E6A, 0x1F35F, 0x1F35E, 0x0A081, 0x0387D,
+ 0x1F361, 0x0654F, 0x1F360, 0x0A082, 0x0387E, 0x1F363,
+ 0x1F362, 0x050CA, 0x0A084, 0x1F365, 0x03F7D, 0x0A083,
+ 0x1F364, 0x032E6, 0x1F366, 0x0A085, 0x06550, 0x020D0,
+ 0x1F356, 0x1F355, 0x00A73, 0x1F357, 0x1F358, 0x1F359,
+ 0x07E69, 0x0654D, 0x1F35B, 0x0FB6C, 0x1F35A, 0x0654E,
+ 0x03F7B, 0x1F35D, 0x03F7C, 0x0FB6D, 0x1F35C, 0x009AA,
+ 0x03880, 0x1F36B, 0x0A086, 0x1F36A, 0x01FDA, 0x1F36C,
+ 0x0A087, 0x01051, 0x049C2, 0x0FB71, 0x07E6E, 0x0A088,
+ 0x03F7E, 0x06553, 0x1F36E, 0x1F36D, 0x06552, 0x028A6,
+ 0x02A90, 0x0A089, 0x1F36F, 0x03881, 0x0074A, 0x049C0,
+ 0x0FB6F, 0x0FB6E, 0x02614, 0x0FB70, 0x1F368, 0x1F367,
+ 0x07E6B, 0x0387F, 0x049C1, 0x07E6C, 0x06551, 0x050CB,
+ 0x014AA, 0x07E6D, 0x1F369, 0x02615, 0x0072C, 0x1F373,
+ 0x1F372, 0x008BB, 0x00450, 0x07E70, 0x1F375, 0x1F374,
+ 0x050CE, 0x03882, 0x1F376, 0x0FB74, 0x02617, 0x1F377,
+ 0x1F378, 0x07E71, 0x06557, 0x0FB75, 0x050CF, 0x050D0,
+ 0x0A08C, 0x03883, 0x02A91, 0x06555, 0x050CC, 0x06554,
+ 0x0A08A, 0x1F370, 0x050CD, 0x06556, 0x0FB72, 0x02616,
+ 0x07E6F, 0x0A08B, 0x01FDB, 0x0053A, 0x03F7F, 0x0FB73,
+ 0x1F371, 0x020D1, 0x01FE0, 0x1F3F9, 0x1F3F8, 0x02A98,
+ 0x00C4E, 0x0A0B6, 0x0FBB1, 0x1F3FA, 0x0FBB0, 0x1F3FC,
+ 0x1F3FD, 0x1F3FB, 0x0A0B7, 0x1F400, 0x1F401, 0x1F402,
+ 0x1F3FE, 0x1F3FF, 0x1F404, 0x1F405, 0x0FBB2, 0x1F403,
+ 0x1F3EF, 0x1F3F0, 0x1F3ED, 0x1F3EE, 0x1F3F3, 0x1F3F4,
+ 0x0FBAB, 0x1F3F1, 0x1F3F2, 0x0A0B5, 0x1F3F6, 0x1F3F5,
+ 0x0FBAC, 0x01052, 0x0FBAF, 0x1F3F7, 0x0FBAD, 0x0FBAE,
+ 0x004BC, 0x1F40D, 0x1F40E, 0x1F40C, 0x0FBB8, 0x049CC,
+ 0x1F410, 0x1F40F, 0x03F87, 0x0A0B9, 0x0A0BA, 0x1F412,
+ 0x0FBB9, 0x1F411, 0x1F415, 0x1F416, 0x1F413, 0x1F414,
+ 0x1F418, 0x0A0BB, 0x0FBBA, 0x1F417, 0x07E95, 0x07E93,
+ 0x1F406, 0x1F407, 0x0A0B8, 0x07E92, 0x0FBB5, 0x1F408,
+ 0x0FBB3, 0x0FBB4, 0x07E94, 0x0FBB7, 0x1F409, 0x0FBB6,
+ 0x03F86, 0x01DA3, 0x1F40B, 0x1F40A, 0x019C7, 0x06572,
+ 0x1F421, 0x1F420, 0x0250F, 0x00DBF, 0x1F422, 0x1F423,
+ 0x0FBBE, 0x050E2, 0x049CD, 0x1F425, 0x1F424, 0x07E97,
+ 0x1F427, 0x0FBC0, 0x1F428, 0x0FBBF, 0x1F426, 0x1F42A,
+ 0x1F42B, 0x1F429, 0x0A0C0, 0x013C7, 0x0A0BD, 0x1F419,
+ 0x0A0BC, 0x1F41C, 0x1F41D, 0x1F41E, 0x1F41A, 0x1F41B,
+ 0x0FBBC, 0x1F41F, 0x06571, 0x0FBBB, 0x01FE1, 0x0FBBD,
+ 0x0A0BF, 0x0A0BE, 0x07E96, 0x0FBC6, 0x1F437, 0x1F438,
+ 0x1F435, 0x1F436, 0x0A0C3, 0x1F43A, 0x1F439, 0x0FBC7,
+ 0x1F43B, 0x0FBC9, 0x0FBCA, 0x0FBC8, 0x07E99, 0x0A0C4,
+ 0x07E9A, 0x1F43C, 0x1F43D, 0x1F43E, 0x0A0C5, 0x050E4,
+ 0x0FBCB, 0x0FBCC, 0x050E3, 0x07E98, 0x0FBC2, 0x1F42C,
+ 0x0FBC1, 0x1F42F, 0x1F430, 0x1F42D, 0x1F42E, 0x0A0C1,
+ 0x1F432, 0x1F433, 0x0FBC3, 0x1F431, 0x0FBC5, 0x1F434,
+ 0x0FBC4, 0x0A0C2, 0x00AF6, 0x1F444, 0x0FBCF, 0x0261C,
+ 0x014AB, 0x0A0C8, 0x1F446, 0x1F445, 0x06573, 0x0261D,
+ 0x1F448, 0x1F447, 0x02A99, 0x0FBD1, 0x0A0C9, 0x1F449,
+ 0x0FBD0, 0x06574, 0x1F44C, 0x049CF, 0x1F44A, 0x1F44B,
+ 0x032EC, 0x1F440, 0x1F43F, 0x07E9B, 0x01B62, 0x0388A,
+ 0x1F441, 0x07E9C, 0x0A0C6, 0x00D6A, 0x0A0C7, 0x0FBCD,
+ 0x049CE, 0x00EDF, 0x0FBCE, 0x1F443, 0x1F442, 0x07E9D,
+ 0x03888, 0x0FB91, 0x1F3A8, 0x00E96, 0x00CEA, 0x0FB93,
+ 0x0FB94, 0x0FB92, 0x1F3A9, 0x03889, 0x0FB95, 0x0A0A7,
+ 0x0155F, 0x050E0, 0x0A0A8, 0x1F3AB, 0x1F3AA, 0x07E89,
+ 0x07E8A, 0x0A0AA, 0x0FB96, 0x0A0A9, 0x06567, 0x1F3A2,
+ 0x1F3A1, 0x02A95, 0x0250A, 0x06568, 0x1F3A4, 0x1F3A3,
+ 0x050DF, 0x02A96, 0x1F3A5, 0x06569, 0x00C4B, 0x00AFF,
+ 0x03887, 0x1F3A7, 0x1F3A6, 0x07E88, 0x0261B, 0x1F3BC,
+ 0x1F3BD, 0x1F3BA, 0x1F3BB, 0x0656C, 0x0FB97, 0x1F3BE,
+ 0x0656B, 0x1F3C0, 0x0FB98, 0x1F3C1, 0x07E8C, 0x1F3BF,
+ 0x1F3C2, 0x0FB9A, 0x0FB99, 0x0A0AC, 0x0656D, 0x0FB9B,
+ 0x1F3C4, 0x1F3C3, 0x07E8D, 0x049C9, 0x0A0AB, 0x1F3AE,
+ 0x1F3AC, 0x1F3AD, 0x1F3B1, 0x1F3B2, 0x1F3AF, 0x1F3B0,
+ 0x1F3B5, 0x1F3B6, 0x1F3B7, 0x1F3B3, 0x1F3B4, 0x0656A,
+ 0x1F3B9, 0x1F3B8, 0x07E8B, 0x03F84, 0x1F3CF, 0x1F3CE,
+ 0x032EB, 0x0250B, 0x0FB9E, 0x0A0AF, 0x1F3D0, 0x0A0AE,
+ 0x0A0B1, 0x1F3D1, 0x0A0B0, 0x049CA, 0x1F3D3, 0x1F3D4,
+ 0x0FBA0, 0x0FB9F, 0x1F3D2, 0x0FBA1, 0x0A0B2, 0x1F3D5,
+ 0x07E90, 0x07E8E, 0x1F3C6, 0x1F3C5, 0x0656E, 0x1F3C7,
+ 0x1F3C8, 0x0656F, 0x07E8F, 0x0FB9C, 0x0A0AD, 0x0FB9D,
+ 0x1F3C9, 0x050E1, 0x01FDF, 0x1F3CC, 0x1F3CD, 0x1F3CA,
+ 0x1F3CB, 0x00410, 0x0FBA9, 0x1F3DF, 0x1F3DE, 0x0FBA8,
+ 0x02A97, 0x1F3E1, 0x1F3E0, 0x0250E, 0x0FBAA, 0x1F3E3,
+ 0x1F3E4, 0x07E91, 0x1F3E2, 0x1F3E7, 0x1F3E8, 0x1F3E5,
+ 0x1F3E6, 0x1F3EA, 0x1F3EB, 0x1F3EC, 0x1F3E9, 0x0A0B4,
+ 0x03F85, 0x0FBA4, 0x1F3D6, 0x0FBA2, 0x0FBA3, 0x1F3D8,
+ 0x0FBA6, 0x1F3D7, 0x0FBA5, 0x1F3DB, 0x0A0B3, 0x1F3DC,
+ 0x1F3D9, 0x1F3DA, 0x049CB, 0x0FBA7, 0x1F3DD, 0x06570,
+ 0x0014C, 0x1F4A6, 0x1F4A7, 0x1F4A5, 0x0FBE7, 0x00DEF,
+ 0x1F4A9, 0x1F4A8, 0x01166, 0x050EB, 0x050EC, 0x1F4AB,
+ 0x1F4AA, 0x0A0D7, 0x0FBE8, 0x1F4AD, 0x1F4AC, 0x0A0D8,
+ 0x0A0D9, 0x1F4B0, 0x1F4B1, 0x1F4AE, 0x1F4AF, 0x0FBE6,
+ 0x1F49C, 0x1F49D, 0x1F49B, 0x0FBE5, 0x07EA2, 0x1F49F,
+ 0x1F49E, 0x0A0D6, 0x019F6, 0x1F4A1, 0x1F4A2, 0x1F4A0,
+ 0x050EA, 0x01C9E, 0x1F4A4, 0x1F4A3, 0x0133A, 0x00E4E,
+ 0x1F4BE, 0x1F4BD, 0x00BEE, 0x001AE, 0x050EE, 0x1F4C0,
+ 0x1F4BF, 0x050ED, 0x020DA, 0x1F4C2, 0x1F4C1, 0x050EF,
+ 0x0FBEB, 0x1F4C3, 0x1F4C4, 0x0FBE9, 0x0FBEA, 0x1F4C6,
+ 0x1F4C7, 0x1F4C5, 0x0A0DC, 0x1F4B4, 0x1F4B5, 0x1F4B2,
+ 0x1F4B3, 0x03F8A, 0x1F4B7, 0x1F4B8, 0x1F4B6, 0x0A0DA,
+ 0x02A9B, 0x1F4BA, 0x1F4B9, 0x0145F, 0x004AD, 0x0A0DB,
+ 0x1F4BC, 0x1F4BB, 0x03F8B, 0x003A6, 0x0A0DE, 0x1F4D1,
+ 0x1F4D0, 0x0FBED, 0x00DCA, 0x0FBEE, 0x1F4D2, 0x00EFE,
+ 0x02096, 0x0A0DF, 0x1F4D4, 0x1F4D3, 0x07EA6, 0x0FBEF,
+ 0x1F4D6, 0x1F4D5, 0x0A0E0, 0x1F4D9, 0x1F4DA, 0x1F4DB,
+ 0x1F4D7, 0x1F4D8, 0x07EA3, 0x1F4CA, 0x1F4CB, 0x1F4C8,
+ 0x1F4C9, 0x0388E, 0x0FBEC, 0x1F4CC, 0x049D8, 0x00CEB,
+ 0x0657A, 0x0A0DD, 0x1F4CD, 0x049D9, 0x00521, 0x1F4CF,
+ 0x1F4CE, 0x00CFA, 0x01B67, 0x1F4E4, 0x1F4E3, 0x032EF,
+ 0x00292, 0x0FBF2, 0x1F4E6, 0x1F4E5, 0x0FBF1, 0x014D2,
+ 0x0A0E5, 0x0A0E4, 0x028AA, 0x1F4E9, 0x0657F, 0x1F4EA,
+ 0x1F4E7, 0x1F4E8, 0x1F4ED, 0x1F4EE, 0x1F4EB, 0x1F4EC,
+ 0x0412E, 0x1F4DC, 0x0A0E1, 0x0A0E2, 0x049DA, 0x1F4DE,
+ 0x1F4DF, 0x1F4DD, 0x0657B, 0x01B66, 0x1F4E0, 0x0FBF0,
+ 0x0388F, 0x00522, 0x0A0E3, 0x1F4E2, 0x1F4E1, 0x0657E,
+ 0x007C2, 0x0A0EB, 0x1F4F8, 0x1F4F7, 0x0FBF5, 0x00F7A,
+ 0x1F4F9, 0x0FBF6, 0x020DB, 0x028AB, 0x1F4FB, 0x1F4FC,
+ 0x1F4FA, 0x0FBF7, 0x01DFE, 0x0BEFA, 0x1F4FD, 0x07EA7,
+ 0x1F502, 0x13FC2, 0x1F503, 0x1F4FE, 0x1F4FF, 0x1F4F1,
+ 0x0FBF3, 0x1F4F2, 0x1F4EF, 0x1F4F0, 0x02576, 0x0A0E7,
+ 0x1F4F3, 0x0A0E6, 0x07092, 0x0FBF4, 0x1F4F5, 0x1F4F4,
+ 0x049DB, 0x0096F, 0x1F4F6, 0x0A0EA, 0x02623, 0x006FF,
+ 0x1F45C, 0x1F45D, 0x1F45B, 0x07E9E, 0x03F88, 0x1F45F,
+ 0x1F45E, 0x020D7, 0x06575, 0x1F462, 0x0FBD2, 0x1F460,
+ 0x1F461, 0x1F464, 0x0FBD4, 0x0FBD3, 0x1F463, 0x1F467,
+ 0x1F468, 0x1F469, 0x1F465, 0x1F466, 0x1F44F, 0x1F450,
+ 0x1F451, 0x1F44D, 0x1F44E, 0x1F453, 0x1F454, 0x1F452,
+ 0x020D6, 0x0388B, 0x1F457, 0x1F458, 0x1F455, 0x1F456,
+ 0x028A9, 0x1F45A, 0x1F459, 0x00DED, 0x020D8, 0x1F472,
+ 0x1F471, 0x0261F, 0x006F0, 0x0FBD6, 0x1F474, 0x1F473,
+ 0x050E5, 0x049D3, 0x0FBD7, 0x1F475, 0x015EE, 0x1F477,
+ 0x0A0CD, 0x1F478, 0x1F476, 0x050E6, 0x1F47A, 0x1F47B,
+ 0x1F479, 0x0A0CE, 0x0A0CB, 0x1F46A, 0x0A0CA, 0x0261E,
+ 0x049D0, 0x0A0CC, 0x1F46C, 0x1F46B, 0x06576, 0x049D1,
+ 0x1F46E, 0x1F46D, 0x01FE2, 0x004DE, 0x049D2, 0x1F470,
+ 0x1F46F, 0x0FBD5, 0x00376, 0x0FBDB, 0x0FBDC, 0x1F482,
+ 0x0A0D0, 0x00C5E, 0x1F484, 0x1F483, 0x00BEB, 0x020D9,
+ 0x06578, 0x1F486, 0x1F485, 0x07E9F, 0x0A0D1, 0x1F487,
+ 0x07EA0, 0x050E8, 0x1F488, 0x0FBDF, 0x1F489, 0x0FBDD,
+ 0x0FBDE, 0x050E7, 0x0A0CF, 0x1F47D, 0x1F47C, 0x0FBD8,
+ 0x06577, 0x1F47F, 0x1F47E, 0x032ED, 0x012BA, 0x03F89,
+ 0x0FBD9, 0x1F480, 0x032EE, 0x00C4F, 0x1F481, 0x0FBDA,
+ 0x01B63, 0x00DEE, 0x0FBE1, 0x1F491, 0x0115B, 0x001CE,
+ 0x049D6, 0x1F493, 0x1F492, 0x0A0D4, 0x049D7, 0x1F495,
+ 0x1F494, 0x02A9A, 0x0A0D5, 0x0FBE3, 0x1F497, 0x1F496,
+ 0x0FBE2, 0x0FBE4, 0x1F49A, 0x1F498, 0x1F499, 0x049D4,
+ 0x1F48A, 0x0A0D2, 0x0FBE0, 0x049D5, 0x0A0D3, 0x1F48C,
+ 0x1F48B, 0x07EA1, 0x01FE3, 0x1F48E, 0x1F48D, 0x02622,
+ 0x00520, 0x050E9, 0x1F490, 0x1F48F, 0x06579, 0x0018A,
+ 0x09FE6, 0x1F0E6, 0x1F0E5, 0x0459C, 0x00DCB, 0x1F0E7,
+ 0x0FA96, 0x012D0, 0x020A6, 0x1F0E9, 0x1F0EA, 0x1F0E8,
+ 0x0FA97, 0x09FE7, 0x1F0EC, 0x1F0EB, 0x06370, 0x09FE8,
+ 0x1F0EE, 0x1F0EF, 0x0FA98, 0x1F0ED, 0x1F0DC, 0x1F0DD,
+ 0x1F0DE, 0x1F0DA, 0x1F0DB, 0x1F0DF, 0x1F0E0, 0x0FA93,
+ 0x0FA94, 0x0507C, 0x1F0E2, 0x1F0E3, 0x1F0E1, 0x0507B,
+ 0x00AAE, 0x1F0E4, 0x0FA95, 0x00F5D, 0x00DB4, 0x0FA9C,
+ 0x1F0F9, 0x00FF2, 0x003AC, 0x1F0FB, 0x1F0FC, 0x1F0FA,
+ 0x029E0, 0x025CF, 0x1F0FE, 0x1F0FD, 0x029E1, 0x029E2,
+ 0x09FE9, 0x1F180, 0x1F0FF, 0x07E04, 0x0FA9D, 0x1F183,
+ 0x1F181, 0x1F182, 0x0FA9A, 0x1F0F1, 0x0FA99, 0x1F0F0,
+ 0x0384C, 0x1F0F3, 0x1F0F4, 0x1F0F2, 0x0FA9B, 0x019F7,
+ 0x1F0F6, 0x1F0F5, 0x02878, 0x0018C, 0x06371, 0x1F0F8,
+ 0x1F0F7, 0x07E03, 0x002FC, 0x0507E, 0x1F18E, 0x1F18D,
+ 0x06373, 0x00D2C, 0x1F190, 0x1F18F, 0x01356, 0x01357,
+ 0x0FAA0, 0x1F192, 0x1F191, 0x0507F, 0x02879, 0x1F194,
+ 0x1F193, 0x0384D, 0x1F197, 0x0FAA1, 0x0FAA2, 0x1F195,
+ 0x1F196, 0x1F186, 0x1F187, 0x1F188, 0x1F184, 0x1F185,
+ 0x0507D, 0x1F189, 0x0FA9E, 0x06372, 0x020A7, 0x07E05,
+ 0x1F18B, 0x1F18A, 0x09FEA, 0x00AF8, 0x0FA9F, 0x1F18C,
+ 0x00A30, 0x0106F, 0x1F19F, 0x1F19E, 0x01AD6, 0x005F6,
+ 0x1F1A1, 0x1F1A2, 0x1F1A0, 0x0FAA8, 0x0099E, 0x0FAA9,
+ 0x1F1A3, 0x06375, 0x0459E, 0x07E07, 0x1F1A6, 0x1F1A4,
+ 0x1F1A5, 0x09FEC, 0x0FAAA, 0x1F1A7, 0x09FEB, 0x0FAA4,
+ 0x1F199, 0x1F198, 0x0FAA3, 0x0FAA6, 0x0459D, 0x1F19B,
+ 0x1F19A, 0x0FAA5, 0x01C49, 0x07E06, 0x1F19C, 0x03F56,
+ 0x0077E, 0x05080, 0x1F19D, 0x0FAA7, 0x06374, 0x008A2,
+ 0x1F1B3, 0x1F1B4, 0x0FAAE, 0x1F1B2, 0x00AB0, 0x1F1B6,
+ 0x1F1B5, 0x04980, 0x0384E, 0x0FAAF, 0x1F1B8, 0x1F1B7,
+ 0x06377, 0x04981, 0x1F1BA, 0x1F1B9, 0x07E09, 0x07E0A,
+ 0x1F1BC, 0x1F1BD, 0x1F1BB, 0x0FAB0, 0x1F1AA, 0x1F1AB,
+ 0x1F1AC, 0x1F1A8, 0x1F1A9, 0x0FAAC, 0x07E08, 0x0FAAB,
+ 0x1F1AD, 0x029E3, 0x06376, 0x0FAAD, 0x1F1AE, 0x1F1AF,
+ 0x0459F, 0x1F1B1, 0x1F1B0, 0x01AD7, 0x00822, 0x1DFF2,
+ 0x1DFF3, 0x1DFF1, 0x0FA82, 0x03F52, 0x1DFF5, 0x1DFF4,
+ 0x00BF6, 0x062F8, 0x07DFD, 0x1DFF7, 0x1DFF6, 0x09FE0,
+ 0x062F9, 0x1DFF9, 0x1DFF8, 0x029A6, 0x0FA83, 0x1DFFC,
+ 0x1DFFD, 0x1DFFA, 0x1DFFB, 0x13FC3, 0x17DF6, 0x17DF7,
+ 0x0FA80, 0x0412F, 0x05074, 0x1C24C, 0x05F7C, 0x05F7E,
+ 0x03848, 0x05F7F, 0x1C24E, 0x1C24D, 0x07DFC, 0x01FC6,
+ 0x1DFF0, 0x1C24F, 0x02577, 0x029A7, 0x1EF67, 0x1EF66,
+ 0x024EE, 0x003BE, 0x0FA88, 0x1EF69, 0x1EF68, 0x062FA,
+ 0x0384B, 0x1EF6B, 0x1EF6A, 0x015EF, 0x05076, 0x0FA89,
+ 0x1EF6D, 0x1EF6C, 0x07E00, 0x1EF6F, 0x0FA8A, 0x1EF6E,
+ 0x062FB, 0x1EF60, 0x0FA84, 0x1DFFE, 0x1DFFF, 0x07DFE,
+ 0x0FA85, 0x1EF62, 0x1EF61, 0x03F54, 0x0384A, 0x1EF63,
+ 0x0FA86, 0x00E30, 0x002EC, 0x0FA87, 0x1EF65, 0x1EF64,
+ 0x07DFF, 0x002FE, 0x09FE3, 0x1EF7C, 0x1EF7B, 0x07E01,
+ 0x0095C, 0x1EF7E, 0x1EF7D, 0x01456, 0x0133B, 0x05077,
+ 0x1F0C0, 0x1EF7F, 0x062FD, 0x05078, 0x1F0C2, 0x1F0C1,
+ 0x01C46, 0x03F55, 0x1F0C4, 0x1F0C5, 0x1F0C3, 0x0FA8D,
+ 0x1EF72, 0x1EF73, 0x1EF74, 0x1EF70, 0x1EF71, 0x062FC,
+ 0x1EF75, 0x0FA8B, 0x09FE2, 0x0154E, 0x1EF78, 0x0FA8C,
+ 0x1EF76, 0x1EF77, 0x00F5C, 0x1EF7A, 0x1EF79, 0x00DB2,
+ 0x0106E, 0x1F0D3, 0x1F0D2, 0x00ED0, 0x0045A, 0x07E02,
+ 0x0FA8F, 0x1F0D4, 0x1F0D5, 0x01C48, 0x0FA91, 0x0FA90,
+ 0x025CE, 0x032BE, 0x062FF, 0x1F0D7, 0x1F0D6, 0x0FA92,
+ 0x09FE5, 0x1F0D9, 0x1F0D8, 0x09FE4, 0x1F0C8, 0x1F0C9,
+ 0x1F0C6, 0x1F0C7, 0x05079, 0x1F0CB, 0x1F0CC, 0x1F0CA,
+ 0x0FA8E, 0x0507A, 0x1F0CE, 0x1F0CD, 0x024EF, 0x0018F,
+ 0x1F0D0, 0x1F0D1, 0x1F0CF, 0x062FE, 0x04986, 0x1F211,
+ 0x1F210, 0x029E5, 0x0149C, 0x09FFF, 0x1F212, 0x0FAD5,
+ 0x0FAD6, 0x0FAD8, 0x1F214, 0x1F213, 0x0FAD7, 0x0A000,
+ 0x0A001, 0x1F216, 0x1F215, 0x0FAD9, 0x0A003, 0x0FADA,
+ 0x1F217, 0x0A002, 0x0FAD1, 0x1F205, 0x1F203, 0x1F204,
+ 0x1F207, 0x1F208, 0x1F209, 0x1F206, 0x0FAD2, 0x1F20C,
+ 0x0FAD3, 0x1F20A, 0x1F20B, 0x00E31, 0x0FAD4, 0x1F20F,
+ 0x1F20D, 0x1F20E, 0x003BC, 0x1F221, 0x0FADD, 0x1F21F,
+ 0x1F220, 0x01D2E, 0x1F223, 0x1F222, 0x0384F, 0x0A007,
+ 0x1F225, 0x1F226, 0x07E18, 0x1F224, 0x1F229, 0x1F22A,
+ 0x1F227, 0x1F228, 0x01ADD, 0x0A009, 0x1F22B, 0x0A008,
+ 0x04987, 0x0FADC, 0x07E16, 0x1F218, 0x0FADB, 0x07E15,
+ 0x1F21B, 0x1F21C, 0x1F219, 0x1F21A, 0x0637A, 0x0A005,
+ 0x0A006, 0x07E17, 0x0A004, 0x025F0, 0x1F21E, 0x1F21D,
+ 0x01ADC, 0x05088, 0x1F235, 0x1F234, 0x05087, 0x01978,
+ 0x1F238, 0x07E1A, 0x1F236, 0x1F237, 0x07E1C, 0x1F239,
+ 0x0FAE2, 0x07E1B, 0x1F23B, 0x0A00D, 0x1F23C, 0x1F23A,
+ 0x0FAE3, 0x01979, 0x0A00E, 0x1F23D, 0x04989, 0x1F22E,
+ 0x1F22F, 0x1F22C, 0x1F22D, 0x1F231, 0x0A00A, 0x1F232,
+ 0x0FADE, 0x1F230, 0x04988, 0x0FADF, 0x1F233, 0x07E19,
+ 0x01ADE, 0x0A00C, 0x0FAE1, 0x0FAE0, 0x0A00B, 0x032C2,
+ 0x1F249, 0x1F24A, 0x1F248, 0x0A010, 0x05089, 0x1F24C,
+ 0x0A011, 0x1F24B, 0x0A012, 0x0FAEA, 0x1F24E, 0x0508A,
+ 0x1F24D, 0x0A014, 0x1F250, 0x0A013, 0x1F24F, 0x029E6,
+ 0x07E1D, 0x1F253, 0x1F251, 0x1F252, 0x0FAE4, 0x0FAE5,
+ 0x0FAE6, 0x1F23E, 0x1F23F, 0x1F242, 0x0A00F, 0x1F240,
+ 0x1F241, 0x0FAE8, 0x1F244, 0x1F245, 0x0FAE7, 0x1F243,
+ 0x0FAE9, 0x1F247, 0x1F246, 0x03850, 0x01286, 0x1F25E,
+ 0x1F25D, 0x03851, 0x00D2D, 0x1F260, 0x1F261, 0x1F25F,
+ 0x07E1E, 0x00A68, 0x1F262, 0x0A015, 0x0637C, 0x0508C,
+ 0x0498A, 0x1F265, 0x1F263, 0x1F264, 0x03852, 0x0FAEE,
+ 0x1F266, 0x0A016, 0x0FAEB, 0x0FAEC, 0x1F254, 0x1F255,
+ 0x1F258, 0x0637B, 0x1F259, 0x1F256, 0x1F257, 0x032C3,
+ 0x0FAED, 0x0508B, 0x03F59, 0x01310, 0x032C4, 0x1F25C,
+ 0x1F25A, 0x1F25B, 0x04982, 0x09FEE, 0x1F1C4, 0x00FF3,
+ 0x01457, 0x06378, 0x1F1C6, 0x1F1C5, 0x0FAB4, 0x0287B,
+ 0x0FAB6, 0x0FAB5, 0x00FF6, 0x03F57, 0x0FAB7, 0x09FEF,
+ 0x1F1C7, 0x05083, 0x09FF0, 0x1F1C8, 0x0FAB8, 0x01FC8,
+ 0x09FED, 0x0FAB2, 0x0FAB1, 0x1F1BE, 0x07E0B, 0x05081,
+ 0x0FAB3, 0x1F1BF, 0x024F0, 0x0287A, 0x1F1C1, 0x1F1C0,
+ 0x01FC7, 0x00E5A, 0x05082, 0x1F1C3, 0x1F1C2, 0x07E0C,
+ 0x032C0, 0x0FABE, 0x0FABF, 0x1F1D1, 0x1F1D2, 0x07E10,
+ 0x1F1D5, 0x1F1D3, 0x1F1D4, 0x0FAC2, 0x0FAC3, 0x1F1D6,
+ 0x0FAC0, 0x0FAC1, 0x1F1D9, 0x1F1DA, 0x1F1D7, 0x1F1D8,
+ 0x05085, 0x09FF2, 0x1F1DC, 0x1F1DB, 0x0FAC4, 0x0FAB9,
+ 0x0FABA, 0x1F1CA, 0x07E0D, 0x1F1C9, 0x1F1CB, 0x1F1CC,
+ 0x07E0E, 0x0FABB, 0x0FABD, 0x1F1CD, 0x1F1CE, 0x0FABC,
+ 0x09FF1, 0x07E0F, 0x1F1D0, 0x1F1CF, 0x05084, 0x0287C,
+ 0x1F1E6, 0x1F1E5, 0x03F58, 0x0287D, 0x09FF6, 0x1F1E9,
+ 0x1F1E7, 0x1F1E8, 0x07E13, 0x09FF8, 0x1F1EA, 0x09FF7,
+ 0x1F1ED, 0x09FF9, 0x0FAC8, 0x1F1EB, 0x1F1EC, 0x09FFB,
+ 0x04984, 0x09FFA, 0x04983, 0x09FF3, 0x1F1DE, 0x1F1DD,
+ 0x07E11, 0x1F1DF, 0x1F1E0, 0x0FAC6, 0x09FF4, 0x0FAC5,
+ 0x07E12, 0x1F1E2, 0x1F1E1, 0x05086, 0x00ED2, 0x09FF5,
+ 0x1F1E4, 0x1F1E3, 0x0FAC7, 0x004D4, 0x1F1F9, 0x1F1FA,
+ 0x09FFC, 0x0FACD, 0x029E4, 0x0FACE, 0x1F1FB, 0x0287E,
+ 0x09FFD, 0x0FAD0, 0x1F1FC, 0x0FACF, 0x06379, 0x1F1FE,
+ 0x1F1FF, 0x1F1FD, 0x09FFE, 0x04985, 0x07E14, 0x1F202,
+ 0x1F200, 0x1F201, 0x1F1EF, 0x1F1F0, 0x1F1F1, 0x1F1EE,
+ 0x0FAC9, 0x1F1F3, 0x1F1F4, 0x1F1F2, 0x0FACA, 0x032C1,
+ 0x1F1F6, 0x0FACC, 0x1F1F5, 0x0FACB, 0x01C9F, 0x1F1F8,
+ 0x1F1F7, 0x01FC9, 0x000EC, 0x0650B, 0x0650C, 0x07E2B,
+ 0x029EC, 0x00DB6, 0x0FB04, 0x1F298, 0x0098C, 0x01FCC,
+ 0x0650D, 0x07E2C, 0x0FB05, 0x0FB06, 0x0FB08, 0x1F29A,
+ 0x1F299, 0x0FB07, 0x00ED3, 0x05094, 0x1F29B, 0x07E2D,
+ 0x0FB09, 0x03855, 0x06508, 0x0FB02, 0x1F292, 0x0FB01,
+ 0x1F295, 0x1F296, 0x1F293, 0x1F294, 0x05093, 0x0FB03,
+ 0x0650A, 0x07E2A, 0x06509, 0x00BB6, 0x0A02B, 0x1F297,
+ 0x00A54, 0x00708, 0x1F2A2, 0x1F2A1, 0x007A8, 0x004CA,
+ 0x029EE, 0x07E2F, 0x05095, 0x0197B, 0x01C4A, 0x0A02D,
+ 0x07E30, 0x01FCD, 0x0FB0C, 0x0650F, 0x0FB0D, 0x1F2A3,
+ 0x0650E, 0x01D78, 0x06510, 0x07E31, 0x07E32, 0x04993,
+ 0x07E2E, 0x0A02C, 0x03F5D, 0x1F29E, 0x1F29F, 0x03856,
+ 0x1F29C, 0x1F29D, 0x03857, 0x0FB0A, 0x1F2A0, 0x029ED,
+ 0x004B8, 0x024F5, 0x03F5E, 0x0FB0B, 0x03858, 0x008AC,
+ 0x0FB13, 0x07E35, 0x0FB12, 0x06512, 0x01C4C, 0x07E36,
+ 0x0FB14, 0x01550, 0x02882, 0x07E37, 0x07E38, 0x06513,
+ 0x05096, 0x06514, 0x0A032, 0x1F2A7, 0x1F2A8, 0x006E7,
+ 0x032CA, 0x1F2A9, 0x0FB15, 0x029EF, 0x07E34, 0x0A02E,
+ 0x0A02F, 0x0FB0E, 0x07E33, 0x0FB10, 0x06511, 0x1F2A4,
+ 0x0FB0F, 0x04994, 0x02881, 0x0A031, 0x0A030, 0x0FB11,
+ 0x01289, 0x1F2A6, 0x1F2A5, 0x01C4B, 0x05098, 0x1F2AE,
+ 0x1F2AD, 0x07E3A, 0x06519, 0x1F2AF, 0x1F2B0, 0x0FB19,
+ 0x0A038, 0x05099, 0x1F2B2, 0x1F2B1, 0x07E3B, 0x0FB1A,
+ 0x1F2B4, 0x1F2B5, 0x04995, 0x1F2B3, 0x0149D, 0x03F60,
+ 0x0FB1B, 0x025F2, 0x0A033, 0x06516, 0x06515, 0x03F5F,
+ 0x0A035, 0x1F2AA, 0x07E39, 0x0A034, 0x0FB16, 0x06517,
+ 0x1F2AC, 0x1F2AB, 0x0FB17, 0x05097, 0x0A036, 0x0A037,
+ 0x0FB18, 0x06518, 0x0031A, 0x0A03C, 0x1F2BA, 0x1F2B9,
+ 0x07E3F, 0x0057E, 0x0FB1C, 0x1F2BB, 0x00F5E, 0x01551,
+ 0x025F3, 0x1F2BC, 0x07E40, 0x04996, 0x00BB8, 0x1F2BD,
+ 0x04997, 0x0385A, 0x00E32, 0x0651D, 0x1F2BF, 0x1F2BE,
+ 0x07E41, 0x0651A, 0x0A03A, 0x1F2B7, 0x1F2B6, 0x0A039,
+ 0x03859, 0x07E3D, 0x07E3C, 0x0509A, 0x029F0, 0x0651C,
+ 0x0A03B, 0x0651B, 0x07E3E, 0x0096A, 0x1F2B8, 0x0509B,
+ 0x01D79, 0x0073E, 0x0A01C, 0x1F26B, 0x1F26A, 0x0FAF0,
+ 0x01312, 0x0FAF1, 0x1F26C, 0x0074E, 0x00DE2, 0x0637D,
+ 0x0FAF2, 0x1F26D, 0x029E9, 0x025F1, 0x0508D, 0x1F26E,
+ 0x0072A, 0x01288, 0x1F270, 0x1F271, 0x1F26F, 0x0637E,
+ 0x1F267, 0x0A018, 0x0498B, 0x0A017, 0x029E7, 0x0A019,
+ 0x0A01A, 0x1F268, 0x029E8, 0x0175C, 0x0287F, 0x0A01B,
+ 0x1F269, 0x03F5A, 0x02880, 0x0498C, 0x0FAEF, 0x00DB5,
+ 0x07E1F, 0x1F27B, 0x1F27A, 0x0FAF4, 0x024F1, 0x1F27E,
+ 0x0A01F, 0x1F27C, 0x1F27D, 0x0FAF5, 0x1F280, 0x1F27F,
+ 0x06502, 0x0FAF6, 0x1F282, 0x07E21, 0x07E20, 0x1F281,
+ 0x029EA, 0x07E23, 0x07E22, 0x0154F, 0x0637F, 0x06500,
+ 0x0498D, 0x0FAF3, 0x1F272, 0x1F273, 0x0A01D, 0x0508E,
+ 0x032C5, 0x1F275, 0x1F276, 0x1F274, 0x06501, 0x03853,
+ 0x0A01E, 0x1F279, 0x1F277, 0x1F278, 0x0074F, 0x03854,
+ 0x032C7, 0x0FAFA, 0x1F286, 0x029EB, 0x07E25, 0x0A024,
+ 0x024F3, 0x01FCA, 0x0508F, 0x032C8, 0x1F287, 0x0A025,
+ 0x07E26, 0x0A026, 0x1F288, 0x1F289, 0x006E6, 0x0498E,
+ 0x1F28B, 0x1F28A, 0x032C9, 0x032C6, 0x0A021, 0x0A022,
+ 0x0A020, 0x03F5B, 0x1F283, 0x1F284, 0x06503, 0x0FAF7,
+ 0x024F2, 0x07E24, 0x1F285, 0x0FAF8, 0x01313, 0x01ADF,
+ 0x0FAF9, 0x0A023, 0x00AB1, 0x0055E, 0x1F28F, 0x1F28E,
+ 0x00972, 0x005FA, 0x024F4, 0x0FAFE, 0x1F290, 0x04990,
+ 0x020BC, 0x0FAFF, 0x1F291, 0x01D2F, 0x04991, 0x0A02A,
+ 0x05092, 0x0A029, 0x0FB00, 0x04992, 0x06507, 0x06506,
+ 0x01FCB, 0x03F5C, 0x05090, 0x06504, 0x0A027, 0x1F28C,
+ 0x1F28D, 0x07E28, 0x07E27, 0x0A028, 0x05091, 0x0FAFC,
+ 0x0FAFB, 0x0197A, 0x003D6, 0x0FAFD, 0x07E29, 0x0498F,
+ 0x06505, 0x00056, 0x020C0, 0x02888, 0x0005C, 0x0005A,
+ 0x0071E, 0x00CE4, 0x00A32, 0x005D6, 0x00A34, 0x0288A,
+ 0x02889, 0x00A33, 0x049A2, 0x0A046, 0x01D7A, 0x025F9,
+ 0x0A045, 0x01315, 0x01316, 0x07E4B, 0x01458, 0x00676,
+ 0x00F71, 0x01B51, 0x006FD, 0x07E4A, 0x06529, 0x01768,
+ 0x00AB3, 0x07E49, 0x009E4, 0x03F64, 0x050A1, 0x00DE3,
+ 0x00064, 0x008B8, 0x00AB4, 0x00BBB, 0x007FA, 0x0003C,
+ 0x009E7, 0x00AFA, 0x01459, 0x00AB5, 0x001AF, 0x03862,
+ 0x0288C, 0x0019E, 0x00BFD, 0x01C51, 0x0149F, 0x00F73,
+ 0x029FA, 0x07E4C, 0x0A047, 0x1F2D4, 0x03863, 0x00F74,
+ 0x01B52, 0x01B53, 0x050A2, 0x0137D, 0x006E8, 0x008A4,
+ 0x029F9, 0x00E33, 0x006E0, 0x03F65, 0x049A3, 0x1F2D3,
+ 0x03861, 0x00A35, 0x0197C, 0x00F72, 0x012D1, 0x0288B,
+ 0x0015C, 0x01FCF, 0x049A4, 0x001A6, 0x00BBC, 0x1F2D5,
+ 0x0A048, 0x00AB6, 0x0075A, 0x020C2, 0x03864, 0x0104E,
+ 0x050A5, 0x01D7B, 0x0A049, 0x1F2D6, 0x024F8, 0x0652B,
+ 0x1F2D7, 0x03865, 0x025FA, 0x07E4E, 0x014A0, 0x0652C,
+ 0x029FC, 0x00E5D, 0x00CE5, 0x0288D, 0x0098F, 0x006E9,
+ 0x0FB2C, 0x0652A, 0x01C52, 0x0104D, 0x0FB2B, 0x0128B,
+ 0x050A3, 0x07E4D, 0x029FB, 0x00990, 0x01FD0, 0x024F7,
+ 0x050A4, 0x020C1, 0x01B54, 0x1F2DD, 0x0FB30, 0x0FB2E,
+ 0x0FB2F, 0x049A6, 0x1F2DF, 0x1F2DE, 0x0288E, 0x029FD,
+ 0x0FB31, 0x025FD, 0x07E4F, 0x1F2E0, 0x0652E, 0x1F2E2,
+ 0x1F2E1, 0x0A04D, 0x0128C, 0x03F67, 0x0FB33, 0x0FB32,
+ 0x01B55, 0x025FC, 0x03F66, 0x0652D, 0x025FB, 0x0083C,
+ 0x1F2DA, 0x0FB2D, 0x1F2D8, 0x1F2D9, 0x0A04B, 0x050A6,
+ 0x050A7, 0x024F9, 0x0A04A, 0x0A04C, 0x1F2DC, 0x1F2DB,
+ 0x049A5, 0x00538, 0x0FB35, 0x0FB34, 0x01147, 0x0051E,
+ 0x03866, 0x0A04F, 0x1F2E7, 0x024FA, 0x002BC, 0x1F2E8,
+ 0x0FB36, 0x00DE4, 0x01555, 0x050AA, 0x1F2E9, 0x0FB37,
+ 0x0288F, 0x01FD2, 0x1F2EA, 0x0FB38, 0x032D0, 0x0652F,
+ 0x1F2E3, 0x020C3, 0x01FD1, 0x025FE, 0x03F68, 0x0A04E,
+ 0x06530, 0x01769, 0x01D7C, 0x1F2E4, 0x050A8, 0x00ED4,
+ 0x0099F, 0x050A9, 0x1F2E6, 0x1F2E5, 0x06531, 0x00F5F,
+ 0x0FB20, 0x0FB1F, 0x006B4, 0x0067C, 0x029F1, 0x1F2C2,
+ 0x1F2C1, 0x032CB, 0x0149E, 0x0509E, 0x1F2C3, 0x00A6A,
+ 0x00E5B, 0x025F4, 0x0FB21, 0x1F2C4, 0x1F2C5, 0x02883,
+ 0x0651F, 0x0FB22, 0x03F61, 0x0509C, 0x04998, 0x0FB1D,
+ 0x07E42, 0x0175D, 0x0107A, 0x0A03D, 0x07E43, 0x04999,
+ 0x01B50, 0x0509D, 0x0651E, 0x0104A, 0x0137C, 0x0499A,
+ 0x0FB1E, 0x1F2C0, 0x07E44, 0x0385C, 0x07E45, 0x0A040,
+ 0x1F2CA, 0x1F2CB, 0x032CC, 0x1F2CD, 0x1F2CC, 0x0385D,
+ 0x02884, 0x06523, 0x03F63, 0x1F2CE, 0x0FB24, 0x0FB25,
+ 0x1F2D1, 0x1F2CF, 0x1F2D0, 0x00F70, 0x07E46, 0x0FB26,
+ 0x1F2D2, 0x0499C, 0x03F62, 0x0095E, 0x01C4D, 0x0499B,
+ 0x00BF7, 0x06520, 0x1F2C6, 0x0FB23, 0x0A03E, 0x0A03F,
+ 0x1F2C7, 0x025F5, 0x0385B, 0x06521, 0x0509F, 0x1F2C9,
+ 0x1F2C8, 0x06522, 0x00AF9, 0x0A042, 0x0FB27, 0x00A56,
+ 0x006DE, 0x029F2, 0x029F3, 0x032CD, 0x032CE, 0x02886,
+ 0x0385E, 0x07E48, 0x0175F, 0x050A0, 0x0FB29, 0x01C4F,
+ 0x029F4, 0x0FB28, 0x01553, 0x0A043, 0x025F6, 0x01314,
+ 0x006FC, 0x0098E, 0x02885, 0x01552, 0x0A041, 0x06525,
+ 0x0128A, 0x020BD, 0x06524, 0x01C4E, 0x07E47, 0x0499D,
+ 0x00CE2, 0x0071A, 0x06526, 0x01FCE, 0x0175E, 0x024F6,
+ 0x00046, 0x009E2, 0x01C50, 0x00DB7, 0x00BB9, 0x00188,
+ 0x06527, 0x0499E, 0x0017C, 0x00D2F, 0x025F7, 0x00BBA,
+ 0x00DB8, 0x02887, 0x049A1, 0x06528, 0x0499F, 0x049A0,
+ 0x0104C, 0x020BF, 0x0FB2A, 0x029F8, 0x025F8, 0x00A31,
+ 0x0051C, 0x01554, 0x029F5, 0x00BFC, 0x032CF, 0x0A044,
+ 0x0385F, 0x029F6, 0x00AB2, 0x020BE, 0x00E5C, 0x00A57,
+ 0x00D2E, 0x001AC, 0x029F7, 0x03860, 0x00125,
+};
+
+static const uint8_t on2avc_cb7_bits[ON2AVC_CB7_CODES] = {
+ 1, 8, 8, 8, 8, 7,
+ 10, 11, 7, 11, 12, 10,
+ 10, 12, 14, 14, 15, 14,
+ 11, 11, 13, 13, 12, 10,
+ 11, 13, 12, 12, 14, 14,
+ 14, 13, 11, 12, 9, 10,
+ 12, 7, 11, 11, 7, 7,
+ 11, 12, 7, 7, 10, 9,
+ 11, 11, 11, 13, 13, 12,
+ 14, 15, 11, 12, 14, 12,
+ 13, 12, 12, 12, 12, 11,
+ 11, 15, 15, 10, 12, 15,
+ 12, 12, 14, 11, 7, 10,
+ 8, 11, 11, 11, 16, 13,
+ 12, 14, 12, 16, 15, 12,
+ 13, 14, 14, 12, 14, 17,
+ 15, 16, 16, 12, 14, 16,
+ 14, 12, 12, 13, 16, 14,
+ 12, 17, 16, 16, 15, 13,
+ 13, 14, 12, 14, 12, 16,
+ 16, 12, 16, 17, 16, 17,
+ 15, 16, 16, 15, 17, 15,
+ 17, 17, 16, 17, 16, 15,
+ 14, 16, 14, 16, 14, 11,
+ 14, 16, 15, 11, 17, 17,
+ 15, 13, 17, 16, 17, 17,
+ 15, 14, 17, 15, 14, 16,
+ 11, 16, 17, 16, 14, 12,
+ 17, 15, 12, 13, 15, 17,
+ 16, 13, 15, 17, 16, 13,
+ 15, 16, 17, 15, 13, 14,
+ 16, 17, 17, 14, 14, 16,
+ 16, 13, 12, 15, 17, 16,
+ 14, 11, 15, 15, 12, 10,
+ 14, 16, 16, 16, 12, 15,
+ 16, 12, 12, 13, 15, 17,
+ 14, 12, 15, 17, 14, 14,
+ 15, 16, 16, 16, 16, 16,
+ 16, 16, 16, 12, 16, 17,
+ 14, 11, 13, 15, 17, 15,
+ 12, 14, 16, 11, 14, 17,
+ 17, 14, 15, 17, 14, 17,
+ 16, 15, 17, 15, 14, 17,
+ 15, 14, 17, 17, 12, 15,
+ 16, 14, 12, 13, 16, 13,
+ 16, 16, 15, 16, 16, 16,
+ 17, 17, 16, 14, 16, 14,
+ 17, 17, 11, 14, 12, 13,
+ 15, 12, 14, 15, 12, 13,
+ 14, 12, 13, 14, 14, 16,
+ 17, 15, 11, 12, 14, 15,
+ 13, 12, 12, 14, 14, 13,
+ 15, 17, 16, 16, 14, 14,
+ 13, 13, 14, 12, 16, 17,
+ 12, 7, 12, 12, 7, 7,
+ 11, 11, 8, 10, 11, 13,
+ 13, 11, 15, 14, 12, 10,
+ 14, 11, 11, 13, 12, 11,
+ 12, 13, 12, 15, 14, 12,
+ 11, 14, 11, 15, 13, 11,
+ 7, 11, 11, 9, 10, 7,
+ 13, 14, 7, 7, 12, 12,
+ 12, 11, 12, 17, 14, 12,
+ 14, 16, 14, 14, 14, 11,
+ 12, 12, 11, 13, 15, 14,
+ 13, 15, 16, 14, 14, 15,
+ 12, 14, 14, 12, 7, 11,
+ 12, 12, 11, 7, 12, 13,
+ 13, 12, 9, 14, 14, 9,
+ 12, 12, 12, 13, 13, 14,
+ 15, 14, 14, 12, 11, 14,
+ 13, 11, 12, 13, 14, 14,
+ 13, 15, 15, 16, 14, 12,
+ 14, 12, 12, 14, 9, 14,
+ 13, 9, 12, 17, 15, 12,
+ 12, 14, 13, 13, 13, 13,
+ 14, 16, 13, 16, 15, 12,
+ 14, 16, 13, 14, 12, 11,
+ 13, 17, 15, 13, 15, 17,
+ 15, 13, 15, 13, 15, 17,
+ 13, 11, 14, 15, 13, 13,
+ 14, 17, 17, 17, 16, 14,
+ 17, 16, 15, 16, 17, 16,
+ 14, 15, 17, 15, 17, 16,
+ 14, 14, 14, 15, 12, 13,
+ 14, 17, 16, 14, 16, 17,
+ 17, 17, 14, 17, 17, 15,
+ 17, 15, 17, 16, 16, 11,
+ 17, 16, 12, 12, 17, 17,
+ 15, 15, 14, 17, 14, 13,
+ 14, 16, 16, 15, 13, 14,
+ 16, 14, 13, 14, 15, 17,
+ 14, 12, 14, 17, 16, 14,
+ 12, 16, 14, 13, 11, 15,
+ 17, 16, 13, 12, 15, 17,
+ 10, 12, 13, 16, 17, 14,
+ 13, 14, 15, 12, 13, 14,
+ 15, 17, 14, 14, 16, 15,
+ 14, 14, 17, 17, 14, 13,
+ 14, 16, 17, 15, 13, 15,
+ 15, 12, 11, 14, 17, 16,
+ 14, 13, 16, 15, 17, 16,
+ 15, 17, 16, 15, 15, 17,
+ 15, 16, 17, 16, 17, 17,
+ 17, 13, 12, 14, 17, 14,
+ 13, 15, 14, 17, 14, 14,
+ 16, 15, 16, 14, 15, 14,
+ 15, 17, 14, 17, 17, 15,
+ 12, 17, 17, 12, 12, 14,
+ 13, 14, 13, 14, 16, 15,
+ 13, 15, 17, 13, 13, 14,
+ 11, 13, 14, 13, 12, 14,
+ 15, 13, 17, 15, 14, 15,
+ 16, 13, 16, 16, 14, 12,
+ 14, 13, 14, 14, 7, 12,
+ 13, 12, 12, 9, 14, 14,
+ 9, 12, 14, 12, 12, 12,
+ 14, 15, 15, 15, 11, 11,
+ 13, 13, 12, 12, 13, 15,
+ 14, 14, 15, 16, 15, 15,
+ 12, 14, 12, 13, 14, 9,
+ 14, 13, 9, 8, 15, 15,
+ 15, 15, 12, 16, 16, 12,
+ 14, 15, 15, 15, 16, 17,
+ 17, 17, 17, 16, 15, 15,
+ 17, 15, 14, 15, 17, 16,
+ 15, 15, 17, 17, 16, 13,
+ 15, 15, 15, 15, 12, 15,
+ 16, 11, 12, 17, 16, 11,
+ 11, 15, 15, 15, 14, 14,
+ 15, 17, 14, 17, 15, 16,
+ 16, 16, 14, 17, 15, 15,
+ 13, 16, 15, 14, 15, 16,
+ 17, 15, 16, 14, 15, 16,
+ 13, 11, 14, 15, 16, 14,
+ 12, 16, 16, 16, 14, 12,
+ 16, 17, 13, 14, 13, 16,
+ 17, 16, 15, 15, 17, 17,
+ 14, 15, 15, 15, 15, 12,
+ 14, 17, 16, 15, 15, 17,
+ 17, 17, 15, 16, 16, 14,
+ 16, 13, 17, 16, 14, 15,
+ 16, 17, 15, 16, 16, 17,
+ 15, 16, 14, 17, 17, 16,
+ 16, 14, 15, 17, 17, 15,
+ 14, 14, 15, 13, 16, 17,
+ 14, 16, 17, 16, 16, 16,
+ 16, 17, 17, 16, 14, 17,
+ 16, 15, 16, 11, 17, 17,
+ 16, 16, 13, 17, 16, 14,
+ 14, 16, 17, 15, 15, 13,
+ 16, 15, 15, 15, 16, 15,
+ 16, 15, 12, 15, 17, 16,
+ 15, 12, 15, 16, 13, 12,
+ 15, 16, 17, 14, 11, 17,
+ 16, 13, 12, 15, 17, 17,
+ 15, 13, 16, 15, 12, 13,
+ 15, 17, 17, 14, 15, 17,
+ 15, 14, 17, 15, 17, 17,
+ 16, 12, 17, 17, 17, 16,
+ 14, 15, 17, 11, 13, 15,
+ 17, 16, 15, 12, 17, 17,
+ 11, 15, 17, 17, 16, 14,
+ 17, 15, 17, 16, 14, 17,
+ 17, 15, 16, 17, 14, 16,
+ 17, 14, 17, 16, 15, 14,
+ 17, 17, 12, 17, 17, 17,
+ 15, 15, 17, 16, 17, 15,
+ 14, 17, 14, 16, 17, 12,
+ 14, 17, 16, 17, 13, 17,
+ 16, 13, 15, 16, 15, 16,
+ 14, 15, 17, 17, 15, 14,
+ 14, 16, 17, 14, 11, 15,
+ 16, 16, 14, 16, 17, 17,
+ 15, 14, 15, 15, 15, 15,
+ 13, 15, 17, 14, 11, 17,
+ 17, 12, 11, 15, 17, 17,
+ 15, 14, 17, 16, 14, 17,
+ 17, 15, 15, 16, 15, 15,
+ 16, 14, 14, 15, 15, 15,
+ 16, 17, 15, 15, 16, 14,
+ 15, 16, 13, 11, 14, 16,
+ 17, 14, 13, 17, 17, 14,
+ 12, 16, 16, 17, 16, 17,
+ 17, 17, 16, 17, 17, 17,
+ 17, 17, 17, 17, 16, 17,
+ 17, 17, 17, 17, 17, 17,
+ 16, 17, 17, 16, 17, 17,
+ 16, 13, 16, 17, 16, 16,
+ 11, 17, 17, 17, 16, 15,
+ 17, 17, 14, 16, 16, 17,
+ 16, 17, 17, 17, 17, 17,
+ 17, 16, 16, 17, 15, 15,
+ 17, 17, 16, 15, 16, 17,
+ 16, 16, 15, 16, 17, 16,
+ 14, 13, 17, 17, 13, 15,
+ 17, 17, 14, 12, 17, 17,
+ 16, 15, 15, 17, 17, 15,
+ 17, 16, 17, 16, 17, 17,
+ 17, 17, 16, 13, 16, 17,
+ 16, 17, 17, 17, 17, 17,
+ 16, 17, 15, 16, 13, 16,
+ 16, 16, 15, 16, 17, 17,
+ 17, 17, 16, 17, 17, 16,
+ 17, 16, 16, 16, 15, 16,
+ 15, 17, 17, 17, 16, 15,
+ 16, 16, 15, 15, 16, 17,
+ 16, 17, 17, 17, 17, 16,
+ 17, 17, 16, 17, 16, 17,
+ 16, 16, 12, 17, 16, 14,
+ 13, 16, 17, 17, 15, 14,
+ 17, 17, 14, 16, 16, 17,
+ 16, 15, 17, 15, 17, 17,
+ 14, 17, 17, 15, 13, 14,
+ 17, 15, 16, 12, 16, 16,
+ 15, 12, 16, 17, 17, 15,
+ 14, 16, 17, 12, 12, 16,
+ 16, 16, 17, 14, 16, 16,
+ 13, 15, 16, 17, 17, 15,
+ 15, 16, 16, 16, 15, 17,
+ 17, 14, 14, 15, 17, 17,
+ 15, 14, 17, 15, 12, 12,
+ 14, 17, 17, 15, 14, 17,
+ 17, 17, 17, 15, 16, 17,
+ 15, 17, 16, 17, 15, 17,
+ 17, 16, 16, 16, 15, 16,
+ 17, 17, 15, 15, 16, 17,
+ 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 15,
+ 17, 17, 15, 14, 17, 17,
+ 14, 14, 16, 16, 17, 16,
+ 16, 17, 16, 15, 17, 17,
+ 16, 16, 17, 16, 16, 17,
+ 15, 15, 17, 17, 15, 17,
+ 17, 15, 15, 16, 16, 16,
+ 17, 15, 13, 17, 17, 17,
+ 17, 11, 16, 17, 17, 16,
+ 14, 17, 17, 14, 16, 17,
+ 17, 15, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 16,
+ 14, 16, 17, 16, 16, 17,
+ 16, 17, 16, 17, 16, 17,
+ 17, 17, 15, 16, 17, 15,
+ 9, 17, 17, 17, 16, 12,
+ 17, 17, 13, 15, 15, 17,
+ 17, 16, 16, 17, 17, 16,
+ 16, 17, 17, 17, 17, 16,
+ 17, 17, 17, 16, 15, 17,
+ 17, 16, 13, 17, 17, 17,
+ 15, 13, 17, 17, 13, 12,
+ 17, 17, 12, 9, 15, 17,
+ 17, 15, 14, 17, 17, 15,
+ 16, 17, 17, 16, 16, 17,
+ 17, 17, 16, 17, 17, 17,
+ 17, 14, 17, 17, 17, 16,
+ 14, 17, 17, 13, 11, 16,
+ 17, 17, 14, 10, 16, 17,
+ 17, 16, 12, 16, 17, 12,
+ 14, 16, 17, 17, 15, 16,
+ 17, 17, 16, 17, 17, 17,
+ 17, 17, 15, 17, 17, 17,
+ 17, 14, 16, 17, 15, 12,
+ 15, 16, 17, 15, 11, 17,
+ 17, 12, 13, 17, 17, 14,
+ 10, 16, 17, 17, 16, 13,
+ 16, 16, 14, 17, 15, 17,
+ 17, 17, 17, 17, 17, 17,
+ 15, 17, 16, 16, 15, 17,
+ 17, 17, 15, 13, 17, 16,
+ 14, 11, 16, 17, 17, 15,
+ 11, 16, 17, 17, 16, 12,
+ 17, 16, 14, 14, 17, 17,
+ 17, 16, 13, 16, 17, 15,
+ 17, 17, 17, 17, 17, 17,
+ 16, 17, 17, 17, 14, 16,
+ 17, 16, 15, 16, 17, 17,
+ 15, 12, 17, 16, 14, 11,
+ 17, 17, 17, 15, 14, 17,
+ 17, 14, 15, 17, 16, 17,
+ 17, 17, 16, 16, 17, 17,
+ 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17,
+ 14, 14, 17, 17, 17, 17,
+ 14, 17, 17, 12, 14, 17,
+ 17, 14, 11, 16, 17, 17,
+ 15, 15, 16, 17, 13, 17,
+ 16, 17, 17, 15, 17, 17,
+ 17, 16, 16, 17, 16, 14,
+ 15, 16, 17, 17, 15, 15,
+ 17, 17, 13, 11, 15, 17,
+ 17, 16, 10, 16, 16, 17,
+ 16, 12, 17, 17, 12, 14,
+ 15, 17, 17, 15, 16, 17,
+ 15, 15, 17, 16, 17, 16,
+ 16, 15, 16, 17, 17, 16,
+ 15, 17, 17, 14, 13, 14,
+ 16, 17, 14, 12, 17, 16,
+ 13, 12, 16, 17, 13, 9,
+ 15, 17, 17, 16, 15, 17,
+ 17, 14, 16, 16, 17, 17,
+ 16, 16, 17, 17, 17, 15,
+ 17, 16, 16, 15, 16, 17,
+ 17, 15, 13, 17, 17, 14,
+ 11, 15, 17, 17, 15, 9,
+ 16, 17, 17, 15, 12, 17,
+ 16, 13, 14, 17, 17, 17,
+ 16, 16, 17, 17, 15, 16,
+ 17, 17, 16, 17, 17, 17,
+ 17, 17, 17, 17, 17, 16,
+ 16, 15, 17, 17, 17, 15,
+ 12, 17, 16, 12, 12, 16,
+ 17, 12, 10, 17, 17, 17,
+ 14, 14, 17, 17, 14, 14,
+ 16, 17, 17, 15, 16, 17,
+ 17, 17, 16, 17, 16, 17,
+ 14, 17, 17, 17, 16, 13,
+ 17, 17, 14, 9, 15, 17,
+ 17, 15, 10, 15, 17, 17,
+ 15, 12, 17, 17, 13, 13,
+ 16, 17, 17, 15, 14, 17,
+ 17, 14, 17, 16, 16, 17,
+ 17, 17, 17, 17, 17, 17,
+ 15, 17, 16, 15, 14, 15,
+ 17, 17, 16, 12, 16, 17,
+ 12, 13, 17, 17, 13, 11,
+ 17, 17, 17, 16, 12, 16,
+ 17, 15, 15, 15, 17, 17,
+ 17, 16, 16, 17, 16, 16,
+ 17, 17, 16, 16, 15, 17,
+ 17, 16, 13, 15, 17, 14,
+ 11, 15, 17, 16, 15, 12,
+ 17, 17, 16, 17, 12, 17,
+ 17, 15, 14, 16, 17, 17,
+ 15, 15, 17, 17, 15, 15,
+ 17, 17, 17, 16, 17, 17,
+ 17, 17, 17, 16, 15, 16,
+ 17, 14, 15, 16, 17, 17,
+ 15, 17, 17, 13, 12, 17,
+ 17, 17, 16, 14, 17, 17,
+ 12, 15, 15, 17, 17, 16,
+ 15, 17, 17, 14, 16, 17,
+ 17, 17, 17, 17, 17, 17,
+ 16, 15, 15, 17, 15, 15,
+ 14, 15, 17, 17, 15, 13,
+ 17, 17, 14, 14, 17, 17,
+ 14, 10, 16, 17, 17, 15,
+ 14, 17, 17, 13, 15, 16,
+ 17, 17, 15, 17, 16, 17,
+ 15, 17, 16, 17, 17, 15,
+ 16, 17, 17, 14, 14, 17,
+ 16, 12, 10, 16, 17, 17,
+ 15, 10, 16, 17, 17, 15,
+ 12, 17, 17, 13, 13, 15,
+ 17, 17, 15, 15, 17, 17,
+ 13, 14, 17, 17, 17, 16,
+ 17, 17, 17, 17, 17, 15,
+ 17, 16, 16, 13, 17, 16,
+ 17, 17, 12, 17, 17, 12,
+ 13, 17, 17, 12, 11, 15,
+ 16, 17, 17, 13, 16, 16,
+ 14, 14, 15, 17, 17, 16,
+ 16, 17, 17, 16, 17, 17,
+ 17, 17, 15, 17, 17, 17,
+ 16, 15, 17, 17, 14, 9,
+ 17, 17, 17, 15, 15, 17,
+ 17, 14, 13, 16, 17, 16,
+ 16, 16, 17, 17, 16, 16,
+ 16, 17, 17, 16, 16, 16,
+ 17, 16, 16, 17, 17, 17,
+ 17, 17, 17, 17, 16, 17,
+ 16, 17, 17, 12, 16, 17,
+ 17, 17, 10, 17, 16, 17,
+ 17, 13, 17, 17, 14, 16,
+ 17, 17, 15, 17, 17, 17,
+ 17, 17, 13, 16, 17, 16,
+ 15, 16, 15, 17, 16, 15,
+ 17, 17, 17, 17, 15, 16,
+ 16, 15, 16, 14, 17, 17,
+ 13, 15, 17, 17, 15, 13,
+ 17, 15, 17, 17, 15, 17,
+ 16, 15, 17, 16, 17, 17,
+ 16, 13, 16, 17, 15, 17,
+ 17, 17, 17, 17, 16, 17,
+ 16, 17, 15, 16, 17, 15,
+ 13, 16, 16, 16, 16, 14,
+ 17, 17, 17, 16, 15, 17,
+ 16, 17, 16, 16, 17, 15,
+ 17, 16, 17, 16, 17, 14,
+ 15, 17, 17, 17, 16, 16,
+ 16, 17, 17, 17, 16, 17,
+ 17, 16, 17, 17, 16, 17,
+ 16, 17, 17, 14, 13, 17,
+ 17, 14, 12, 17, 17, 17,
+ 15, 12, 17, 16, 15, 15,
+ 15, 17, 17, 17, 14, 16,
+ 17, 16, 16, 16, 17, 17,
+ 17, 15, 17, 17, 17, 14,
+ 16, 15, 14, 13, 14, 17,
+ 17, 17, 15, 16, 17, 12,
+ 13, 15, 17, 17, 16, 14,
+ 16, 16, 12, 14, 16, 16,
+ 17, 15, 16, 17, 16, 13,
+ 16, 16, 16, 17, 15, 15,
+ 16, 17, 14, 14, 17, 17,
+ 13, 12, 15, 17, 17, 15,
+ 14, 16, 16, 17, 17, 15,
+ 17, 17, 17, 16, 16, 17,
+ 16, 16, 17, 17, 17, 17,
+ 15, 16, 17, 17, 16, 16,
+ 16, 17, 15, 17, 17, 17,
+ 15, 16, 16, 17, 17, 16,
+ 16, 15, 17, 17, 15, 14,
+ 17, 17, 14, 14, 16, 17,
+ 17, 17, 15, 16, 17, 16,
+ 17, 16, 16, 17, 17, 16,
+ 15, 16, 15, 16, 17, 17,
+ 15, 17, 17, 16, 16, 16,
+ 15, 17, 17, 15, 12, 16,
+ 17, 17, 16, 11, 17, 17,
+ 16, 16, 14, 16, 17, 14,
+ 16, 16, 17, 16, 15, 17,
+ 17, 17, 16, 15, 15, 17,
+ 17, 17, 17, 17, 17, 17,
+ 16, 17, 17, 17, 16, 14,
+ 17, 16, 17, 16, 13, 17,
+ 17, 13, 8, 15, 15, 15,
+ 14, 12, 16, 17, 12, 13,
+ 15, 15, 16, 16, 16, 17,
+ 17, 16, 12, 15, 17, 15,
+ 16, 14, 15, 16, 17, 16,
+ 17, 17, 17, 17, 15, 16,
+ 15, 15, 15, 12, 16, 17,
+ 12, 11, 17, 17, 11, 11,
+ 14, 15, 15, 13, 13, 16,
+ 15, 13, 16, 15, 16, 17,
+ 15, 13, 15, 15, 15, 15,
+ 15, 16, 14, 17, 17, 14,
+ 17, 17, 14, 16, 17, 14,
+ 11, 14, 14, 16, 14, 12,
+ 16, 15, 16, 15, 13, 15,
+ 16, 13, 14, 15, 15, 15,
+ 15, 15, 16, 17, 17, 11,
+ 14, 17, 16, 14, 15, 16,
+ 16, 16, 15, 16, 15, 17,
+ 16, 15, 14, 16, 16, 16,
+ 13, 17, 17, 13, 15, 17,
+ 17, 15, 15, 17, 17, 16,
+ 16, 15, 17, 17, 15, 16,
+ 17, 17, 15, 17, 13, 14,
+ 16, 14, 16, 15, 15, 14,
+ 16, 17, 15, 16, 16, 15,
+ 17, 17, 16, 15, 16, 16,
+ 16, 15, 10, 16, 17, 17,
+ 15, 11, 16, 17, 12, 13,
+ 14, 17, 15, 15, 12, 17,
+ 15, 14, 12, 15, 17, 17,
+ 15, 15, 16, 17, 17, 16,
+ 14, 15, 15, 15, 14, 15,
+ 16, 15, 15, 12, 17, 15,
+ 13, 11, 16, 17, 17, 16,
+ 13, 16, 17, 11, 12, 15,
+ 16, 17, 14, 14, 15, 17,
+ 11, 13, 17, 17, 17, 15,
+ 17, 16, 15, 16, 14, 16,
+ 16, 17, 14, 13, 14, 16,
+ 17, 14, 14, 15, 16, 12,
+ 15, 17, 17, 16, 14, 17,
+ 16, 17, 17, 16, 17, 17,
+ 15, 16, 17, 15, 15, 17,
+ 14, 15, 15, 13, 15, 15,
+ 15, 16, 17, 17, 16, 15,
+ 14, 17, 17, 17, 15, 14,
+ 16, 17, 17, 17, 11, 14,
+ 14, 16, 17, 14, 15, 16,
+ 14, 13, 15, 14, 17, 16,
+ 15, 16, 17, 17, 11, 15,
+ 17, 17, 14, 14, 16, 16,
+ 16, 14, 17, 17, 15, 16,
+ 14, 15, 17, 16, 13, 13,
+ 16, 16, 12, 11, 17, 17,
+ 12, 11, 14, 16, 17, 15,
+ 14, 16, 17, 13, 15, 16,
+ 15, 16, 16, 15, 15, 15,
+ 13, 14, 15, 15, 16, 17,
+ 17, 15, 15, 16, 15, 16,
+ 16, 13, 10, 16, 15, 15,
+ 15, 7, 14, 14, 7, 7,
+ 11, 12, 12, 11, 12, 14,
+ 14, 12, 15, 16, 13, 14,
+ 16, 13, 13, 15, 13, 11,
+ 12, 13, 11, 15, 15, 13,
+ 12, 15, 12, 14, 15, 12,
+ 7, 12, 12, 12, 11, 6,
+ 12, 12, 13, 12, 9, 14,
+ 14, 9, 12, 13, 13, 12,
+ 14, 15, 16, 17, 14, 12,
+ 13, 13, 15, 13, 11, 12,
+ 14, 12, 11, 14, 15, 17,
+ 14, 12, 13, 12, 13, 14,
+ 9, 13, 15, 9, 12, 17,
+ 16, 12, 11, 14, 14, 13,
+ 15, 13, 16, 17, 14, 15,
+ 17, 14, 14, 15, 13, 15,
+ 14, 12, 12, 14, 12, 11,
+ 16, 15, 13, 13, 16, 13,
+ 15, 15, 14, 12, 13, 14,
+ 15, 14, 13, 17, 16, 16,
+ 16, 15, 17, 17, 14, 14,
+ 16, 14, 15, 17, 15, 17,
+ 17, 16, 13, 14, 16, 16,
+ 13, 14, 14, 15, 14, 12,
+ 17, 16, 17, 17, 16, 15,
+ 15, 14, 16, 16, 17, 17,
+ 15, 11, 16, 16, 13, 11,
+ 14, 16, 17, 14, 10, 17,
+ 16, 12, 13, 15, 17, 16,
+ 14, 13, 17, 16, 14, 15,
+ 17, 14, 13, 14, 14, 16,
+ 15, 13, 13, 17, 15, 12,
+ 12, 15, 17, 17, 15, 12,
+ 16, 16, 11, 11, 14, 17,
+ 17, 14, 13, 15, 17, 12,
+ 12, 14, 16, 17, 17, 14,
+ 15, 16, 14, 15, 15, 16,
+ 15, 13, 13, 16, 15, 15,
+ 13, 15, 15, 13, 13, 15,
+ 16, 17, 15, 14, 15, 16,
+ 17, 17, 14, 17, 17, 14,
+ 14, 15, 14, 17, 16, 16,
+ 17, 17, 17, 12, 15, 16,
+ 17, 15, 14, 12, 13, 15,
+ 12, 15, 17, 16, 16, 16,
+ 17, 14, 14, 15, 15, 17,
+ 17, 15, 12, 16, 16, 12,
+ 11, 14, 14, 14, 14, 14,
+ 14, 15, 13, 15, 16, 13,
+ 14, 16, 13, 16, 14, 13,
+ 11, 12, 14, 13, 16, 15,
+ 13, 14, 15, 13, 15, 15,
+ 12, 11, 15, 13, 13, 14,
+ 7, 12, 13, 12, 12, 9,
+ 15, 15, 9, 12, 14, 12,
+ 12, 14, 15, 15, 15, 15,
+ 13, 14, 16, 14, 14, 12,
+ 11, 13, 14, 12, 14, 16,
+ 14, 14, 12, 14, 12, 12,
+ 12, 9, 14, 14, 9,
+};
+
+static const uint16_t on2avc_cb7_syms[ON2AVC_CB7_CODES] = {
+ 0x0000, 0x0002, 0x0004, 0x000C, 0x000E, 0x0011,
+ 0x0013, 0x001D, 0x001F, 0x0020, 0x0022, 0x0024,
+ 0x002C, 0x002E, 0x0031, 0x0033, 0x003D, 0x003F,
+ 0x0040, 0x0042, 0x0044, 0x004C, 0x004E, 0x00C0,
+ 0x00C2, 0x00C4, 0x00CC, 0x00CE, 0x00D1, 0x00D3,
+ 0x00DD, 0x00DF, 0x00E0, 0x00E2, 0x00E4, 0x00EC,
+ 0x00EE, 0x00F1, 0x00F3, 0x00FD, 0x00FF, 0x0101,
+ 0x0103, 0x010D, 0x010F, 0x0110, 0x0112, 0x0114,
+ 0x011C, 0x011E, 0x0121, 0x0123, 0x012D, 0x012F,
+ 0x0130, 0x0132, 0x0134, 0x013C, 0x013E, 0x0141,
+ 0x0143, 0x014D, 0x014F, 0x01C1, 0x01C3, 0x01CD,
+ 0x01CF, 0x01D0, 0x01D2, 0x01D4, 0x01DC, 0x01DE,
+ 0x01E1, 0x01E3, 0x01ED, 0x01EF, 0x01F0, 0x01F2,
+ 0x01F4, 0x01FC, 0x01FE, 0x0200, 0x0202, 0x0204,
+ 0x020C, 0x020E, 0x0211, 0x0213, 0x021D, 0x021F,
+ 0x0220, 0x0222, 0x0224, 0x022C, 0x022E, 0x0231,
+ 0x0233, 0x023D, 0x023F, 0x0240, 0x0242, 0x0244,
+ 0x024C, 0x024E, 0x02C0, 0x02C2, 0x02C4, 0x02CC,
+ 0x02CE, 0x02D1, 0x02D3, 0x02DD, 0x02DF, 0x02E0,
+ 0x02E2, 0x02E4, 0x02EC, 0x02EE, 0x02F1, 0x02F3,
+ 0x02FD, 0x02FF, 0x0301, 0x0303, 0x030D, 0x030F,
+ 0x0310, 0x0312, 0x0314, 0x031C, 0x031E, 0x0321,
+ 0x0323, 0x032D, 0x032F, 0x0330, 0x0332, 0x0334,
+ 0x033C, 0x033E, 0x0341, 0x0343, 0x034D, 0x034F,
+ 0x03C1, 0x03C3, 0x03CD, 0x03CF, 0x03D0, 0x03D2,
+ 0x03D4, 0x03DC, 0x03DE, 0x03E1, 0x03E3, 0x03ED,
+ 0x03EF, 0x03F0, 0x03F2, 0x03F4, 0x03FC, 0x03FE,
+ 0x0400, 0x0402, 0x0404, 0x040C, 0x040E, 0x0411,
+ 0x0413, 0x041D, 0x041F, 0x0420, 0x0422, 0x0424,
+ 0x042C, 0x042E, 0x0431, 0x0433, 0x043D, 0x043F,
+ 0x0440, 0x0442, 0x0444, 0x044C, 0x044E, 0x04C0,
+ 0x04C2, 0x04C4, 0x04CC, 0x04CE, 0x04D1, 0x04D3,
+ 0x04DD, 0x04DF, 0x04E0, 0x04E2, 0x04E4, 0x04EC,
+ 0x04EE, 0x04F1, 0x04F3, 0x04FD, 0x04FF, 0x0C00,
+ 0x0C02, 0x0C04, 0x0C0C, 0x0C0E, 0x0C11, 0x0C13,
+ 0x0C1D, 0x0C1F, 0x0C20, 0x0C22, 0x0C24, 0x0C2C,
+ 0x0C2E, 0x0C31, 0x0C33, 0x0C3D, 0x0C3F, 0x0C40,
+ 0x0C42, 0x0C44, 0x0C4C, 0x0C4E, 0x0CC0, 0x0CC2,
+ 0x0CC4, 0x0CCC, 0x0CCE, 0x0CD1, 0x0CD3, 0x0CDD,
+ 0x0CDF, 0x0CE0, 0x0CE2, 0x0CE4, 0x0CEC, 0x0CEE,
+ 0x0CF1, 0x0CF3, 0x0CFD, 0x0CFF, 0x0D01, 0x0D03,
+ 0x0D0D, 0x0D0F, 0x0D10, 0x0D12, 0x0D14, 0x0D1C,
+ 0x0D1E, 0x0D21, 0x0D23, 0x0D2D, 0x0D2F, 0x0D30,
+ 0x0D32, 0x0D34, 0x0D3C, 0x0D3E, 0x0D41, 0x0D43,
+ 0x0D4D, 0x0D4F, 0x0DC1, 0x0DC3, 0x0DCD, 0x0DCF,
+ 0x0DD0, 0x0DD2, 0x0DD4, 0x0DDC, 0x0DDE, 0x0DE1,
+ 0x0DE3, 0x0DED, 0x0DEF, 0x0DF0, 0x0DF2, 0x0DF4,
+ 0x0DFC, 0x0DFE, 0x0E00, 0x0E02, 0x0E04, 0x0E0C,
+ 0x0E0E, 0x0E11, 0x0E13, 0x0E1D, 0x0E1F, 0x0E20,
+ 0x0E22, 0x0E24, 0x0E2C, 0x0E2E, 0x0E31, 0x0E33,
+ 0x0E3D, 0x0E3F, 0x0E40, 0x0E42, 0x0E44, 0x0E4C,
+ 0x0E4E, 0x0EC0, 0x0EC2, 0x0EC4, 0x0ECC, 0x0ECE,
+ 0x0ED1, 0x0ED3, 0x0EDD, 0x0EDF, 0x0EE0, 0x0EE2,
+ 0x0EE4, 0x0EEC, 0x0EEE, 0x0EF1, 0x0EF3, 0x0EFD,
+ 0x0EFF, 0x0F01, 0x0F03, 0x0F0D, 0x0F0F, 0x0F10,
+ 0x0F12, 0x0F14, 0x0F1C, 0x0F1E, 0x0F21, 0x0F23,
+ 0x0F2D, 0x0F2F, 0x0F30, 0x0F32, 0x0F34, 0x0F3C,
+ 0x0F3E, 0x0F41, 0x0F43, 0x0F4D, 0x0F4F, 0x0FC1,
+ 0x0FC3, 0x0FCD, 0x0FCF, 0x0FD0, 0x0FD2, 0x0FD4,
+ 0x0FDC, 0x0FDE, 0x0FE1, 0x0FE3, 0x0FED, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FF4, 0x0FFC, 0x0FFE, 0x1001,
+ 0x1003, 0x100D, 0x100F, 0x1010, 0x1012, 0x1014,
+ 0x101C, 0x101E, 0x1021, 0x1023, 0x102D, 0x102F,
+ 0x1030, 0x1032, 0x1034, 0x103C, 0x103E, 0x1041,
+ 0x1043, 0x104D, 0x104F, 0x10C1, 0x10C3, 0x10CD,
+ 0x10CF, 0x10D0, 0x10D2, 0x10D4, 0x10DC, 0x10DE,
+ 0x10E1, 0x10E3, 0x10ED, 0x10EF, 0x10F0, 0x10F2,
+ 0x10F4, 0x10FC, 0x10FE, 0x1100, 0x1102, 0x1104,
+ 0x110C, 0x110E, 0x1111, 0x1113, 0x111D, 0x111F,
+ 0x1120, 0x1122, 0x1124, 0x112C, 0x112E, 0x1131,
+ 0x1133, 0x113D, 0x113F, 0x1140, 0x1142, 0x1144,
+ 0x114C, 0x114E, 0x11C0, 0x11C2, 0x11C4, 0x11CC,
+ 0x11CE, 0x11D1, 0x11D3, 0x11DD, 0x11DF, 0x11E0,
+ 0x11E2, 0x11E4, 0x11EC, 0x11EE, 0x11F1, 0x11F3,
+ 0x11FD, 0x11FF, 0x1201, 0x1203, 0x120D, 0x120F,
+ 0x1210, 0x1212, 0x1214, 0x121C, 0x121E, 0x1221,
+ 0x1223, 0x122D, 0x122F, 0x1230, 0x1232, 0x1234,
+ 0x123C, 0x123E, 0x1241, 0x1243, 0x124D, 0x124F,
+ 0x12C1, 0x12C3, 0x12CD, 0x12CF, 0x12D0, 0x12D2,
+ 0x12D4, 0x12DC, 0x12DE, 0x12E1, 0x12E3, 0x12ED,
+ 0x12EF, 0x12F0, 0x12F2, 0x12F4, 0x12FC, 0x12FE,
+ 0x1300, 0x1302, 0x1304, 0x130C, 0x130E, 0x1311,
+ 0x1313, 0x131D, 0x131F, 0x1320, 0x1322, 0x1324,
+ 0x132C, 0x132E, 0x1331, 0x1333, 0x133D, 0x133F,
+ 0x1340, 0x1342, 0x1344, 0x134C, 0x134E, 0x13C0,
+ 0x13C2, 0x13C4, 0x13CC, 0x13CE, 0x13D1, 0x13D3,
+ 0x13DD, 0x13DF, 0x13E0, 0x13E2, 0x13E4, 0x13EC,
+ 0x13EE, 0x13F1, 0x13F3, 0x13FD, 0x13FF, 0x1401,
+ 0x1403, 0x140D, 0x140F, 0x1410, 0x1412, 0x1414,
+ 0x141C, 0x141E, 0x1421, 0x1423, 0x142D, 0x142F,
+ 0x1430, 0x1432, 0x1434, 0x143C, 0x143E, 0x1441,
+ 0x1443, 0x144D, 0x144F, 0x14C1, 0x14C3, 0x14CD,
+ 0x14CF, 0x14D0, 0x14D2, 0x14D4, 0x14DC, 0x14DE,
+ 0x14E1, 0x14E3, 0x14ED, 0x14EF, 0x14F0, 0x14F2,
+ 0x14F4, 0x14FC, 0x14FE, 0x1C01, 0x1C03, 0x1C0D,
+ 0x1C0F, 0x1C10, 0x1C12, 0x1C14, 0x1C1C, 0x1C1E,
+ 0x1C21, 0x1C23, 0x1C2D, 0x1C2F, 0x1C30, 0x1C32,
+ 0x1C34, 0x1C3C, 0x1C3E, 0x1C41, 0x1C43, 0x1C4D,
+ 0x1C4F, 0x1CC1, 0x1CC3, 0x1CCD, 0x1CCF, 0x1CD0,
+ 0x1CD2, 0x1CD4, 0x1CDC, 0x1CDE, 0x1CE1, 0x1CE3,
+ 0x1CED, 0x1CEF, 0x1CF0, 0x1CF2, 0x1CF4, 0x1CFC,
+ 0x1CFE, 0x1D00, 0x1D02, 0x1D04, 0x1D0C, 0x1D0E,
+ 0x1D11, 0x1D13, 0x1D1D, 0x1D1F, 0x1D20, 0x1D22,
+ 0x1D24, 0x1D2C, 0x1D2E, 0x1D31, 0x1D33, 0x1D3D,
+ 0x1D3F, 0x1D40, 0x1D42, 0x1D44, 0x1D4C, 0x1D4E,
+ 0x1DC0, 0x1DC2, 0x1DC4, 0x1DCC, 0x1DCE, 0x1DD1,
+ 0x1DD3, 0x1DDD, 0x1DDF, 0x1DE0, 0x1DE2, 0x1DE4,
+ 0x1DEC, 0x1DEE, 0x1DF1, 0x1DF3, 0x1DFD, 0x1DFF,
+ 0x1E01, 0x1E03, 0x1E0D, 0x1E0F, 0x1E10, 0x1E12,
+ 0x1E14, 0x1E1C, 0x1E1E, 0x1E21, 0x1E23, 0x1E2D,
+ 0x1E2F, 0x1E30, 0x1E32, 0x1E34, 0x1E3C, 0x1E3E,
+ 0x1E41, 0x1E43, 0x1E4D, 0x1E4F, 0x1EC1, 0x1EC3,
+ 0x1ECD, 0x1ECF, 0x1ED0, 0x1ED2, 0x1ED4, 0x1EDC,
+ 0x1EDE, 0x1EE1, 0x1EE3, 0x1EED, 0x1EEF, 0x1EF0,
+ 0x1EF2, 0x1EF4, 0x1EFC, 0x1EFE, 0x1F00, 0x1F02,
+ 0x1F04, 0x1F0C, 0x1F0E, 0x1F11, 0x1F13, 0x1F1D,
+ 0x1F1F, 0x1F20, 0x1F22, 0x1F24, 0x1F2C, 0x1F2E,
+ 0x1F31, 0x1F33, 0x1F3D, 0x1F3F, 0x1F40, 0x1F42,
+ 0x1F44, 0x1F4C, 0x1F4E, 0x1FC0, 0x1FC2, 0x1FC4,
+ 0x1FCC, 0x1FCE, 0x1FD1, 0x1FD3, 0x1FDD, 0x1FDF,
+ 0x1FE0, 0x1FE2, 0x1FE4, 0x1FEC, 0x1FEE, 0x1FF1,
+ 0x1FF3, 0x1FFD, 0x1FFF, 0x2000, 0x2002, 0x2004,
+ 0x200C, 0x200E, 0x2011, 0x2013, 0x201D, 0x201F,
+ 0x2020, 0x2022, 0x2024, 0x202C, 0x202E, 0x2031,
+ 0x2033, 0x203D, 0x203F, 0x2040, 0x2042, 0x2044,
+ 0x204C, 0x204E, 0x20C0, 0x20C2, 0x20C4, 0x20CC,
+ 0x20CE, 0x20D1, 0x20D3, 0x20DD, 0x20DF, 0x20E0,
+ 0x20E2, 0x20E4, 0x20EC, 0x20EE, 0x20F1, 0x20F3,
+ 0x20FD, 0x20FF, 0x2101, 0x2103, 0x210D, 0x210F,
+ 0x2110, 0x2112, 0x2114, 0x211C, 0x211E, 0x2121,
+ 0x2123, 0x212D, 0x212F, 0x2130, 0x2132, 0x2134,
+ 0x213C, 0x213E, 0x2141, 0x2143, 0x214D, 0x214F,
+ 0x21C1, 0x21C3, 0x21CD, 0x21CF, 0x21D0, 0x21D2,
+ 0x21D4, 0x21DC, 0x21DE, 0x21E1, 0x21E3, 0x21ED,
+ 0x21EF, 0x21F0, 0x21F2, 0x21F4, 0x21FC, 0x21FE,
+ 0x2200, 0x2202, 0x2204, 0x220C, 0x220E, 0x2211,
+ 0x2213, 0x221D, 0x221F, 0x2220, 0x2222, 0x2224,
+ 0x222C, 0x222E, 0x2231, 0x2233, 0x223D, 0x223F,
+ 0x2240, 0x2242, 0x2244, 0x224C, 0x224E, 0x22C0,
+ 0x22C2, 0x22C4, 0x22CC, 0x22CE, 0x22D1, 0x22D3,
+ 0x22DD, 0x22DF, 0x22E0, 0x22E2, 0x22E4, 0x22EC,
+ 0x22EE, 0x22F1, 0x22F3, 0x22FD, 0x22FF, 0x2301,
+ 0x2303, 0x230D, 0x230F, 0x2310, 0x2312, 0x2314,
+ 0x231C, 0x231E, 0x2321, 0x2323, 0x232D, 0x232F,
+ 0x2330, 0x2332, 0x2334, 0x233C, 0x233E, 0x2341,
+ 0x2343, 0x234D, 0x234F, 0x23C1, 0x23C3, 0x23CD,
+ 0x23CF, 0x23D0, 0x23D2, 0x23D4, 0x23DC, 0x23DE,
+ 0x23E1, 0x23E3, 0x23ED, 0x23EF, 0x23F0, 0x23F2,
+ 0x23F4, 0x23FC, 0x23FE, 0x2400, 0x2402, 0x2404,
+ 0x240C, 0x240E, 0x2411, 0x2413, 0x241D, 0x241F,
+ 0x2420, 0x2422, 0x2424, 0x242C, 0x242E, 0x2431,
+ 0x2433, 0x243D, 0x243F, 0x2440, 0x2442, 0x2444,
+ 0x244C, 0x244E, 0x24C0, 0x24C2, 0x24C4, 0x24CC,
+ 0x24CE, 0x24D1, 0x24D3, 0x24DD, 0x24DF, 0x24E0,
+ 0x24E2, 0x24E4, 0x24EC, 0x24EE, 0x24F1, 0x24F3,
+ 0x24FD, 0x24FF, 0x2C00, 0x2C02, 0x2C04, 0x2C0C,
+ 0x2C0E, 0x2C11, 0x2C13, 0x2C1D, 0x2C1F, 0x2C20,
+ 0x2C22, 0x2C24, 0x2C2C, 0x2C2E, 0x2C31, 0x2C33,
+ 0x2C3D, 0x2C3F, 0x2C40, 0x2C42, 0x2C44, 0x2C4C,
+ 0x2C4E, 0x2CC0, 0x2CC2, 0x2CC4, 0x2CCC, 0x2CCE,
+ 0x2CD1, 0x2CD3, 0x2CDD, 0x2CDF, 0x2CE0, 0x2CE2,
+ 0x2CE4, 0x2CEC, 0x2CEE, 0x2CF1, 0x2CF3, 0x2CFD,
+ 0x2CFF, 0x2D01, 0x2D03, 0x2D0D, 0x2D0F, 0x2D10,
+ 0x2D12, 0x2D14, 0x2D1C, 0x2D1E, 0x2D21, 0x2D23,
+ 0x2D2D, 0x2D2F, 0x2D30, 0x2D32, 0x2D34, 0x2D3C,
+ 0x2D3E, 0x2D41, 0x2D43, 0x2D4D, 0x2D4F, 0x2DC1,
+ 0x2DC3, 0x2DCD, 0x2DCF, 0x2DD0, 0x2DD2, 0x2DD4,
+ 0x2DDC, 0x2DDE, 0x2DE1, 0x2DE3, 0x2DED, 0x2DEF,
+ 0x2DF0, 0x2DF2, 0x2DF4, 0x2DFC, 0x2DFE, 0x2E00,
+ 0x2E02, 0x2E04, 0x2E0C, 0x2E0E, 0x2E11, 0x2E13,
+ 0x2E1D, 0x2E1F, 0x2E20, 0x2E22, 0x2E24, 0x2E2C,
+ 0x2E2E, 0x2E31, 0x2E33, 0x2E3D, 0x2E3F, 0x2E40,
+ 0x2E42, 0x2E44, 0x2E4C, 0x2E4E, 0x2EC0, 0x2EC2,
+ 0x2EC4, 0x2ECC, 0x2ECE, 0x2ED1, 0x2ED3, 0x2EDD,
+ 0x2EDF, 0x2EE0, 0x2EE2, 0x2EE4, 0x2EEC, 0x2EEE,
+ 0x2EF1, 0x2EF3, 0x2EFD, 0x2EFF, 0x2F01, 0x2F03,
+ 0x2F0D, 0x2F0F, 0x2F10, 0x2F12, 0x2F14, 0x2F1C,
+ 0x2F1E, 0x2F21, 0x2F23, 0x2F2D, 0x2F2F, 0x2F30,
+ 0x2F32, 0x2F34, 0x2F3C, 0x2F3E, 0x2F41, 0x2F43,
+ 0x2F4D, 0x2F4F, 0x2FC1, 0x2FC3, 0x2FCD, 0x2FCF,
+ 0x2FD0, 0x2FD2, 0x2FD4, 0x2FDC, 0x2FDE, 0x2FE1,
+ 0x2FE3, 0x2FED, 0x2FEF, 0x2FF0, 0x2FF2, 0x2FF4,
+ 0x2FFC, 0x2FFE, 0x3001, 0x3003, 0x300D, 0x300F,
+ 0x3010, 0x3012, 0x3014, 0x301C, 0x301E, 0x3021,
+ 0x3023, 0x302D, 0x302F, 0x3030, 0x3032, 0x3034,
+ 0x303C, 0x303E, 0x3041, 0x3043, 0x304D, 0x304F,
+ 0x30C1, 0x30C3, 0x30CD, 0x30CF, 0x30D0, 0x30D2,
+ 0x30D4, 0x30DC, 0x30DE, 0x30E1, 0x30E3, 0x30ED,
+ 0x30EF, 0x30F0, 0x30F2, 0x30F4, 0x30FC, 0x30FE,
+ 0x3100, 0x3102, 0x3104, 0x310C, 0x310E, 0x3111,
+ 0x3113, 0x311D, 0x311F, 0x3120, 0x3122, 0x3124,
+ 0x312C, 0x312E, 0x3131, 0x3133, 0x313D, 0x313F,
+ 0x3140, 0x3142, 0x3144, 0x314C, 0x314E, 0x31C0,
+ 0x31C2, 0x31C4, 0x31CC, 0x31CE, 0x31D1, 0x31D3,
+ 0x31DD, 0x31DF, 0x31E0, 0x31E2, 0x31E4, 0x31EC,
+ 0x31EE, 0x31F1, 0x31F3, 0x31FD, 0x31FF, 0x3201,
+ 0x3203, 0x320D, 0x320F, 0x3210, 0x3212, 0x3214,
+ 0x321C, 0x321E, 0x3221, 0x3223, 0x322D, 0x322F,
+ 0x3230, 0x3232, 0x3234, 0x323C, 0x323E, 0x3241,
+ 0x3243, 0x324D, 0x324F, 0x32C1, 0x32C3, 0x32CD,
+ 0x32CF, 0x32D0, 0x32D2, 0x32D4, 0x32DC, 0x32DE,
+ 0x32E1, 0x32E3, 0x32ED, 0x32EF, 0x32F0, 0x32F2,
+ 0x32F4, 0x32FC, 0x32FE, 0x3300, 0x3302, 0x3304,
+ 0x330C, 0x330E, 0x3311, 0x3313, 0x331D, 0x331F,
+ 0x3320, 0x3322, 0x3324, 0x332C, 0x332E, 0x3331,
+ 0x3333, 0x333D, 0x333F, 0x3340, 0x3342, 0x3344,
+ 0x334C, 0x334E, 0x33C0, 0x33C2, 0x33C4, 0x33CC,
+ 0x33CE, 0x33D1, 0x33D3, 0x33DD, 0x33DF, 0x33E0,
+ 0x33E2, 0x33E4, 0x33EC, 0x33EE, 0x33F1, 0x33F3,
+ 0x33FD, 0x33FF, 0x3401, 0x3403, 0x340D, 0x340F,
+ 0x3410, 0x3412, 0x3414, 0x341C, 0x341E, 0x3421,
+ 0x3423, 0x342D, 0x342F, 0x3430, 0x3432, 0x3434,
+ 0x343C, 0x343E, 0x3441, 0x3443, 0x344D, 0x344F,
+ 0x34C1, 0x34C3, 0x34CD, 0x34CF, 0x34D0, 0x34D2,
+ 0x34D4, 0x34DC, 0x34DE, 0x34E1, 0x34E3, 0x34ED,
+ 0x34EF, 0x34F0, 0x34F2, 0x34F4, 0x34FC, 0x34FE,
+ 0x3C01, 0x3C03, 0x3C0D, 0x3C0F, 0x3C10, 0x3C12,
+ 0x3C14, 0x3C1C, 0x3C1E, 0x3C21, 0x3C23, 0x3C2D,
+ 0x3C2F, 0x3C30, 0x3C32, 0x3C34, 0x3C3C, 0x3C3E,
+ 0x3C41, 0x3C43, 0x3C4D, 0x3C4F, 0x3CC1, 0x3CC3,
+ 0x3CCD, 0x3CCF, 0x3CD0, 0x3CD2, 0x3CD4, 0x3CDC,
+ 0x3CDE, 0x3CE1, 0x3CE3, 0x3CED, 0x3CEF, 0x3CF0,
+ 0x3CF2, 0x3CF4, 0x3CFC, 0x3CFE, 0x3D00, 0x3D02,
+ 0x3D04, 0x3D0C, 0x3D0E, 0x3D11, 0x3D13, 0x3D1D,
+ 0x3D1F, 0x3D20, 0x3D22, 0x3D24, 0x3D2C, 0x3D2E,
+ 0x3D31, 0x3D33, 0x3D3D, 0x3D3F, 0x3D40, 0x3D42,
+ 0x3D44, 0x3D4C, 0x3D4E, 0x3DC0, 0x3DC2, 0x3DC4,
+ 0x3DCC, 0x3DCE, 0x3DD1, 0x3DD3, 0x3DDD, 0x3DDF,
+ 0x3DE0, 0x3DE2, 0x3DE4, 0x3DEC, 0x3DEE, 0x3DF1,
+ 0x3DF3, 0x3DFD, 0x3DFF, 0x3E01, 0x3E03, 0x3E0D,
+ 0x3E0F, 0x3E10, 0x3E12, 0x3E14, 0x3E1C, 0x3E1E,
+ 0x3E21, 0x3E23, 0x3E2D, 0x3E2F, 0x3E30, 0x3E32,
+ 0x3E34, 0x3E3C, 0x3E3E, 0x3E41, 0x3E43, 0x3E4D,
+ 0x3E4F, 0x3EC1, 0x3EC3, 0x3ECD, 0x3ECF, 0x3ED0,
+ 0x3ED2, 0x3ED4, 0x3EDC, 0x3EDE, 0x3EE1, 0x3EE3,
+ 0x3EED, 0x3EEF, 0x3EF0, 0x3EF2, 0x3EF4, 0x3EFC,
+ 0x3EFE, 0x3F00, 0x3F02, 0x3F04, 0x3F0C, 0x3F0E,
+ 0x3F11, 0x3F13, 0x3F1D, 0x3F1F, 0x3F20, 0x3F22,
+ 0x3F24, 0x3F2C, 0x3F2E, 0x3F31, 0x3F33, 0x3F3D,
+ 0x3F3F, 0x3F40, 0x3F42, 0x3F44, 0x3F4C, 0x3F4E,
+ 0x3FC0, 0x3FC2, 0x3FC4, 0x3FCC, 0x3FCE, 0x3FD1,
+ 0x3FD3, 0x3FDD, 0x3FDF, 0x3FE0, 0x3FE2, 0x3FE4,
+ 0x3FEC, 0x3FEE, 0x3FF1, 0x3FF3, 0x3FFD, 0x3FFF,
+ 0x4000, 0x4002, 0x4004, 0x400C, 0x400E, 0x4011,
+ 0x4013, 0x401D, 0x401F, 0x4020, 0x4022, 0x4024,
+ 0x402C, 0x402E, 0x4031, 0x4033, 0x403D, 0x403F,
+ 0x4040, 0x4042, 0x4044, 0x404C, 0x404E, 0x40C0,
+ 0x40C2, 0x40C4, 0x40CC, 0x40CE, 0x40D1, 0x40D3,
+ 0x40DD, 0x40DF, 0x40E0, 0x40E2, 0x40E4, 0x40EC,
+ 0x40EE, 0x40F1, 0x40F3, 0x40FD, 0x40FF, 0x4101,
+ 0x4103, 0x410D, 0x410F, 0x4110, 0x4112, 0x4114,
+ 0x411C, 0x411E, 0x4121, 0x4123, 0x412D, 0x412F,
+ 0x4130, 0x4132, 0x4134, 0x413C, 0x413E, 0x4141,
+ 0x4143, 0x414D, 0x414F, 0x41C1, 0x41C3, 0x41CD,
+ 0x41CF, 0x41D0, 0x41D2, 0x41D4, 0x41DC, 0x41DE,
+ 0x41E1, 0x41E3, 0x41ED, 0x41EF, 0x41F0, 0x41F2,
+ 0x41F4, 0x41FC, 0x41FE, 0x4200, 0x4202, 0x4204,
+ 0x420C, 0x420E, 0x4211, 0x4213, 0x421D, 0x421F,
+ 0x4220, 0x4222, 0x4224, 0x422C, 0x422E, 0x4231,
+ 0x4233, 0x423D, 0x423F, 0x4240, 0x4242, 0x4244,
+ 0x424C, 0x424E, 0x42C0, 0x42C2, 0x42C4, 0x42CC,
+ 0x42CE, 0x42D1, 0x42D3, 0x42DD, 0x42DF, 0x42E0,
+ 0x42E2, 0x42E4, 0x42EC, 0x42EE, 0x42F1, 0x42F3,
+ 0x42FD, 0x42FF, 0x4301, 0x4303, 0x430D, 0x430F,
+ 0x4310, 0x4312, 0x4314, 0x431C, 0x431E, 0x4321,
+ 0x4323, 0x432D, 0x432F, 0x4330, 0x4332, 0x4334,
+ 0x433C, 0x433E, 0x4341, 0x4343, 0x434D, 0x434F,
+ 0x43C1, 0x43C3, 0x43CD, 0x43CF, 0x43D0, 0x43D2,
+ 0x43D4, 0x43DC, 0x43DE, 0x43E1, 0x43E3, 0x43ED,
+ 0x43EF, 0x43F0, 0x43F2, 0x43F4, 0x43FC, 0x43FE,
+ 0x4400, 0x4402, 0x4404, 0x440C, 0x440E, 0x4411,
+ 0x4413, 0x441D, 0x441F, 0x4420, 0x4422, 0x4424,
+ 0x442C, 0x442E, 0x4431, 0x4433, 0x443D, 0x443F,
+ 0x4440, 0x4442, 0x4444, 0x444C, 0x444E, 0x44C0,
+ 0x44C2, 0x44C4, 0x44CC, 0x44CE, 0x44D1, 0x44D3,
+ 0x44DD, 0x44DF, 0x44E0, 0x44E2, 0x44E4, 0x44EC,
+ 0x44EE, 0x44F1, 0x44F3, 0x44FD, 0x44FF, 0x4C00,
+ 0x4C02, 0x4C04, 0x4C0C, 0x4C0E, 0x4C11, 0x4C13,
+ 0x4C1D, 0x4C1F, 0x4C20, 0x4C22, 0x4C24, 0x4C2C,
+ 0x4C2E, 0x4C31, 0x4C33, 0x4C3D, 0x4C3F, 0x4C40,
+ 0x4C42, 0x4C44, 0x4C4C, 0x4C4E, 0x4CC0, 0x4CC2,
+ 0x4CC4, 0x4CCC, 0x4CCE, 0x4CD1, 0x4CD3, 0x4CDD,
+ 0x4CDF, 0x4CE0, 0x4CE2, 0x4CE4, 0x4CEC, 0x4CEE,
+ 0x4CF1, 0x4CF3, 0x4CFD, 0x4CFF, 0x4D01, 0x4D03,
+ 0x4D0D, 0x4D0F, 0x4D10, 0x4D12, 0x4D14, 0x4D1C,
+ 0x4D1E, 0x4D21, 0x4D23, 0x4D2D, 0x4D2F, 0x4D30,
+ 0x4D32, 0x4D34, 0x4D3C, 0x4D3E, 0x4D41, 0x4D43,
+ 0x4D4D, 0x4D4F, 0x4DC1, 0x4DC3, 0x4DCD, 0x4DCF,
+ 0x4DD0, 0x4DD2, 0x4DD4, 0x4DDC, 0x4DDE, 0x4DE1,
+ 0x4DE3, 0x4DED, 0x4DEF, 0x4DF0, 0x4DF2, 0x4DF4,
+ 0x4DFC, 0x4DFE, 0x4E00, 0x4E02, 0x4E04, 0x4E0C,
+ 0x4E0E, 0x4E11, 0x4E13, 0x4E1D, 0x4E1F, 0x4E20,
+ 0x4E22, 0x4E24, 0x4E2C, 0x4E2E, 0x4E31, 0x4E33,
+ 0x4E3D, 0x4E3F, 0x4E40, 0x4E42, 0x4E44, 0x4E4C,
+ 0x4E4E, 0x4EC0, 0x4EC2, 0x4EC4, 0x4ECC, 0x4ECE,
+ 0x4ED1, 0x4ED3, 0x4EDD, 0x4EDF, 0x4EE0, 0x4EE2,
+ 0x4EE4, 0x4EEC, 0x4EEE, 0x4EF1, 0x4EF3, 0x4EFD,
+ 0x4EFF, 0x4F01, 0x4F03, 0x4F0D, 0x4F0F, 0x4F10,
+ 0x4F12, 0x4F14, 0x4F1C, 0x4F1E, 0x4F21, 0x4F23,
+ 0x4F2D, 0x4F2F, 0x4F30, 0x4F32, 0x4F34, 0x4F3C,
+ 0x4F3E, 0x4F41, 0x4F43, 0x4F4D, 0x4F4F, 0x4FC1,
+ 0x4FC3, 0x4FCD, 0x4FCF, 0x4FD0, 0x4FD2, 0x4FD4,
+ 0x4FDC, 0x4FDE, 0x4FE1, 0x4FE3, 0x4FED, 0x4FEF,
+ 0x4FF0, 0x4FF2, 0x4FF4, 0x4FFC, 0x4FFE, 0xC000,
+ 0xC002, 0xC004, 0xC00C, 0xC00E, 0xC011, 0xC013,
+ 0xC01D, 0xC01F, 0xC020, 0xC022, 0xC024, 0xC02C,
+ 0xC02E, 0xC031, 0xC033, 0xC03D, 0xC03F, 0xC040,
+ 0xC042, 0xC044, 0xC04C, 0xC04E, 0xC0C0, 0xC0C2,
+ 0xC0C4, 0xC0CC, 0xC0CE, 0xC0D1, 0xC0D3, 0xC0DD,
+ 0xC0DF, 0xC0E0, 0xC0E2, 0xC0E4, 0xC0EC, 0xC0EE,
+ 0xC0F1, 0xC0F3, 0xC0FD, 0xC0FF, 0xC101, 0xC103,
+ 0xC10D, 0xC10F, 0xC110, 0xC112, 0xC114, 0xC11C,
+ 0xC11E, 0xC121, 0xC123, 0xC12D, 0xC12F, 0xC130,
+ 0xC132, 0xC134, 0xC13C, 0xC13E, 0xC141, 0xC143,
+ 0xC14D, 0xC14F, 0xC1C1, 0xC1C3, 0xC1CD, 0xC1CF,
+ 0xC1D0, 0xC1D2, 0xC1D4, 0xC1DC, 0xC1DE, 0xC1E1,
+ 0xC1E3, 0xC1ED, 0xC1EF, 0xC1F0, 0xC1F2, 0xC1F4,
+ 0xC1FC, 0xC1FE, 0xC200, 0xC202, 0xC204, 0xC20C,
+ 0xC20E, 0xC211, 0xC213, 0xC21D, 0xC21F, 0xC220,
+ 0xC222, 0xC224, 0xC22C, 0xC22E, 0xC231, 0xC233,
+ 0xC23D, 0xC23F, 0xC240, 0xC242, 0xC244, 0xC24C,
+ 0xC24E, 0xC2C0, 0xC2C2, 0xC2C4, 0xC2CC, 0xC2CE,
+ 0xC2D1, 0xC2D3, 0xC2DD, 0xC2DF, 0xC2E0, 0xC2E2,
+ 0xC2E4, 0xC2EC, 0xC2EE, 0xC2F1, 0xC2F3, 0xC2FD,
+ 0xC2FF, 0xC301, 0xC303, 0xC30D, 0xC30F, 0xC310,
+ 0xC312, 0xC314, 0xC31C, 0xC31E, 0xC321, 0xC323,
+ 0xC32D, 0xC32F, 0xC330, 0xC332, 0xC334, 0xC33C,
+ 0xC33E, 0xC341, 0xC343, 0xC34D, 0xC34F, 0xC3C1,
+ 0xC3C3, 0xC3CD, 0xC3CF, 0xC3D0, 0xC3D2, 0xC3D4,
+ 0xC3DC, 0xC3DE, 0xC3E1, 0xC3E3, 0xC3ED, 0xC3EF,
+ 0xC3F0, 0xC3F2, 0xC3F4, 0xC3FC, 0xC3FE, 0xC400,
+ 0xC402, 0xC404, 0xC40C, 0xC40E, 0xC411, 0xC413,
+ 0xC41D, 0xC41F, 0xC420, 0xC422, 0xC424, 0xC42C,
+ 0xC42E, 0xC431, 0xC433, 0xC43D, 0xC43F, 0xC440,
+ 0xC442, 0xC444, 0xC44C, 0xC44E, 0xC4C0, 0xC4C2,
+ 0xC4C4, 0xC4CC, 0xC4CE, 0xC4D1, 0xC4D3, 0xC4DD,
+ 0xC4DF, 0xC4E0, 0xC4E2, 0xC4E4, 0xC4EC, 0xC4EE,
+ 0xC4F1, 0xC4F3, 0xC4FD, 0xC4FF, 0xCC00, 0xCC02,
+ 0xCC04, 0xCC0C, 0xCC0E, 0xCC11, 0xCC13, 0xCC1D,
+ 0xCC1F, 0xCC20, 0xCC22, 0xCC24, 0xCC2C, 0xCC2E,
+ 0xCC31, 0xCC33, 0xCC3D, 0xCC3F, 0xCC40, 0xCC42,
+ 0xCC44, 0xCC4C, 0xCC4E, 0xCCC0, 0xCCC2, 0xCCC4,
+ 0xCCCC, 0xCCCE, 0xCCD1, 0xCCD3, 0xCCDD, 0xCCDF,
+ 0xCCE0, 0xCCE2, 0xCCE4, 0xCCEC, 0xCCEE, 0xCCF1,
+ 0xCCF3, 0xCCFD, 0xCCFF, 0xCD01, 0xCD03, 0xCD0D,
+ 0xCD0F, 0xCD10, 0xCD12, 0xCD14, 0xCD1C, 0xCD1E,
+ 0xCD21, 0xCD23, 0xCD2D, 0xCD2F, 0xCD30, 0xCD32,
+ 0xCD34, 0xCD3C, 0xCD3E, 0xCD41, 0xCD43, 0xCD4D,
+ 0xCD4F, 0xCDC1, 0xCDC3, 0xCDCD, 0xCDCF, 0xCDD0,
+ 0xCDD2, 0xCDD4, 0xCDDC, 0xCDDE, 0xCDE1, 0xCDE3,
+ 0xCDED, 0xCDEF, 0xCDF0, 0xCDF2, 0xCDF4, 0xCDFC,
+ 0xCDFE, 0xCE00, 0xCE02, 0xCE04, 0xCE0C, 0xCE0E,
+ 0xCE11, 0xCE13, 0xCE1D, 0xCE1F, 0xCE20, 0xCE22,
+ 0xCE24, 0xCE2C, 0xCE2E, 0xCE31, 0xCE33, 0xCE3D,
+ 0xCE3F, 0xCE40, 0xCE42, 0xCE44, 0xCE4C, 0xCE4E,
+ 0xCEC0, 0xCEC2, 0xCEC4, 0xCECC, 0xCECE, 0xCED1,
+ 0xCED3, 0xCEDD, 0xCEDF, 0xCEE0, 0xCEE2, 0xCEE4,
+ 0xCEEC, 0xCEEE, 0xCEF1, 0xCEF3, 0xCEFD, 0xCEFF,
+ 0xCF01, 0xCF03, 0xCF0D, 0xCF0F, 0xCF10, 0xCF12,
+ 0xCF14, 0xCF1C, 0xCF1E, 0xCF21, 0xCF23, 0xCF2D,
+ 0xCF2F, 0xCF30, 0xCF32, 0xCF34, 0xCF3C, 0xCF3E,
+ 0xCF41, 0xCF43, 0xCF4D, 0xCF4F, 0xCFC1, 0xCFC3,
+ 0xCFCD, 0xCFCF, 0xCFD0, 0xCFD2, 0xCFD4, 0xCFDC,
+ 0xCFDE, 0xCFE1, 0xCFE3, 0xCFED, 0xCFEF, 0xCFF0,
+ 0xCFF2, 0xCFF4, 0xCFFC, 0xCFFE, 0xD001, 0xD003,
+ 0xD00D, 0xD00F, 0xD010, 0xD012, 0xD014, 0xD01C,
+ 0xD01E, 0xD021, 0xD023, 0xD02D, 0xD02F, 0xD030,
+ 0xD032, 0xD034, 0xD03C, 0xD03E, 0xD041, 0xD043,
+ 0xD04D, 0xD04F, 0xD0C1, 0xD0C3, 0xD0CD, 0xD0CF,
+ 0xD0D0, 0xD0D2, 0xD0D4, 0xD0DC, 0xD0DE, 0xD0E1,
+ 0xD0E3, 0xD0ED, 0xD0EF, 0xD0F0, 0xD0F2, 0xD0F4,
+ 0xD0FC, 0xD0FE, 0xD100, 0xD102, 0xD104, 0xD10C,
+ 0xD10E, 0xD111, 0xD113, 0xD11D, 0xD11F, 0xD120,
+ 0xD122, 0xD124, 0xD12C, 0xD12E, 0xD131, 0xD133,
+ 0xD13D, 0xD13F, 0xD140, 0xD142, 0xD144, 0xD14C,
+ 0xD14E, 0xD1C0, 0xD1C2, 0xD1C4, 0xD1CC, 0xD1CE,
+ 0xD1D1, 0xD1D3, 0xD1DD, 0xD1DF, 0xD1E0, 0xD1E2,
+ 0xD1E4, 0xD1EC, 0xD1EE, 0xD1F1, 0xD1F3, 0xD1FD,
+ 0xD1FF, 0xD201, 0xD203, 0xD20D, 0xD20F, 0xD210,
+ 0xD212, 0xD214, 0xD21C, 0xD21E, 0xD221, 0xD223,
+ 0xD22D, 0xD22F, 0xD230, 0xD232, 0xD234, 0xD23C,
+ 0xD23E, 0xD241, 0xD243, 0xD24D, 0xD24F, 0xD2C1,
+ 0xD2C3, 0xD2CD, 0xD2CF, 0xD2D0, 0xD2D2, 0xD2D4,
+ 0xD2DC, 0xD2DE, 0xD2E1, 0xD2E3, 0xD2ED, 0xD2EF,
+ 0xD2F0, 0xD2F2, 0xD2F4, 0xD2FC, 0xD2FE, 0xD300,
+ 0xD302, 0xD304, 0xD30C, 0xD30E, 0xD311, 0xD313,
+ 0xD31D, 0xD31F, 0xD320, 0xD322, 0xD324, 0xD32C,
+ 0xD32E, 0xD331, 0xD333, 0xD33D, 0xD33F, 0xD340,
+ 0xD342, 0xD344, 0xD34C, 0xD34E, 0xD3C0, 0xD3C2,
+ 0xD3C4, 0xD3CC, 0xD3CE, 0xD3D1, 0xD3D3, 0xD3DD,
+ 0xD3DF, 0xD3E0, 0xD3E2, 0xD3E4, 0xD3EC, 0xD3EE,
+ 0xD3F1, 0xD3F3, 0xD3FD, 0xD3FF, 0xD401, 0xD403,
+ 0xD40D, 0xD40F, 0xD410, 0xD412, 0xD414, 0xD41C,
+ 0xD41E, 0xD421, 0xD423, 0xD42D, 0xD42F, 0xD430,
+ 0xD432, 0xD434, 0xD43C, 0xD43E, 0xD441, 0xD443,
+ 0xD44D, 0xD44F, 0xD4C1, 0xD4C3, 0xD4CD, 0xD4CF,
+ 0xD4D0, 0xD4D2, 0xD4D4, 0xD4DC, 0xD4DE, 0xD4E1,
+ 0xD4E3, 0xD4ED, 0xD4EF, 0xD4F0, 0xD4F2, 0xD4F4,
+ 0xD4FC, 0xD4FE, 0xDC01, 0xDC03, 0xDC0D, 0xDC0F,
+ 0xDC10, 0xDC12, 0xDC14, 0xDC1C, 0xDC1E, 0xDC21,
+ 0xDC23, 0xDC2D, 0xDC2F, 0xDC30, 0xDC32, 0xDC34,
+ 0xDC3C, 0xDC3E, 0xDC41, 0xDC43, 0xDC4D, 0xDC4F,
+ 0xDCC1, 0xDCC3, 0xDCCD, 0xDCCF, 0xDCD0, 0xDCD2,
+ 0xDCD4, 0xDCDC, 0xDCDE, 0xDCE1, 0xDCE3, 0xDCED,
+ 0xDCEF, 0xDCF0, 0xDCF2, 0xDCF4, 0xDCFC, 0xDCFE,
+ 0xDD00, 0xDD02, 0xDD04, 0xDD0C, 0xDD0E, 0xDD11,
+ 0xDD13, 0xDD1D, 0xDD1F, 0xDD20, 0xDD22, 0xDD24,
+ 0xDD2C, 0xDD2E, 0xDD31, 0xDD33, 0xDD3D, 0xDD3F,
+ 0xDD40, 0xDD42, 0xDD44, 0xDD4C, 0xDD4E, 0xDDC0,
+ 0xDDC2, 0xDDC4, 0xDDCC, 0xDDCE, 0xDDD1, 0xDDD3,
+ 0xDDDD, 0xDDDF, 0xDDE0, 0xDDE2, 0xDDE4, 0xDDEC,
+ 0xDDEE, 0xDDF1, 0xDDF3, 0xDDFD, 0xDDFF, 0xDE01,
+ 0xDE03, 0xDE0D, 0xDE0F, 0xDE10, 0xDE12, 0xDE14,
+ 0xDE1C, 0xDE1E, 0xDE21, 0xDE23, 0xDE2D, 0xDE2F,
+ 0xDE30, 0xDE32, 0xDE34, 0xDE3C, 0xDE3E, 0xDE41,
+ 0xDE43, 0xDE4D, 0xDE4F, 0xDEC1, 0xDEC3, 0xDECD,
+ 0xDECF, 0xDED0, 0xDED2, 0xDED4, 0xDEDC, 0xDEDE,
+ 0xDEE1, 0xDEE3, 0xDEED, 0xDEEF, 0xDEF0, 0xDEF2,
+ 0xDEF4, 0xDEFC, 0xDEFE, 0xDF00, 0xDF02, 0xDF04,
+ 0xDF0C, 0xDF0E, 0xDF11, 0xDF13, 0xDF1D, 0xDF1F,
+ 0xDF20, 0xDF22, 0xDF24, 0xDF2C, 0xDF2E, 0xDF31,
+ 0xDF33, 0xDF3D, 0xDF3F, 0xDF40, 0xDF42, 0xDF44,
+ 0xDF4C, 0xDF4E, 0xDFC0, 0xDFC2, 0xDFC4, 0xDFCC,
+ 0xDFCE, 0xDFD1, 0xDFD3, 0xDFDD, 0xDFDF, 0xDFE0,
+ 0xDFE2, 0xDFE4, 0xDFEC, 0xDFEE, 0xDFF1, 0xDFF3,
+ 0xDFFD, 0xDFFF, 0xE000, 0xE002, 0xE004, 0xE00C,
+ 0xE00E, 0xE011, 0xE013, 0xE01D, 0xE01F, 0xE020,
+ 0xE022, 0xE024, 0xE02C, 0xE02E, 0xE031, 0xE033,
+ 0xE03D, 0xE03F, 0xE040, 0xE042, 0xE044, 0xE04C,
+ 0xE04E, 0xE0C0, 0xE0C2, 0xE0C4, 0xE0CC, 0xE0CE,
+ 0xE0D1, 0xE0D3, 0xE0DD, 0xE0DF, 0xE0E0, 0xE0E2,
+ 0xE0E4, 0xE0EC, 0xE0EE, 0xE0F1, 0xE0F3, 0xE0FD,
+ 0xE0FF, 0xE101, 0xE103, 0xE10D, 0xE10F, 0xE110,
+ 0xE112, 0xE114, 0xE11C, 0xE11E, 0xE121, 0xE123,
+ 0xE12D, 0xE12F, 0xE130, 0xE132, 0xE134, 0xE13C,
+ 0xE13E, 0xE141, 0xE143, 0xE14D, 0xE14F, 0xE1C1,
+ 0xE1C3, 0xE1CD, 0xE1CF, 0xE1D0, 0xE1D2, 0xE1D4,
+ 0xE1DC, 0xE1DE, 0xE1E1, 0xE1E3, 0xE1ED, 0xE1EF,
+ 0xE1F0, 0xE1F2, 0xE1F4, 0xE1FC, 0xE1FE, 0xE200,
+ 0xE202, 0xE204, 0xE20C, 0xE20E, 0xE211, 0xE213,
+ 0xE21D, 0xE21F, 0xE220, 0xE222, 0xE224, 0xE22C,
+ 0xE22E, 0xE231, 0xE233, 0xE23D, 0xE23F, 0xE240,
+ 0xE242, 0xE244, 0xE24C, 0xE24E, 0xE2C0, 0xE2C2,
+ 0xE2C4, 0xE2CC, 0xE2CE, 0xE2D1, 0xE2D3, 0xE2DD,
+ 0xE2DF, 0xE2E0, 0xE2E2, 0xE2E4, 0xE2EC, 0xE2EE,
+ 0xE2F1, 0xE2F3, 0xE2FD, 0xE2FF, 0xE301, 0xE303,
+ 0xE30D, 0xE30F, 0xE310, 0xE312, 0xE314, 0xE31C,
+ 0xE31E, 0xE321, 0xE323, 0xE32D, 0xE32F, 0xE330,
+ 0xE332, 0xE334, 0xE33C, 0xE33E, 0xE341, 0xE343,
+ 0xE34D, 0xE34F, 0xE3C1, 0xE3C3, 0xE3CD, 0xE3CF,
+ 0xE3D0, 0xE3D2, 0xE3D4, 0xE3DC, 0xE3DE, 0xE3E1,
+ 0xE3E3, 0xE3ED, 0xE3EF, 0xE3F0, 0xE3F2, 0xE3F4,
+ 0xE3FC, 0xE3FE, 0xE400, 0xE402, 0xE404, 0xE40C,
+ 0xE40E, 0xE411, 0xE413, 0xE41D, 0xE41F, 0xE420,
+ 0xE422, 0xE424, 0xE42C, 0xE42E, 0xE431, 0xE433,
+ 0xE43D, 0xE43F, 0xE440, 0xE442, 0xE444, 0xE44C,
+ 0xE44E, 0xE4C0, 0xE4C2, 0xE4C4, 0xE4CC, 0xE4CE,
+ 0xE4D1, 0xE4D3, 0xE4DD, 0xE4DF, 0xE4E0, 0xE4E2,
+ 0xE4E4, 0xE4EC, 0xE4EE, 0xE4F1, 0xE4F3, 0xE4FD,
+ 0xE4FF, 0xEC00, 0xEC02, 0xEC04, 0xEC0C, 0xEC0E,
+ 0xEC11, 0xEC13, 0xEC1D, 0xEC1F, 0xEC20, 0xEC22,
+ 0xEC24, 0xEC2C, 0xEC2E, 0xEC31, 0xEC33, 0xEC3D,
+ 0xEC3F, 0xEC40, 0xEC42, 0xEC44, 0xEC4C, 0xEC4E,
+ 0xECC0, 0xECC2, 0xECC4, 0xECCC, 0xECCE, 0xECD1,
+ 0xECD3, 0xECDD, 0xECDF, 0xECE0, 0xECE2, 0xECE4,
+ 0xECEC, 0xECEE, 0xECF1, 0xECF3, 0xECFD, 0xECFF,
+ 0xED01, 0xED03, 0xED0D, 0xED0F, 0xED10, 0xED12,
+ 0xED14, 0xED1C, 0xED1E, 0xED21, 0xED23, 0xED2D,
+ 0xED2F, 0xED30, 0xED32, 0xED34, 0xED3C, 0xED3E,
+ 0xED41, 0xED43, 0xED4D, 0xED4F, 0xEDC1, 0xEDC3,
+ 0xEDCD, 0xEDCF, 0xEDD0, 0xEDD2, 0xEDD4, 0xEDDC,
+ 0xEDDE, 0xEDE1, 0xEDE3, 0xEDED, 0xEDEF, 0xEDF0,
+ 0xEDF2, 0xEDF4, 0xEDFC, 0xEDFE, 0xEE00, 0xEE02,
+ 0xEE04, 0xEE0C, 0xEE0E, 0xEE11, 0xEE13, 0xEE1D,
+ 0xEE1F, 0xEE20, 0xEE22, 0xEE24, 0xEE2C, 0xEE2E,
+ 0xEE31, 0xEE33, 0xEE3D, 0xEE3F, 0xEE40, 0xEE42,
+ 0xEE44, 0xEE4C, 0xEE4E, 0xEEC0, 0xEEC2, 0xEEC4,
+ 0xEECC, 0xEECE, 0xEED1, 0xEED3, 0xEEDD, 0xEEDF,
+ 0xEEE0, 0xEEE2, 0xEEE4, 0xEEEC, 0xEEEE, 0xEEF1,
+ 0xEEF3, 0xEEFD, 0xEEFF, 0xEF01, 0xEF03, 0xEF0D,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF14, 0xEF1C, 0xEF1E,
+ 0xEF21, 0xEF23, 0xEF2D, 0xEF2F, 0xEF30, 0xEF32,
+ 0xEF34, 0xEF3C, 0xEF3E, 0xEF41, 0xEF43, 0xEF4D,
+ 0xEF4F, 0xEFC1, 0xEFC3, 0xEFCD, 0xEFCF, 0xEFD0,
+ 0xEFD2, 0xEFD4, 0xEFDC, 0xEFDE, 0xEFE1, 0xEFE3,
+ 0xEFED, 0xEFEF, 0xEFF0, 0xEFF2, 0xEFF4, 0xEFFC,
+ 0xEFFE, 0xF001, 0xF003, 0xF00D, 0xF00F, 0xF010,
+ 0xF012, 0xF014, 0xF01C, 0xF01E, 0xF021, 0xF023,
+ 0xF02D, 0xF02F, 0xF030, 0xF032, 0xF034, 0xF03C,
+ 0xF03E, 0xF041, 0xF043, 0xF04D, 0xF04F, 0xF0C1,
+ 0xF0C3, 0xF0CD, 0xF0CF, 0xF0D0, 0xF0D2, 0xF0D4,
+ 0xF0DC, 0xF0DE, 0xF0E1, 0xF0E3, 0xF0ED, 0xF0EF,
+ 0xF0F0, 0xF0F2, 0xF0F4, 0xF0FC, 0xF0FE, 0xF100,
+ 0xF102, 0xF104, 0xF10C, 0xF10E, 0xF111, 0xF113,
+ 0xF11D, 0xF11F, 0xF120, 0xF122, 0xF124, 0xF12C,
+ 0xF12E, 0xF131, 0xF133, 0xF13D, 0xF13F, 0xF140,
+ 0xF142, 0xF144, 0xF14C, 0xF14E, 0xF1C0, 0xF1C2,
+ 0xF1C4, 0xF1CC, 0xF1CE, 0xF1D1, 0xF1D3, 0xF1DD,
+ 0xF1DF, 0xF1E0, 0xF1E2, 0xF1E4, 0xF1EC, 0xF1EE,
+ 0xF1F1, 0xF1F3, 0xF1FD, 0xF1FF, 0xF201, 0xF203,
+ 0xF20D, 0xF20F, 0xF210, 0xF212, 0xF214, 0xF21C,
+ 0xF21E, 0xF221, 0xF223, 0xF22D, 0xF22F, 0xF230,
+ 0xF232, 0xF234, 0xF23C, 0xF23E, 0xF241, 0xF243,
+ 0xF24D, 0xF24F, 0xF2C1, 0xF2C3, 0xF2CD, 0xF2CF,
+ 0xF2D0, 0xF2D2, 0xF2D4, 0xF2DC, 0xF2DE, 0xF2E1,
+ 0xF2E3, 0xF2ED, 0xF2EF, 0xF2F0, 0xF2F2, 0xF2F4,
+ 0xF2FC, 0xF2FE, 0xF300, 0xF302, 0xF304, 0xF30C,
+ 0xF30E, 0xF311, 0xF313, 0xF31D, 0xF31F, 0xF320,
+ 0xF322, 0xF324, 0xF32C, 0xF32E, 0xF331, 0xF333,
+ 0xF33D, 0xF33F, 0xF340, 0xF342, 0xF344, 0xF34C,
+ 0xF34E, 0xF3C0, 0xF3C2, 0xF3C4, 0xF3CC, 0xF3CE,
+ 0xF3D1, 0xF3D3, 0xF3DD, 0xF3DF, 0xF3E0, 0xF3E2,
+ 0xF3E4, 0xF3EC, 0xF3EE, 0xF3F1, 0xF3F3, 0xF3FD,
+ 0xF3FF, 0xF401, 0xF403, 0xF40D, 0xF40F, 0xF410,
+ 0xF412, 0xF414, 0xF41C, 0xF41E, 0xF421, 0xF423,
+ 0xF42D, 0xF42F, 0xF430, 0xF432, 0xF434, 0xF43C,
+ 0xF43E, 0xF441, 0xF443, 0xF44D, 0xF44F, 0xF4C1,
+ 0xF4C3, 0xF4CD, 0xF4CF, 0xF4D0, 0xF4D2, 0xF4D4,
+ 0xF4DC, 0xF4DE, 0xF4E1, 0xF4E3, 0xF4ED, 0xF4EF,
+ 0xF4F0, 0xF4F2, 0xF4F4, 0xF4FC, 0xF4FE, 0xFC01,
+ 0xFC03, 0xFC0D, 0xFC0F, 0xFC10, 0xFC12, 0xFC14,
+ 0xFC1C, 0xFC1E, 0xFC21, 0xFC23, 0xFC2D, 0xFC2F,
+ 0xFC30, 0xFC32, 0xFC34, 0xFC3C, 0xFC3E, 0xFC41,
+ 0xFC43, 0xFC4D, 0xFC4F, 0xFCC1, 0xFCC3, 0xFCCD,
+ 0xFCCF, 0xFCD0, 0xFCD2, 0xFCD4, 0xFCDC, 0xFCDE,
+ 0xFCE1, 0xFCE3, 0xFCED, 0xFCEF, 0xFCF0, 0xFCF2,
+ 0xFCF4, 0xFCFC, 0xFCFE, 0xFD00, 0xFD02, 0xFD04,
+ 0xFD0C, 0xFD0E, 0xFD11, 0xFD13, 0xFD1D, 0xFD1F,
+ 0xFD20, 0xFD22, 0xFD24, 0xFD2C, 0xFD2E, 0xFD31,
+ 0xFD33, 0xFD3D, 0xFD3F, 0xFD40, 0xFD42, 0xFD44,
+ 0xFD4C, 0xFD4E, 0xFDC0, 0xFDC2, 0xFDC4, 0xFDCC,
+ 0xFDCE, 0xFDD1, 0xFDD3, 0xFDDD, 0xFDDF, 0xFDE0,
+ 0xFDE2, 0xFDE4, 0xFDEC, 0xFDEE, 0xFDF1, 0xFDF3,
+ 0xFDFD, 0xFDFF, 0xFE01, 0xFE03, 0xFE0D, 0xFE0F,
+ 0xFE10, 0xFE12, 0xFE14, 0xFE1C, 0xFE1E, 0xFE21,
+ 0xFE23, 0xFE2D, 0xFE2F, 0xFE30, 0xFE32, 0xFE34,
+ 0xFE3C, 0xFE3E, 0xFE41, 0xFE43, 0xFE4D, 0xFE4F,
+ 0xFEC1, 0xFEC3, 0xFECD, 0xFECF, 0xFED0, 0xFED2,
+ 0xFED4, 0xFEDC, 0xFEDE, 0xFEE1, 0xFEE3, 0xFEED,
+ 0xFEEF, 0xFEF0, 0xFEF2, 0xFEF4, 0xFEFC, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF04, 0xFF0C, 0xFF0E, 0xFF11,
+ 0xFF13, 0xFF1D, 0xFF1F, 0xFF20, 0xFF22, 0xFF24,
+ 0xFF2C, 0xFF2E, 0xFF31, 0xFF33, 0xFF3D, 0xFF3F,
+ 0xFF40, 0xFF42, 0xFF44, 0xFF4C, 0xFF4E, 0xFFC0,
+ 0xFFC2, 0xFFC4, 0xFFCC, 0xFFCE, 0xFFD1, 0xFFD3,
+ 0xFFDD, 0xFFDF, 0xFFE0, 0xFFE2, 0xFFE4, 0xFFEC,
+ 0xFFEE, 0xFFF1, 0xFFF3, 0xFFFD, 0xFFFF,
+};
+
+#define ON2AVC_CB8_CODES 3281
+static const uint32_t on2avc_cb8_codes[ON2AVC_CB8_CODES] = {
+ 0x028C, 0x05E6, 0xFAD9, 0x7DEF, 0x06CE, 0x004C,
+ 0x0178, 0x0A1D, 0x00AE, 0x046E, 0x03D5, 0x3F58,
+ 0x0EAA, 0x0233, 0x1A6A, 0x271F, 0x05CE, 0x0179,
+ 0x02FB, 0x0029, 0x237D, 0x7DF0, 0x03BA, 0xFAD6,
+ 0xFAD7, 0x7DEE, 0xFAD5, 0x0081, 0x033C, 0x1A69,
+ 0xFAD8, 0x05A1, 0x01F1, 0x063D, 0x237C, 0x003E,
+ 0x0323, 0x010C, 0x05A3, 0x05A2, 0x0051, 0x019D,
+ 0xFADB, 0x0EAB, 0x00AA, 0x003E, 0x01A6, 0x7DF2,
+ 0x0058, 0x01F1, 0x029B, 0x03C0, 0x122D, 0x0075,
+ 0x3F5A, 0x0B98, 0x0005, 0x058B, 0x0D68, 0x013F,
+ 0x00D0, 0x05CF, 0x01C0, 0x03BB, 0x046F, 0xFADA,
+ 0x01A0, 0x0972, 0x122C, 0x3F59, 0x0766, 0x05A4,
+ 0x00ED, 0x05A5, 0x0D67, 0x03D0, 0x0046, 0x01FF,
+ 0x7DF1, 0x00D6, 0x017C, 0x0034, 0x08B5, 0x0234,
+ 0x237E, 0x0033, 0x0083, 0x0B99, 0x0EAC, 0x0202,
+ 0x0714, 0x0715, 0x01C3, 0x05A6, 0x0324, 0x13EC,
+ 0x02F8, 0x7DF3, 0x13EB, 0x0140, 0x0470, 0x04F8,
+ 0x0007, 0x0377, 0x0208, 0x04A3, 0x13EA, 0x0006,
+ 0x0188, 0x033D, 0x122E, 0x1A6B, 0x0A1E, 0x0126,
+ 0x03C1, 0x05E7, 0x05D0, 0x04F7, 0x03DB, 0x033E,
+ 0x122F, 0x0082, 0x1A6F, 0x2380, 0x05D2, 0x0009,
+ 0x05A9, 0x1A70, 0x1233, 0x05A7, 0x05A8, 0x0975,
+ 0x2381, 0x1234, 0x0788, 0x2720, 0x1235, 0x05D3,
+ 0xFADD, 0x3F5B, 0x0789, 0x0D69, 0xFADE, 0xFADF,
+ 0x01C4, 0x0EAD, 0x0EA1, 0x1230, 0x0008, 0x13ED,
+ 0x1A6C, 0xFADC, 0x1231, 0x0973, 0x1232, 0x1A6D,
+ 0x13EE, 0x1A6E, 0x0974, 0x237F, 0x05D1, 0x033F,
+ 0x0267, 0x078A, 0xFAE3, 0xFAE2, 0x0B9A, 0x00FC,
+ 0x0EAE, 0x05D6, 0x0325, 0x0326, 0x0B9B, 0x3F5F,
+ 0x3F5E, 0x0471, 0x02F9, 0xFAE4, 0x1A72, 0x03C2,
+ 0x05D7, 0x2721, 0x3F60, 0xFAE5, 0x2382, 0xFAE0,
+ 0x7DF5, 0xFAE1, 0x7DF4, 0x000A, 0x0235, 0x3F5C,
+ 0x1A71, 0x0716, 0x036C, 0x0767, 0x05D4, 0x3F5D,
+ 0x0717, 0x01BF, 0x000B, 0x05D5, 0x0243, 0xFAD0,
+ 0x04F6, 0x7DE5, 0xFACF, 0x0E9E, 0x0074, 0x271A,
+ 0x1A61, 0x015B, 0x0046, 0x06CA, 0x237A, 0x7DE6,
+ 0x0070, 0x1A62, 0x1227, 0x7DE7, 0x0032, 0xFAD1,
+ 0x05CA, 0x7DE8, 0x237B, 0x13E6, 0x05C8, 0x1226,
+ 0x2377, 0x2719, 0x3F54, 0x3F55, 0x13E5, 0x2378,
+ 0x03BF, 0x05C9, 0x01C0, 0x7DE4, 0x7DE3, 0x0A19,
+ 0x0045, 0x1A60, 0x2379, 0x021B, 0x271C, 0x13E7,
+ 0x271B, 0x1A67, 0x059D, 0x0EA6, 0x0EA7, 0x0174,
+ 0x0EA5, 0x0A1A, 0x1FFD, 0x033A, 0x0E9F, 0x3F57,
+ 0x122B, 0xFAD2, 0x0D64, 0x05CC, 0x06CB, 0x1FFE,
+ 0x059E, 0x02F7, 0x1228, 0x7DE9, 0x059B, 0x096C,
+ 0x1A63, 0x1A64, 0x1A65, 0x1229, 0x0EA3, 0x059C,
+ 0x096D, 0x05CB, 0x003C, 0x1A66, 0x0D63, 0x3F56,
+ 0x122A, 0x0EA4, 0x0712, 0x0232, 0x13E8, 0x061E,
+ 0x08B4, 0x016E, 0x0176, 0x033B, 0x0028, 0x05E5,
+ 0x061F, 0x0000, 0x0376, 0x0071, 0x096F, 0x7DEB,
+ 0x0001, 0x05CD, 0xFAD3, 0x0186, 0x0EA9, 0x13E9,
+ 0x06CD, 0x7DEA, 0x0340, 0x271D, 0x0175, 0x01C1,
+ 0x0D65, 0x1FFF, 0x0B97, 0x0EA8, 0x06CC, 0x0375,
+ 0x05E4, 0x08B3, 0x05E3, 0x0341, 0x0EA0, 0x096E,
+ 0x03CF, 0x0056, 0x0970, 0x1A68, 0x029A, 0x010A,
+ 0x00A8, 0x01CA, 0x7DED, 0x00A5, 0x001E, 0x05A0,
+ 0x0D66, 0x0047, 0x0971, 0x0A1C, 0x02CE, 0xFAD4,
+ 0x0004, 0x010F, 0x271E, 0x0415, 0x0212, 0x019F,
+ 0x7DEC, 0x01C2, 0x0187, 0x059F, 0x0A1B, 0x0527,
+ 0x0002, 0x003D, 0x0041, 0x0177, 0x0713, 0x010E,
+ 0x0102, 0x02CF, 0x00CA, 0x0003, 0x01BF, 0x0120,
+ 0x05DE, 0x0043, 0x01D0, 0x018C, 0x00AB, 0x029F,
+ 0x03DF, 0x03C5, 0x0247, 0x08BB, 0x0013, 0x03D2,
+ 0x0015, 0x0EB0, 0x02FA, 0x05E8, 0x0014, 0x0EB1,
+ 0x0476, 0x1A78, 0x01F4, 0x06D1, 0x017C, 0x0042,
+ 0x063F, 0x0011, 0x0012, 0x01C7, 0x04FB, 0x1A77,
+ 0x01AA, 0x04FC, 0x0A21, 0x021D, 0x01EE, 0x02BC,
+ 0x01C2, 0x021E, 0x00AA, 0x00D6, 0x021F, 0x016F,
+ 0x0077, 0x01AB, 0x00AC, 0x0073, 0x078D, 0x00AF,
+ 0x002E, 0x0220, 0x0086, 0x0103, 0x0086, 0x0127,
+ 0x0BA0, 0x05DF, 0x0EA5, 0x03D3, 0x05E0, 0x017D,
+ 0xFAE7, 0x015A, 0x03C6, 0x0768, 0xFAE6, 0x3F65,
+ 0x01F3, 0x0B9F, 0x0016, 0x0EA4, 0x078C, 0x02BD,
+ 0x004D, 0x0116, 0x037A, 0x0076, 0x0056, 0x058E,
+ 0x06D2, 0x0014, 0x009F, 0x0A23, 0x0346, 0x014E,
+ 0x02BF, 0x00A7, 0x0528, 0x0378, 0x0106, 0x01C3,
+ 0x017E, 0x0044, 0x03C7, 0x097F, 0x04A5, 0x020B,
+ 0x05E9, 0x0A24, 0x03D9, 0x0661, 0x0660, 0x014F,
+ 0x02BE, 0x023B, 0x04FD, 0x0313, 0x0017, 0x08BC,
+ 0x0769, 0x0622, 0x0D6C, 0x03D7, 0x01C8, 0x0A22,
+ 0x01AB, 0x0203, 0x076A, 0x03D8, 0x02D1, 0x00A6,
+ 0x05E3, 0x1A79, 0x1A7A, 0x0981, 0x05B1, 0x04FF,
+ 0x0982, 0x0348, 0x0128, 0x08BD, 0x0D6D, 0x13F4,
+ 0x05B2, 0x0624, 0x05B3, 0x0EB2, 0x2729, 0x1237,
+ 0x05B4, 0x0129, 0x0349, 0x2386, 0x0019, 0x04FE,
+ 0x05B0, 0xFAE8, 0x3F66, 0x0623, 0x05E1, 0x05E2,
+ 0x3F67, 0x0980, 0x0347, 0x0BA1, 0x0046, 0x0045,
+ 0x0EA6, 0x01C9, 0x0018, 0x13F3, 0x078E, 0x0152,
+ 0x0983, 0x1238, 0x272B, 0x01F2, 0x028F, 0x05E5,
+ 0x3F69, 0x0418, 0x02FC, 0x017F, 0x0EB3, 0x00EF,
+ 0x0790, 0x0791, 0x1239, 0x05E6, 0x05E7, 0x1A7C,
+ 0x034A, 0x001A, 0x0984, 0x05B5, 0x272A, 0x1A7B,
+ 0x0EA7, 0x0529, 0x02FB, 0x2387, 0x3F68, 0x078F,
+ 0x006D, 0x0D6E, 0x05B6, 0x039F, 0x014E, 0x058F,
+ 0x13F5, 0x05E4, 0x020C, 0x0342, 0x1A73, 0x7DF7,
+ 0x2724, 0x0082, 0x0209, 0x1A74, 0x05DB, 0x03D6,
+ 0x001F, 0x0B9C, 0x04F9, 0x0096, 0x03C3, 0x0620,
+ 0x7DF9, 0x7DF8, 0x0EA2, 0x000C, 0x2725, 0x3F61,
+ 0x0977, 0x0976, 0x2723, 0x05D8, 0x2722, 0x058C,
+ 0x08B6, 0x05D9, 0x2383, 0x0236, 0x036D, 0x0A1F,
+ 0x05AA, 0x019C, 0x01C0, 0x0327, 0x05DA, 0x7DF6,
+ 0x02CF, 0x05DD, 0x0341, 0x05AE, 0x0EAF, 0x2384,
+ 0x0342, 0x13F0, 0x000D, 0x08B7, 0x000E, 0x003F,
+ 0x097B, 0x0343, 0x0D6A, 0x1A75, 0x000F, 0x3F63,
+ 0x05AF, 0x06CF, 0x06D0, 0x2385, 0x13F1, 0x058D,
+ 0x0237, 0x05AB, 0x7DFA, 0x0EA3, 0x03C4, 0x13EF,
+ 0x05DC, 0x2726, 0x1236, 0x017A, 0x0978, 0x05AD,
+ 0x05AC, 0x0340, 0x0238, 0x097A, 0x3F62, 0x0979,
+ 0x03DE, 0x0010, 0x0345, 0x002A, 0x03D1, 0x01A7,
+ 0x01F2, 0x009E, 0x020A, 0x0189, 0x0D6B, 0x03C6,
+ 0x00EE, 0x0A20, 0x017B, 0x04FA, 0x0472, 0x0040,
+ 0x00CB, 0x08B9, 0x02D0, 0x029E, 0x0020, 0x0344,
+ 0x0239, 0x02D0, 0x0B9D, 0x023A, 0x0B9E, 0x028D,
+ 0x03C5, 0x03BE, 0x08B8, 0x078B, 0x0337, 0x0246,
+ 0x004C, 0x0416, 0x0141, 0x04A4, 0x00E2, 0x0213,
+ 0x028E, 0x01A7, 0x021C, 0x00D4, 0x01C6, 0x0072,
+ 0x0067, 0x002B, 0x0473, 0x036F, 0x01E0, 0x036E,
+ 0x0041, 0x3F64, 0x097E, 0x0621, 0x02BB, 0x00D7,
+ 0x2728, 0x2727, 0x01C1, 0x0129, 0x0417, 0x13F2,
+ 0x097C, 0x0142, 0x097D, 0x1A76, 0x08BA, 0x063E,
+ 0x0100, 0x01AA, 0x018A, 0x00EA, 0x014D, 0x001E,
+ 0x01C5, 0x03C7, 0x0053, 0x05EC, 0x012D, 0x004C,
+ 0x0D71, 0x01D0, 0x0023, 0x0D72, 0x0185, 0x02D2,
+ 0x0719, 0x012F, 0x0502, 0x012E, 0x0A28, 0x098E,
+ 0x238B, 0x272D, 0x05EE, 0x05BE, 0x0130, 0xFAEE,
+ 0x272E, 0x0BA2, 0x05EB, 0x01CF, 0xFAED, 0x238A,
+ 0x01CE, 0x098C, 0x7DFD, 0x05BD, 0x004A, 0x0036,
+ 0x0037, 0x0628, 0x02FD, 0x048A, 0x017E, 0x004B,
+ 0x098D, 0x0153, 0x0216, 0x0D73, 0x1A82, 0x0042,
+ 0x017F, 0x026C, 0x020D, 0x0794, 0x0143, 0x007E,
+ 0x062A, 0x0798, 0x004F, 0x0EBA, 0x0BA4, 0x023E,
+ 0x05BF, 0x0EB9, 0x0592, 0x03CC, 0x004E, 0x018E,
+ 0x032C, 0x0629, 0x0BA3, 0x01F7, 0x0EB8, 0x004D,
+ 0x0990, 0x0350, 0x098F, 0x0343, 0x0023, 0x052B,
+ 0x004E, 0x0178, 0x04A6, 0x0291, 0x05ED, 0x00DC,
+ 0x032D, 0x0504, 0x0991, 0x0A29, 0x0593, 0x01F3,
+ 0x0A2A, 0x0505, 0x015B, 0x0666, 0x0087, 0x03DA,
+ 0x0BA5, 0x076D, 0x05C1, 0x03CD, 0x0024, 0x0992,
+ 0x04A7, 0x0131, 0x05C2, 0x272F, 0x01D1, 0x076B,
+ 0x076C, 0x1242, 0x05EF, 0x062B, 0x0EAE, 0x13FD,
+ 0x05C0, 0x0EBB, 0x023F, 0x0D74, 0x0503, 0x02FE,
+ 0x041A, 0x037B, 0x08BE, 0x0240, 0x0316, 0x0EBD,
+ 0x3F70, 0x0EBC, 0x0A2B, 0x0BA7, 0x0053, 0x05C5,
+ 0x13FE, 0x0506, 0x03CE, 0x0026, 0x0994, 0x0038,
+ 0x0027, 0x0132, 0x020E, 0x2731, 0x0EBE, 0x0796,
+ 0x018F, 0x05C6, 0x02FF, 0x0795, 0x1A83, 0x3F6E,
+ 0x0BA6, 0x0025, 0x1243, 0x3F6F, 0x004F, 0x2730,
+ 0x062C, 0x0993, 0x05C3, 0x05C4, 0x0051, 0x0052,
+ 0x0351, 0x062D, 0x0050, 0x01F6, 0x08BF, 0x3F71,
+ 0x238E, 0x05C7, 0x01F7, 0x05C8, 0x062E, 0x012A,
+ 0x032F, 0x0077, 0x1A86, 0x0EBF, 0x03DB, 0x04AA,
+ 0x0BA8, 0x13FF, 0x062F, 0xFAF2, 0x071A, 0x0054,
+ 0xFAF1, 0x2732, 0xFAF0, 0x238C, 0x238D, 0xFAEF,
+ 0x1A84, 0x0392, 0x1244, 0x0995, 0x0799, 0x007F,
+ 0x032E, 0x7DFE, 0x1A85, 0x05EE, 0x018A, 0x0996,
+ 0x0028, 0x0152, 0x025A, 0x0A25, 0x7DFC, 0x3F6B,
+ 0x023C, 0x018B, 0x05B7, 0x0180, 0x00FD, 0x01BA,
+ 0x05EA, 0x123D, 0x05E8, 0x002F, 0x0625, 0x05B9,
+ 0x05B8, 0x0477, 0x13F7, 0x0D6F, 0x3F6C, 0xFAEA,
+ 0x01CB, 0xFAE9, 0x0985, 0x2388, 0x7DFB, 0x034B,
+ 0x01CA, 0x0047, 0x123A, 0x3F6A, 0x017D, 0x0662,
+ 0x123C, 0x123B, 0x0379, 0x024A, 0x13F6, 0x1A7D,
+ 0x016A, 0x0EAA, 0x123F, 0xFAEC, 0x0EA9, 0x13FB,
+ 0x0182, 0x0792, 0x05BA, 0x0181, 0x0D70, 0x001F,
+ 0x001E, 0x05BB, 0x3F6D, 0x0020, 0x2389, 0x1240,
+ 0x0183, 0x0501, 0x1A7F, 0x06D6, 0x0663, 0x06D3,
+ 0x13F8, 0x034C, 0x0EB4, 0x123E, 0x1A7E, 0x13F9,
+ 0x001B, 0x05E9, 0x0EA8, 0x001C, 0xFAEB, 0x05EA,
+ 0x034D, 0x0500, 0x13FA, 0x001D, 0x0048, 0x0794,
+ 0x0075, 0x0795, 0x0793, 0x0074, 0x008A, 0x03C9,
+ 0x05EB, 0x0087, 0x0076, 0x012B, 0x012C, 0x037A,
+ 0x0718, 0x0022, 0x272C, 0x0988, 0x0EB5, 0x0328,
+ 0x03CA, 0x05EC, 0x0EAB, 0x06D7, 0x0021, 0x0664,
+ 0x1A80, 0x0986, 0x0419, 0x03C8, 0x034E, 0x0987,
+ 0x0626, 0x02FC, 0x00AE, 0x01CC, 0x023D, 0x012A,
+ 0x0021, 0x0A26, 0x05BC, 0x01F6, 0x0221, 0x0049,
+ 0x0EB6, 0x0042, 0x02D2, 0x00F2, 0x00AF, 0x0290,
+ 0x0043, 0x052A, 0x13FC, 0x0A27, 0x032A, 0x1241,
+ 0x0EB7, 0x0EAD, 0x034F, 0x0EAC, 0x0022, 0x05ED,
+ 0x0797, 0x032B, 0x0035, 0x0989, 0x0184, 0x037B,
+ 0x098A, 0x1A81, 0x098B, 0x0796, 0x01CD, 0x025B,
+ 0x03CB, 0x0627, 0x02DA, 0x010C, 0x02D1, 0x06EA,
+ 0x0665, 0x0329, 0x0D78, 0x7E05, 0x7E04, 0x140A,
+ 0x0EB3, 0x0ECF, 0x3F7C, 0x1256, 0x05FB, 0x05CF,
+ 0xFAFF, 0x3F7D, 0x0ED0, 0x7E06, 0x3F7E, 0x3F7F,
+ 0xFB00, 0x239B, 0x0ED2, 0x1257, 0x7E07, 0x0ED1,
+ 0x002D, 0x1255, 0x273A, 0x09A4, 0x239A, 0x0ECD,
+ 0x273B, 0x1A8C, 0x002E, 0x09A5, 0xFAFE, 0x273C,
+ 0x0BAF, 0x0BB0, 0x05CE, 0x09A6, 0x00D1, 0x0ECE,
+ 0x09A8, 0x0030, 0x1A8E, 0x0ED3, 0x09A7, 0x0667,
+ 0x1258, 0x2740, 0x0D79, 0x3F80, 0x0189, 0x09A9,
+ 0x0EB5, 0x0359, 0x0ED4, 0x125A, 0x239D, 0x1259,
+ 0x05D1, 0x0D7A, 0x7E0A, 0x7E09, 0x09AA, 0x273D,
+ 0x0EB4, 0x273E, 0x002F, 0x0354, 0x05FC, 0x239C,
+ 0x1A8D, 0x0355, 0x0357, 0x05D0, 0x0358, 0x0356,
+ 0x01D2, 0x0508, 0x7E08, 0x273F, 0x0302, 0x0ED7,
+ 0x239E, 0x3F84, 0x08C4, 0x01D3, 0x0BB1, 0x0509,
+ 0x239F, 0x0303, 0x0133, 0x035C, 0x125B, 0x03D1,
+ 0x0ED8, 0x035D, 0x035E, 0x2743, 0x2744, 0x09AD,
+ 0x018A, 0x0031, 0x09AC, 0x3F82, 0x2741, 0x3F81,
+ 0x035A, 0x3F83, 0x05FD, 0x09AB, 0x0ED5, 0x0ED6,
+ 0x0633, 0x2742, 0x0055, 0x08C3, 0x0636, 0x035B,
+ 0x05FE, 0x0D7B, 0x0039, 0xFB05, 0x7E0B, 0x7E0C,
+ 0x140D, 0x018B, 0x09AF, 0x2746, 0x0032, 0x0056,
+ 0x09B0, 0x03D2, 0x0A30, 0x2747, 0x0057, 0x0EDA,
+ 0x050A, 0x125E, 0x0033, 0x2748, 0x0D7C, 0x03D3,
+ 0x3F85, 0x0034, 0xFB01, 0x140B, 0xFB02, 0x05FF,
+ 0x125C, 0xFB03, 0x125D, 0x1A8F, 0x0600, 0x05D2,
+ 0x0602, 0x2745, 0x0601, 0x0ED9, 0x1A90, 0xFB04,
+ 0x140C, 0x09AE, 0x033A, 0x7E0F, 0x23A2, 0x0A31,
+ 0x0EB6, 0x0058, 0x3F8A, 0x23A3, 0x01D6, 0x04AB,
+ 0x0059, 0x0EDB, 0x02D3, 0x018C, 0x04C6, 0x1260,
+ 0x3F8B, 0x125F, 0x1261, 0x071E, 0x7E10, 0x2749,
+ 0x140E, 0x3F87, 0x3F86, 0x0035, 0x3F88, 0x3F89,
+ 0x7E0D, 0x23A0, 0x1A91, 0x0797, 0x0603, 0x1A92,
+ 0x050B, 0x066A, 0x0306, 0x7E0E, 0x23A1, 0x079B,
+ 0x0BAA, 0x3F73, 0x7E01, 0x0292, 0x0216, 0x0998,
+ 0x1247, 0x2390, 0x0301, 0x0999, 0x1400, 0x1A87,
+ 0x041E, 0x1401, 0x0EC1, 0x2391, 0x3F74, 0x0A2C,
+ 0x1248, 0x3F75, 0x05C9, 0x0EC2, 0x2733, 0x238F,
+ 0xFAF3, 0xFAF4, 0x0EC0, 0x0997, 0x3F72, 0xFAF5,
+ 0x1245, 0x08C0, 0x0BA9, 0x1246, 0x020F, 0x041B,
+ 0x0186, 0x7E00, 0x7DFF, 0x0300, 0xFAFA, 0x2734,
+ 0x05F2, 0x124D, 0x2395, 0x099A, 0x2735, 0x3F77,
+ 0x0EC4, 0x0EC5, 0x1403, 0x0EC6, 0x1402, 0x1A89,
+ 0x3F78, 0x05F5, 0x05F3, 0x05F4, 0x2736, 0x1404,
+ 0x7E02, 0x124E, 0x0D75, 0x0029, 0x2392, 0xFAF7,
+ 0xFAF6, 0x0EC3, 0x1249, 0x2394, 0x2393, 0x05F0,
+ 0xFAF8, 0x124B, 0x124C, 0x124A, 0x3F76, 0x05CA,
+ 0x05F1, 0xFAF9, 0x1A88, 0x0187, 0x05F7, 0x124F,
+ 0x0631, 0x0D76, 0x0EAF, 0x2737, 0x0BAC, 0x099D,
+ 0x0A2D, 0x1250, 0x1407, 0x0BAD, 0x3F7A, 0x2396,
+ 0x2397, 0x0353, 0x1A8B, 0x08C2, 0x05CD, 0x099E,
+ 0x05CC, 0x0352, 0x002A, 0x05CB, 0x03CF, 0x1A8A,
+ 0x1405, 0x1406, 0x099B, 0x0EC7, 0x0630, 0x002B,
+ 0x3F79, 0x08C1, 0x0BAB, 0x0507, 0x05F6, 0x0EC8,
+ 0x099C, 0x0EB0, 0x0A2F, 0x0EB1, 0x2739, 0x09A1,
+ 0x03D0, 0x1252, 0x7E03, 0x0241, 0x0188, 0x0EB2,
+ 0x0BAE, 0x05FA, 0x09A2, 0x1254, 0x2398, 0xFAFB,
+ 0x1253, 0x2399, 0x0ECC, 0xFAFD, 0xFAFC, 0x09A3,
+ 0x1408, 0x09A0, 0x05F8, 0x3F7B, 0x099F, 0x0D77,
+ 0x1409, 0x002C, 0x0EC9, 0x0ECB, 0x0A2E, 0x1251,
+ 0x0ECA, 0x079A, 0x071B, 0x05F9, 0x2738, 0x0632,
+ 0x002E, 0x0012, 0x7E25, 0xFB1C, 0x0262, 0x001C,
+ 0x03D6, 0x018E, 0x007C, 0x0342, 0x052E, 0x7E26,
+ 0xFB1D, 0x01D7, 0x0D7F, 0x126A, 0x2756, 0x09B6,
+ 0xFB20, 0x3F97, 0xFB21, 0xFB1E, 0xFB1F, 0x23AF,
+ 0xFB19, 0xFB1A, 0x23AE, 0x7E24, 0x1A95, 0x2755,
+ 0x2754, 0x05D7, 0x050D, 0x0EE3, 0xFB1B, 0x0EE2,
+ 0x0BB5, 0x00E3, 0x08CB, 0x05D8, 0x01B9, 0x00E7,
+ 0x1412, 0x1A96, 0x015A, 0x009A, 0x007B, 0xFB24,
+ 0x3F99, 0x026D, 0x0026, 0x0EE5, 0x0EE4, 0x0222,
+ 0x05D9, 0x0D82, 0x7E28, 0x3F9A, 0x0A36, 0xFB25,
+ 0xFB26, 0x23B1, 0x7E29, 0x126B, 0x7E27, 0x23B0,
+ 0xFB22, 0x1411, 0x0BB6, 0x3F98, 0x126C, 0x09B7,
+ 0x02C2, 0x0442, 0x0A33, 0x012B, 0x01C1, 0x0034,
+ 0xFB23, 0x126D, 0x03DF, 0x0084, 0x0EB7, 0x23B2,
+ 0x7E2A, 0x052F, 0x018D, 0x0B16, 0x7E2B, 0x01A2,
+ 0x0736, 0x00F3, 0x060F, 0x003B, 0x003B, 0x081A,
+ 0x003F, 0x1416, 0x003E, 0x3F9D, 0x126E, 0x7E2E,
+ 0x7E2C, 0x7E2D, 0x2757, 0x060E, 0xFB28, 0xFB27,
+ 0x3F9B, 0x050E, 0x0EE6, 0x018F, 0x05DA, 0x0136,
+ 0x071F, 0xFB29, 0x1413, 0x0137, 0x3F9C, 0x0EE7,
+ 0x05DB, 0x02DB, 0x05EF, 0x23B5, 0x0EBB, 0x0243,
+ 0xFB2D, 0x0307, 0xFB2E, 0x275A, 0x0293, 0x041F,
+ 0x0686, 0x3F9E, 0x0217, 0x0612, 0x05FA, 0x23B6,
+ 0x7E2F, 0x1A97, 0x275B, 0x0613, 0xFB2F, 0x7E30,
+ 0xFB2A, 0x23B4, 0x126F, 0x23B3, 0x1270, 0x2758,
+ 0xFB2B, 0x0610, 0x0BB7, 0x03D7, 0x2759, 0x0916,
+ 0x050F, 0x0EBA, 0x0BF6, 0xFB2C, 0x0611, 0x00D3,
+ 0x2C5E, 0x7E36, 0xFB34, 0xFB33, 0x3FA2, 0xFB35,
+ 0x2FDE, 0x1417, 0x0A37, 0x3FA3, 0x02A2, 0x7E37,
+ 0xFB36, 0x005E, 0x058A, 0x076F, 0x0886, 0x005F,
+ 0xFB3B, 0x0686, 0x0342, 0xFB37, 0xFB3A, 0x3F9F,
+ 0x3FA0, 0xFB31, 0xFB30, 0x23B7, 0x3FA1, 0x23BB,
+ 0x23BA, 0x1271, 0x0D83, 0x1036, 0x7E32, 0x1272,
+ 0x7E31, 0x7E33, 0x162E, 0x1273, 0xFB32, 0xFB0C,
+ 0x1262, 0xFB0D, 0xFB0B, 0x3F8F, 0x0037, 0x1263,
+ 0x3F90, 0x0EDD, 0x0038, 0x05D3, 0xFB0E, 0x23A7,
+ 0x0606, 0x1265, 0x3F91, 0x1264, 0x0039, 0xFB0F,
+ 0x7E14, 0xFB10, 0x274A, 0x274B, 0xFB07, 0xFB08,
+ 0x23A5, 0xFB06, 0x23A4, 0x0EDC, 0xFB0A, 0xFB09,
+ 0x7E11, 0x0036, 0x0605, 0x3F8C, 0x7E12, 0x0604,
+ 0x3F8E, 0x23A6, 0x7E13, 0x3F8D, 0x03DE, 0x7E19,
+ 0x7E18, 0x0242, 0x0097, 0x08C5, 0xFB13, 0x7E1A,
+ 0x005A, 0x079B, 0x0607, 0x09B2, 0x033B, 0x05D4,
+ 0x09B3, 0xFB14, 0x23A8, 0x0637, 0x7E1B, 0x23AA,
+ 0x23A9, 0x0608, 0x274C, 0xFB12, 0xFB11, 0x7E15,
+ 0x1266, 0x140F, 0x1267, 0x7E16, 0x274D, 0x079E,
+ 0x274E, 0x0EDE, 0x066B, 0x09B1, 0x0D7D, 0x3F92,
+ 0x7E17, 0x079A, 0x002A, 0x00D2, 0x23AC, 0x23AB,
+ 0x02F2, 0x00B6, 0x0BB2, 0x05D5, 0x0066, 0x03A2,
+ 0x003A, 0x060B, 0x060A, 0x0317, 0x079F, 0x0362,
+ 0x2750, 0x050C, 0x3F95, 0x7E1D, 0x7E1E, 0xFB15,
+ 0x23AD, 0x274F, 0x3F93, 0x3F94, 0x7E1C, 0x0609,
+ 0x08C6, 0x0EE0, 0x0EDF, 0x035F, 0x0136, 0x076E,
+ 0x1A93, 0x1268, 0x0A32, 0x024B, 0x08C7, 0x1410,
+ 0x01EC, 0x0036, 0x0EE1, 0x0363, 0x0072, 0x0030,
+ 0x003E, 0x2753, 0x7E21, 0x00D7, 0x0117, 0x003A,
+ 0x0BB4, 0x0126, 0x018D, 0x05D6, 0x7E22, 0xFB16,
+ 0x0D7E, 0x060D, 0xFB18, 0xFB17, 0x7E23, 0x7E1F,
+ 0x2752, 0x1269, 0x2751, 0x09B4, 0x08CA, 0x1A94,
+ 0x3F96, 0x0BB3, 0x0107, 0x09B5, 0x005B, 0x03D6,
+ 0x00B0, 0x0101, 0x7E20, 0x060C, 0x03D7, 0x0032,
+ 0x04DE, 0xFA91, 0x7DA8, 0x088E, 0x0374, 0x7DA9,
+ 0x054E, 0x007A, 0x0223, 0x0152, 0x3F26, 0x7DAA,
+ 0x0610, 0x1A36, 0x13B3, 0x0E58, 0x1A35, 0x7DAD,
+ 0x3F27, 0x7DAE, 0x7DAB, 0x7DAC, 0xFA8D, 0x2347,
+ 0xFA8E, 0xFA8C, 0x7DA6, 0x3F24, 0x2348, 0x7DA7,
+ 0x0E4F, 0x02C8, 0x0376, 0xFA90, 0xFA8F, 0x0116,
+ 0x008A, 0x059A, 0x3F25, 0x0044, 0x00AC, 0x1A37,
+ 0x0153, 0x0066, 0x01DE, 0x049C, 0xFA96, 0x3F28,
+ 0x0370, 0x00EA, 0x054F, 0x3F29, 0x006B, 0x093C,
+ 0x0570, 0x11E2, 0x26E0, 0x1A38, 0x26E1, 0x234A,
+ 0x7DB1, 0x093D, 0x1FD7, 0x2349, 0x7DAF, 0x7DB0,
+ 0x0310, 0x0775, 0xFA93, 0xFA92, 0x13B4, 0x009A,
+ 0x0022, 0x093B, 0x020E, 0x002A, 0x003C, 0xFA95,
+ 0xFA94, 0x033C, 0x00A8, 0x00C9, 0x26E3, 0xFA99,
+ 0x051D, 0x00FA, 0x0154, 0x093E, 0x00DE, 0x0371,
+ 0x002E, 0xFA9A, 0x11E3, 0x0377, 0x0776, 0x7DB2,
+ 0x11E4, 0x11E5, 0x7DB3, 0x3F2B, 0xFA9B, 0x234E,
+ 0x11E6, 0x26E2, 0x059B, 0xFA98, 0xFA97, 0x234B,
+ 0x0A0D, 0x059C, 0x234C, 0x0571, 0x006C, 0x075C,
+ 0x234D, 0x3F2A, 0x06C2, 0x00FE, 0x0311, 0x059D,
+ 0x010A, 0x031C, 0x059E, 0x11E8, 0x0587, 0x2352,
+ 0x0312, 0x7DB6, 0xFA9E, 0x04DF, 0x1FD8, 0x11E9,
+ 0x093F, 0x0A0E, 0x0E5A, 0x11EA, 0x2353, 0x1FD9,
+ 0x0573, 0x11EB, 0x7DB7, 0xFA9F, 0x0E5B, 0xFA9C,
+ 0xFA9D, 0x7DB4, 0x234F, 0x0E59, 0x0572, 0x2351,
+ 0x2350, 0x11E7, 0x049D, 0x3F2D, 0x3F2C, 0x0023,
+ 0x010D, 0x088F, 0x7DB5, 0x26E4, 0x0611, 0xFAA4,
+ 0x1A39, 0xFAA5, 0xFAA3, 0x26E7, 0xFAA6, 0x3F2F,
+ 0x2356, 0x2357, 0x0940, 0x13B8, 0xFAA7, 0x7DBC,
+ 0x1FDA, 0x2358, 0xFAA8, 0x3F30, 0x26E8, 0xFAA9,
+ 0xFAAA, 0xFAAB, 0x2359, 0x7DBD, 0x7DB9, 0x2354,
+ 0x11EC, 0xFAA0, 0x7DB8, 0x13B5, 0x11ED, 0x2355,
+ 0x7DBA, 0x13B6, 0x13B7, 0x7DBB, 0xFAA1, 0x26E5,
+ 0x0612, 0x3F2E, 0x26E6, 0xFAA2, 0x7D9E, 0x0590,
+ 0x7D9F, 0xBF7D, 0x0D0F, 0x13AF, 0x0591, 0x1A1C,
+ 0x1FD3, 0x17EE, 0x0592, 0x3F1A, 0xBF7E, 0x11DC,
+ 0x0593, 0x206F, 0x7DA0, 0x3F1C, 0xBF7F, 0x1A1E,
+ 0x3F1D, 0x1A1D, 0x245C, 0x110E, 0x110F, 0x58BE,
+ 0x0220, 0x0150, 0x1FD2, 0x7D9C, 0x04DC, 0x05E6,
+ 0x0D0E, 0x001E, 0xBF7C, 0x58BF, 0x0B80, 0x054C,
+ 0x13AE, 0x206E, 0x02A3, 0x051C, 0x1A30, 0x245F,
+ 0x0466, 0x7DA1, 0x030A, 0x3F1F, 0xFA82, 0x088C,
+ 0x05E7, 0x04DD, 0x13B0, 0x0790, 0x1A31, 0x1FD4,
+ 0x13B1, 0x7DA2, 0x2638, 0x1A32, 0x2341, 0x2340,
+ 0x2639, 0x3F1E, 0xFA80, 0x0594, 0x11DE, 0x11DF,
+ 0x0596, 0x1A1F, 0x0595, 0x02C4, 0x051A, 0x0E4D,
+ 0x0E4C, 0x040C, 0x245E, 0x0464, 0xFA81, 0x245D,
+ 0x0222, 0x0074, 0x031A, 0x3F21, 0x263B, 0x06EB,
+ 0x0254, 0x0774, 0x0020, 0x0078, 0x0410, 0x02EE,
+ 0x13B2, 0xFA84, 0x06C0, 0x0A0A, 0x0E4E, 0x0597,
+ 0xFA85, 0xFA87, 0x0598, 0x11E0, 0xFA86, 0x263C,
+ 0x1FD5, 0x2343, 0xFA83, 0x3F20, 0x2342, 0x030B,
+ 0x263A, 0x0B81, 0x0586, 0x040E, 0x040F, 0x2345,
+ 0x2344, 0x02C6, 0x0130, 0x030C, 0x054D, 0x01BE,
+ 0x0132, 0x0599, 0x3F23, 0x00FA, 0x012E, 0x03CE,
+ 0xFA8B, 0x263E, 0x02C7, 0x006A, 0x093A, 0x0E6E,
+ 0x0182, 0x0021, 0x00C8, 0x1A33, 0x7DA5, 0x0E6F,
+ 0x1FD6, 0x1A34, 0x2346, 0x263F, 0x3F22, 0x7DA4,
+ 0xFA88, 0x7DA3, 0x030D, 0x0A0C, 0xFA89, 0x11E1,
+ 0x088D, 0x0256, 0x030F, 0x030E, 0x02F8, 0x0060,
+ 0x02B8, 0xFA8A, 0x263D, 0x0257, 0x13BE, 0x7DCD,
+ 0xFAB4, 0x0E83, 0x13BF, 0x015B, 0x26F8, 0x26F7,
+ 0x0B89, 0x0947, 0x3F39, 0x11F9, 0x13C0, 0x26F9,
+ 0x05AF, 0x11FC, 0x11FA, 0x11FB, 0x0E84, 0x11FE,
+ 0xFAB5, 0x11FD, 0x26F5, 0xFAB2, 0x235F, 0x05AC,
+ 0x26F6, 0x05AD, 0x7DCB, 0x7DCA, 0x2360, 0x0946,
+ 0x7DCC, 0xFAB3, 0x057A, 0x0318, 0x11F8, 0x05AE,
+ 0x2361, 0x0B88, 0x26FB, 0x1203, 0x1204, 0x0E85,
+ 0x0E86, 0x0D4F, 0x0E87, 0x0948, 0x0A10, 0x1FE2,
+ 0x057C, 0x1A3F, 0x0D50, 0x015D, 0x057D, 0x1205,
+ 0x1A40, 0x13C2, 0x26FC, 0x26FD, 0x1206, 0x3F3A,
+ 0x1A41, 0x1FE1, 0x0E8E, 0x26FA, 0xFAB6, 0x11FF,
+ 0x1201, 0x7DCE, 0x1200, 0x05B0, 0x13C1, 0x089E,
+ 0x0319, 0x015C, 0x057B, 0x070A, 0x1A3E, 0x1202,
+ 0x011D, 0x031A, 0x7DCF, 0x1209, 0x0E90, 0x015F,
+ 0x002B, 0x05B1, 0x0D54, 0x04E5, 0x0160, 0x05B2,
+ 0x13C4, 0x0E88, 0x1FE5, 0x1FE6, 0x2362, 0x3F3B,
+ 0x13C5, 0x26FF, 0x0161, 0x057E, 0x0779, 0x0D51,
+ 0x13C3, 0x1A42, 0x04E4, 0x1208, 0x1A44, 0x1FE3,
+ 0x1207, 0x1A43, 0x0225, 0x26FE, 0x1FE4, 0x015E,
+ 0x0D53, 0x002A, 0x0E8F, 0x0D52, 0x0778, 0x2701,
+ 0x2363, 0x3F3E, 0x1FE8, 0xFAB8, 0x13C9, 0x2365,
+ 0x2364, 0x031B, 0x120A, 0x0E8B, 0x05B8, 0x0E8A,
+ 0x13CA, 0x3F3F, 0x2702, 0x1FE9, 0x120B, 0x7DD0,
+ 0x094A, 0x2366, 0xFAB9, 0x13CB, 0x1A45, 0x13C7,
+ 0x05B3, 0xFAB7, 0x13C6, 0x3F3D, 0x05B4, 0x3F3C,
+ 0x1FE7, 0x05B5, 0x13C8, 0x0E89, 0x1A46, 0x1A47,
+ 0x05B6, 0x05B7, 0x2700, 0x0949, 0x0122, 0x05B9,
+ 0x2704, 0x031D, 0x0469, 0x094C, 0xFABA, 0x120F,
+ 0x1A48, 0x0638, 0x1210, 0x13CC, 0x01B3, 0x3F42,
+ 0x1A49, 0xFABB, 0x3F41, 0x0E8C, 0x1A4A, 0x2367,
+ 0x3F43, 0x094D, 0x2703, 0x094B, 0x7DD1, 0x3F40,
+ 0x031C, 0x0226, 0x1FEA, 0x7DD2, 0x120C, 0x03DA,
+ 0x0B8A, 0x120D, 0x002C, 0x03CC, 0x04E6, 0x7DD3,
+ 0x120E, 0x089F, 0x04E2, 0x059F, 0xFAAD, 0x0117,
+ 0x0137, 0x0613, 0x235C, 0x3F31, 0x0899, 0x02EF,
+ 0x0025, 0x0942, 0x0468, 0x0E8C, 0x0A0F, 0x13BA,
+ 0x7DBE, 0x13B9, 0x05A0, 0x7DC0, 0x26EB, 0x7DBF,
+ 0x235A, 0x235B, 0x0372, 0x0313, 0x0941, 0x0898,
+ 0x26E9, 0x0574, 0x02C9, 0x051E, 0x0024, 0x1FDB,
+ 0x0467, 0x0791, 0x04E1, 0x26EA, 0xFAAC, 0x04E0,
+ 0x3F34, 0x0E5D, 0x26ED, 0xFAAE, 0x1FDC, 0x0575,
+ 0x0314, 0x7DC4, 0x1FDD, 0x1FDE, 0x05A1, 0x0E5E,
+ 0x26EE, 0x26EF, 0x7DC5, 0x11EE, 0xFAAF, 0x3F35,
+ 0x11EF, 0x26F0, 0x7DC6, 0xFAB0, 0x05A2, 0x7DC1,
+ 0x0E5C, 0x7DC2, 0x00CA, 0x01B0, 0x235D, 0x3F32,
+ 0x075E, 0x0B82, 0x0155, 0x0156, 0x3F33, 0x26EC,
+ 0x0708, 0x0B83, 0x1A3B, 0x7DC3, 0x1A3A, 0x089B,
+ 0x11F2, 0x05A5, 0x0E5F, 0x0027, 0x01B2, 0x089C,
+ 0x26F3, 0x0B85, 0x0157, 0x011C, 0x0944, 0x0577,
+ 0x7DC8, 0x13BB, 0x089D, 0x05A6, 0x0315, 0x0E8D,
+ 0xFAB1, 0x1A3C, 0x03AC, 0x0576, 0x7DC7, 0x0B84,
+ 0x05A3, 0x26F1, 0x26F2, 0x05A4, 0x0224, 0x0943,
+ 0x0D4C, 0x11F0, 0x1FDF, 0x089A, 0x02F0, 0x0D4D,
+ 0x0026, 0x11F1, 0x0777, 0x0E82, 0x0029, 0x05A8,
+ 0x1A3D, 0x0028, 0x00CB, 0x0159, 0x11F6, 0x0709,
+ 0x0614, 0x04E3, 0x015A, 0x0578, 0x0B87, 0x1FE0,
+ 0x05AA, 0x7DC9, 0x05A9, 0x05AB, 0x0579, 0x11F7,
+ 0x3F38, 0x0945, 0x13BC, 0x26F4, 0x235E, 0x3F36,
+ 0x0158, 0x05A7, 0x3F37, 0x0E80, 0x11F3, 0x13BD,
+ 0x0B86, 0x0E81, 0x0316, 0x0317, 0x0D4E, 0x11F5,
+ 0x11F4, 0x075F, 0x06C3, 0x08A6, 0x0B8D, 0x0584,
+ 0x022A, 0x02CA, 0x13D5, 0x0E93, 0x0217, 0x011F,
+ 0x0124, 0x0120, 0x0B8E, 0x06C4, 0x0326, 0x0327,
+ 0x05BC, 0x0B8F, 0xFAC1, 0x0955, 0x1217, 0x7DD9,
+ 0x0328, 0x0323, 0x0324, 0x2369, 0x7DD8, 0x0031,
+ 0x1FF3, 0x1216, 0xFAC0, 0x1215, 0x0032, 0x00CD,
+ 0x03AF, 0x0A12, 0x01BC, 0x0070, 0x0325, 0x0E92,
+ 0x038E, 0x02D7, 0x2708, 0x13D7, 0x0296, 0x039A,
+ 0x00FE, 0x070D, 0x01ED, 0x02D8, 0x0398, 0x077E,
+ 0x0167, 0x0244, 0x0329, 0x01BD, 0x0521, 0x022B,
+ 0x1A50, 0x0122, 0x08A9, 0x0A13, 0x05DD, 0x070C,
+ 0x04E9, 0x0033, 0x0121, 0x13D6, 0x0956, 0x08A7,
+ 0x0585, 0x0166, 0x0204, 0x08A8, 0x0586, 0x04A0,
+ 0x02CB, 0x003D, 0x0588, 0x0289, 0x03C2, 0x03B8,
+ 0x077F, 0x0587, 0x04EB, 0x00CF, 0x01A3, 0x13D9,
+ 0x0617, 0x01A2, 0x06C5, 0x0522, 0x03B9, 0x070E,
+ 0x0762, 0x08AA, 0x1A51, 0x0169, 0x03BA, 0x1218,
+ 0x0523, 0x04EC, 0x3F49, 0x0E96, 0x04EA, 0x02CA,
+ 0x0D59, 0x13D8, 0x03D2, 0x0E95, 0x0957, 0x0E94,
+ 0x0168, 0x0123, 0x031E, 0x0412, 0x032A, 0x00CE,
+ 0x039C, 0x0E95, 0x0D5A, 0x0071, 0x13DC, 0x7DDA,
+ 0x236C, 0x0E96, 0x13DD, 0x032C, 0x1A52, 0x0B90,
+ 0x0589, 0x032D, 0x2709, 0x1FF6, 0x058A, 0x1219,
+ 0x05BD, 0x058B, 0x0035, 0x270A, 0x05DE, 0x095A,
+ 0x1A53, 0x016B, 0x022C, 0x070F, 0x13DA, 0x0958,
+ 0x3F4A, 0x0588, 0x0D5B, 0x13DB, 0x236A, 0x0780,
+ 0x3F4B, 0x1FF4, 0x0959, 0x0034, 0x016A, 0x236B,
+ 0x1FF5, 0x032B, 0x270B, 0x02F3, 0xFAC4, 0x7DDC,
+ 0x1FF7, 0x0124, 0x095C, 0x016C, 0x0072, 0x016A,
+ 0x04EE, 0x270D, 0x270C, 0x022D, 0x04A1, 0x270E,
+ 0x0E97, 0x0618, 0xFAC5, 0x0E98, 0x3F4C, 0x236E,
+ 0x1A54, 0x05BF, 0x032E, 0x121A, 0xFAC2, 0x05BE,
+ 0x01EE, 0x04ED, 0x236D, 0x03BB, 0x0125, 0x00EC,
+ 0x7DDB, 0xFAC3, 0x05DF, 0x00C9, 0x08AB, 0x095B,
+ 0x013C, 0x01FE, 0x0B8B, 0xFABD, 0x7DD4, 0x0615,
+ 0x01EA, 0x0E91, 0x057F, 0x016E, 0x0156, 0x08A1,
+ 0x094E, 0x7DD5, 0x03D1, 0x01B6, 0x1FEC, 0x1FEB,
+ 0xFABE, 0x7DD6, 0x1212, 0x7DD7, 0xFABF, 0x1A4C,
+ 0x0E8D, 0x3F44, 0xFABC, 0x002D, 0x006A, 0x01B5,
+ 0x13CD, 0x08A0, 0x01B4, 0x03D0, 0x006B, 0x1211,
+ 0x3F45, 0x0227, 0x02FE, 0x077A, 0x1A4B, 0x014A,
+ 0x0E91, 0x1FED, 0x2705, 0x0162, 0x094F, 0x002E,
+ 0x04E8, 0x1FEE, 0x0A11, 0x0950, 0x0581, 0x1FEF,
+ 0x1FF0, 0x2706, 0x3F47, 0x1A4F, 0x0582, 0x05BA,
+ 0x002F, 0x031E, 0x13CF, 0x0760, 0x0580, 0x0E92,
+ 0x031D, 0x04E7, 0x1A4D, 0x1A4E, 0x0E8E, 0x01B7,
+ 0x02F1, 0x02F2, 0x3F46, 0x0E8F, 0x0616, 0x0D55,
+ 0x006C, 0x0E93, 0x0E90, 0x13CE, 0x049E, 0x0411,
+ 0x13D0, 0x08A2, 0x03AD, 0x02D3, 0x0228, 0x13D1,
+ 0x006D, 0x006D, 0x0792, 0x01B8, 0x077C, 0x0229,
+ 0x0320, 0x1FF1, 0x3F48, 0x0D56, 0x13D2, 0x01B9,
+ 0x2707, 0x2368, 0x0D57, 0x00CC, 0x0520, 0x1213,
+ 0x0163, 0x051F, 0x0951, 0x1214, 0x0E94, 0x0164,
+ 0x00FC, 0x070B, 0x077B, 0x0761, 0x00C6, 0x017A,
+ 0x031F, 0x0583, 0x01EE, 0x00D4, 0x0165, 0x0952,
+ 0x02C8, 0x00C8, 0x023A, 0x0030, 0x01EC, 0x00FD,
+ 0x02F9, 0x01BB, 0x0953, 0x01A0, 0x13D4, 0x08A5,
+ 0x0030, 0x08A4, 0x077D, 0x006E, 0x0D58, 0x0954,
+ 0x05DC, 0x0123, 0x0321, 0x01BA, 0x0288, 0x05BB,
+ 0x13D3, 0x0322, 0x03AE, 0x0B8C, 0x049F, 0x1FF2,
+ 0x08A3, 0x006E, 0x02D6, 0x006F, 0x011E, 0x0373,
+ 0x03BF, 0x01EA, 0x08AF, 0x0595, 0x0100, 0x0112,
+ 0x0050, 0x02B9, 0x014C, 0x01A4, 0x0258, 0x04F2,
+ 0x0596, 0x00A4, 0x13E1, 0x0124, 0x08B0, 0x04F3,
+ 0x0171, 0x0413, 0x2713, 0x0E9B, 0x046C, 0x00A2,
+ 0x0765, 0x05E0, 0x019C, 0x0964, 0x0335, 0x061C,
+ 0x3F4F, 0x0E9A, 0x009A, 0x0170, 0x0784, 0x003E,
+ 0x012F, 0x01A3, 0x023D, 0x01F0, 0x016B, 0x00A3,
+ 0x023F, 0x03C4, 0x03D4, 0x0377, 0x0052, 0x01BE,
+ 0x0031, 0x0012, 0x0157, 0x021A, 0x0242, 0x039E,
+ 0x04A2, 0x05E1, 0x02F6, 0x1A5D, 0x0336, 0x0126,
+ 0x05E2, 0x2374, 0x05C4, 0x046D, 0x0311, 0x01A5,
+ 0x04F4, 0xFAC8, 0x023E, 0x0A17, 0x0D5F, 0x05C3,
+ 0x08B1, 0x009C, 0x02CD, 0x0299, 0x036A, 0x0376,
+ 0x006C, 0x0037, 0x0785, 0x0076, 0x0040, 0x0965,
+ 0x13E2, 0x02CC, 0x0259, 0x0414, 0x06C6, 0x01A6,
+ 0x033F, 0x0334, 0x0E9C, 0x0786, 0x0127, 0x0966,
+ 0x06C7, 0x063B, 0x0039, 0x0172, 0x0374, 0x003A,
+ 0x0597, 0x0128, 0x00FF, 0x0526, 0x2375, 0x0044,
+ 0x0337, 0x0B95, 0x0230, 0x7DDE, 0x0D60, 0x0185,
+ 0x0D61, 0x0038, 0x0321, 0x003F, 0x009D, 0x0101,
+ 0x03B9, 0x0312, 0x0969, 0x1A5E, 0x1220, 0x2714,
+ 0x003B, 0x0598, 0x2715, 0x1FFB, 0x08B2, 0x096A,
+ 0x0EA1, 0x7DDF, 0x1FFC, 0x0A18, 0x1A5F, 0x1222,
+ 0x1221, 0x0173, 0x0793, 0x061D, 0x096B, 0x7DE0,
+ 0x0787, 0x0231, 0x0711, 0x0EA0, 0xFAC9, 0x121D,
+ 0x05C5, 0x121F, 0x121E, 0x3F50, 0x0E9D, 0x0338,
+ 0x0968, 0x0967, 0x04F5, 0x0B96, 0x05C7, 0x05C6,
+ 0x03BE, 0x01B8, 0x1225, 0x1224, 0x02CE, 0x0160,
+ 0x0102, 0xFACD, 0x3F51, 0x0322, 0xFACE, 0x0339,
+ 0x059A, 0x019E, 0x063C, 0x01BF, 0x7DE2, 0x3F52,
+ 0x0D62, 0x2718, 0x3F53, 0x2717, 0x0EA2, 0x0599,
+ 0x13E3, 0xFACA, 0xFACB, 0x06C8, 0x06C9, 0xFACC,
+ 0x7DE1, 0x0125, 0x01BC, 0x13E4, 0x1223, 0x0336,
+ 0x02BA, 0x028B, 0x2716, 0x2376, 0x02CD, 0x013D,
+ 0x095E, 0x05C0, 0x0016, 0x016F, 0x0525, 0x2371,
+ 0x2370, 0x0205, 0x01C8, 0x058C, 0x0B91, 0x00E6,
+ 0x0639, 0x0330, 0x2372, 0x3F4D, 0x0763, 0x016E,
+ 0x121B, 0x1FF9, 0x058D, 0x016D, 0x1A55, 0x270F,
+ 0x13DE, 0xFAC6, 0x1FF8, 0x236F, 0x1A56, 0x04EF,
+ 0x0298, 0x0E99, 0x095D, 0x01BE, 0x02CC, 0x0524,
+ 0x032F, 0x7DDD, 0x0589, 0x095F, 0x03BC, 0x1A59,
+ 0x0E9A, 0x0E9B, 0x061A, 0x13E0, 0x0E9C, 0x08AD,
+ 0x0332, 0x0A15, 0x0591, 0x0D5D, 0x0590, 0x0960,
+ 0x2373, 0x2711, 0x1A5A, 0x058A, 0x006F, 0x3F4E,
+ 0x2712, 0x0764, 0x08AC, 0x05C1, 0xFAC7, 0x0331,
+ 0x1FFA, 0x13DF, 0x2710, 0x1A57, 0x0E97, 0x058E,
+ 0x0619, 0x0A14, 0x1A58, 0x0D5C, 0x0782, 0x058F,
+ 0x121C, 0x0781, 0x0210, 0x0594, 0x0962, 0x0080,
+ 0x0399, 0x03C3, 0x02F5, 0x0184, 0x028A, 0x046B,
+ 0x0963, 0x0B92, 0x0100, 0x1A5B, 0x0A16, 0x0E9D,
+ 0x03BD, 0x0B93, 0x01A4, 0x0333, 0x0783, 0x033E,
+ 0x00FE, 0x0592, 0x031F, 0x046A, 0x0593, 0x0961,
+ 0x04F0, 0x00FF, 0x02F4, 0x0073, 0x0E98, 0x04F1,
+ 0x033D, 0x0266, 0x02FF, 0x03D3, 0x0320, 0x0206,
+ 0x004E, 0x023C, 0x01EF, 0x0211, 0x0027, 0x000C,
+ 0x063A, 0x08AE, 0x008C, 0x03CE, 0x02D9, 0x02FA,
+ 0x01A2, 0x01A5, 0x061B, 0x0E9E, 0x05C2, 0x022F,
+ 0x039D, 0x01F0, 0x1A5C, 0x0E9F, 0x02CB, 0x03B8,
+ 0x014B, 0x0B94, 0x0E99, 0x013E, 0x016F, 0x0036,
+ 0x0334, 0x0D5E, 0x0310, 0x0207, 0x0044, 0x017B,
+ 0x00DF, 0x0042, 0x022E, 0x0710, 0x007E,
+};
+
+static const uint8_t on2avc_cb8_bits[ON2AVC_CB8_CODES] = {
+ 11, 11, 16, 15, 11, 9,
+ 13, 12, 9, 11, 11, 14,
+ 13, 12, 13, 14, 14, 13,
+ 10, 11, 15, 15, 10, 16,
+ 16, 15, 16, 11, 13, 13,
+ 16, 13, 11, 11, 15, 13,
+ 11, 9, 13, 13, 10, 9,
+ 16, 13, 9, 10, 10, 15,
+ 10, 10, 10, 12, 14, 11,
+ 14, 12, 14, 11, 12, 11,
+ 12, 14, 10, 10, 11, 16,
+ 10, 13, 14, 14, 11, 13,
+ 11, 13, 12, 10, 10, 10,
+ 15, 10, 10, 12, 12, 12,
+ 15, 12, 11, 12, 13, 10,
+ 11, 11, 12, 13, 11, 13,
+ 12, 15, 13, 11, 11, 12,
+ 14, 11, 11, 11, 13, 14,
+ 11, 13, 14, 13, 12, 12,
+ 12, 11, 14, 12, 10, 13,
+ 14, 11, 13, 15, 14, 14,
+ 13, 13, 14, 13, 13, 13,
+ 15, 14, 12, 14, 14, 14,
+ 16, 14, 12, 12, 16, 16,
+ 12, 13, 12, 14, 14, 13,
+ 13, 16, 14, 13, 14, 13,
+ 13, 13, 13, 15, 14, 13,
+ 10, 12, 16, 16, 12, 10,
+ 13, 14, 11, 11, 12, 14,
+ 14, 11, 12, 16, 13, 12,
+ 14, 14, 14, 16, 15, 16,
+ 15, 16, 15, 14, 12, 14,
+ 13, 11, 10, 11, 14, 14,
+ 11, 9, 14, 14, 10, 16,
+ 12, 15, 16, 12, 11, 14,
+ 13, 9, 11, 11, 15, 15,
+ 12, 13, 14, 15, 12, 16,
+ 14, 15, 15, 13, 14, 14,
+ 15, 14, 14, 14, 13, 15,
+ 12, 14, 12, 15, 15, 12,
+ 11, 13, 15, 10, 14, 13,
+ 14, 13, 13, 13, 13, 13,
+ 13, 12, 13, 13, 12, 14,
+ 14, 16, 12, 14, 11, 13,
+ 13, 12, 14, 15, 13, 13,
+ 13, 13, 13, 14, 13, 13,
+ 13, 14, 13, 13, 12, 14,
+ 14, 13, 11, 12, 13, 12,
+ 12, 10, 13, 13, 11, 11,
+ 12, 14, 11, 12, 13, 15,
+ 14, 14, 16, 11, 13, 13,
+ 11, 15, 10, 14, 13, 12,
+ 12, 13, 12, 13, 11, 11,
+ 11, 12, 11, 10, 12, 13,
+ 10, 10, 13, 13, 10, 10,
+ 10, 10, 15, 11, 11, 13,
+ 12, 11, 13, 12, 11, 16,
+ 14, 10, 14, 11, 10, 10,
+ 15, 12, 11, 13, 12, 11,
+ 14, 13, 11, 13, 11, 10,
+ 9, 10, 10, 14, 10, 9,
+ 14, 13, 9, 9, 10, 10,
+ 10, 10, 10, 12, 14, 10,
+ 14, 13, 12, 11, 14, 13,
+ 11, 13, 9, 11, 13, 13,
+ 11, 14, 14, 12, 12, 13,
+ 10, 12, 12, 10, 9, 10,
+ 10, 10, 10, 9, 10, 10,
+ 11, 10, 8, 12, 12, 9,
+ 11, 10, 10, 11, 11, 12,
+ 12, 14, 12, 10, 14, 13,
+ 16, 10, 10, 11, 16, 14,
+ 11, 12, 14, 12, 12, 10,
+ 11, 10, 10, 11, 9, 11,
+ 11, 9, 11, 12, 13, 10,
+ 10, 11, 11, 11, 11, 10,
+ 13, 13, 10, 13, 11, 11,
+ 11, 12, 11, 11, 11, 10,
+ 10, 12, 12, 10, 14, 12,
+ 11, 12, 12, 11, 12, 12,
+ 11, 10, 11, 11, 11, 11,
+ 14, 13, 13, 13, 13, 12,
+ 13, 13, 12, 12, 12, 13,
+ 13, 12, 13, 13, 14, 14,
+ 13, 12, 13, 15, 14, 12,
+ 13, 16, 14, 12, 14, 14,
+ 14, 13, 13, 12, 13, 13,
+ 12, 12, 14, 13, 12, 10,
+ 13, 14, 14, 10, 11, 14,
+ 14, 11, 10, 13, 13, 11,
+ 12, 12, 14, 14, 14, 13,
+ 13, 14, 13, 13, 14, 13,
+ 12, 11, 12, 15, 14, 12,
+ 9, 12, 13, 10, 9, 11,
+ 13, 14, 11, 10, 13, 15,
+ 14, 10, 11, 13, 14, 11,
+ 11, 12, 12, 10, 12, 12,
+ 15, 15, 12, 14, 14, 14,
+ 13, 13, 14, 14, 14, 11,
+ 12, 14, 15, 12, 10, 12,
+ 13, 9, 9, 11, 14, 15,
+ 11, 14, 13, 13, 13, 15,
+ 13, 13, 14, 12, 14, 13,
+ 13, 13, 12, 13, 14, 14,
+ 13, 11, 11, 15, 13, 11,
+ 12, 13, 15, 12, 12, 13,
+ 14, 14, 14, 13, 13, 13,
+ 13, 13, 12, 13, 14, 13,
+ 10, 14, 13, 11, 10, 11,
+ 11, 11, 11, 11, 12, 12,
+ 11, 12, 13, 12, 11, 13,
+ 10, 12, 11, 10, 11, 13,
+ 12, 10, 12, 12, 12, 11,
+ 12, 10, 12, 12, 10, 10,
+ 11, 11, 11, 11, 9, 10,
+ 11, 10, 10, 9, 12, 12,
+ 9, 11, 11, 10, 9, 10,
+ 13, 14, 13, 12, 10, 10,
+ 14, 14, 10, 11, 11, 13,
+ 13, 11, 13, 13, 12, 11,
+ 10, 11, 11, 10, 10, 9,
+ 12, 12, 9, 11, 12, 13,
+ 12, 12, 11, 12, 13, 11,
+ 11, 12, 12, 12, 12, 13,
+ 15, 14, 14, 13, 12, 16,
+ 14, 12, 11, 12, 16, 15,
+ 12, 13, 15, 13, 13, 12,
+ 12, 12, 12, 11, 10, 13,
+ 13, 10, 10, 12, 13, 10,
+ 10, 10, 11, 11, 11, 11,
+ 12, 12, 11, 13, 12, 12,
+ 13, 13, 11, 12, 13, 11,
+ 11, 12, 12, 11, 13, 13,
+ 13, 13, 13, 10, 14, 11,
+ 11, 10, 11, 11, 11, 10,
+ 11, 12, 13, 12, 11, 10,
+ 12, 12, 10, 11, 10, 11,
+ 12, 11, 13, 12, 14, 13,
+ 11, 12, 13, 14, 12, 11,
+ 11, 14, 14, 12, 12, 13,
+ 13, 13, 12, 12, 12, 12,
+ 11, 10, 12, 12, 10, 13,
+ 14, 13, 12, 12, 13, 13,
+ 13, 12, 12, 14, 13, 12,
+ 14, 12, 11, 14, 13, 11,
+ 11, 13, 12, 11, 13, 14,
+ 12, 14, 14, 14, 13, 14,
+ 12, 13, 13, 13, 13, 13,
+ 13, 12, 13, 10, 12, 14,
+ 15, 13, 10, 13, 12, 11,
+ 11, 12, 13, 13, 11, 11,
+ 12, 13, 12, 16, 11, 13,
+ 16, 14, 16, 15, 15, 16,
+ 13, 11, 14, 13, 12, 11,
+ 11, 15, 13, 11, 9, 13,
+ 14, 11, 10, 12, 15, 14,
+ 12, 11, 13, 13, 10, 11,
+ 11, 14, 14, 11, 12, 13,
+ 13, 11, 13, 12, 14, 16,
+ 12, 16, 13, 15, 15, 13,
+ 12, 13, 14, 14, 10, 11,
+ 14, 14, 11, 10, 13, 13,
+ 9, 12, 14, 16, 12, 13,
+ 13, 12, 13, 13, 12, 14,
+ 14, 13, 14, 14, 15, 14,
+ 13, 12, 13, 11, 11, 11,
+ 13, 13, 13, 14, 13, 13,
+ 14, 14, 12, 14, 16, 14,
+ 13, 12, 13, 14, 13, 12,
+ 12, 12, 12, 12, 11, 12,
+ 14, 11, 12, 12, 12, 11,
+ 11, 14, 14, 13, 13, 11,
+ 12, 14, 12, 11, 14, 11,
+ 13, 13, 11, 12, 13, 13,
+ 12, 12, 11, 12, 12, 12,
+ 11, 12, 13, 11, 10, 13,
+ 13, 11, 10, 11, 11, 11,
+ 11, 11, 13, 12, 11, 14,
+ 13, 12, 13, 12, 11, 14,
+ 12, 11, 12, 13, 13, 11,
+ 13, 13, 13, 12, 12, 10,
+ 12, 12, 10, 10, 10, 11,
+ 11, 11, 12, 15, 15, 13,
+ 12, 13, 14, 14, 14, 13,
+ 16, 14, 13, 15, 14, 14,
+ 16, 15, 13, 14, 15, 13,
+ 14, 14, 14, 13, 15, 13,
+ 14, 13, 14, 13, 16, 14,
+ 12, 12, 13, 13, 12, 13,
+ 13, 14, 13, 13, 13, 11,
+ 14, 14, 12, 14, 13, 13,
+ 12, 13, 13, 14, 15, 14,
+ 13, 12, 15, 15, 13, 14,
+ 12, 14, 14, 13, 14, 15,
+ 13, 13, 13, 13, 13, 13,
+ 12, 12, 15, 14, 12, 13,
+ 15, 14, 12, 12, 12, 12,
+ 15, 12, 12, 13, 14, 12,
+ 13, 13, 13, 14, 14, 13,
+ 13, 14, 13, 14, 14, 14,
+ 13, 14, 14, 13, 13, 13,
+ 12, 14, 13, 12, 12, 13,
+ 14, 12, 12, 16, 15, 15,
+ 13, 13, 13, 14, 14, 13,
+ 13, 12, 12, 14, 13, 13,
+ 12, 14, 14, 14, 12, 12,
+ 14, 14, 16, 13, 16, 14,
+ 14, 16, 14, 13, 14, 13,
+ 14, 14, 14, 13, 13, 16,
+ 13, 13, 11, 15, 15, 12,
+ 12, 13, 14, 15, 12, 11,
+ 13, 13, 11, 13, 11, 14,
+ 14, 14, 14, 11, 15, 14,
+ 13, 14, 14, 14, 14, 14,
+ 15, 15, 13, 11, 14, 13,
+ 12, 11, 12, 15, 15, 12,
+ 12, 14, 15, 11, 11, 13,
+ 14, 15, 12, 13, 13, 13,
+ 11, 13, 13, 15, 14, 12,
+ 14, 14, 13, 13, 14, 15,
+ 16, 16, 13, 13, 14, 16,
+ 14, 12, 12, 14, 11, 11,
+ 13, 15, 15, 12, 16, 14,
+ 14, 14, 15, 13, 14, 14,
+ 13, 13, 13, 13, 13, 13,
+ 14, 14, 14, 14, 14, 13,
+ 15, 14, 12, 14, 15, 16,
+ 16, 13, 14, 15, 15, 14,
+ 16, 14, 14, 14, 14, 13,
+ 14, 16, 13, 13, 14, 14,
+ 12, 12, 12, 14, 12, 13,
+ 12, 14, 13, 12, 14, 15,
+ 15, 13, 13, 12, 13, 13,
+ 13, 13, 14, 13, 12, 13,
+ 13, 13, 13, 13, 12, 14,
+ 14, 12, 12, 12, 14, 13,
+ 13, 12, 12, 12, 14, 13,
+ 12, 14, 15, 12, 13, 12,
+ 12, 14, 13, 14, 15, 16,
+ 14, 15, 13, 16, 16, 13,
+ 13, 13, 14, 14, 13, 12,
+ 13, 14, 13, 13, 12, 14,
+ 13, 12, 11, 14, 14, 12,
+ 7, 10, 15, 16, 10, 7,
+ 12, 13, 7, 11, 11, 15,
+ 16, 12, 12, 14, 14, 13,
+ 16, 14, 16, 16, 16, 15,
+ 16, 16, 15, 15, 13, 14,
+ 14, 13, 12, 13, 16, 13,
+ 12, 9, 12, 13, 9, 9,
+ 13, 13, 9, 8, 10, 16,
+ 14, 10, 11, 13, 13, 10,
+ 13, 12, 15, 14, 12, 16,
+ 16, 15, 15, 14, 15, 15,
+ 16, 13, 12, 14, 14, 13,
+ 10, 13, 12, 11, 9, 11,
+ 16, 14, 11, 9, 12, 15,
+ 15, 11, 9, 13, 15, 9,
+ 11, 11, 14, 14, 12, 12,
+ 14, 13, 14, 14, 14, 15,
+ 15, 15, 14, 14, 16, 16,
+ 14, 12, 13, 13, 13, 11,
+ 11, 16, 13, 12, 14, 13,
+ 13, 10, 11, 15, 12, 12,
+ 16, 12, 16, 14, 11, 11,
+ 13, 14, 11, 14, 11, 15,
+ 15, 13, 14, 14, 16, 15,
+ 16, 15, 14, 15, 14, 14,
+ 16, 14, 12, 12, 14, 12,
+ 12, 12, 12, 16, 14, 12,
+ 15, 15, 16, 16, 14, 16,
+ 14, 13, 12, 14, 14, 15,
+ 16, 13, 12, 11, 14, 13,
+ 16, 12, 12, 16, 16, 14,
+ 14, 16, 16, 15, 14, 15,
+ 15, 14, 12, 13, 15, 14,
+ 15, 15, 14, 14, 16, 16,
+ 14, 16, 16, 14, 14, 14,
+ 14, 13, 14, 13, 16, 15,
+ 14, 14, 14, 14, 14, 16,
+ 15, 16, 14, 14, 16, 16,
+ 15, 16, 15, 13, 16, 16,
+ 15, 14, 14, 14, 15, 14,
+ 14, 15, 15, 14, 11, 15,
+ 15, 12, 10, 12, 16, 15,
+ 13, 11, 14, 13, 11, 13,
+ 13, 16, 15, 12, 15, 15,
+ 15, 14, 14, 16, 16, 15,
+ 14, 13, 14, 15, 14, 12,
+ 14, 13, 11, 13, 12, 14,
+ 15, 11, 9, 12, 15, 15,
+ 11, 9, 12, 13, 9, 10,
+ 12, 14, 14, 10, 12, 13,
+ 14, 12, 14, 15, 15, 16,
+ 15, 14, 14, 14, 15, 14,
+ 12, 13, 13, 13, 12, 11,
+ 13, 14, 12, 10, 12, 13,
+ 9, 7, 13, 13, 7, 6,
+ 9, 14, 15, 9, 10, 14,
+ 12, 9, 13, 13, 15, 16,
+ 12, 14, 16, 16, 15, 15,
+ 14, 14, 14, 13, 12, 13,
+ 14, 12, 11, 13, 13, 10,
+ 9, 10, 15, 14, 10, 6,
+ 12, 16, 15, 12, 10, 15,
+ 13, 10, 12, 13, 14, 15,
+ 12, 13, 13, 13, 13, 15,
+ 14, 15, 15, 15, 16, 15,
+ 16, 16, 15, 14, 15, 15,
+ 13, 11, 12, 16, 16, 12,
+ 9, 14, 14, 8, 9, 13,
+ 13, 8, 9, 11, 16, 14,
+ 11, 11, 13, 14, 11, 13,
+ 13, 14, 14, 13, 14, 15,
+ 15, 13, 13, 15, 15, 15,
+ 13, 12, 16, 16, 13, 10,
+ 13, 13, 10, 6, 11, 16,
+ 16, 10, 9, 12, 14, 16,
+ 11, 10, 13, 13, 10, 11,
+ 12, 16, 14, 12, 12, 15,
+ 14, 14, 15, 14, 16, 15,
+ 14, 14, 14, 16, 16, 15,
+ 12, 14, 15, 13, 11, 11,
+ 15, 14, 11, 9, 13, 14,
+ 9, 11, 14, 14, 11, 15,
+ 13, 15, 16, 12, 13, 14,
+ 13, 12, 13, 14, 15, 13,
+ 13, 14, 15, 16, 13, 16,
+ 16, 15, 15, 13, 13, 15,
+ 15, 14, 11, 14, 14, 13,
+ 10, 12, 15, 14, 12, 16,
+ 13, 16, 16, 14, 16, 14,
+ 15, 15, 13, 13, 16, 15,
+ 13, 15, 16, 14, 14, 16,
+ 16, 16, 15, 15, 15, 15,
+ 14, 16, 15, 13, 14, 15,
+ 15, 13, 13, 15, 16, 14,
+ 12, 14, 14, 16, 15, 14,
+ 15, 16, 13, 13, 14, 15,
+ 13, 13, 14, 14, 16, 14,
+ 14, 14, 15, 14, 16, 15,
+ 14, 15, 14, 15, 15, 16,
+ 12, 13, 13, 15, 12, 12,
+ 13, 13, 16, 16, 12, 13,
+ 13, 14, 14, 11, 13, 14,
+ 11, 15, 13, 14, 16, 12,
+ 12, 12, 13, 11, 13, 13,
+ 13, 15, 14, 13, 15, 15,
+ 14, 14, 16, 14, 14, 14,
+ 14, 15, 14, 11, 11, 13,
+ 13, 11, 14, 11, 16, 14,
+ 12, 9, 11, 14, 14, 11,
+ 10, 12, 13, 10, 11, 12,
+ 13, 16, 11, 12, 13, 14,
+ 16, 16, 14, 14, 16, 14,
+ 13, 15, 16, 14, 15, 13,
+ 14, 12, 11, 11, 11, 15,
+ 15, 11, 9, 13, 13, 9,
+ 9, 14, 14, 9, 9, 11,
+ 16, 14, 11, 11, 13, 12,
+ 11, 13, 12, 13, 15, 12,
+ 13, 13, 15, 14, 14, 15,
+ 16, 15, 13, 12, 16, 14,
+ 12, 10, 13, 13, 10, 8,
+ 10, 16, 14, 10, 13, 15,
+ 16, 13, 13, 13, 14, 14,
+ 12, 13, 14, 14, 13, 14,
+ 14, 14, 14, 14, 13, 14,
+ 16, 14, 14, 16, 15, 14,
+ 14, 14, 15, 15, 15, 13,
+ 15, 16, 13, 13, 14, 14,
+ 15, 12, 14, 14, 14, 13,
+ 13, 12, 13, 13, 12, 13,
+ 13, 13, 12, 13, 13, 14,
+ 13, 13, 14, 14, 14, 14,
+ 13, 13, 12, 14, 16, 14,
+ 14, 15, 14, 14, 13, 12,
+ 13, 13, 13, 11, 13, 14,
+ 12, 13, 15, 14, 12, 13,
+ 13, 14, 12, 12, 13, 14,
+ 13, 13, 13, 13, 15, 14,
+ 13, 14, 13, 13, 12, 12,
+ 13, 13, 12, 14, 13, 13,
+ 14, 13, 12, 14, 13, 13,
+ 12, 13, 12, 12, 12, 14,
+ 15, 14, 13, 16, 13, 15,
+ 15, 13, 14, 13, 14, 13,
+ 13, 14, 14, 13, 14, 15,
+ 13, 15, 16, 13, 13, 13,
+ 14, 16, 13, 14, 14, 14,
+ 13, 14, 13, 13, 13, 13,
+ 14, 14, 14, 13, 11, 14,
+ 14, 13, 11, 13, 16, 14,
+ 13, 11, 14, 13, 12, 14,
+ 13, 16, 14, 13, 13, 15,
+ 14, 13, 14, 13, 15, 14,
+ 13, 12, 13, 15, 14, 10,
+ 12, 14, 13, 10, 12, 15,
+ 14, 12, 12, 14, 16, 12,
+ 11, 12, 15, 14, 12, 12,
+ 13, 13, 11, 12, 12, 13,
+ 15, 13, 14, 15, 14, 15,
+ 15, 15, 11, 13, 13, 12,
+ 14, 13, 11, 11, 13, 13,
+ 11, 11, 12, 14, 16, 12,
+ 14, 13, 14, 16, 13, 13,
+ 13, 15, 13, 13, 14, 13,
+ 14, 14, 15, 14, 16, 14,
+ 14, 14, 15, 16, 14, 15,
+ 13, 15, 12, 12, 15, 14,
+ 11, 12, 13, 13, 14, 14,
+ 11, 12, 13, 15, 13, 12,
+ 14, 14, 13, 13, 12, 12,
+ 14, 12, 13, 12, 13, 13,
+ 15, 13, 12, 14, 13, 12,
+ 16, 13, 12, 13, 15, 12,
+ 14, 14, 14, 14, 12, 13,
+ 12, 14, 13, 12, 12, 12,
+ 13, 14, 12, 13, 13, 14,
+ 13, 13, 12, 13, 14, 11,
+ 12, 12, 13, 13, 12, 13,
+ 14, 15, 14, 14, 13, 14,
+ 14, 13, 13, 14, 15, 14,
+ 13, 14, 14, 13, 14, 13,
+ 12, 13, 13, 13, 12, 14,
+ 14, 11, 11, 12, 12, 13,
+ 12, 10, 13, 13, 10, 12,
+ 11, 12, 12, 11, 13, 13,
+ 14, 12, 16, 13, 14, 15,
+ 13, 13, 13, 15, 15, 13,
+ 13, 14, 16, 14, 13, 12,
+ 12, 12, 12, 11, 13, 13,
+ 10, 10, 14, 13, 10, 10,
+ 11, 11, 11, 10, 10, 12,
+ 13, 10, 13, 12, 11, 12,
+ 13, 12, 12, 12, 11, 11,
+ 12, 13, 12, 13, 13, 12,
+ 13, 13, 11, 12, 13, 11,
+ 10, 11, 11, 11, 10, 12,
+ 12, 13, 12, 12, 11, 13,
+ 12, 11, 11, 11, 12, 11,
+ 11, 12, 13, 13, 12, 14,
+ 11, 12, 14, 12, 12, 11,
+ 12, 13, 11, 12, 13, 13,
+ 13, 12, 11, 11, 13, 12,
+ 10, 13, 12, 11, 13, 15,
+ 15, 13, 13, 13, 13, 12,
+ 13, 13, 14, 13, 13, 14,
+ 14, 13, 13, 14, 11, 13,
+ 13, 13, 12, 11, 13, 13,
+ 14, 13, 12, 13, 15, 12,
+ 14, 13, 13, 13, 13, 15,
+ 13, 13, 14, 12, 16, 15,
+ 13, 9, 13, 13, 11, 10,
+ 12, 14, 14, 12, 11, 14,
+ 13, 12, 16, 13, 14, 15,
+ 13, 14, 13, 14, 16, 14,
+ 11, 12, 15, 12, 11, 11,
+ 15, 16, 11, 10, 12, 13,
+ 11, 10, 12, 16, 15, 12,
+ 11, 12, 13, 9, 10, 12,
+ 13, 15, 11, 12, 13, 13,
+ 16, 15, 14, 15, 16, 13,
+ 13, 14, 16, 13, 12, 12,
+ 13, 12, 12, 11, 12, 14,
+ 14, 12, 10, 12, 13, 10,
+ 13, 13, 14, 13, 13, 13,
+ 12, 13, 12, 13, 13, 13,
+ 13, 14, 14, 13, 13, 14,
+ 13, 13, 13, 11, 13, 12,
+ 11, 12, 13, 13, 13, 12,
+ 12, 12, 14, 13, 12, 12,
+ 12, 12, 13, 13, 11, 11,
+ 13, 12, 12, 10, 12, 13,
+ 11, 12, 11, 12, 12, 12,
+ 13, 13, 14, 12, 13, 12,
+ 14, 15, 12, 12, 11, 14,
+ 13, 11, 13, 14, 12, 13,
+ 11, 11, 12, 11, 10, 10,
+ 13, 13, 10, 10, 13, 13,
+ 10, 10, 10, 12, 11, 11,
+ 10, 12, 13, 11, 13, 12,
+ 13, 12, 12, 12, 12, 13,
+ 11, 11, 13, 12, 11, 14,
+ 13, 13, 12, 12, 11, 13,
+ 12, 11, 10, 11, 12, 11,
+ 10, 9, 12, 13, 9, 9,
+ 10, 10, 10, 10, 10, 12,
+ 13, 11, 13, 12, 12, 12,
+ 13, 11, 14, 12, 11, 10,
+ 11, 11, 10, 13, 13, 12,
+ 14, 12, 11, 13, 12, 11,
+ 9, 10, 10, 10, 10, 10,
+ 10, 10, 11, 10, 9, 12,
+ 12, 9, 10, 10, 10, 10,
+ 11, 11, 12, 13, 13, 11,
+ 11, 15, 14, 11, 10, 10,
+ 12, 16, 10, 12, 12, 14,
+ 12, 11, 10, 10, 10, 10,
+ 9, 13, 12, 9, 11, 13,
+ 13, 11, 10, 11, 11, 11,
+ 10, 10, 12, 12, 11, 13,
+ 11, 11, 13, 13, 11, 13,
+ 13, 11, 10, 11, 15, 10,
+ 13, 12, 12, 15, 12, 11,
+ 12, 13, 11, 11, 11, 11,
+ 10, 10, 13, 13, 14, 14,
+ 13, 13, 14, 13, 12, 13,
+ 13, 15, 13, 12, 13, 14,
+ 14, 13, 11, 12, 13, 15,
+ 12, 12, 11, 13, 16, 14,
+ 14, 14, 14, 14, 12, 13,
+ 13, 13, 12, 12, 14, 14,
+ 12, 9, 14, 14, 10, 9,
+ 11, 16, 14, 11, 16, 13,
+ 13, 10, 11, 12, 15, 14,
+ 12, 14, 14, 14, 13, 13,
+ 13, 16, 16, 11, 11, 16,
+ 15, 12, 9, 13, 14, 10,
+ 10, 11, 14, 15, 11, 11,
+ 13, 14, 10, 9, 11, 15,
+ 15, 11, 10, 13, 12, 9,
+ 11, 13, 15, 14, 11, 13,
+ 14, 13, 13, 13, 13, 14,
+ 13, 16, 13, 15, 13, 12,
+ 10, 13, 13, 10, 10, 11,
+ 13, 15, 11, 13, 12, 13,
+ 13, 13, 12, 13, 13, 12,
+ 13, 12, 13, 12, 13, 13,
+ 15, 14, 13, 11, 12, 14,
+ 14, 11, 12, 14, 16, 13,
+ 13, 13, 14, 13, 12, 13,
+ 12, 12, 13, 12, 12, 13,
+ 14, 12, 10, 13, 13, 11,
+ 10, 10, 12, 11, 11, 11,
+ 13, 12, 11, 13, 12, 13,
+ 12, 12, 11, 13, 12, 10,
+ 10, 13, 11, 11, 13, 13,
+ 12, 11, 12, 11, 12, 12,
+ 10, 10, 10, 11, 11, 11,
+ 9, 10, 11, 10, 11, 9,
+ 11, 12, 9, 10, 10, 10,
+ 10, 11, 12, 13, 14, 12,
+ 10, 11, 13, 13, 11, 10,
+ 10, 12, 12, 11, 13, 13,
+ 13, 12, 10, 11, 11, 10,
+ 10, 9, 12, 11, 8,
+};
+
+static const uint16_t on2avc_cb8_syms[ON2AVC_CB8_CODES] = {
+ 0x0000, 0x0002, 0x0004, 0x000C, 0x000E, 0x0011,
+ 0x0013, 0x001D, 0x001F, 0x0020, 0x0022, 0x0024,
+ 0x002C, 0x002E, 0x0031, 0x0033, 0x003D, 0x003F,
+ 0x0040, 0x0042, 0x0044, 0x004C, 0x004E, 0x00C0,
+ 0x00C2, 0x00C4, 0x00CC, 0x00CE, 0x00D1, 0x00D3,
+ 0x00DD, 0x00DF, 0x00E0, 0x00E2, 0x00E4, 0x00EC,
+ 0x00EE, 0x00F1, 0x00F3, 0x00FD, 0x00FF, 0x0101,
+ 0x0103, 0x010D, 0x010F, 0x0110, 0x0112, 0x0114,
+ 0x011C, 0x011E, 0x0121, 0x0123, 0x012D, 0x012F,
+ 0x0130, 0x0132, 0x0134, 0x013C, 0x013E, 0x0141,
+ 0x0143, 0x014D, 0x014F, 0x01C1, 0x01C3, 0x01CD,
+ 0x01CF, 0x01D0, 0x01D2, 0x01D4, 0x01DC, 0x01DE,
+ 0x01E1, 0x01E3, 0x01ED, 0x01EF, 0x01F0, 0x01F2,
+ 0x01F4, 0x01FC, 0x01FE, 0x0200, 0x0202, 0x0204,
+ 0x020C, 0x020E, 0x0211, 0x0213, 0x021D, 0x021F,
+ 0x0220, 0x0222, 0x0224, 0x022C, 0x022E, 0x0231,
+ 0x0233, 0x023D, 0x023F, 0x0240, 0x0242, 0x0244,
+ 0x024C, 0x024E, 0x02C0, 0x02C2, 0x02C4, 0x02CC,
+ 0x02CE, 0x02D1, 0x02D3, 0x02DD, 0x02DF, 0x02E0,
+ 0x02E2, 0x02E4, 0x02EC, 0x02EE, 0x02F1, 0x02F3,
+ 0x02FD, 0x02FF, 0x0301, 0x0303, 0x030D, 0x030F,
+ 0x0310, 0x0312, 0x0314, 0x031C, 0x031E, 0x0321,
+ 0x0323, 0x032D, 0x032F, 0x0330, 0x0332, 0x0334,
+ 0x033C, 0x033E, 0x0341, 0x0343, 0x034D, 0x034F,
+ 0x03C1, 0x03C3, 0x03CD, 0x03CF, 0x03D0, 0x03D2,
+ 0x03D4, 0x03DC, 0x03DE, 0x03E1, 0x03E3, 0x03ED,
+ 0x03EF, 0x03F0, 0x03F2, 0x03F4, 0x03FC, 0x03FE,
+ 0x0400, 0x0402, 0x0404, 0x040C, 0x040E, 0x0411,
+ 0x0413, 0x041D, 0x041F, 0x0420, 0x0422, 0x0424,
+ 0x042C, 0x042E, 0x0431, 0x0433, 0x043D, 0x043F,
+ 0x0440, 0x0442, 0x0444, 0x044C, 0x044E, 0x04C0,
+ 0x04C2, 0x04C4, 0x04CC, 0x04CE, 0x04D1, 0x04D3,
+ 0x04DD, 0x04DF, 0x04E0, 0x04E2, 0x04E4, 0x04EC,
+ 0x04EE, 0x04F1, 0x04F3, 0x04FD, 0x04FF, 0x0C00,
+ 0x0C02, 0x0C04, 0x0C0C, 0x0C0E, 0x0C11, 0x0C13,
+ 0x0C1D, 0x0C1F, 0x0C20, 0x0C22, 0x0C24, 0x0C2C,
+ 0x0C2E, 0x0C31, 0x0C33, 0x0C3D, 0x0C3F, 0x0C40,
+ 0x0C42, 0x0C44, 0x0C4C, 0x0C4E, 0x0CC0, 0x0CC2,
+ 0x0CC4, 0x0CCC, 0x0CCE, 0x0CD1, 0x0CD3, 0x0CDD,
+ 0x0CDF, 0x0CE0, 0x0CE2, 0x0CE4, 0x0CEC, 0x0CEE,
+ 0x0CF1, 0x0CF3, 0x0CFD, 0x0CFF, 0x0D01, 0x0D03,
+ 0x0D0D, 0x0D0F, 0x0D10, 0x0D12, 0x0D14, 0x0D1C,
+ 0x0D1E, 0x0D21, 0x0D23, 0x0D2D, 0x0D2F, 0x0D30,
+ 0x0D32, 0x0D34, 0x0D3C, 0x0D3E, 0x0D41, 0x0D43,
+ 0x0D4D, 0x0D4F, 0x0DC1, 0x0DC3, 0x0DCD, 0x0DCF,
+ 0x0DD0, 0x0DD2, 0x0DD4, 0x0DDC, 0x0DDE, 0x0DE1,
+ 0x0DE3, 0x0DED, 0x0DEF, 0x0DF0, 0x0DF2, 0x0DF4,
+ 0x0DFC, 0x0DFE, 0x0E00, 0x0E02, 0x0E04, 0x0E0C,
+ 0x0E0E, 0x0E11, 0x0E13, 0x0E1D, 0x0E1F, 0x0E20,
+ 0x0E22, 0x0E24, 0x0E2C, 0x0E2E, 0x0E31, 0x0E33,
+ 0x0E3D, 0x0E3F, 0x0E40, 0x0E42, 0x0E44, 0x0E4C,
+ 0x0E4E, 0x0EC0, 0x0EC2, 0x0EC4, 0x0ECC, 0x0ECE,
+ 0x0ED1, 0x0ED3, 0x0EDD, 0x0EDF, 0x0EE0, 0x0EE2,
+ 0x0EE4, 0x0EEC, 0x0EEE, 0x0EF1, 0x0EF3, 0x0EFD,
+ 0x0EFF, 0x0F01, 0x0F03, 0x0F0D, 0x0F0F, 0x0F10,
+ 0x0F12, 0x0F14, 0x0F1C, 0x0F1E, 0x0F21, 0x0F23,
+ 0x0F2D, 0x0F2F, 0x0F30, 0x0F32, 0x0F34, 0x0F3C,
+ 0x0F3E, 0x0F41, 0x0F43, 0x0F4D, 0x0F4F, 0x0FC1,
+ 0x0FC3, 0x0FCD, 0x0FCF, 0x0FD0, 0x0FD2, 0x0FD4,
+ 0x0FDC, 0x0FDE, 0x0FE1, 0x0FE3, 0x0FED, 0x0FEF,
+ 0x0FF0, 0x0FF2, 0x0FF4, 0x0FFC, 0x0FFE, 0x1001,
+ 0x1003, 0x100D, 0x100F, 0x1010, 0x1012, 0x1014,
+ 0x101C, 0x101E, 0x1021, 0x1023, 0x102D, 0x102F,
+ 0x1030, 0x1032, 0x1034, 0x103C, 0x103E, 0x1041,
+ 0x1043, 0x104D, 0x104F, 0x10C1, 0x10C3, 0x10CD,
+ 0x10CF, 0x10D0, 0x10D2, 0x10D4, 0x10DC, 0x10DE,
+ 0x10E1, 0x10E3, 0x10ED, 0x10EF, 0x10F0, 0x10F2,
+ 0x10F4, 0x10FC, 0x10FE, 0x1100, 0x1102, 0x1104,
+ 0x110C, 0x110E, 0x1111, 0x1113, 0x111D, 0x111F,
+ 0x1120, 0x1122, 0x1124, 0x112C, 0x112E, 0x1131,
+ 0x1133, 0x113D, 0x113F, 0x1140, 0x1142, 0x1144,
+ 0x114C, 0x114E, 0x11C0, 0x11C2, 0x11C4, 0x11CC,
+ 0x11CE, 0x11D1, 0x11D3, 0x11DD, 0x11DF, 0x11E0,
+ 0x11E2, 0x11E4, 0x11EC, 0x11EE, 0x11F1, 0x11F3,
+ 0x11FD, 0x11FF, 0x1201, 0x1203, 0x120D, 0x120F,
+ 0x1210, 0x1212, 0x1214, 0x121C, 0x121E, 0x1221,
+ 0x1223, 0x122D, 0x122F, 0x1230, 0x1232, 0x1234,
+ 0x123C, 0x123E, 0x1241, 0x1243, 0x124D, 0x124F,
+ 0x12C1, 0x12C3, 0x12CD, 0x12CF, 0x12D0, 0x12D2,
+ 0x12D4, 0x12DC, 0x12DE, 0x12E1, 0x12E3, 0x12ED,
+ 0x12EF, 0x12F0, 0x12F2, 0x12F4, 0x12FC, 0x12FE,
+ 0x1300, 0x1302, 0x1304, 0x130C, 0x130E, 0x1311,
+ 0x1313, 0x131D, 0x131F, 0x1320, 0x1322, 0x1324,
+ 0x132C, 0x132E, 0x1331, 0x1333, 0x133D, 0x133F,
+ 0x1340, 0x1342, 0x1344, 0x134C, 0x134E, 0x13C0,
+ 0x13C2, 0x13C4, 0x13CC, 0x13CE, 0x13D1, 0x13D3,
+ 0x13DD, 0x13DF, 0x13E0, 0x13E2, 0x13E4, 0x13EC,
+ 0x13EE, 0x13F1, 0x13F3, 0x13FD, 0x13FF, 0x1401,
+ 0x1403, 0x140D, 0x140F, 0x1410, 0x1412, 0x1414,
+ 0x141C, 0x141E, 0x1421, 0x1423, 0x142D, 0x142F,
+ 0x1430, 0x1432, 0x1434, 0x143C, 0x143E, 0x1441,
+ 0x1443, 0x144D, 0x144F, 0x14C1, 0x14C3, 0x14CD,
+ 0x14CF, 0x14D0, 0x14D2, 0x14D4, 0x14DC, 0x14DE,
+ 0x14E1, 0x14E3, 0x14ED, 0x14EF, 0x14F0, 0x14F2,
+ 0x14F4, 0x14FC, 0x14FE, 0x1C01, 0x1C03, 0x1C0D,
+ 0x1C0F, 0x1C10, 0x1C12, 0x1C14, 0x1C1C, 0x1C1E,
+ 0x1C21, 0x1C23, 0x1C2D, 0x1C2F, 0x1C30, 0x1C32,
+ 0x1C34, 0x1C3C, 0x1C3E, 0x1C41, 0x1C43, 0x1C4D,
+ 0x1C4F, 0x1CC1, 0x1CC3, 0x1CCD, 0x1CCF, 0x1CD0,
+ 0x1CD2, 0x1CD4, 0x1CDC, 0x1CDE, 0x1CE1, 0x1CE3,
+ 0x1CED, 0x1CEF, 0x1CF0, 0x1CF2, 0x1CF4, 0x1CFC,
+ 0x1CFE, 0x1D00, 0x1D02, 0x1D04, 0x1D0C, 0x1D0E,
+ 0x1D11, 0x1D13, 0x1D1D, 0x1D1F, 0x1D20, 0x1D22,
+ 0x1D24, 0x1D2C, 0x1D2E, 0x1D31, 0x1D33, 0x1D3D,
+ 0x1D3F, 0x1D40, 0x1D42, 0x1D44, 0x1D4C, 0x1D4E,
+ 0x1DC0, 0x1DC2, 0x1DC4, 0x1DCC, 0x1DCE, 0x1DD1,
+ 0x1DD3, 0x1DDD, 0x1DDF, 0x1DE0, 0x1DE2, 0x1DE4,
+ 0x1DEC, 0x1DEE, 0x1DF1, 0x1DF3, 0x1DFD, 0x1DFF,
+ 0x1E01, 0x1E03, 0x1E0D, 0x1E0F, 0x1E10, 0x1E12,
+ 0x1E14, 0x1E1C, 0x1E1E, 0x1E21, 0x1E23, 0x1E2D,
+ 0x1E2F, 0x1E30, 0x1E32, 0x1E34, 0x1E3C, 0x1E3E,
+ 0x1E41, 0x1E43, 0x1E4D, 0x1E4F, 0x1EC1, 0x1EC3,
+ 0x1ECD, 0x1ECF, 0x1ED0, 0x1ED2, 0x1ED4, 0x1EDC,
+ 0x1EDE, 0x1EE1, 0x1EE3, 0x1EED, 0x1EEF, 0x1EF0,
+ 0x1EF2, 0x1EF4, 0x1EFC, 0x1EFE, 0x1F00, 0x1F02,
+ 0x1F04, 0x1F0C, 0x1F0E, 0x1F11, 0x1F13, 0x1F1D,
+ 0x1F1F, 0x1F20, 0x1F22, 0x1F24, 0x1F2C, 0x1F2E,
+ 0x1F31, 0x1F33, 0x1F3D, 0x1F3F, 0x1F40, 0x1F42,
+ 0x1F44, 0x1F4C, 0x1F4E, 0x1FC0, 0x1FC2, 0x1FC4,
+ 0x1FCC, 0x1FCE, 0x1FD1, 0x1FD3, 0x1FDD, 0x1FDF,
+ 0x1FE0, 0x1FE2, 0x1FE4, 0x1FEC, 0x1FEE, 0x1FF1,
+ 0x1FF3, 0x1FFD, 0x1FFF, 0x2000, 0x2002, 0x2004,
+ 0x200C, 0x200E, 0x2011, 0x2013, 0x201D, 0x201F,
+ 0x2020, 0x2022, 0x2024, 0x202C, 0x202E, 0x2031,
+ 0x2033, 0x203D, 0x203F, 0x2040, 0x2042, 0x2044,
+ 0x204C, 0x204E, 0x20C0, 0x20C2, 0x20C4, 0x20CC,
+ 0x20CE, 0x20D1, 0x20D3, 0x20DD, 0x20DF, 0x20E0,
+ 0x20E2, 0x20E4, 0x20EC, 0x20EE, 0x20F1, 0x20F3,
+ 0x20FD, 0x20FF, 0x2101, 0x2103, 0x210D, 0x210F,
+ 0x2110, 0x2112, 0x2114, 0x211C, 0x211E, 0x2121,
+ 0x2123, 0x212D, 0x212F, 0x2130, 0x2132, 0x2134,
+ 0x213C, 0x213E, 0x2141, 0x2143, 0x214D, 0x214F,
+ 0x21C1, 0x21C3, 0x21CD, 0x21CF, 0x21D0, 0x21D2,
+ 0x21D4, 0x21DC, 0x21DE, 0x21E1, 0x21E3, 0x21ED,
+ 0x21EF, 0x21F0, 0x21F2, 0x21F4, 0x21FC, 0x21FE,
+ 0x2200, 0x2202, 0x2204, 0x220C, 0x220E, 0x2211,
+ 0x2213, 0x221D, 0x221F, 0x2220, 0x2222, 0x2224,
+ 0x222C, 0x222E, 0x2231, 0x2233, 0x223D, 0x223F,
+ 0x2240, 0x2242, 0x2244, 0x224C, 0x224E, 0x22C0,
+ 0x22C2, 0x22C4, 0x22CC, 0x22CE, 0x22D1, 0x22D3,
+ 0x22DD, 0x22DF, 0x22E0, 0x22E2, 0x22E4, 0x22EC,
+ 0x22EE, 0x22F1, 0x22F3, 0x22FD, 0x22FF, 0x2301,
+ 0x2303, 0x230D, 0x230F, 0x2310, 0x2312, 0x2314,
+ 0x231C, 0x231E, 0x2321, 0x2323, 0x232D, 0x232F,
+ 0x2330, 0x2332, 0x2334, 0x233C, 0x233E, 0x2341,
+ 0x2343, 0x234D, 0x234F, 0x23C1, 0x23C3, 0x23CD,
+ 0x23CF, 0x23D0, 0x23D2, 0x23D4, 0x23DC, 0x23DE,
+ 0x23E1, 0x23E3, 0x23ED, 0x23EF, 0x23F0, 0x23F2,
+ 0x23F4, 0x23FC, 0x23FE, 0x2400, 0x2402, 0x2404,
+ 0x240C, 0x240E, 0x2411, 0x2413, 0x241D, 0x241F,
+ 0x2420, 0x2422, 0x2424, 0x242C, 0x242E, 0x2431,
+ 0x2433, 0x243D, 0x243F, 0x2440, 0x2442, 0x2444,
+ 0x244C, 0x244E, 0x24C0, 0x24C2, 0x24C4, 0x24CC,
+ 0x24CE, 0x24D1, 0x24D3, 0x24DD, 0x24DF, 0x24E0,
+ 0x24E2, 0x24E4, 0x24EC, 0x24EE, 0x24F1, 0x24F3,
+ 0x24FD, 0x24FF, 0x2C00, 0x2C02, 0x2C04, 0x2C0C,
+ 0x2C0E, 0x2C11, 0x2C13, 0x2C1D, 0x2C1F, 0x2C20,
+ 0x2C22, 0x2C24, 0x2C2C, 0x2C2E, 0x2C31, 0x2C33,
+ 0x2C3D, 0x2C3F, 0x2C40, 0x2C42, 0x2C44, 0x2C4C,
+ 0x2C4E, 0x2CC0, 0x2CC2, 0x2CC4, 0x2CCC, 0x2CCE,
+ 0x2CD1, 0x2CD3, 0x2CDD, 0x2CDF, 0x2CE0, 0x2CE2,
+ 0x2CE4, 0x2CEC, 0x2CEE, 0x2CF1, 0x2CF3, 0x2CFD,
+ 0x2CFF, 0x2D01, 0x2D03, 0x2D0D, 0x2D0F, 0x2D10,
+ 0x2D12, 0x2D14, 0x2D1C, 0x2D1E, 0x2D21, 0x2D23,
+ 0x2D2D, 0x2D2F, 0x2D30, 0x2D32, 0x2D34, 0x2D3C,
+ 0x2D3E, 0x2D41, 0x2D43, 0x2D4D, 0x2D4F, 0x2DC1,
+ 0x2DC3, 0x2DCD, 0x2DCF, 0x2DD0, 0x2DD2, 0x2DD4,
+ 0x2DDC, 0x2DDE, 0x2DE1, 0x2DE3, 0x2DED, 0x2DEF,
+ 0x2DF0, 0x2DF2, 0x2DF4, 0x2DFC, 0x2DFE, 0x2E00,
+ 0x2E02, 0x2E04, 0x2E0C, 0x2E0E, 0x2E11, 0x2E13,
+ 0x2E1D, 0x2E1F, 0x2E20, 0x2E22, 0x2E24, 0x2E2C,
+ 0x2E2E, 0x2E31, 0x2E33, 0x2E3D, 0x2E3F, 0x2E40,
+ 0x2E42, 0x2E44, 0x2E4C, 0x2E4E, 0x2EC0, 0x2EC2,
+ 0x2EC4, 0x2ECC, 0x2ECE, 0x2ED1, 0x2ED3, 0x2EDD,
+ 0x2EDF, 0x2EE0, 0x2EE2, 0x2EE4, 0x2EEC, 0x2EEE,
+ 0x2EF1, 0x2EF3, 0x2EFD, 0x2EFF, 0x2F01, 0x2F03,
+ 0x2F0D, 0x2F0F, 0x2F10, 0x2F12, 0x2F14, 0x2F1C,
+ 0x2F1E, 0x2F21, 0x2F23, 0x2F2D, 0x2F2F, 0x2F30,
+ 0x2F32, 0x2F34, 0x2F3C, 0x2F3E, 0x2F41, 0x2F43,
+ 0x2F4D, 0x2F4F, 0x2FC1, 0x2FC3, 0x2FCD, 0x2FCF,
+ 0x2FD0, 0x2FD2, 0x2FD4, 0x2FDC, 0x2FDE, 0x2FE1,
+ 0x2FE3, 0x2FED, 0x2FEF, 0x2FF0, 0x2FF2, 0x2FF4,
+ 0x2FFC, 0x2FFE, 0x3001, 0x3003, 0x300D, 0x300F,
+ 0x3010, 0x3012, 0x3014, 0x301C, 0x301E, 0x3021,
+ 0x3023, 0x302D, 0x302F, 0x3030, 0x3032, 0x3034,
+ 0x303C, 0x303E, 0x3041, 0x3043, 0x304D, 0x304F,
+ 0x30C1, 0x30C3, 0x30CD, 0x30CF, 0x30D0, 0x30D2,
+ 0x30D4, 0x30DC, 0x30DE, 0x30E1, 0x30E3, 0x30ED,
+ 0x30EF, 0x30F0, 0x30F2, 0x30F4, 0x30FC, 0x30FE,
+ 0x3100, 0x3102, 0x3104, 0x310C, 0x310E, 0x3111,
+ 0x3113, 0x311D, 0x311F, 0x3120, 0x3122, 0x3124,
+ 0x312C, 0x312E, 0x3131, 0x3133, 0x313D, 0x313F,
+ 0x3140, 0x3142, 0x3144, 0x314C, 0x314E, 0x31C0,
+ 0x31C2, 0x31C4, 0x31CC, 0x31CE, 0x31D1, 0x31D3,
+ 0x31DD, 0x31DF, 0x31E0, 0x31E2, 0x31E4, 0x31EC,
+ 0x31EE, 0x31F1, 0x31F3, 0x31FD, 0x31FF, 0x3201,
+ 0x3203, 0x320D, 0x320F, 0x3210, 0x3212, 0x3214,
+ 0x321C, 0x321E, 0x3221, 0x3223, 0x322D, 0x322F,
+ 0x3230, 0x3232, 0x3234, 0x323C, 0x323E, 0x3241,
+ 0x3243, 0x324D, 0x324F, 0x32C1, 0x32C3, 0x32CD,
+ 0x32CF, 0x32D0, 0x32D2, 0x32D4, 0x32DC, 0x32DE,
+ 0x32E1, 0x32E3, 0x32ED, 0x32EF, 0x32F0, 0x32F2,
+ 0x32F4, 0x32FC, 0x32FE, 0x3300, 0x3302, 0x3304,
+ 0x330C, 0x330E, 0x3311, 0x3313, 0x331D, 0x331F,
+ 0x3320, 0x3322, 0x3324, 0x332C, 0x332E, 0x3331,
+ 0x3333, 0x333D, 0x333F, 0x3340, 0x3342, 0x3344,
+ 0x334C, 0x334E, 0x33C0, 0x33C2, 0x33C4, 0x33CC,
+ 0x33CE, 0x33D1, 0x33D3, 0x33DD, 0x33DF, 0x33E0,
+ 0x33E2, 0x33E4, 0x33EC, 0x33EE, 0x33F1, 0x33F3,
+ 0x33FD, 0x33FF, 0x3401, 0x3403, 0x340D, 0x340F,
+ 0x3410, 0x3412, 0x3414, 0x341C, 0x341E, 0x3421,
+ 0x3423, 0x342D, 0x342F, 0x3430, 0x3432, 0x3434,
+ 0x343C, 0x343E, 0x3441, 0x3443, 0x344D, 0x344F,
+ 0x34C1, 0x34C3, 0x34CD, 0x34CF, 0x34D0, 0x34D2,
+ 0x34D4, 0x34DC, 0x34DE, 0x34E1, 0x34E3, 0x34ED,
+ 0x34EF, 0x34F0, 0x34F2, 0x34F4, 0x34FC, 0x34FE,
+ 0x3C01, 0x3C03, 0x3C0D, 0x3C0F, 0x3C10, 0x3C12,
+ 0x3C14, 0x3C1C, 0x3C1E, 0x3C21, 0x3C23, 0x3C2D,
+ 0x3C2F, 0x3C30, 0x3C32, 0x3C34, 0x3C3C, 0x3C3E,
+ 0x3C41, 0x3C43, 0x3C4D, 0x3C4F, 0x3CC1, 0x3CC3,
+ 0x3CCD, 0x3CCF, 0x3CD0, 0x3CD2, 0x3CD4, 0x3CDC,
+ 0x3CDE, 0x3CE1, 0x3CE3, 0x3CED, 0x3CEF, 0x3CF0,
+ 0x3CF2, 0x3CF4, 0x3CFC, 0x3CFE, 0x3D00, 0x3D02,
+ 0x3D04, 0x3D0C, 0x3D0E, 0x3D11, 0x3D13, 0x3D1D,
+ 0x3D1F, 0x3D20, 0x3D22, 0x3D24, 0x3D2C, 0x3D2E,
+ 0x3D31, 0x3D33, 0x3D3D, 0x3D3F, 0x3D40, 0x3D42,
+ 0x3D44, 0x3D4C, 0x3D4E, 0x3DC0, 0x3DC2, 0x3DC4,
+ 0x3DCC, 0x3DCE, 0x3DD1, 0x3DD3, 0x3DDD, 0x3DDF,
+ 0x3DE0, 0x3DE2, 0x3DE4, 0x3DEC, 0x3DEE, 0x3DF1,
+ 0x3DF3, 0x3DFD, 0x3DFF, 0x3E01, 0x3E03, 0x3E0D,
+ 0x3E0F, 0x3E10, 0x3E12, 0x3E14, 0x3E1C, 0x3E1E,
+ 0x3E21, 0x3E23, 0x3E2D, 0x3E2F, 0x3E30, 0x3E32,
+ 0x3E34, 0x3E3C, 0x3E3E, 0x3E41, 0x3E43, 0x3E4D,
+ 0x3E4F, 0x3EC1, 0x3EC3, 0x3ECD, 0x3ECF, 0x3ED0,
+ 0x3ED2, 0x3ED4, 0x3EDC, 0x3EDE, 0x3EE1, 0x3EE3,
+ 0x3EED, 0x3EEF, 0x3EF0, 0x3EF2, 0x3EF4, 0x3EFC,
+ 0x3EFE, 0x3F00, 0x3F02, 0x3F04, 0x3F0C, 0x3F0E,
+ 0x3F11, 0x3F13, 0x3F1D, 0x3F1F, 0x3F20, 0x3F22,
+ 0x3F24, 0x3F2C, 0x3F2E, 0x3F31, 0x3F33, 0x3F3D,
+ 0x3F3F, 0x3F40, 0x3F42, 0x3F44, 0x3F4C, 0x3F4E,
+ 0x3FC0, 0x3FC2, 0x3FC4, 0x3FCC, 0x3FCE, 0x3FD1,
+ 0x3FD3, 0x3FDD, 0x3FDF, 0x3FE0, 0x3FE2, 0x3FE4,
+ 0x3FEC, 0x3FEE, 0x3FF1, 0x3FF3, 0x3FFD, 0x3FFF,
+ 0x4000, 0x4002, 0x4004, 0x400C, 0x400E, 0x4011,
+ 0x4013, 0x401D, 0x401F, 0x4020, 0x4022, 0x4024,
+ 0x402C, 0x402E, 0x4031, 0x4033, 0x403D, 0x403F,
+ 0x4040, 0x4042, 0x4044, 0x404C, 0x404E, 0x40C0,
+ 0x40C2, 0x40C4, 0x40CC, 0x40CE, 0x40D1, 0x40D3,
+ 0x40DD, 0x40DF, 0x40E0, 0x40E2, 0x40E4, 0x40EC,
+ 0x40EE, 0x40F1, 0x40F3, 0x40FD, 0x40FF, 0x4101,
+ 0x4103, 0x410D, 0x410F, 0x4110, 0x4112, 0x4114,
+ 0x411C, 0x411E, 0x4121, 0x4123, 0x412D, 0x412F,
+ 0x4130, 0x4132, 0x4134, 0x413C, 0x413E, 0x4141,
+ 0x4143, 0x414D, 0x414F, 0x41C1, 0x41C3, 0x41CD,
+ 0x41CF, 0x41D0, 0x41D2, 0x41D4, 0x41DC, 0x41DE,
+ 0x41E1, 0x41E3, 0x41ED, 0x41EF, 0x41F0, 0x41F2,
+ 0x41F4, 0x41FC, 0x41FE, 0x4200, 0x4202, 0x4204,
+ 0x420C, 0x420E, 0x4211, 0x4213, 0x421D, 0x421F,
+ 0x4220, 0x4222, 0x4224, 0x422C, 0x422E, 0x4231,
+ 0x4233, 0x423D, 0x423F, 0x4240, 0x4242, 0x4244,
+ 0x424C, 0x424E, 0x42C0, 0x42C2, 0x42C4, 0x42CC,
+ 0x42CE, 0x42D1, 0x42D3, 0x42DD, 0x42DF, 0x42E0,
+ 0x42E2, 0x42E4, 0x42EC, 0x42EE, 0x42F1, 0x42F3,
+ 0x42FD, 0x42FF, 0x4301, 0x4303, 0x430D, 0x430F,
+ 0x4310, 0x4312, 0x4314, 0x431C, 0x431E, 0x4321,
+ 0x4323, 0x432D, 0x432F, 0x4330, 0x4332, 0x4334,
+ 0x433C, 0x433E, 0x4341, 0x4343, 0x434D, 0x434F,
+ 0x43C1, 0x43C3, 0x43CD, 0x43CF, 0x43D0, 0x43D2,
+ 0x43D4, 0x43DC, 0x43DE, 0x43E1, 0x43E3, 0x43ED,
+ 0x43EF, 0x43F0, 0x43F2, 0x43F4, 0x43FC, 0x43FE,
+ 0x4400, 0x4402, 0x4404, 0x440C, 0x440E, 0x4411,
+ 0x4413, 0x441D, 0x441F, 0x4420, 0x4422, 0x4424,
+ 0x442C, 0x442E, 0x4431, 0x4433, 0x443D, 0x443F,
+ 0x4440, 0x4442, 0x4444, 0x444C, 0x444E, 0x44C0,
+ 0x44C2, 0x44C4, 0x44CC, 0x44CE, 0x44D1, 0x44D3,
+ 0x44DD, 0x44DF, 0x44E0, 0x44E2, 0x44E4, 0x44EC,
+ 0x44EE, 0x44F1, 0x44F3, 0x44FD, 0x44FF, 0x4C00,
+ 0x4C02, 0x4C04, 0x4C0C, 0x4C0E, 0x4C11, 0x4C13,
+ 0x4C1D, 0x4C1F, 0x4C20, 0x4C22, 0x4C24, 0x4C2C,
+ 0x4C2E, 0x4C31, 0x4C33, 0x4C3D, 0x4C3F, 0x4C40,
+ 0x4C42, 0x4C44, 0x4C4C, 0x4C4E, 0x4CC0, 0x4CC2,
+ 0x4CC4, 0x4CCC, 0x4CCE, 0x4CD1, 0x4CD3, 0x4CDD,
+ 0x4CDF, 0x4CE0, 0x4CE2, 0x4CE4, 0x4CEC, 0x4CEE,
+ 0x4CF1, 0x4CF3, 0x4CFD, 0x4CFF, 0x4D01, 0x4D03,
+ 0x4D0D, 0x4D0F, 0x4D10, 0x4D12, 0x4D14, 0x4D1C,
+ 0x4D1E, 0x4D21, 0x4D23, 0x4D2D, 0x4D2F, 0x4D30,
+ 0x4D32, 0x4D34, 0x4D3C, 0x4D3E, 0x4D41, 0x4D43,
+ 0x4D4D, 0x4D4F, 0x4DC1, 0x4DC3, 0x4DCD, 0x4DCF,
+ 0x4DD0, 0x4DD2, 0x4DD4, 0x4DDC, 0x4DDE, 0x4DE1,
+ 0x4DE3, 0x4DED, 0x4DEF, 0x4DF0, 0x4DF2, 0x4DF4,
+ 0x4DFC, 0x4DFE, 0x4E00, 0x4E02, 0x4E04, 0x4E0C,
+ 0x4E0E, 0x4E11, 0x4E13, 0x4E1D, 0x4E1F, 0x4E20,
+ 0x4E22, 0x4E24, 0x4E2C, 0x4E2E, 0x4E31, 0x4E33,
+ 0x4E3D, 0x4E3F, 0x4E40, 0x4E42, 0x4E44, 0x4E4C,
+ 0x4E4E, 0x4EC0, 0x4EC2, 0x4EC4, 0x4ECC, 0x4ECE,
+ 0x4ED1, 0x4ED3, 0x4EDD, 0x4EDF, 0x4EE0, 0x4EE2,
+ 0x4EE4, 0x4EEC, 0x4EEE, 0x4EF1, 0x4EF3, 0x4EFD,
+ 0x4EFF, 0x4F01, 0x4F03, 0x4F0D, 0x4F0F, 0x4F10,
+ 0x4F12, 0x4F14, 0x4F1C, 0x4F1E, 0x4F21, 0x4F23,
+ 0x4F2D, 0x4F2F, 0x4F30, 0x4F32, 0x4F34, 0x4F3C,
+ 0x4F3E, 0x4F41, 0x4F43, 0x4F4D, 0x4F4F, 0x4FC1,
+ 0x4FC3, 0x4FCD, 0x4FCF, 0x4FD0, 0x4FD2, 0x4FD4,
+ 0x4FDC, 0x4FDE, 0x4FE1, 0x4FE3, 0x4FED, 0x4FEF,
+ 0x4FF0, 0x4FF2, 0x4FF4, 0x4FFC, 0x4FFE, 0xC000,
+ 0xC002, 0xC004, 0xC00C, 0xC00E, 0xC011, 0xC013,
+ 0xC01D, 0xC01F, 0xC020, 0xC022, 0xC024, 0xC02C,
+ 0xC02E, 0xC031, 0xC033, 0xC03D, 0xC03F, 0xC040,
+ 0xC042, 0xC044, 0xC04C, 0xC04E, 0xC0C0, 0xC0C2,
+ 0xC0C4, 0xC0CC, 0xC0CE, 0xC0D1, 0xC0D3, 0xC0DD,
+ 0xC0DF, 0xC0E0, 0xC0E2, 0xC0E4, 0xC0EC, 0xC0EE,
+ 0xC0F1, 0xC0F3, 0xC0FD, 0xC0FF, 0xC101, 0xC103,
+ 0xC10D, 0xC10F, 0xC110, 0xC112, 0xC114, 0xC11C,
+ 0xC11E, 0xC121, 0xC123, 0xC12D, 0xC12F, 0xC130,
+ 0xC132, 0xC134, 0xC13C, 0xC13E, 0xC141, 0xC143,
+ 0xC14D, 0xC14F, 0xC1C1, 0xC1C3, 0xC1CD, 0xC1CF,
+ 0xC1D0, 0xC1D2, 0xC1D4, 0xC1DC, 0xC1DE, 0xC1E1,
+ 0xC1E3, 0xC1ED, 0xC1EF, 0xC1F0, 0xC1F2, 0xC1F4,
+ 0xC1FC, 0xC1FE, 0xC200, 0xC202, 0xC204, 0xC20C,
+ 0xC20E, 0xC211, 0xC213, 0xC21D, 0xC21F, 0xC220,
+ 0xC222, 0xC224, 0xC22C, 0xC22E, 0xC231, 0xC233,
+ 0xC23D, 0xC23F, 0xC240, 0xC242, 0xC244, 0xC24C,
+ 0xC24E, 0xC2C0, 0xC2C2, 0xC2C4, 0xC2CC, 0xC2CE,
+ 0xC2D1, 0xC2D3, 0xC2DD, 0xC2DF, 0xC2E0, 0xC2E2,
+ 0xC2E4, 0xC2EC, 0xC2EE, 0xC2F1, 0xC2F3, 0xC2FD,
+ 0xC2FF, 0xC301, 0xC303, 0xC30D, 0xC30F, 0xC310,
+ 0xC312, 0xC314, 0xC31C, 0xC31E, 0xC321, 0xC323,
+ 0xC32D, 0xC32F, 0xC330, 0xC332, 0xC334, 0xC33C,
+ 0xC33E, 0xC341, 0xC343, 0xC34D, 0xC34F, 0xC3C1,
+ 0xC3C3, 0xC3CD, 0xC3CF, 0xC3D0, 0xC3D2, 0xC3D4,
+ 0xC3DC, 0xC3DE, 0xC3E1, 0xC3E3, 0xC3ED, 0xC3EF,
+ 0xC3F0, 0xC3F2, 0xC3F4, 0xC3FC, 0xC3FE, 0xC400,
+ 0xC402, 0xC404, 0xC40C, 0xC40E, 0xC411, 0xC413,
+ 0xC41D, 0xC41F, 0xC420, 0xC422, 0xC424, 0xC42C,
+ 0xC42E, 0xC431, 0xC433, 0xC43D, 0xC43F, 0xC440,
+ 0xC442, 0xC444, 0xC44C, 0xC44E, 0xC4C0, 0xC4C2,
+ 0xC4C4, 0xC4CC, 0xC4CE, 0xC4D1, 0xC4D3, 0xC4DD,
+ 0xC4DF, 0xC4E0, 0xC4E2, 0xC4E4, 0xC4EC, 0xC4EE,
+ 0xC4F1, 0xC4F3, 0xC4FD, 0xC4FF, 0xCC00, 0xCC02,
+ 0xCC04, 0xCC0C, 0xCC0E, 0xCC11, 0xCC13, 0xCC1D,
+ 0xCC1F, 0xCC20, 0xCC22, 0xCC24, 0xCC2C, 0xCC2E,
+ 0xCC31, 0xCC33, 0xCC3D, 0xCC3F, 0xCC40, 0xCC42,
+ 0xCC44, 0xCC4C, 0xCC4E, 0xCCC0, 0xCCC2, 0xCCC4,
+ 0xCCCC, 0xCCCE, 0xCCD1, 0xCCD3, 0xCCDD, 0xCCDF,
+ 0xCCE0, 0xCCE2, 0xCCE4, 0xCCEC, 0xCCEE, 0xCCF1,
+ 0xCCF3, 0xCCFD, 0xCCFF, 0xCD01, 0xCD03, 0xCD0D,
+ 0xCD0F, 0xCD10, 0xCD12, 0xCD14, 0xCD1C, 0xCD1E,
+ 0xCD21, 0xCD23, 0xCD2D, 0xCD2F, 0xCD30, 0xCD32,
+ 0xCD34, 0xCD3C, 0xCD3E, 0xCD41, 0xCD43, 0xCD4D,
+ 0xCD4F, 0xCDC1, 0xCDC3, 0xCDCD, 0xCDCF, 0xCDD0,
+ 0xCDD2, 0xCDD4, 0xCDDC, 0xCDDE, 0xCDE1, 0xCDE3,
+ 0xCDED, 0xCDEF, 0xCDF0, 0xCDF2, 0xCDF4, 0xCDFC,
+ 0xCDFE, 0xCE00, 0xCE02, 0xCE04, 0xCE0C, 0xCE0E,
+ 0xCE11, 0xCE13, 0xCE1D, 0xCE1F, 0xCE20, 0xCE22,
+ 0xCE24, 0xCE2C, 0xCE2E, 0xCE31, 0xCE33, 0xCE3D,
+ 0xCE3F, 0xCE40, 0xCE42, 0xCE44, 0xCE4C, 0xCE4E,
+ 0xCEC0, 0xCEC2, 0xCEC4, 0xCECC, 0xCECE, 0xCED1,
+ 0xCED3, 0xCEDD, 0xCEDF, 0xCEE0, 0xCEE2, 0xCEE4,
+ 0xCEEC, 0xCEEE, 0xCEF1, 0xCEF3, 0xCEFD, 0xCEFF,
+ 0xCF01, 0xCF03, 0xCF0D, 0xCF0F, 0xCF10, 0xCF12,
+ 0xCF14, 0xCF1C, 0xCF1E, 0xCF21, 0xCF23, 0xCF2D,
+ 0xCF2F, 0xCF30, 0xCF32, 0xCF34, 0xCF3C, 0xCF3E,
+ 0xCF41, 0xCF43, 0xCF4D, 0xCF4F, 0xCFC1, 0xCFC3,
+ 0xCFCD, 0xCFCF, 0xCFD0, 0xCFD2, 0xCFD4, 0xCFDC,
+ 0xCFDE, 0xCFE1, 0xCFE3, 0xCFED, 0xCFEF, 0xCFF0,
+ 0xCFF2, 0xCFF4, 0xCFFC, 0xCFFE, 0xD001, 0xD003,
+ 0xD00D, 0xD00F, 0xD010, 0xD012, 0xD014, 0xD01C,
+ 0xD01E, 0xD021, 0xD023, 0xD02D, 0xD02F, 0xD030,
+ 0xD032, 0xD034, 0xD03C, 0xD03E, 0xD041, 0xD043,
+ 0xD04D, 0xD04F, 0xD0C1, 0xD0C3, 0xD0CD, 0xD0CF,
+ 0xD0D0, 0xD0D2, 0xD0D4, 0xD0DC, 0xD0DE, 0xD0E1,
+ 0xD0E3, 0xD0ED, 0xD0EF, 0xD0F0, 0xD0F2, 0xD0F4,
+ 0xD0FC, 0xD0FE, 0xD100, 0xD102, 0xD104, 0xD10C,
+ 0xD10E, 0xD111, 0xD113, 0xD11D, 0xD11F, 0xD120,
+ 0xD122, 0xD124, 0xD12C, 0xD12E, 0xD131, 0xD133,
+ 0xD13D, 0xD13F, 0xD140, 0xD142, 0xD144, 0xD14C,
+ 0xD14E, 0xD1C0, 0xD1C2, 0xD1C4, 0xD1CC, 0xD1CE,
+ 0xD1D1, 0xD1D3, 0xD1DD, 0xD1DF, 0xD1E0, 0xD1E2,
+ 0xD1E4, 0xD1EC, 0xD1EE, 0xD1F1, 0xD1F3, 0xD1FD,
+ 0xD1FF, 0xD201, 0xD203, 0xD20D, 0xD20F, 0xD210,
+ 0xD212, 0xD214, 0xD21C, 0xD21E, 0xD221, 0xD223,
+ 0xD22D, 0xD22F, 0xD230, 0xD232, 0xD234, 0xD23C,
+ 0xD23E, 0xD241, 0xD243, 0xD24D, 0xD24F, 0xD2C1,
+ 0xD2C3, 0xD2CD, 0xD2CF, 0xD2D0, 0xD2D2, 0xD2D4,
+ 0xD2DC, 0xD2DE, 0xD2E1, 0xD2E3, 0xD2ED, 0xD2EF,
+ 0xD2F0, 0xD2F2, 0xD2F4, 0xD2FC, 0xD2FE, 0xD300,
+ 0xD302, 0xD304, 0xD30C, 0xD30E, 0xD311, 0xD313,
+ 0xD31D, 0xD31F, 0xD320, 0xD322, 0xD324, 0xD32C,
+ 0xD32E, 0xD331, 0xD333, 0xD33D, 0xD33F, 0xD340,
+ 0xD342, 0xD344, 0xD34C, 0xD34E, 0xD3C0, 0xD3C2,
+ 0xD3C4, 0xD3CC, 0xD3CE, 0xD3D1, 0xD3D3, 0xD3DD,
+ 0xD3DF, 0xD3E0, 0xD3E2, 0xD3E4, 0xD3EC, 0xD3EE,
+ 0xD3F1, 0xD3F3, 0xD3FD, 0xD3FF, 0xD401, 0xD403,
+ 0xD40D, 0xD40F, 0xD410, 0xD412, 0xD414, 0xD41C,
+ 0xD41E, 0xD421, 0xD423, 0xD42D, 0xD42F, 0xD430,
+ 0xD432, 0xD434, 0xD43C, 0xD43E, 0xD441, 0xD443,
+ 0xD44D, 0xD44F, 0xD4C1, 0xD4C3, 0xD4CD, 0xD4CF,
+ 0xD4D0, 0xD4D2, 0xD4D4, 0xD4DC, 0xD4DE, 0xD4E1,
+ 0xD4E3, 0xD4ED, 0xD4EF, 0xD4F0, 0xD4F2, 0xD4F4,
+ 0xD4FC, 0xD4FE, 0xDC01, 0xDC03, 0xDC0D, 0xDC0F,
+ 0xDC10, 0xDC12, 0xDC14, 0xDC1C, 0xDC1E, 0xDC21,
+ 0xDC23, 0xDC2D, 0xDC2F, 0xDC30, 0xDC32, 0xDC34,
+ 0xDC3C, 0xDC3E, 0xDC41, 0xDC43, 0xDC4D, 0xDC4F,
+ 0xDCC1, 0xDCC3, 0xDCCD, 0xDCCF, 0xDCD0, 0xDCD2,
+ 0xDCD4, 0xDCDC, 0xDCDE, 0xDCE1, 0xDCE3, 0xDCED,
+ 0xDCEF, 0xDCF0, 0xDCF2, 0xDCF4, 0xDCFC, 0xDCFE,
+ 0xDD00, 0xDD02, 0xDD04, 0xDD0C, 0xDD0E, 0xDD11,
+ 0xDD13, 0xDD1D, 0xDD1F, 0xDD20, 0xDD22, 0xDD24,
+ 0xDD2C, 0xDD2E, 0xDD31, 0xDD33, 0xDD3D, 0xDD3F,
+ 0xDD40, 0xDD42, 0xDD44, 0xDD4C, 0xDD4E, 0xDDC0,
+ 0xDDC2, 0xDDC4, 0xDDCC, 0xDDCE, 0xDDD1, 0xDDD3,
+ 0xDDDD, 0xDDDF, 0xDDE0, 0xDDE2, 0xDDE4, 0xDDEC,
+ 0xDDEE, 0xDDF1, 0xDDF3, 0xDDFD, 0xDDFF, 0xDE01,
+ 0xDE03, 0xDE0D, 0xDE0F, 0xDE10, 0xDE12, 0xDE14,
+ 0xDE1C, 0xDE1E, 0xDE21, 0xDE23, 0xDE2D, 0xDE2F,
+ 0xDE30, 0xDE32, 0xDE34, 0xDE3C, 0xDE3E, 0xDE41,
+ 0xDE43, 0xDE4D, 0xDE4F, 0xDEC1, 0xDEC3, 0xDECD,
+ 0xDECF, 0xDED0, 0xDED2, 0xDED4, 0xDEDC, 0xDEDE,
+ 0xDEE1, 0xDEE3, 0xDEED, 0xDEEF, 0xDEF0, 0xDEF2,
+ 0xDEF4, 0xDEFC, 0xDEFE, 0xDF00, 0xDF02, 0xDF04,
+ 0xDF0C, 0xDF0E, 0xDF11, 0xDF13, 0xDF1D, 0xDF1F,
+ 0xDF20, 0xDF22, 0xDF24, 0xDF2C, 0xDF2E, 0xDF31,
+ 0xDF33, 0xDF3D, 0xDF3F, 0xDF40, 0xDF42, 0xDF44,
+ 0xDF4C, 0xDF4E, 0xDFC0, 0xDFC2, 0xDFC4, 0xDFCC,
+ 0xDFCE, 0xDFD1, 0xDFD3, 0xDFDD, 0xDFDF, 0xDFE0,
+ 0xDFE2, 0xDFE4, 0xDFEC, 0xDFEE, 0xDFF1, 0xDFF3,
+ 0xDFFD, 0xDFFF, 0xE000, 0xE002, 0xE004, 0xE00C,
+ 0xE00E, 0xE011, 0xE013, 0xE01D, 0xE01F, 0xE020,
+ 0xE022, 0xE024, 0xE02C, 0xE02E, 0xE031, 0xE033,
+ 0xE03D, 0xE03F, 0xE040, 0xE042, 0xE044, 0xE04C,
+ 0xE04E, 0xE0C0, 0xE0C2, 0xE0C4, 0xE0CC, 0xE0CE,
+ 0xE0D1, 0xE0D3, 0xE0DD, 0xE0DF, 0xE0E0, 0xE0E2,
+ 0xE0E4, 0xE0EC, 0xE0EE, 0xE0F1, 0xE0F3, 0xE0FD,
+ 0xE0FF, 0xE101, 0xE103, 0xE10D, 0xE10F, 0xE110,
+ 0xE112, 0xE114, 0xE11C, 0xE11E, 0xE121, 0xE123,
+ 0xE12D, 0xE12F, 0xE130, 0xE132, 0xE134, 0xE13C,
+ 0xE13E, 0xE141, 0xE143, 0xE14D, 0xE14F, 0xE1C1,
+ 0xE1C3, 0xE1CD, 0xE1CF, 0xE1D0, 0xE1D2, 0xE1D4,
+ 0xE1DC, 0xE1DE, 0xE1E1, 0xE1E3, 0xE1ED, 0xE1EF,
+ 0xE1F0, 0xE1F2, 0xE1F4, 0xE1FC, 0xE1FE, 0xE200,
+ 0xE202, 0xE204, 0xE20C, 0xE20E, 0xE211, 0xE213,
+ 0xE21D, 0xE21F, 0xE220, 0xE222, 0xE224, 0xE22C,
+ 0xE22E, 0xE231, 0xE233, 0xE23D, 0xE23F, 0xE240,
+ 0xE242, 0xE244, 0xE24C, 0xE24E, 0xE2C0, 0xE2C2,
+ 0xE2C4, 0xE2CC, 0xE2CE, 0xE2D1, 0xE2D3, 0xE2DD,
+ 0xE2DF, 0xE2E0, 0xE2E2, 0xE2E4, 0xE2EC, 0xE2EE,
+ 0xE2F1, 0xE2F3, 0xE2FD, 0xE2FF, 0xE301, 0xE303,
+ 0xE30D, 0xE30F, 0xE310, 0xE312, 0xE314, 0xE31C,
+ 0xE31E, 0xE321, 0xE323, 0xE32D, 0xE32F, 0xE330,
+ 0xE332, 0xE334, 0xE33C, 0xE33E, 0xE341, 0xE343,
+ 0xE34D, 0xE34F, 0xE3C1, 0xE3C3, 0xE3CD, 0xE3CF,
+ 0xE3D0, 0xE3D2, 0xE3D4, 0xE3DC, 0xE3DE, 0xE3E1,
+ 0xE3E3, 0xE3ED, 0xE3EF, 0xE3F0, 0xE3F2, 0xE3F4,
+ 0xE3FC, 0xE3FE, 0xE400, 0xE402, 0xE404, 0xE40C,
+ 0xE40E, 0xE411, 0xE413, 0xE41D, 0xE41F, 0xE420,
+ 0xE422, 0xE424, 0xE42C, 0xE42E, 0xE431, 0xE433,
+ 0xE43D, 0xE43F, 0xE440, 0xE442, 0xE444, 0xE44C,
+ 0xE44E, 0xE4C0, 0xE4C2, 0xE4C4, 0xE4CC, 0xE4CE,
+ 0xE4D1, 0xE4D3, 0xE4DD, 0xE4DF, 0xE4E0, 0xE4E2,
+ 0xE4E4, 0xE4EC, 0xE4EE, 0xE4F1, 0xE4F3, 0xE4FD,
+ 0xE4FF, 0xEC00, 0xEC02, 0xEC04, 0xEC0C, 0xEC0E,
+ 0xEC11, 0xEC13, 0xEC1D, 0xEC1F, 0xEC20, 0xEC22,
+ 0xEC24, 0xEC2C, 0xEC2E, 0xEC31, 0xEC33, 0xEC3D,
+ 0xEC3F, 0xEC40, 0xEC42, 0xEC44, 0xEC4C, 0xEC4E,
+ 0xECC0, 0xECC2, 0xECC4, 0xECCC, 0xECCE, 0xECD1,
+ 0xECD3, 0xECDD, 0xECDF, 0xECE0, 0xECE2, 0xECE4,
+ 0xECEC, 0xECEE, 0xECF1, 0xECF3, 0xECFD, 0xECFF,
+ 0xED01, 0xED03, 0xED0D, 0xED0F, 0xED10, 0xED12,
+ 0xED14, 0xED1C, 0xED1E, 0xED21, 0xED23, 0xED2D,
+ 0xED2F, 0xED30, 0xED32, 0xED34, 0xED3C, 0xED3E,
+ 0xED41, 0xED43, 0xED4D, 0xED4F, 0xEDC1, 0xEDC3,
+ 0xEDCD, 0xEDCF, 0xEDD0, 0xEDD2, 0xEDD4, 0xEDDC,
+ 0xEDDE, 0xEDE1, 0xEDE3, 0xEDED, 0xEDEF, 0xEDF0,
+ 0xEDF2, 0xEDF4, 0xEDFC, 0xEDFE, 0xEE00, 0xEE02,
+ 0xEE04, 0xEE0C, 0xEE0E, 0xEE11, 0xEE13, 0xEE1D,
+ 0xEE1F, 0xEE20, 0xEE22, 0xEE24, 0xEE2C, 0xEE2E,
+ 0xEE31, 0xEE33, 0xEE3D, 0xEE3F, 0xEE40, 0xEE42,
+ 0xEE44, 0xEE4C, 0xEE4E, 0xEEC0, 0xEEC2, 0xEEC4,
+ 0xEECC, 0xEECE, 0xEED1, 0xEED3, 0xEEDD, 0xEEDF,
+ 0xEEE0, 0xEEE2, 0xEEE4, 0xEEEC, 0xEEEE, 0xEEF1,
+ 0xEEF3, 0xEEFD, 0xEEFF, 0xEF01, 0xEF03, 0xEF0D,
+ 0xEF0F, 0xEF10, 0xEF12, 0xEF14, 0xEF1C, 0xEF1E,
+ 0xEF21, 0xEF23, 0xEF2D, 0xEF2F, 0xEF30, 0xEF32,
+ 0xEF34, 0xEF3C, 0xEF3E, 0xEF41, 0xEF43, 0xEF4D,
+ 0xEF4F, 0xEFC1, 0xEFC3, 0xEFCD, 0xEFCF, 0xEFD0,
+ 0xEFD2, 0xEFD4, 0xEFDC, 0xEFDE, 0xEFE1, 0xEFE3,
+ 0xEFED, 0xEFEF, 0xEFF0, 0xEFF2, 0xEFF4, 0xEFFC,
+ 0xEFFE, 0xF001, 0xF003, 0xF00D, 0xF00F, 0xF010,
+ 0xF012, 0xF014, 0xF01C, 0xF01E, 0xF021, 0xF023,
+ 0xF02D, 0xF02F, 0xF030, 0xF032, 0xF034, 0xF03C,
+ 0xF03E, 0xF041, 0xF043, 0xF04D, 0xF04F, 0xF0C1,
+ 0xF0C3, 0xF0CD, 0xF0CF, 0xF0D0, 0xF0D2, 0xF0D4,
+ 0xF0DC, 0xF0DE, 0xF0E1, 0xF0E3, 0xF0ED, 0xF0EF,
+ 0xF0F0, 0xF0F2, 0xF0F4, 0xF0FC, 0xF0FE, 0xF100,
+ 0xF102, 0xF104, 0xF10C, 0xF10E, 0xF111, 0xF113,
+ 0xF11D, 0xF11F, 0xF120, 0xF122, 0xF124, 0xF12C,
+ 0xF12E, 0xF131, 0xF133, 0xF13D, 0xF13F, 0xF140,
+ 0xF142, 0xF144, 0xF14C, 0xF14E, 0xF1C0, 0xF1C2,
+ 0xF1C4, 0xF1CC, 0xF1CE, 0xF1D1, 0xF1D3, 0xF1DD,
+ 0xF1DF, 0xF1E0, 0xF1E2, 0xF1E4, 0xF1EC, 0xF1EE,
+ 0xF1F1, 0xF1F3, 0xF1FD, 0xF1FF, 0xF201, 0xF203,
+ 0xF20D, 0xF20F, 0xF210, 0xF212, 0xF214, 0xF21C,
+ 0xF21E, 0xF221, 0xF223, 0xF22D, 0xF22F, 0xF230,
+ 0xF232, 0xF234, 0xF23C, 0xF23E, 0xF241, 0xF243,
+ 0xF24D, 0xF24F, 0xF2C1, 0xF2C3, 0xF2CD, 0xF2CF,
+ 0xF2D0, 0xF2D2, 0xF2D4, 0xF2DC, 0xF2DE, 0xF2E1,
+ 0xF2E3, 0xF2ED, 0xF2EF, 0xF2F0, 0xF2F2, 0xF2F4,
+ 0xF2FC, 0xF2FE, 0xF300, 0xF302, 0xF304, 0xF30C,
+ 0xF30E, 0xF311, 0xF313, 0xF31D, 0xF31F, 0xF320,
+ 0xF322, 0xF324, 0xF32C, 0xF32E, 0xF331, 0xF333,
+ 0xF33D, 0xF33F, 0xF340, 0xF342, 0xF344, 0xF34C,
+ 0xF34E, 0xF3C0, 0xF3C2, 0xF3C4, 0xF3CC, 0xF3CE,
+ 0xF3D1, 0xF3D3, 0xF3DD, 0xF3DF, 0xF3E0, 0xF3E2,
+ 0xF3E4, 0xF3EC, 0xF3EE, 0xF3F1, 0xF3F3, 0xF3FD,
+ 0xF3FF, 0xF401, 0xF403, 0xF40D, 0xF40F, 0xF410,
+ 0xF412, 0xF414, 0xF41C, 0xF41E, 0xF421, 0xF423,
+ 0xF42D, 0xF42F, 0xF430, 0xF432, 0xF434, 0xF43C,
+ 0xF43E, 0xF441, 0xF443, 0xF44D, 0xF44F, 0xF4C1,
+ 0xF4C3, 0xF4CD, 0xF4CF, 0xF4D0, 0xF4D2, 0xF4D4,
+ 0xF4DC, 0xF4DE, 0xF4E1, 0xF4E3, 0xF4ED, 0xF4EF,
+ 0xF4F0, 0xF4F2, 0xF4F4, 0xF4FC, 0xF4FE, 0xFC01,
+ 0xFC03, 0xFC0D, 0xFC0F, 0xFC10, 0xFC12, 0xFC14,
+ 0xFC1C, 0xFC1E, 0xFC21, 0xFC23, 0xFC2D, 0xFC2F,
+ 0xFC30, 0xFC32, 0xFC34, 0xFC3C, 0xFC3E, 0xFC41,
+ 0xFC43, 0xFC4D, 0xFC4F, 0xFCC1, 0xFCC3, 0xFCCD,
+ 0xFCCF, 0xFCD0, 0xFCD2, 0xFCD4, 0xFCDC, 0xFCDE,
+ 0xFCE1, 0xFCE3, 0xFCED, 0xFCEF, 0xFCF0, 0xFCF2,
+ 0xFCF4, 0xFCFC, 0xFCFE, 0xFD00, 0xFD02, 0xFD04,
+ 0xFD0C, 0xFD0E, 0xFD11, 0xFD13, 0xFD1D, 0xFD1F,
+ 0xFD20, 0xFD22, 0xFD24, 0xFD2C, 0xFD2E, 0xFD31,
+ 0xFD33, 0xFD3D, 0xFD3F, 0xFD40, 0xFD42, 0xFD44,
+ 0xFD4C, 0xFD4E, 0xFDC0, 0xFDC2, 0xFDC4, 0xFDCC,
+ 0xFDCE, 0xFDD1, 0xFDD3, 0xFDDD, 0xFDDF, 0xFDE0,
+ 0xFDE2, 0xFDE4, 0xFDEC, 0xFDEE, 0xFDF1, 0xFDF3,
+ 0xFDFD, 0xFDFF, 0xFE01, 0xFE03, 0xFE0D, 0xFE0F,
+ 0xFE10, 0xFE12, 0xFE14, 0xFE1C, 0xFE1E, 0xFE21,
+ 0xFE23, 0xFE2D, 0xFE2F, 0xFE30, 0xFE32, 0xFE34,
+ 0xFE3C, 0xFE3E, 0xFE41, 0xFE43, 0xFE4D, 0xFE4F,
+ 0xFEC1, 0xFEC3, 0xFECD, 0xFECF, 0xFED0, 0xFED2,
+ 0xFED4, 0xFEDC, 0xFEDE, 0xFEE1, 0xFEE3, 0xFEED,
+ 0xFEEF, 0xFEF0, 0xFEF2, 0xFEF4, 0xFEFC, 0xFEFE,
+ 0xFF00, 0xFF02, 0xFF04, 0xFF0C, 0xFF0E, 0xFF11,
+ 0xFF13, 0xFF1D, 0xFF1F, 0xFF20, 0xFF22, 0xFF24,
+ 0xFF2C, 0xFF2E, 0xFF31, 0xFF33, 0xFF3D, 0xFF3F,
+ 0xFF40, 0xFF42, 0xFF44, 0xFF4C, 0xFF4E, 0xFFC0,
+ 0xFFC2, 0xFFC4, 0xFFCC, 0xFFCE, 0xFFD1, 0xFFD3,
+ 0xFFDD, 0xFFDF, 0xFFE0, 0xFFE2, 0xFFE4, 0xFFEC,
+ 0xFFEE, 0xFFF1, 0xFFF3, 0xFFFD, 0xFFFF,
+};
+
+#define ON2AVC_CB9_CODES 121
+static const uint16_t on2avc_cb9_codes[ON2AVC_CB9_CODES] = {
+ 0x0000, 0x000F, 0x0098, 0x026E, 0x045C, 0x00A6,
+ 0x00AC, 0x045D, 0x027E, 0x009A, 0x0012, 0x000E,
+ 0x001A, 0x00DE, 0x022C, 0x053E, 0x00A2, 0x009E,
+ 0x0538, 0x01B2, 0x00BA, 0x0018, 0x00AD, 0x00BF,
+ 0x01BE, 0x037E, 0x05C6, 0x0132, 0x0112, 0x08B5,
+ 0x0457, 0x01B6, 0x00BC, 0x02AE, 0x022A, 0x045E,
+ 0x08B6, 0x08FA, 0x0147, 0x013E, 0x119F, 0x05C7,
+ 0x044F, 0x0170, 0x0456, 0x047F, 0x06C7, 0x0A72,
+ 0x0D8B, 0x0267, 0x0266, 0x0D8A, 0x08B7, 0x05CF,
+ 0x045F, 0x0054, 0x00A4, 0x0118, 0x0142, 0x0234,
+ 0x036F, 0x036E, 0x029E, 0x0156, 0x0114, 0x0088,
+ 0x00A0, 0x00A5, 0x00DA, 0x015F, 0x026F, 0x02E2,
+ 0x02E6, 0x0236, 0x015E, 0x0143, 0x00AA, 0x053A,
+ 0x0466, 0x04FE, 0x09FE, 0x119E, 0x0232, 0x0237,
+ 0x0A73, 0x09FF, 0x08B4, 0x046B, 0x02AF, 0x01B0,
+ 0x037F, 0x053F, 0x08FB, 0x0136, 0x0146, 0x08CE,
+ 0x05CE, 0x044E, 0x01B3, 0x008E, 0x00DD, 0x0226,
+ 0x047E, 0x06C6, 0x00AE, 0x011E, 0x06C4, 0x047C,
+ 0x0172, 0x00BE, 0x0010, 0x0016, 0x00BD, 0x0176,
+ 0x053B, 0x009D, 0x009C, 0x046A, 0x0177, 0x00DC,
+ 0x0019,
+};
+
+static const uint8_t on2avc_cb9_bits[ON2AVC_CB9_CODES] = {
+ 1, 4, 8, 10, 11, 8,
+ 8, 11, 10, 8, 5, 4,
+ 5, 8, 10, 11, 8, 8,
+ 11, 9, 8, 5, 8, 8,
+ 9, 10, 11, 9, 9, 12,
+ 11, 9, 8, 10, 10, 11,
+ 12, 12, 9, 9, 13, 11,
+ 11, 9, 11, 11, 11, 12,
+ 12, 10, 10, 12, 12, 11,
+ 11, 7, 8, 9, 9, 10,
+ 10, 10, 10, 9, 9, 8,
+ 8, 8, 8, 9, 10, 10,
+ 10, 10, 9, 9, 8, 11,
+ 11, 11, 12, 13, 10, 10,
+ 12, 12, 12, 11, 10, 9,
+ 10, 11, 12, 9, 9, 12,
+ 11, 11, 9, 8, 8, 10,
+ 11, 11, 8, 9, 11, 11,
+ 9, 8, 5, 5, 8, 9,
+ 11, 8, 8, 11, 9, 8,
+ 5,
+};
+
+static const uint16_t on2avc_cb9_syms[ON2AVC_CB9_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100,
+ 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x01FB,
+ 0x01FC, 0x01FD, 0x01FE, 0x01FF, 0x0200, 0x0201,
+ 0x0202, 0x0203, 0x0204, 0x0205, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x03FB, 0x03FC, 0x03FD,
+ 0x03FE, 0x03FF, 0x0400, 0x0401, 0x0402, 0x0403,
+ 0x0404, 0x0405, 0x04FB, 0x04FC, 0x04FD, 0x04FE,
+ 0x04FF, 0x0500, 0x0501, 0x0502, 0x0503, 0x0504,
+ 0x0505, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00,
+ 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFCFB,
+ 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01,
+ 0xFD02, 0xFD03, 0xFD04, 0xFD05, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFEFB, 0xFEFC, 0xFEFD,
+ 0xFEFE, 0xFEFF, 0xFF00, 0xFF01, 0xFF02, 0xFF03,
+ 0xFF04, 0xFF05, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB10_CODES 121
+static const uint16_t on2avc_cb10_codes[ON2AVC_CB10_CODES] = {
+ 0x002E, 0x001A, 0x003C, 0x001F, 0x006E, 0x002E,
+ 0x00AE, 0x006F, 0x002A, 0x003E, 0x0014, 0x0016,
+ 0x0002, 0x000E, 0x004E, 0x00F7, 0x0042, 0x0027,
+ 0x00F6, 0x0046, 0x0014, 0x0008, 0x0032, 0x0016,
+ 0x0030, 0x0012, 0x0056, 0x0018, 0x005F, 0x00DE,
+ 0x006E, 0x0036, 0x001A, 0x0023, 0x003D, 0x003F,
+ 0x007A, 0x008E, 0x0071, 0x0006, 0x0012, 0x000F,
+ 0x0043, 0x003E, 0x00AE, 0x0001, 0x00AB, 0x00C7,
+ 0x0013, 0x000A, 0x0002, 0x01CA, 0x0003, 0x0000,
+ 0x000F, 0x0022, 0x0016, 0x002A, 0x007F, 0x001C,
+ 0x0036, 0x00AF, 0x00C6, 0x000E, 0x0010, 0x0006,
+ 0x008F, 0x001E, 0x0054, 0x000D, 0x00AA, 0x0056,
+ 0x00AC, 0x001D, 0x0076, 0x0013, 0x004F, 0x0057,
+ 0x00E6, 0x00EE, 0x000E, 0x01CB, 0x00AF, 0x000B,
+ 0x0007, 0x00EF, 0x00AD, 0x00E4, 0x0008, 0x005E,
+ 0x0070, 0x001E, 0x00DF, 0x000C, 0x007E, 0x00CE,
+ 0x0002, 0x001A, 0x003C, 0x0002, 0x0020, 0x003A,
+ 0x004D, 0x00CF, 0x0066, 0x0026, 0x002F, 0x001F,
+ 0x0022, 0x001B, 0x0012, 0x000E, 0x0017, 0x0062,
+ 0x00E7, 0x0019, 0x0014, 0x0006, 0x004C, 0x0012,
+ 0x000C,
+};
+
+static const uint8_t on2avc_cb10_bits[ON2AVC_CB10_CODES] = {
+ 6, 5, 6, 8, 9, 8,
+ 8, 9, 8, 6, 5, 5,
+ 5, 6, 7, 8, 7, 7,
+ 8, 7, 6, 5, 6, 6,
+ 6, 7, 8, 7, 7, 8,
+ 7, 6, 6, 8, 7, 7,
+ 7, 8, 7, 8, 9, 8,
+ 7, 7, 9, 9, 8, 8,
+ 9, 8, 9, 9, 9, 9,
+ 9, 8, 7, 7, 7, 8,
+ 8, 9, 8, 8, 7, 6,
+ 8, 7, 7, 8, 8, 9,
+ 8, 8, 7, 7, 7, 9,
+ 8, 8, 9, 9, 8, 8,
+ 9, 8, 8, 8, 8, 7,
+ 7, 8, 8, 8, 7, 8,
+ 8, 7, 7, 7, 6, 6,
+ 7, 8, 7, 7, 8, 7,
+ 6, 6, 5, 5, 6, 7,
+ 8, 7, 7, 9, 7, 6,
+ 5,
+};
+
+static const uint16_t on2avc_cb10_syms[ON2AVC_CB10_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100,
+ 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x01FB,
+ 0x01FC, 0x01FD, 0x01FE, 0x01FF, 0x0200, 0x0201,
+ 0x0202, 0x0203, 0x0204, 0x0205, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x03FB, 0x03FC, 0x03FD,
+ 0x03FE, 0x03FF, 0x0400, 0x0401, 0x0402, 0x0403,
+ 0x0404, 0x0405, 0x04FB, 0x04FC, 0x04FD, 0x04FE,
+ 0x04FF, 0x0500, 0x0501, 0x0502, 0x0503, 0x0504,
+ 0x0505, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00,
+ 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFCFB,
+ 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01,
+ 0xFD02, 0xFD03, 0xFD04, 0xFD05, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFEFB, 0xFEFC, 0xFEFD,
+ 0xFEFE, 0xFEFF, 0xFF00, 0xFF01, 0xFF02, 0xFF03,
+ 0xFF04, 0xFF05, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB11_CODES 225
+static const uint16_t on2avc_cb11_codes[ON2AVC_CB11_CODES] = {
+ 0x0000, 0x000E, 0x0056, 0x00CD, 0x0173, 0x0232,
+ 0x00C7, 0x014F, 0x01AA, 0x00BE, 0x026F, 0x0192,
+ 0x00BC, 0x0058, 0x000F, 0x000C, 0x0010, 0x004E,
+ 0x0082, 0x0142, 0x01BF, 0x0098, 0x015E, 0x0136,
+ 0x0086, 0x01BB, 0x014E, 0x00BA, 0x003E, 0x0012,
+ 0x0054, 0x0036, 0x0050, 0x008F, 0x014B, 0x0262,
+ 0x00AA, 0x015C, 0x013E, 0x00B7, 0x02BE, 0x0176,
+ 0x00A2, 0x0058, 0x003C, 0x00C2, 0x00A6, 0x008A,
+ 0x00B2, 0x0122, 0x02AC, 0x00CA, 0x012F, 0x014A,
+ 0x00DC, 0x02DE, 0x017A, 0x0134, 0x0092, 0x00B4,
+ 0x0166, 0x0148, 0x016E, 0x013F, 0x0134, 0x02FF,
+ 0x014F, 0x019E, 0x0267, 0x016C, 0x02A6, 0x02CE,
+ 0x013A, 0x010A, 0x0108, 0x026E, 0x02CB, 0x028E,
+ 0x02CF, 0x020F, 0x02DF, 0x010B, 0x02AD, 0x0227,
+ 0x018A, 0x04DB, 0x02A7, 0x02FE, 0x0236, 0x026C,
+ 0x00C6, 0x009C, 0x00C4, 0x00CE, 0x00D6, 0x0135,
+ 0x0156, 0x025A, 0x02FF, 0x0286, 0x015F, 0x0132,
+ 0x00D7, 0x00AC, 0x00A2, 0x0176, 0x0118, 0x0123,
+ 0x0157, 0x01BC, 0x02AE, 0x02EE, 0x04DA, 0x0467,
+ 0x033F, 0x0287, 0x0193, 0x0182, 0x013B, 0x0112,
+ 0x0133, 0x017D, 0x0117, 0x0186, 0x026E, 0x025B,
+ 0x02EF, 0x0466, 0x0316, 0x0237, 0x02F6, 0x01BA,
+ 0x015D, 0x012E, 0x015A, 0x014A, 0x008E, 0x00B6,
+ 0x0135, 0x0100, 0x017B, 0x028C, 0x033E, 0x0297,
+ 0x015B, 0x0102, 0x0140, 0x00D4, 0x00BA, 0x0088,
+ 0x02EE, 0x0283, 0x02BF, 0x020E, 0x02CE, 0x0317,
+ 0x0172, 0x0296, 0x026F, 0x0101, 0x02CF, 0x02F7,
+ 0x01BD, 0x02EF, 0x028F, 0x0263, 0x0164, 0x011A,
+ 0x0147, 0x0292, 0x02FE, 0x015E, 0x02AF, 0x01AB,
+ 0x0130, 0x02CA, 0x0183, 0x014E, 0x017C, 0x017E,
+ 0x00C8, 0x00AA, 0x009E, 0x0132, 0x0152, 0x0226,
+ 0x00CC, 0x017E, 0x0187, 0x00CB, 0x0293, 0x0106,
+ 0x00C0, 0x0087, 0x00BC, 0x005C, 0x003D, 0x005A,
+ 0x00A8, 0x0103, 0x028D, 0x00A4, 0x0116, 0x0146,
+ 0x00B8, 0x01BE, 0x016D, 0x0093, 0x004A, 0x003F,
+ 0x000D, 0x0011, 0x004F, 0x00AE, 0x0166, 0x0266,
+ 0x0090, 0x0109, 0x012C, 0x00A6, 0x0282, 0x017A,
+ 0x00B5, 0x0034, 0x000E,
+};
+
+static const uint8_t on2avc_cb11_bits[ON2AVC_CB11_CODES] = {
+ 2, 4, 7, 9, 10, 11,
+ 9, 10, 10, 9, 11, 10,
+ 9, 7, 4, 4, 5, 7,
+ 9, 9, 10, 9, 10, 10,
+ 9, 10, 9, 8, 7, 5,
+ 7, 7, 8, 9, 9, 10,
+ 9, 10, 10, 9, 10, 9,
+ 9, 8, 7, 9, 8, 9,
+ 9, 10, 10, 9, 10, 10,
+ 9, 10, 10, 9, 9, 8,
+ 10, 9, 9, 10, 10, 10,
+ 9, 10, 10, 9, 11, 10,
+ 10, 10, 10, 11, 10, 10,
+ 10, 11, 10, 10, 10, 11,
+ 10, 11, 11, 10, 11, 10,
+ 9, 9, 9, 9, 9, 10,
+ 10, 11, 11, 10, 10, 10,
+ 9, 9, 8, 10, 10, 10,
+ 10, 10, 10, 10, 11, 12,
+ 11, 10, 10, 10, 10, 10,
+ 10, 9, 10, 10, 10, 11,
+ 11, 12, 11, 11, 10, 10,
+ 10, 10, 10, 9, 9, 9,
+ 9, 10, 10, 10, 11, 11,
+ 10, 10, 9, 9, 9, 9,
+ 11, 10, 10, 11, 11, 11,
+ 10, 11, 10, 10, 11, 10,
+ 10, 10, 10, 10, 9, 10,
+ 10, 10, 11, 9, 10, 10,
+ 9, 10, 10, 10, 9, 9,
+ 9, 8, 9, 9, 10, 11,
+ 9, 10, 10, 9, 10, 10,
+ 9, 9, 8, 7, 7, 8,
+ 9, 10, 10, 9, 10, 10,
+ 9, 10, 9, 9, 8, 7,
+ 4, 5, 7, 8, 9, 10,
+ 9, 10, 10, 9, 10, 9,
+ 8, 7, 5,
+};
+
+static const uint16_t on2avc_cb11_syms[ON2AVC_CB11_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x0006, 0x0007, 0x00F9, 0x00FA, 0x00FB, 0x00FC,
+ 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x0101, 0x0102,
+ 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x01F9,
+ 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
+ 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205,
+ 0x0206, 0x0207, 0x02F9, 0x02FA, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x03F9,
+ 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
+ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405,
+ 0x0406, 0x0407, 0x04F9, 0x04FA, 0x04FB, 0x04FC,
+ 0x04FD, 0x04FE, 0x04FF, 0x0500, 0x0501, 0x0502,
+ 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x05F9,
+ 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0605,
+ 0x0606, 0x0607, 0x06F9, 0x06FA, 0x06FB, 0x06FC,
+ 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702,
+ 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x07F9,
+ 0x07FA, 0x07FB, 0x07FC, 0x07FD, 0x07FE, 0x07FF,
+ 0xF900, 0xF901, 0xF902, 0xF903, 0xF904, 0xF905,
+ 0xF906, 0xF907, 0xF9F9, 0xF9FA, 0xF9FB, 0xF9FC,
+ 0xF9FD, 0xF9FE, 0xF9FF, 0xFA00, 0xFA01, 0xFA02,
+ 0xFA03, 0xFA04, 0xFA05, 0xFA06, 0xFA07, 0xFAF9,
+ 0xFAFA, 0xFAFB, 0xFAFC, 0xFAFD, 0xFAFE, 0xFAFF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFB06, 0xFB07, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC,
+ 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00, 0xFC01, 0xFC02,
+ 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFCF9,
+ 0xFCFA, 0xFCFB, 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF,
+ 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04, 0xFD05,
+ 0xFD06, 0xFD07, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFEF9,
+ 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0xFEFF,
+ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05,
+ 0xFF06, 0xFF07, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC,
+ 0xFFFD, 0xFFFE, 0xFFFF,
+};
+
+#define ON2AVC_CB12_CODES 441
+static const uint16_t on2avc_cb12_codes[ON2AVC_CB12_CODES] = {
+ 0x0000, 0x000C, 0x004F, 0x0156, 0x02E6, 0x0462,
+ 0x044C, 0x086A, 0x0222, 0x0228, 0x047F, 0x037A,
+ 0x028F, 0x02B8, 0x0BB7, 0x04B7, 0x02DA, 0x0262,
+ 0x0124, 0x0052, 0x000F, 0x000D, 0x000E, 0x0058,
+ 0x00A2, 0x0129, 0x02C8, 0x0256, 0x044D, 0x016E,
+ 0x02AA, 0x02BE, 0x027F, 0x02A9, 0x016E, 0x0597,
+ 0x02EE, 0x02EE, 0x013A, 0x00A4, 0x004E, 0x000C,
+ 0x0056, 0x004B, 0x0058, 0x0125, 0x010E, 0x01A7,
+ 0x026A, 0x0415, 0x010C, 0x0228, 0x0446, 0x0232,
+ 0x017E, 0x0128, 0x0473, 0x035E, 0x026A, 0x015E,
+ 0x00DB, 0x005E, 0x0048, 0x017A, 0x00AE, 0x00BA,
+ 0x0172, 0x0229, 0x02FB, 0x0458, 0x05A4, 0x015A,
+ 0x0296, 0x05BE, 0x044E, 0x0216, 0x012A, 0x0423,
+ 0x053E, 0x02F0, 0x02F1, 0x011E, 0x0110, 0x009C,
+ 0x026B, 0x0112, 0x011B, 0x01B3, 0x01BF, 0x0263,
+ 0x057E, 0x04B8, 0x016B, 0x02DE, 0x04DE, 0x0416,
+ 0x02DB, 0x02AB, 0x06EE, 0x04CF, 0x025F, 0x02EB,
+ 0x022A, 0x011A, 0x010A, 0x05A5, 0x0238, 0x0217,
+ 0x02D6, 0x025A, 0x0282, 0x044F, 0x043D, 0x01AE,
+ 0x026B, 0x05C2, 0x043C, 0x044F, 0x02DB, 0x05A7,
+ 0x044E, 0x05BF, 0x0297, 0x022A, 0x026C, 0x02BD,
+ 0x0897, 0x0283, 0x02B6, 0x02B7, 0x0264, 0x0459,
+ 0x040B, 0x04DF, 0x0298, 0x0456, 0x0AFF, 0x06B7,
+ 0x0448, 0x0449, 0x08BE, 0x06EF, 0x04B9, 0x0597,
+ 0x049A, 0x02D2, 0x02F8, 0x08F7, 0x0476, 0x0452,
+ 0x0453, 0x045A, 0x05BE, 0x043E, 0x04D2, 0x02F2,
+ 0x02E4, 0x0477, 0x0AFE, 0x05A6, 0x02E3, 0x0BB6,
+ 0x0A7E, 0x05A6, 0x0A66, 0x08BF, 0x05FF, 0x0492,
+ 0x0170, 0x0106, 0x0140, 0x0142, 0x022E, 0x02CF,
+ 0x02B9, 0x02E2, 0x02F3, 0x05A0, 0x088E, 0x0DD7,
+ 0x04F6, 0x047E, 0x045B, 0x0347, 0x029E, 0x026D,
+ 0x01AC, 0x013B, 0x0104, 0x035F, 0x02EC, 0x026E,
+ 0x0233, 0x0207, 0x023E, 0x026E, 0x053F, 0x05A7,
+ 0x0456, 0x04AE, 0x0DD6, 0x0A67, 0x0493, 0x04BA,
+ 0x05D3, 0x05C3, 0x0246, 0x0247, 0x0202, 0x02E8,
+ 0x05AE, 0x0374, 0x0537, 0x05C6, 0x04BB, 0x0686,
+ 0x04D3, 0x04DE, 0x08C3, 0x05BF, 0x04F7, 0x14FB,
+ 0x0997, 0x0A7F, 0x08C2, 0x0417, 0x0434, 0x0477,
+ 0x037B, 0x0463, 0x02EF, 0x0592, 0x02E5, 0x049B,
+ 0x035A, 0x0436, 0x05AF, 0x0687, 0x0896, 0x095F,
+ 0x09BE, 0x0996, 0x0558, 0x088F, 0x0B8E, 0x057E,
+ 0x04CA, 0x05CE, 0x05F3, 0x047A, 0x05A1, 0x02E2,
+ 0x02FA, 0x0204, 0x022C, 0x020E, 0x0360, 0x02AE,
+ 0x05FC, 0x0457, 0x05DA, 0x086B, 0x14FA, 0x04B6,
+ 0x02FE, 0x040A, 0x02E6, 0x0576, 0x044A, 0x028C,
+ 0x0212, 0x0248, 0x02E0, 0x029A, 0x0126, 0x017E,
+ 0x0130, 0x024C, 0x0232, 0x0596, 0x0378, 0x053A,
+ 0x04CC, 0x0A7C, 0x0470, 0x0593, 0x02D8, 0x029C,
+ 0x02D9, 0x02BE, 0x01A0, 0x014E, 0x0120, 0x013C,
+ 0x06EC, 0x04CD, 0x0559, 0x06B6, 0x0420, 0x057F,
+ 0x0596, 0x09BF, 0x0532, 0x055A, 0x095E, 0x08BC,
+ 0x0472, 0x02CA, 0x05F2, 0x05FD, 0x047E, 0x05A2,
+ 0x06EA, 0x05CF, 0x04D2, 0x043F, 0x028E, 0x0422,
+ 0x0460, 0x05DE, 0x053B, 0x08F6, 0x0B8F, 0x02CE,
+ 0x0473, 0x06ED, 0x0421, 0x028D, 0x023C, 0x047F,
+ 0x05A3, 0x044C, 0x044D, 0x0457, 0x02CA, 0x02D8,
+ 0x027C, 0x029E, 0x023E, 0x027D, 0x0361, 0x0414,
+ 0x05BC, 0x08BD, 0x02DA, 0x024A, 0x0437, 0x055B,
+ 0x0379, 0x01BE, 0x05DF, 0x04D3, 0x0268, 0x0206,
+ 0x0213, 0x02BA, 0x0203, 0x0236, 0x0127, 0x0136,
+ 0x0268, 0x0242, 0x02CF, 0x05FE, 0x05D2, 0x0237,
+ 0x0243, 0x0472, 0x0362, 0x027A, 0x02AE, 0x0471,
+ 0x0474, 0x024B, 0x02AF, 0x01A6, 0x012C, 0x0166,
+ 0x0166, 0x00A6, 0x00AC, 0x0100, 0x01B2, 0x020F,
+ 0x0363, 0x0446, 0x016A, 0x022E, 0x0577, 0x02FF,
+ 0x022D, 0x0168, 0x0475, 0x027E, 0x0222, 0x01A2,
+ 0x017B, 0x00D2, 0x00BE, 0x0050, 0x0054, 0x006A,
+ 0x011A, 0x0143, 0x024F, 0x02E7, 0x0447, 0x0110,
+ 0x0233, 0x02D9, 0x02AF, 0x024E, 0x016A, 0x0536,
+ 0x0342, 0x02BC, 0x0176, 0x00DA, 0x0054, 0x004A,
+ 0x000E, 0x0010, 0x004C, 0x00DC, 0x0164, 0x023A,
+ 0x0476, 0x04CE, 0x0118, 0x02CE, 0x025E, 0x0346,
+ 0x02A8, 0x0122, 0x05BD, 0x022F, 0x02EA, 0x014A,
+ 0x00AA, 0x0051, 0x000F,
+};
+
+static const uint8_t on2avc_cb12_bits[ON2AVC_CB12_CODES] = {
+ 2, 4, 7, 9, 10, 11,
+ 12, 13, 10, 11, 11, 11,
+ 11, 10, 12, 12, 11, 11,
+ 9, 7, 4, 4, 5, 7,
+ 9, 10, 10, 11, 12, 10,
+ 10, 11, 11, 10, 9, 12,
+ 11, 10, 10, 9, 7, 5,
+ 7, 7, 8, 9, 10, 10,
+ 11, 12, 10, 10, 11, 11,
+ 10, 10, 12, 11, 10, 10,
+ 9, 8, 7, 9, 9, 9,
+ 9, 10, 10, 11, 11, 10,
+ 11, 11, 11, 11, 10, 12,
+ 11, 10, 10, 10, 9, 9,
+ 10, 10, 10, 10, 10, 11,
+ 11, 12, 10, 11, 11, 12,
+ 11, 10, 12, 12, 11, 10,
+ 10, 10, 10, 11, 10, 11,
+ 10, 11, 11, 12, 12, 10,
+ 11, 11, 12, 11, 10, 12,
+ 12, 11, 11, 11, 10, 10,
+ 12, 11, 11, 11, 11, 11,
+ 12, 12, 10, 11, 12, 12,
+ 11, 11, 12, 12, 12, 11,
+ 11, 11, 10, 12, 12, 12,
+ 12, 11, 12, 12, 12, 10,
+ 11, 12, 12, 11, 11, 12,
+ 13, 12, 12, 12, 11, 12,
+ 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 11, 12, 13,
+ 12, 12, 11, 11, 11, 10,
+ 10, 10, 10, 11, 10, 10,
+ 11, 11, 11, 11, 11, 11,
+ 12, 12, 13, 12, 12, 12,
+ 11, 11, 11, 11, 11, 10,
+ 11, 11, 11, 11, 12, 12,
+ 12, 12, 12, 12, 12, 14,
+ 13, 13, 12, 12, 12, 11,
+ 11, 11, 11, 11, 11, 11,
+ 11, 12, 11, 12, 12, 13,
+ 12, 13, 12, 12, 12, 12,
+ 12, 11, 11, 11, 11, 11,
+ 10, 11, 11, 11, 11, 11,
+ 11, 12, 11, 13, 14, 12,
+ 11, 12, 11, 11, 11, 11,
+ 11, 11, 10, 10, 10, 9,
+ 10, 10, 10, 11, 11, 11,
+ 12, 13, 12, 11, 10, 10,
+ 10, 10, 10, 10, 10, 10,
+ 12, 12, 12, 12, 12, 12,
+ 12, 12, 11, 12, 13, 12,
+ 11, 10, 11, 11, 11, 11,
+ 12, 11, 11, 12, 11, 12,
+ 11, 11, 11, 12, 12, 11,
+ 11, 12, 12, 11, 10, 12,
+ 11, 11, 11, 11, 11, 11,
+ 11, 10, 10, 11, 11, 12,
+ 11, 12, 10, 11, 12, 12,
+ 11, 10, 11, 11, 11, 11,
+ 11, 10, 11, 10, 10, 10,
+ 10, 11, 11, 11, 11, 10,
+ 11, 12, 11, 11, 10, 12,
+ 11, 11, 10, 10, 10, 10,
+ 9, 9, 9, 10, 10, 11,
+ 11, 12, 10, 11, 11, 11,
+ 11, 10, 11, 11, 11, 10,
+ 9, 9, 9, 7, 7, 8,
+ 9, 10, 10, 11, 12, 10,
+ 10, 11, 11, 10, 9, 11,
+ 11, 10, 10, 9, 8, 7,
+ 4, 5, 7, 9, 10, 11,
+ 11, 12, 10, 10, 11, 11,
+ 10, 10, 11, 11, 10, 10,
+ 9, 7, 5,
+};
+
+static const uint16_t on2avc_cb12_syms[ON2AVC_CB12_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x00F6,
+ 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC,
+ 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x0101, 0x0102,
+ 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108,
+ 0x0109, 0x010A, 0x01F6, 0x01F7, 0x01F8, 0x01F9,
+ 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
+ 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205,
+ 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x02F6,
+ 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308,
+ 0x0309, 0x030A, 0x03F6, 0x03F7, 0x03F8, 0x03F9,
+ 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
+ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405,
+ 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x04F6,
+ 0x04F7, 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC,
+ 0x04FD, 0x04FE, 0x04FF, 0x0500, 0x0501, 0x0502,
+ 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x0508,
+ 0x0509, 0x050A, 0x05F6, 0x05F7, 0x05F8, 0x05F9,
+ 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0605,
+ 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, 0x06F6,
+ 0x06F7, 0x06F8, 0x06F9, 0x06FA, 0x06FB, 0x06FC,
+ 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702,
+ 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x0708,
+ 0x0709, 0x070A, 0x07F6, 0x07F7, 0x07F8, 0x07F9,
+ 0x07FA, 0x07FB, 0x07FC, 0x07FD, 0x07FE, 0x07FF,
+ 0x0800, 0x0801, 0x0802, 0x0803, 0x0804, 0x0805,
+ 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x08F6,
+ 0x08F7, 0x08F8, 0x08F9, 0x08FA, 0x08FB, 0x08FC,
+ 0x08FD, 0x08FE, 0x08FF, 0x0900, 0x0901, 0x0902,
+ 0x0903, 0x0904, 0x0905, 0x0906, 0x0907, 0x0908,
+ 0x0909, 0x090A, 0x09F6, 0x09F7, 0x09F8, 0x09F9,
+ 0x09FA, 0x09FB, 0x09FC, 0x09FD, 0x09FE, 0x09FF,
+ 0x0A00, 0x0A01, 0x0A02, 0x0A03, 0x0A04, 0x0A05,
+ 0x0A06, 0x0A07, 0x0A08, 0x0A09, 0x0A0A, 0x0AF6,
+ 0x0AF7, 0x0AF8, 0x0AF9, 0x0AFA, 0x0AFB, 0x0AFC,
+ 0x0AFD, 0x0AFE, 0x0AFF, 0xF600, 0xF601, 0xF602,
+ 0xF603, 0xF604, 0xF605, 0xF606, 0xF607, 0xF608,
+ 0xF609, 0xF60A, 0xF6F6, 0xF6F7, 0xF6F8, 0xF6F9,
+ 0xF6FA, 0xF6FB, 0xF6FC, 0xF6FD, 0xF6FE, 0xF6FF,
+ 0xF700, 0xF701, 0xF702, 0xF703, 0xF704, 0xF705,
+ 0xF706, 0xF707, 0xF708, 0xF709, 0xF70A, 0xF7F6,
+ 0xF7F7, 0xF7F8, 0xF7F9, 0xF7FA, 0xF7FB, 0xF7FC,
+ 0xF7FD, 0xF7FE, 0xF7FF, 0xF800, 0xF801, 0xF802,
+ 0xF803, 0xF804, 0xF805, 0xF806, 0xF807, 0xF808,
+ 0xF809, 0xF80A, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9,
+ 0xF8FA, 0xF8FB, 0xF8FC, 0xF8FD, 0xF8FE, 0xF8FF,
+ 0xF900, 0xF901, 0xF902, 0xF903, 0xF904, 0xF905,
+ 0xF906, 0xF907, 0xF908, 0xF909, 0xF90A, 0xF9F6,
+ 0xF9F7, 0xF9F8, 0xF9F9, 0xF9FA, 0xF9FB, 0xF9FC,
+ 0xF9FD, 0xF9FE, 0xF9FF, 0xFA00, 0xFA01, 0xFA02,
+ 0xFA03, 0xFA04, 0xFA05, 0xFA06, 0xFA07, 0xFA08,
+ 0xFA09, 0xFA0A, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9,
+ 0xFAFA, 0xFAFB, 0xFAFC, 0xFAFD, 0xFAFE, 0xFAFF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFB06, 0xFB07, 0xFB08, 0xFB09, 0xFB0A, 0xFBF6,
+ 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC,
+ 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00, 0xFC01, 0xFC02,
+ 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
+ 0xFC09, 0xFC0A, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9,
+ 0xFCFA, 0xFCFB, 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF,
+ 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04, 0xFD05,
+ 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFDF6,
+ 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08,
+ 0xFE09, 0xFE0A, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9,
+ 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0xFEFF,
+ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05,
+ 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFFF6,
+ 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC,
+ 0xFFFD, 0xFFFE, 0xFFFF,
+};
+
+#define ON2AVC_CB13_CODES 625
+static const uint16_t on2avc_cb13_codes[ON2AVC_CB13_CODES] = {
+ 0x0000, 0x0015, 0x008E, 0x0338, 0x09FB, 0x0BEC,
+ 0x0C61, 0x13E1, 0x18A7, 0x313B, 0x61BB, 0x05D9,
+ 0x0896, 0x066B, 0x05C6, 0x18A6, 0x40E4, 0x2081,
+ 0x104F, 0x13E0, 0x0C22, 0x07E4, 0x03F7, 0x0087,
+ 0x0014, 0x0016, 0x001D, 0x009C, 0x02E2, 0x037E,
+ 0x0897, 0x0898, 0x0C63, 0x117D, 0x2082, 0x27AA,
+ 0x033B, 0x06C5, 0x04F2, 0x0331, 0x19EB, 0x18A8,
+ 0x13E2, 0x0DE7, 0x0C62, 0x06DF, 0x05C7, 0x02F4,
+ 0x0098, 0x001A, 0x007C, 0x0080, 0x0106, 0x02F5,
+ 0x03EC, 0x0617, 0x0621, 0x08F9, 0x1050, 0x117F,
+ 0x11E0, 0x036A, 0x045A, 0x06C6, 0x037F, 0x117E,
+ 0x2083, 0x0BED, 0x0C9E, 0x0658, 0x04F3, 0x0368,
+ 0x02EE, 0x00FA, 0x008D, 0x031C, 0x01FF, 0x0206,
+ 0x031E, 0x06C8, 0x0659, 0x09B5, 0x0C23, 0x0BEF,
+ 0x0C9F, 0x19EC, 0x04CC, 0x0623, 0x06C7, 0x0622,
+ 0x313C, 0x17BB, 0x11E1, 0x0C64, 0x0BEE, 0x07DC,
+ 0x04CB, 0x0375, 0x0205, 0x026E, 0x0C24, 0x06C9,
+ 0x0324, 0x04DF, 0x0642, 0x09B6, 0x0643, 0x0BF2,
+ 0x083B, 0x1051, 0x27AB, 0x036C, 0x0607, 0x06E2,
+ 0x045B, 0x313D, 0x2084, 0x18A9, 0x13E3, 0x0CA0,
+ 0x0899, 0x066E, 0x06E3, 0x0369, 0x0606, 0x0DE8,
+ 0x061A, 0x0453, 0x065A, 0x065B, 0x089B, 0x089C,
+ 0x09FD, 0x0BA5, 0x18AA, 0x11E2, 0x05C8, 0x09B7,
+ 0x066F, 0x06CA, 0x19ED, 0x2085, 0x2086, 0x0D83,
+ 0x1052, 0x1053, 0x09FC, 0x089A, 0x0644, 0x083E,
+ 0x13E4, 0x08FC, 0x0624, 0x1055, 0x0C65, 0x089D,
+ 0x0645, 0x08FD, 0x0C66, 0x0CA1, 0x1056, 0x05E1,
+ 0x089E, 0x08FA, 0x07E5, 0x313E, 0x2087, 0x11E3,
+ 0x19EE, 0x18AB, 0x1054, 0x19EF, 0x17BC, 0x08FB,
+ 0x07E6, 0x18AD, 0x0BF3, 0x07E7, 0x0C67, 0x1057,
+ 0x07EA, 0x08FF, 0x1058, 0x0DE9, 0x18AE, 0x19F0,
+ 0x0608, 0x089F, 0x08FE, 0x06CB, 0x313F, 0x2088,
+ 0x13E5, 0x3142, 0x11E4, 0x18AC, 0x11E5, 0x0CA2,
+ 0x065E, 0x13E6, 0x27AD, 0x19F1, 0x0D86, 0x0DEA,
+ 0x0CA3, 0x0DEB, 0x17BE, 0x0C2A, 0x13E8, 0x0CA6,
+ 0x0DEE, 0x05FD, 0x0992, 0x0C25, 0x063E, 0x40E5,
+ 0x11E6, 0x3143, 0x18AF, 0x27AC, 0x0C26, 0x17BD,
+ 0x13E7, 0x0C27, 0x11E7, 0x27B2, 0x40E8, 0x18B3,
+ 0x17C0, 0x18FE, 0x19F2, 0x19F3, 0x31FE, 0x17C1,
+ 0x19F6, 0x0BA6, 0x09FE, 0x0DEF, 0x17BF, 0x0C2B,
+ 0x40E6, 0x18B0, 0x40E7, 0x13E9, 0x2089, 0x27AE,
+ 0x27AF, 0x208A, 0x18B1, 0x18B2, 0x27B3, 0xBCEF,
+ 0x2F3A, 0x40EA, 0x17C5, 0x17C6, 0x17C7, 0x19F7,
+ 0x133E, 0x105A, 0x17CA, 0x065F, 0x0CA7, 0x0C7E,
+ 0x1059, 0xBCED, 0x40E9, 0xBCEE, 0x17C2, 0x63FE,
+ 0x208B, 0x208E, 0x208F, 0x17C3, 0x17C4, 0x0625,
+ 0x03ED, 0x045C, 0x04CD, 0x05DA, 0x05CE, 0x05FF,
+ 0x0626, 0x060A, 0x05E3, 0x083F, 0x0BA8, 0x0BA9,
+ 0x40EB, 0x13EA, 0x0CCA, 0x0BA7, 0x08A2, 0x0646,
+ 0x0609, 0x05E2, 0x041E, 0x05FE, 0x0373, 0x0376,
+ 0x099E, 0x05DE, 0x0647, 0x05E6, 0x06D6, 0x07EB,
+ 0x09FF, 0x1B5E, 0x0BAB, 0x08AE, 0x0C36, 0x0FBA,
+ 0x17CB, 0x4CFE, 0x105B, 0x0D87, 0x0DAE, 0x13EB,
+ 0x0BAA, 0x0993, 0x08A3, 0x085E, 0x0600, 0x0601,
+ 0x05DB, 0x0664, 0x04F0, 0x05F8, 0x0634, 0x085F,
+ 0x06F6, 0x08F4, 0x0C5A, 0x0CFC, 0x0DDC, 0x09F6,
+ 0x0C16, 0x115E, 0x13D8, 0x13DA, 0x0C94, 0x0CFA,
+ 0x082E, 0x0B9E, 0x06C2, 0x0BE4, 0x06DA, 0x05C0,
+ 0x0614, 0x05C9, 0x05DF, 0x033A, 0x0336, 0x05FA,
+ 0x04CE, 0x05C1, 0x0890, 0x0891, 0x0838, 0x0839,
+ 0x0CFD, 0x0BA0, 0x61B8, 0x07DE, 0x0635, 0x0B9F,
+ 0x0640, 0x06DB, 0x082F, 0x09AC, 0x04C8, 0x0666,
+ 0x04DE, 0x03F4, 0x0339, 0x2079, 0x267E, 0x179E,
+ 0x30DE, 0x63FF, 0x27A0, 0x1997, 0x36BF, 0x3EEC,
+ 0x99FE, 0x99FF, 0x0C95, 0x1048, 0x0C5B, 0x0636,
+ 0x0C5C, 0x2076, 0x13DB, 0x115F, 0x179C, 0x2077,
+ 0x1046, 0x36BE, 0x1996, 0x2078, 0x61B9, 0x1175,
+ 0x17B0, 0x3EED, 0x19E1, 0x19E2, 0x207A, 0x3EEE,
+ 0xBCEC, 0x3138, 0x3139, 0x07DF, 0x1176, 0x0892,
+ 0x0667, 0x18A0, 0x18A2, 0x13DC, 0x1174, 0x13DD,
+ 0x179F, 0x30DF, 0x19E0, 0x18A3, 0x1049, 0x17B2,
+ 0x207B, 0x17B3, 0x0C17, 0x19E3, 0x17B4, 0x207C,
+ 0x3EEF, 0x207D, 0x19E4, 0x27A1, 0x0C5F, 0x08F5,
+ 0x0DDD, 0x0652, 0x18A4, 0x0C96, 0x0C5D, 0x104A,
+ 0x1177, 0x0CFE, 0x0C5E, 0x0DDE, 0x09F7, 0x17B1,
+ 0x19E6, 0x0C1E, 0x09AE, 0x1179, 0x0DE0, 0x17B5,
+ 0x0BA2, 0x17B6, 0x27A3, 0x40E0, 0x40E1, 0x06DC,
+ 0x09AF, 0x09AD, 0x05C2, 0x19E5, 0x27A2, 0x0DDF,
+ 0x0C1C, 0x0C1D, 0x0BE6, 0x0BA1, 0x1178, 0x0654,
+ 0x13DE, 0x40E2, 0x0893, 0x0668, 0x07E1, 0x0BE7,
+ 0x08F6, 0x0DE1, 0x27A4, 0x104B, 0x19E7, 0x40E3,
+ 0x05D6, 0x09F9, 0x06DD, 0x04CA, 0x17B7, 0x17B8,
+ 0x0C97, 0x0C98, 0x07E0, 0x0C99, 0x0655, 0x09F8,
+ 0x0656, 0x0C9A, 0x0DE2, 0x0669, 0x04D3, 0x061C,
+ 0x0894, 0x13DF, 0x0C1F, 0x104C, 0x27A6, 0x61BA,
+ 0x27A7, 0x066A, 0x061D, 0x0637, 0x04D2, 0x27A5,
+ 0x117A, 0x0C9B, 0x09B0, 0x09B1, 0x05E0, 0x0602,
+ 0x05FB, 0x04F1, 0x08F7, 0x06FA, 0x0603, 0x037C,
+ 0x05C3, 0x0BE8, 0x0895, 0x0C60, 0x117B, 0x19E8,
+ 0x27A8, 0x19E9, 0x0657, 0x083A, 0x06C4, 0x05D7,
+ 0x17B9, 0x0CFF, 0x0DE3, 0x104D, 0x07E2, 0x0641,
+ 0x061E, 0x05D8, 0x0366, 0x0616, 0x032E, 0x0268,
+ 0x02E6, 0x0456, 0x0BA3, 0x06FB, 0x0D80, 0x0DE5,
+ 0x104E, 0x17BA, 0x27A9, 0x0330, 0x07E3, 0x061F,
+ 0x0367, 0x207E, 0x0C9C, 0x117C, 0x0DE4, 0x06DE,
+ 0x0620, 0x0450, 0x042E, 0x02F2, 0x0204, 0x0086,
+ 0x008C, 0x00FE, 0x022A, 0x0372, 0x05CA, 0x0452,
+ 0x08F8, 0x0BA4, 0x19EA, 0x18A5, 0x0306, 0x05FC,
+ 0x03F6, 0x0458, 0x0D81, 0x0BE9, 0x09B2, 0x0C20,
+ 0x09FA, 0x0604, 0x0370, 0x01FE, 0x010A, 0x0084,
+ 0x0012, 0x001C, 0x0088, 0x026A, 0x05CB, 0x063B,
+ 0x09B4, 0x0D82, 0x0DE6, 0x207F, 0x2080, 0x030C,
+ 0x0605, 0x0459, 0x0374, 0x313A, 0x0C9D, 0x0BEA,
+ 0x0BEB, 0x0C21, 0x09B3, 0x063A, 0x0216, 0x009D,
+ 0x001E,
+};
+
+static const uint8_t on2avc_cb13_bits[ON2AVC_CB13_CODES] = {
+ 1, 5, 8, 10, 12, 12,
+ 12, 13, 13, 14, 15, 11,
+ 12, 11, 11, 13, 15, 14,
+ 13, 13, 12, 11, 10, 8,
+ 5, 5, 5, 8, 10, 10,
+ 12, 12, 12, 13, 14, 14,
+ 10, 11, 11, 10, 13, 13,
+ 13, 12, 12, 11, 11, 10,
+ 8, 5, 7, 8, 9, 10,
+ 10, 11, 11, 12, 13, 13,
+ 13, 10, 11, 11, 10, 13,
+ 14, 12, 12, 11, 11, 10,
+ 10, 8, 8, 10, 9, 10,
+ 10, 11, 11, 12, 12, 12,
+ 12, 13, 11, 11, 11, 11,
+ 14, 13, 13, 12, 12, 11,
+ 11, 10, 10, 10, 12, 11,
+ 10, 11, 11, 12, 11, 12,
+ 12, 13, 14, 10, 11, 11,
+ 11, 14, 14, 13, 13, 12,
+ 12, 11, 11, 10, 11, 12,
+ 11, 11, 11, 11, 12, 12,
+ 12, 12, 13, 13, 11, 12,
+ 11, 11, 13, 14, 14, 12,
+ 13, 13, 12, 12, 11, 12,
+ 13, 12, 11, 13, 12, 12,
+ 11, 12, 12, 12, 13, 11,
+ 12, 12, 11, 14, 14, 13,
+ 13, 13, 13, 13, 13, 12,
+ 11, 13, 12, 11, 12, 13,
+ 11, 12, 13, 12, 13, 13,
+ 11, 12, 12, 11, 14, 14,
+ 13, 14, 13, 13, 13, 12,
+ 11, 13, 14, 13, 12, 12,
+ 12, 12, 13, 12, 13, 12,
+ 12, 11, 12, 12, 11, 15,
+ 13, 14, 13, 14, 12, 13,
+ 13, 12, 13, 14, 15, 13,
+ 13, 13, 13, 13, 14, 13,
+ 13, 12, 12, 12, 13, 12,
+ 15, 13, 15, 13, 14, 14,
+ 14, 14, 13, 13, 14, 16,
+ 14, 15, 13, 13, 13, 13,
+ 13, 13, 13, 11, 12, 12,
+ 13, 16, 15, 16, 13, 15,
+ 14, 14, 14, 13, 13, 11,
+ 10, 11, 11, 11, 11, 11,
+ 11, 11, 11, 12, 12, 12,
+ 15, 13, 12, 12, 12, 11,
+ 11, 11, 11, 11, 10, 10,
+ 12, 11, 11, 11, 11, 11,
+ 12, 13, 12, 12, 12, 12,
+ 13, 15, 13, 12, 12, 13,
+ 12, 12, 12, 12, 11, 11,
+ 11, 11, 11, 11, 11, 12,
+ 11, 12, 12, 12, 12, 12,
+ 12, 13, 13, 13, 12, 12,
+ 12, 12, 11, 12, 11, 11,
+ 11, 11, 11, 10, 10, 11,
+ 11, 11, 12, 12, 12, 12,
+ 12, 12, 15, 11, 11, 12,
+ 11, 11, 12, 12, 11, 11,
+ 11, 10, 10, 14, 14, 13,
+ 14, 15, 14, 13, 14, 14,
+ 16, 16, 12, 13, 12, 11,
+ 12, 14, 13, 13, 13, 14,
+ 13, 14, 13, 14, 15, 13,
+ 13, 14, 13, 13, 14, 14,
+ 16, 14, 14, 11, 13, 12,
+ 11, 13, 13, 13, 13, 13,
+ 13, 14, 13, 13, 13, 13,
+ 14, 13, 12, 13, 13, 14,
+ 14, 14, 13, 14, 12, 12,
+ 12, 11, 13, 12, 12, 13,
+ 13, 12, 12, 12, 12, 13,
+ 13, 12, 12, 13, 12, 13,
+ 12, 13, 14, 15, 15, 11,
+ 12, 12, 11, 13, 14, 12,
+ 12, 12, 12, 12, 13, 11,
+ 13, 15, 12, 11, 11, 12,
+ 12, 12, 14, 13, 13, 15,
+ 11, 12, 11, 11, 13, 13,
+ 12, 12, 11, 12, 11, 12,
+ 11, 12, 12, 11, 11, 11,
+ 12, 13, 12, 13, 14, 15,
+ 14, 11, 11, 11, 11, 14,
+ 13, 12, 12, 12, 11, 11,
+ 11, 11, 12, 11, 11, 10,
+ 11, 12, 12, 12, 13, 13,
+ 14, 13, 11, 12, 11, 11,
+ 13, 12, 12, 13, 11, 11,
+ 11, 11, 10, 11, 10, 10,
+ 10, 11, 12, 11, 12, 12,
+ 13, 13, 14, 10, 11, 11,
+ 10, 14, 12, 13, 12, 11,
+ 11, 11, 11, 10, 10, 8,
+ 8, 8, 10, 10, 11, 11,
+ 12, 12, 13, 13, 10, 11,
+ 10, 11, 12, 12, 12, 12,
+ 12, 11, 10, 9, 9, 8,
+ 5, 5, 8, 10, 11, 11,
+ 12, 12, 12, 14, 14, 10,
+ 11, 11, 10, 14, 12, 12,
+ 12, 12, 12, 11, 10, 8,
+ 5,
+};
+
+static const uint16_t on2avc_cb13_syms[ON2AVC_CB13_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B,
+ 0x000C, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8,
+ 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE,
+ 0x00FF, 0x0100, 0x0101, 0x0102, 0x0103, 0x0104,
+ 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A,
+ 0x010B, 0x010C, 0x01F4, 0x01F5, 0x01F6, 0x01F7,
+ 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD,
+ 0x01FE, 0x01FF, 0x0200, 0x0201, 0x0202, 0x0203,
+ 0x0204, 0x0205, 0x0206, 0x0207, 0x0208, 0x0209,
+ 0x020A, 0x020B, 0x020C, 0x02F4, 0x02F5, 0x02F6,
+ 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308,
+ 0x0309, 0x030A, 0x030B, 0x030C, 0x03F4, 0x03F5,
+ 0x03F6, 0x03F7, 0x03F8, 0x03F9, 0x03FA, 0x03FB,
+ 0x03FC, 0x03FD, 0x03FE, 0x03FF, 0x0400, 0x0401,
+ 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x04F4,
+ 0x04F5, 0x04F6, 0x04F7, 0x04F8, 0x04F9, 0x04FA,
+ 0x04FB, 0x04FC, 0x04FD, 0x04FE, 0x04FF, 0x0500,
+ 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506,
+ 0x0507, 0x0508, 0x0509, 0x050A, 0x050B, 0x050C,
+ 0x05F4, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x05F9,
+ 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0605,
+ 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, 0x060B,
+ 0x060C, 0x06F4, 0x06F5, 0x06F6, 0x06F7, 0x06F8,
+ 0x06F9, 0x06FA, 0x06FB, 0x06FC, 0x06FD, 0x06FE,
+ 0x06FF, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704,
+ 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A,
+ 0x070B, 0x070C, 0x07F4, 0x07F5, 0x07F6, 0x07F7,
+ 0x07F8, 0x07F9, 0x07FA, 0x07FB, 0x07FC, 0x07FD,
+ 0x07FE, 0x07FF, 0x0800, 0x0801, 0x0802, 0x0803,
+ 0x0804, 0x0805, 0x0806, 0x0807, 0x0808, 0x0809,
+ 0x080A, 0x080B, 0x080C, 0x08F4, 0x08F5, 0x08F6,
+ 0x08F7, 0x08F8, 0x08F9, 0x08FA, 0x08FB, 0x08FC,
+ 0x08FD, 0x08FE, 0x08FF, 0x0900, 0x0901, 0x0902,
+ 0x0903, 0x0904, 0x0905, 0x0906, 0x0907, 0x0908,
+ 0x0909, 0x090A, 0x090B, 0x090C, 0x09F4, 0x09F5,
+ 0x09F6, 0x09F7, 0x09F8, 0x09F9, 0x09FA, 0x09FB,
+ 0x09FC, 0x09FD, 0x09FE, 0x09FF, 0x0A00, 0x0A01,
+ 0x0A02, 0x0A03, 0x0A04, 0x0A05, 0x0A06, 0x0A07,
+ 0x0A08, 0x0A09, 0x0A0A, 0x0A0B, 0x0A0C, 0x0AF4,
+ 0x0AF5, 0x0AF6, 0x0AF7, 0x0AF8, 0x0AF9, 0x0AFA,
+ 0x0AFB, 0x0AFC, 0x0AFD, 0x0AFE, 0x0AFF, 0x0B00,
+ 0x0B01, 0x0B02, 0x0B03, 0x0B04, 0x0B05, 0x0B06,
+ 0x0B07, 0x0B08, 0x0B09, 0x0B0A, 0x0B0B, 0x0B0C,
+ 0x0BF4, 0x0BF5, 0x0BF6, 0x0BF7, 0x0BF8, 0x0BF9,
+ 0x0BFA, 0x0BFB, 0x0BFC, 0x0BFD, 0x0BFE, 0x0BFF,
+ 0x0C00, 0x0C01, 0x0C02, 0x0C03, 0x0C04, 0x0C05,
+ 0x0C06, 0x0C07, 0x0C08, 0x0C09, 0x0C0A, 0x0C0B,
+ 0x0C0C, 0x0CF4, 0x0CF5, 0x0CF6, 0x0CF7, 0x0CF8,
+ 0x0CF9, 0x0CFA, 0x0CFB, 0x0CFC, 0x0CFD, 0x0CFE,
+ 0x0CFF, 0xF400, 0xF401, 0xF402, 0xF403, 0xF404,
+ 0xF405, 0xF406, 0xF407, 0xF408, 0xF409, 0xF40A,
+ 0xF40B, 0xF40C, 0xF4F4, 0xF4F5, 0xF4F6, 0xF4F7,
+ 0xF4F8, 0xF4F9, 0xF4FA, 0xF4FB, 0xF4FC, 0xF4FD,
+ 0xF4FE, 0xF4FF, 0xF500, 0xF501, 0xF502, 0xF503,
+ 0xF504, 0xF505, 0xF506, 0xF507, 0xF508, 0xF509,
+ 0xF50A, 0xF50B, 0xF50C, 0xF5F4, 0xF5F5, 0xF5F6,
+ 0xF5F7, 0xF5F8, 0xF5F9, 0xF5FA, 0xF5FB, 0xF5FC,
+ 0xF5FD, 0xF5FE, 0xF5FF, 0xF600, 0xF601, 0xF602,
+ 0xF603, 0xF604, 0xF605, 0xF606, 0xF607, 0xF608,
+ 0xF609, 0xF60A, 0xF60B, 0xF60C, 0xF6F4, 0xF6F5,
+ 0xF6F6, 0xF6F7, 0xF6F8, 0xF6F9, 0xF6FA, 0xF6FB,
+ 0xF6FC, 0xF6FD, 0xF6FE, 0xF6FF, 0xF700, 0xF701,
+ 0xF702, 0xF703, 0xF704, 0xF705, 0xF706, 0xF707,
+ 0xF708, 0xF709, 0xF70A, 0xF70B, 0xF70C, 0xF7F4,
+ 0xF7F5, 0xF7F6, 0xF7F7, 0xF7F8, 0xF7F9, 0xF7FA,
+ 0xF7FB, 0xF7FC, 0xF7FD, 0xF7FE, 0xF7FF, 0xF800,
+ 0xF801, 0xF802, 0xF803, 0xF804, 0xF805, 0xF806,
+ 0xF807, 0xF808, 0xF809, 0xF80A, 0xF80B, 0xF80C,
+ 0xF8F4, 0xF8F5, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9,
+ 0xF8FA, 0xF8FB, 0xF8FC, 0xF8FD, 0xF8FE, 0xF8FF,
+ 0xF900, 0xF901, 0xF902, 0xF903, 0xF904, 0xF905,
+ 0xF906, 0xF907, 0xF908, 0xF909, 0xF90A, 0xF90B,
+ 0xF90C, 0xF9F4, 0xF9F5, 0xF9F6, 0xF9F7, 0xF9F8,
+ 0xF9F9, 0xF9FA, 0xF9FB, 0xF9FC, 0xF9FD, 0xF9FE,
+ 0xF9FF, 0xFA00, 0xFA01, 0xFA02, 0xFA03, 0xFA04,
+ 0xFA05, 0xFA06, 0xFA07, 0xFA08, 0xFA09, 0xFA0A,
+ 0xFA0B, 0xFA0C, 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7,
+ 0xFAF8, 0xFAF9, 0xFAFA, 0xFAFB, 0xFAFC, 0xFAFD,
+ 0xFAFE, 0xFAFF, 0xFB00, 0xFB01, 0xFB02, 0xFB03,
+ 0xFB04, 0xFB05, 0xFB06, 0xFB07, 0xFB08, 0xFB09,
+ 0xFB0A, 0xFB0B, 0xFB0C, 0xFBF4, 0xFBF5, 0xFBF6,
+ 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC,
+ 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00, 0xFC01, 0xFC02,
+ 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
+ 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFCF4, 0xFCF5,
+ 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9, 0xFCFA, 0xFCFB,
+ 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01,
+ 0xFD02, 0xFD03, 0xFD04, 0xFD05, 0xFD06, 0xFD07,
+ 0xFD08, 0xFD09, 0xFD0A, 0xFD0B, 0xFD0C, 0xFDF4,
+ 0xFDF5, 0xFDF6, 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA,
+ 0xFDFB, 0xFDFC, 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00,
+ 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06,
+ 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C,
+ 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9,
+ 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0xFEFF,
+ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05,
+ 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B,
+ 0xFF0C, 0xFFF4, 0xFFF5, 0xFFF6, 0xFFF7, 0xFFF8,
+ 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE,
+ 0xFFFF,
+};
+
+#define ON2AVC_CB14_CODES 729
+static const uint16_t on2avc_cb14_codes[ON2AVC_CB14_CODES] = {
+ 0x0000, 0x0018, 0x009C, 0x033F, 0x06CF, 0x0860,
+ 0x3ED2, 0x15F8, 0x0CA3, 0x15F9, 0x3ED3, 0x3ED4,
+ 0x3ED5, 0x03B3, 0x0336, 0x3ECF, 0x3ED0, 0x15F5,
+ 0x15F6, 0x3ED1, 0x1FB6, 0x15F7, 0x0D6D, 0x074E,
+ 0x02A4, 0x008C, 0x0017, 0x0016, 0x0024, 0x00A8,
+ 0x02AB, 0x043C, 0x038D, 0x15FA, 0x0CA4, 0x1FB8,
+ 0x15FB, 0x3ED9, 0x1FB9, 0x15FC, 0x01D8, 0x01F1,
+ 0x3ED6, 0x1090, 0x1FB7, 0x0D6E, 0x3ED7, 0x3ED8,
+ 0x074F, 0x0D6F, 0x0750, 0x01F2, 0x0098, 0x0020,
+ 0x0070, 0x009D, 0x00E4, 0x026F, 0x03AE, 0x055D,
+ 0x06D0, 0x0862, 0x0667, 0x09ED, 0x1900, 0x3EDA,
+ 0x1901, 0x01DE, 0x026B, 0x15FD, 0x15FE, 0x1091,
+ 0x15FF, 0x0D70, 0x0666, 0x0689, 0x0861, 0x034E,
+ 0x026E, 0x00E8, 0x008E, 0x019E, 0x01BF, 0x01F3,
+ 0x02B5, 0x054E, 0x0669, 0x09EE, 0x09EF, 0x0D71,
+ 0x0CA5, 0x1FBB, 0x1FBC, 0x3EDF, 0x02A6, 0x01CA,
+ 0x3EDB, 0x3EDC, 0x3EDD, 0x3EDE, 0x1FBA, 0x1092,
+ 0x0863, 0x0751, 0x0668, 0x038E, 0x02B4, 0x01C4,
+ 0x068A, 0x0CA7, 0x06D1, 0x055F, 0x043E, 0x09F0,
+ 0x0865, 0x0866, 0x0867, 0x0752, 0x1902, 0x3EE2,
+ 0x1096, 0x0278, 0x02B6, 0x3EE0, 0x1FBD, 0x3EE1,
+ 0x0864, 0x1FBE, 0x0CA6, 0x1093, 0x1094, 0x1095,
+ 0x0478, 0x043D, 0x055E, 0x3EE5, 0x0CA9, 0x066A,
+ 0x0D75, 0x0560, 0x0561, 0x0868, 0x0D76, 0x0CAA,
+ 0x0CAB, 0x3EE6, 0x3EE7, 0x3EE8, 0x02AC, 0x038F,
+ 0x3EE3, 0x1FBF, 0x3EE4, 0x0D72, 0x0D73, 0x0D74,
+ 0x09F1, 0x068B, 0x0CA8, 0x0479, 0x06D2, 0x1097,
+ 0x1099, 0x09F3, 0x066B, 0x06D3, 0x0CAD, 0x109A,
+ 0x06D4, 0x068C, 0x06D5, 0x0D79, 0x0D7A, 0x109B,
+ 0x1FC1, 0x02B2, 0x0396, 0x3EE9, 0x1903, 0x3EEA,
+ 0x1904, 0x1905, 0x1FC0, 0x09F2, 0x0D77, 0x0D78,
+ 0x1098, 0x0562, 0x0CAC, 0x190C, 0x109C, 0x06D6,
+ 0x0D7C, 0x1FC4, 0x0D7D, 0x09F4, 0x06D7, 0x09F5,
+ 0x3EEE, 0x0CAE, 0x0D7E, 0x3EEF, 0x03AF, 0x043F,
+ 0x3EEB, 0x1906, 0x1FC2, 0x1907, 0x3EEC, 0x1908,
+ 0x1909, 0x190A, 0x1FC3, 0x3EED, 0x0D7B, 0x190B,
+ 0x1FC6, 0x10A1, 0x10A2, 0x0D7F, 0x0CB0, 0x190E,
+ 0x0D80, 0x10A3, 0x0869, 0x190F, 0x1910, 0x10A4,
+ 0x10A5, 0x0753, 0x068D, 0x3EF0, 0x3EF1, 0x190D,
+ 0x1FC5, 0x3EF2, 0x3EF3, 0x109D, 0x109E, 0x0CAF,
+ 0x109F, 0x3EF4, 0x10A0, 0x10A7, 0x3EFC, 0x0CB1,
+ 0x09F7, 0x1911, 0x10A8, 0x09F8, 0x10A9, 0x1912,
+ 0x06D9, 0x09F9, 0x3EFD, 0x1913, 0x068E, 0x06D8,
+ 0x3EF5, 0x3EF6, 0x3EF7, 0x3EF8, 0x3EF9, 0x0D81,
+ 0x3EFA, 0x1FC7, 0x1FC8, 0x10A6, 0x09F6, 0x3EFB,
+ 0x1FCE, 0x0CB2, 0x3F02, 0x10AA, 0x3F03, 0x1FCF,
+ 0x10AB, 0x10AC, 0x1916, 0x3F04, 0x09FA, 0x0D83,
+ 0x3F05, 0x068F, 0x086A, 0x1914, 0x3EFE, 0x1FC9,
+ 0x1FCA, 0x3EFF, 0x0D82, 0x1FCB, 0x1FCC, 0x3F00,
+ 0x1FCD, 0x3F01, 0x1915, 0x3F0F, 0x1918, 0x10AD,
+ 0x0CB3, 0x3F10, 0x1919, 0x3F11, 0x191A, 0x1FD2,
+ 0x0CB4, 0x0CB5, 0x10AE, 0x191B, 0x047A, 0x06DA,
+ 0x3F06, 0x3F07, 0x1917, 0x3F08, 0x3F09, 0x3F0A,
+ 0x3F0B, 0x3F0C, 0x3F0D, 0x3F0E, 0x1FD0, 0x1FD1,
+ 0x3F18, 0x191F, 0x1FDA, 0x3F19, 0x3F1A, 0x10AF,
+ 0x3F1B, 0x10B2, 0x1FDB, 0x0D86, 0x0D87, 0x10B3,
+ 0x0CB6, 0x086B, 0x09FB, 0x3F12, 0x1FD3, 0x1FD4,
+ 0x3F13, 0x1FD5, 0x191E, 0x1FD6, 0x3F14, 0x3F15,
+ 0x3F16, 0x1FD7, 0x3F17, 0x033A, 0x01AA, 0x02B8,
+ 0x01DF, 0x02B9, 0x02BA, 0x086F, 0x03BB, 0x03B2,
+ 0x046A, 0x066F, 0x08DE, 0x0563, 0x046B, 0x0CB7,
+ 0x11BE, 0x086E, 0x066E, 0x06DB, 0x047B, 0x03BA,
+ 0x0A9E, 0x02B7, 0x0340, 0x0264, 0x01CE, 0x01A9,
+ 0x0265, 0x01A8, 0x0266, 0x02A8, 0x036F, 0x03AB,
+ 0x037A, 0x04FE, 0x0683, 0x06C4, 0x0C90, 0x065D,
+ 0x0D3C, 0x0FEC, 0x0436, 0x06C2, 0x0682, 0x0C8E,
+ 0x055A, 0x033B, 0x065C, 0x0348, 0x03AA, 0x0234,
+ 0x036E, 0x01F0, 0x01A6, 0x3E86, 0x3E87, 0x153E,
+ 0x3E88, 0x3E89, 0x0FEF, 0x3E8A, 0x3E8B, 0x3E8C,
+ 0x3E8D, 0x3E8E, 0x3E8F, 0x3E90, 0x09E4, 0x03AC,
+ 0x11BF, 0x1F8E, 0x1F8F, 0x0FEE, 0x3E80, 0x3E81,
+ 0x3E82, 0x3E83, 0x3E84, 0x3E85, 0x1F90, 0x1F91,
+ 0x3E95, 0x3E96, 0x0C91, 0x3E97, 0x3E98, 0x3E99,
+ 0x3E9A, 0x3E9B, 0x3E9C, 0x3E9D, 0x3E9E, 0x3E9F,
+ 0x3EA0, 0x0858, 0x04FF, 0x0FF0, 0x0FF1, 0x153F,
+ 0x0FF2, 0x3E91, 0x1F92, 0x3E92, 0x1F93, 0x3E93,
+ 0x1F94, 0x3E94, 0x0D3D, 0x3EA3, 0x1F99, 0x0FF7,
+ 0x0D3E, 0x3EA4, 0x1F9A, 0x15D9, 0x0D3F, 0x3EA5,
+ 0x3EA6, 0x3EA7, 0x0D58, 0x3EA8, 0x06C5, 0x072E,
+ 0x3EA1, 0x1F95, 0x1F96, 0x0C92, 0x0FF3, 0x0FF4,
+ 0x0FF5, 0x15D8, 0x1F97, 0x0FF6, 0x1F98, 0x3EA2,
+ 0x3EAC, 0x0FF9, 0x1F9C, 0x15DB, 0x1F9D, 0x15DC,
+ 0x0FFA, 0x1F9E, 0x3EAD, 0x3EAE, 0x3EAF, 0x3EB0,
+ 0x3EB1, 0x065E, 0x055B, 0x3EA9, 0x0D59, 0x15DA,
+ 0x0FF8, 0x3EAA, 0x0D5A, 0x3EAB, 0x0D5B, 0x0D5C,
+ 0x0D5D, 0x072F, 0x1F9B, 0x3EB4, 0x1FA0, 0x073C,
+ 0x0D5F, 0x1FA1, 0x1FA2, 0x0FFE, 0x1FA3, 0x1FA4,
+ 0x3EB5, 0x3EB6, 0x3EB7, 0x3EB8, 0x065F, 0x06C6,
+ 0x3EB2, 0x15DD, 0x0FFB, 0x3EB3, 0x1F9F, 0x0D5E,
+ 0x0C93, 0x0C94, 0x0FFC, 0x0FFD, 0x15DE, 0x15DF,
+ 0x1FA7, 0x15E1, 0x06C7, 0x0D62, 0x15E2, 0x0C96,
+ 0x15E3, 0x1082, 0x15E4, 0x1FA8, 0x3EBA, 0x3EBB,
+ 0x3EBC, 0x0660, 0x046E, 0x3EB9, 0x1FA5, 0x0FFF,
+ 0x1FA6, 0x1080, 0x1081, 0x0D60, 0x0C95, 0x15E0,
+ 0x0D61, 0x073D, 0x085A, 0x15E6, 0x09E9, 0x085B,
+ 0x0C97, 0x1083, 0x0C98, 0x0D63, 0x0D64, 0x0C99,
+ 0x15E7, 0x15E8, 0x1FAC, 0x3EBE, 0x0684, 0x037B,
+ 0x1FA9, 0x1FAA, 0x3EBD, 0x073E, 0x1FAB, 0x15E5,
+ 0x06C8, 0x09E5, 0x09E6, 0x09E7, 0x0661, 0x09E8,
+ 0x1FAE, 0x0C9A, 0x06CA, 0x055C, 0x0C9B, 0x3EC0,
+ 0x15EB, 0x1085, 0x1086, 0x15EC, 0x1087, 0x3EC1,
+ 0x3EC2, 0x02A9, 0x02B3, 0x1FAD, 0x15E9, 0x3EBF,
+ 0x15EA, 0x1084, 0x0D65, 0x0662, 0x0D66, 0x06C9,
+ 0x0438, 0x054A, 0x073F, 0x085D, 0x0663, 0x0439,
+ 0x0686, 0x06CB, 0x0C9E, 0x0C9F, 0x1088, 0x15EF,
+ 0x3EC6, 0x1089, 0x1FAF, 0x3EC7, 0x0349, 0x0267,
+ 0x3EC3, 0x3EC4, 0x15ED, 0x15EE, 0x3EC5, 0x09EA,
+ 0x0C9C, 0x0C9D, 0x054B, 0x0685, 0x085C, 0x09EB,
+ 0x01BC, 0x01DC, 0x01BE, 0x03AD, 0x038A, 0x0749,
+ 0x0688, 0x0665, 0x074A, 0x0CA1, 0x0D68, 0x3EC8,
+ 0x1FB1, 0x0236, 0x034A, 0x1FB0, 0x108A, 0x108B,
+ 0x0CA0, 0x0D67, 0x0687, 0x0748, 0x0664, 0x038B,
+ 0x023E, 0x01DA, 0x01DB, 0x006E, 0x0094, 0x00E6,
+ 0x033E, 0x043A, 0x06CD, 0x085E, 0x085F, 0x0D69,
+ 0x0D6A, 0x1FB3, 0x1FB4, 0x3ECA, 0x034B, 0x023F,
+ 0x3EC9, 0x108C, 0x1FB2, 0x15F0, 0x15F1, 0x074B,
+ 0x06CC, 0x074C, 0x038C, 0x0268, 0x0136, 0x0095,
+ 0x0014, 0x001E, 0x0097, 0x019C, 0x074D, 0x0D6C,
+ 0x06CE, 0x0CA2, 0x108E, 0x09EC, 0x3ECD, 0x108F,
+ 0x3ECE, 0x026A, 0x02AA, 0x3ECB, 0x1FB5, 0x15F2,
+ 0x3ECC, 0x15F3, 0x15F4, 0x0D6B, 0x108D, 0x043B,
+ 0x0269, 0x0096, 0x0022,
+};
+
+static const uint8_t on2avc_cb14_bits[ON2AVC_CB14_CODES] = {
+ 1, 5, 8, 10, 11, 12,
+ 14, 13, 12, 13, 14, 14,
+ 14, 10, 10, 14, 14, 13,
+ 13, 14, 13, 13, 12, 11,
+ 10, 8, 5, 5, 6, 8,
+ 10, 11, 10, 13, 12, 13,
+ 13, 14, 13, 13, 9, 9,
+ 14, 13, 13, 12, 14, 14,
+ 11, 12, 11, 9, 8, 6,
+ 7, 8, 8, 10, 10, 11,
+ 11, 12, 11, 12, 13, 14,
+ 13, 9, 10, 13, 13, 13,
+ 13, 12, 11, 11, 12, 10,
+ 10, 8, 8, 9, 9, 9,
+ 10, 11, 11, 12, 12, 12,
+ 12, 13, 13, 14, 10, 9,
+ 14, 14, 14, 14, 13, 13,
+ 12, 11, 11, 10, 10, 9,
+ 11, 12, 11, 11, 11, 12,
+ 12, 12, 12, 11, 13, 14,
+ 13, 10, 10, 14, 13, 14,
+ 12, 13, 12, 13, 13, 13,
+ 11, 11, 11, 14, 12, 11,
+ 12, 11, 11, 12, 12, 12,
+ 12, 14, 14, 14, 10, 10,
+ 14, 13, 14, 12, 12, 12,
+ 12, 11, 12, 11, 11, 13,
+ 13, 12, 11, 11, 12, 13,
+ 11, 11, 11, 12, 12, 13,
+ 13, 10, 10, 14, 13, 14,
+ 13, 13, 13, 12, 12, 12,
+ 13, 11, 12, 13, 13, 11,
+ 12, 13, 12, 12, 11, 12,
+ 14, 12, 12, 14, 10, 11,
+ 14, 13, 13, 13, 14, 13,
+ 13, 13, 13, 14, 12, 13,
+ 13, 13, 13, 12, 12, 13,
+ 12, 13, 12, 13, 13, 13,
+ 13, 11, 11, 14, 14, 13,
+ 13, 14, 14, 13, 13, 12,
+ 13, 14, 13, 13, 14, 12,
+ 12, 13, 13, 12, 13, 13,
+ 11, 12, 14, 13, 11, 11,
+ 14, 14, 14, 14, 14, 12,
+ 14, 13, 13, 13, 12, 14,
+ 13, 12, 14, 13, 14, 13,
+ 13, 13, 13, 14, 12, 12,
+ 14, 11, 12, 13, 14, 13,
+ 13, 14, 12, 13, 13, 14,
+ 13, 14, 13, 14, 13, 13,
+ 12, 14, 13, 14, 13, 13,
+ 12, 12, 13, 13, 11, 11,
+ 14, 14, 13, 14, 14, 14,
+ 14, 14, 14, 14, 13, 13,
+ 14, 13, 13, 14, 14, 13,
+ 14, 13, 13, 12, 12, 13,
+ 12, 12, 12, 14, 13, 13,
+ 14, 13, 13, 13, 14, 14,
+ 14, 13, 14, 10, 9, 10,
+ 9, 10, 10, 12, 10, 10,
+ 11, 11, 12, 11, 11, 12,
+ 13, 12, 11, 11, 11, 10,
+ 12, 10, 10, 10, 9, 9,
+ 10, 9, 10, 10, 10, 10,
+ 10, 11, 11, 11, 12, 11,
+ 12, 12, 11, 11, 11, 12,
+ 11, 10, 11, 10, 10, 10,
+ 10, 9, 9, 14, 14, 13,
+ 14, 14, 12, 14, 14, 14,
+ 14, 14, 14, 14, 12, 10,
+ 13, 13, 13, 12, 14, 14,
+ 14, 14, 14, 14, 13, 13,
+ 14, 14, 12, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14,
+ 14, 12, 11, 12, 12, 13,
+ 12, 14, 13, 14, 13, 14,
+ 13, 14, 12, 14, 13, 12,
+ 12, 14, 13, 13, 12, 14,
+ 14, 14, 12, 14, 11, 11,
+ 14, 13, 13, 12, 12, 12,
+ 12, 13, 13, 12, 13, 14,
+ 14, 12, 13, 13, 13, 13,
+ 12, 13, 14, 14, 14, 14,
+ 14, 11, 11, 14, 12, 13,
+ 12, 14, 12, 14, 12, 12,
+ 12, 11, 13, 14, 13, 11,
+ 12, 13, 13, 12, 13, 13,
+ 14, 14, 14, 14, 11, 11,
+ 14, 13, 12, 14, 13, 12,
+ 12, 12, 12, 12, 13, 13,
+ 13, 13, 11, 12, 13, 12,
+ 13, 13, 13, 13, 14, 14,
+ 14, 11, 11, 14, 13, 12,
+ 13, 13, 13, 12, 12, 13,
+ 12, 11, 12, 13, 12, 12,
+ 12, 13, 12, 12, 12, 12,
+ 13, 13, 13, 14, 11, 10,
+ 13, 13, 14, 11, 13, 13,
+ 11, 12, 12, 12, 11, 12,
+ 13, 12, 11, 11, 12, 14,
+ 13, 13, 13, 13, 13, 14,
+ 14, 10, 10, 13, 13, 14,
+ 13, 13, 12, 11, 12, 11,
+ 11, 11, 11, 12, 11, 11,
+ 11, 11, 12, 12, 13, 13,
+ 14, 13, 13, 14, 10, 10,
+ 14, 14, 13, 13, 14, 12,
+ 12, 12, 11, 11, 12, 12,
+ 9, 9, 9, 10, 10, 11,
+ 11, 11, 11, 12, 12, 14,
+ 13, 10, 10, 13, 13, 13,
+ 12, 12, 11, 11, 11, 10,
+ 10, 9, 9, 7, 8, 8,
+ 10, 11, 11, 12, 12, 12,
+ 12, 13, 13, 14, 10, 10,
+ 14, 13, 13, 13, 13, 11,
+ 11, 11, 10, 10, 9, 8,
+ 5, 5, 8, 9, 11, 12,
+ 11, 12, 13, 12, 14, 13,
+ 14, 10, 10, 14, 13, 13,
+ 14, 13, 13, 12, 13, 11,
+ 10, 8, 6,
+};
+
+static const uint16_t on2avc_cb14_syms[ON2AVC_CB14_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B,
+ 0x000C, 0x000D, 0x00F3, 0x00F4, 0x00F5, 0x00F6,
+ 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC,
+ 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x0101, 0x0102,
+ 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108,
+ 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x01F3,
+ 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9,
+ 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
+ 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205,
+ 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x020B,
+ 0x020C, 0x020D, 0x02F3, 0x02F4, 0x02F5, 0x02F6,
+ 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308,
+ 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x03F3,
+ 0x03F4, 0x03F5, 0x03F6, 0x03F7, 0x03F8, 0x03F9,
+ 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
+ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405,
+ 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x040B,
+ 0x040C, 0x040D, 0x04F3, 0x04F4, 0x04F5, 0x04F6,
+ 0x04F7, 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC,
+ 0x04FD, 0x04FE, 0x04FF, 0x0500, 0x0501, 0x0502,
+ 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x0508,
+ 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x05F3,
+ 0x05F4, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x05F9,
+ 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0605,
+ 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, 0x060B,
+ 0x060C, 0x060D, 0x06F3, 0x06F4, 0x06F5, 0x06F6,
+ 0x06F7, 0x06F8, 0x06F9, 0x06FA, 0x06FB, 0x06FC,
+ 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702,
+ 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x0708,
+ 0x0709, 0x070A, 0x070B, 0x070C, 0x070D, 0x07F3,
+ 0x07F4, 0x07F5, 0x07F6, 0x07F7, 0x07F8, 0x07F9,
+ 0x07FA, 0x07FB, 0x07FC, 0x07FD, 0x07FE, 0x07FF,
+ 0x0800, 0x0801, 0x0802, 0x0803, 0x0804, 0x0805,
+ 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
+ 0x080C, 0x080D, 0x08F3, 0x08F4, 0x08F5, 0x08F6,
+ 0x08F7, 0x08F8, 0x08F9, 0x08FA, 0x08FB, 0x08FC,
+ 0x08FD, 0x08FE, 0x08FF, 0x0900, 0x0901, 0x0902,
+ 0x0903, 0x0904, 0x0905, 0x0906, 0x0907, 0x0908,
+ 0x0909, 0x090A, 0x090B, 0x090C, 0x090D, 0x09F3,
+ 0x09F4, 0x09F5, 0x09F6, 0x09F7, 0x09F8, 0x09F9,
+ 0x09FA, 0x09FB, 0x09FC, 0x09FD, 0x09FE, 0x09FF,
+ 0x0A00, 0x0A01, 0x0A02, 0x0A03, 0x0A04, 0x0A05,
+ 0x0A06, 0x0A07, 0x0A08, 0x0A09, 0x0A0A, 0x0A0B,
+ 0x0A0C, 0x0A0D, 0x0AF3, 0x0AF4, 0x0AF5, 0x0AF6,
+ 0x0AF7, 0x0AF8, 0x0AF9, 0x0AFA, 0x0AFB, 0x0AFC,
+ 0x0AFD, 0x0AFE, 0x0AFF, 0x0B00, 0x0B01, 0x0B02,
+ 0x0B03, 0x0B04, 0x0B05, 0x0B06, 0x0B07, 0x0B08,
+ 0x0B09, 0x0B0A, 0x0B0B, 0x0B0C, 0x0B0D, 0x0BF3,
+ 0x0BF4, 0x0BF5, 0x0BF6, 0x0BF7, 0x0BF8, 0x0BF9,
+ 0x0BFA, 0x0BFB, 0x0BFC, 0x0BFD, 0x0BFE, 0x0BFF,
+ 0x0C00, 0x0C01, 0x0C02, 0x0C03, 0x0C04, 0x0C05,
+ 0x0C06, 0x0C07, 0x0C08, 0x0C09, 0x0C0A, 0x0C0B,
+ 0x0C0C, 0x0C0D, 0x0CF3, 0x0CF4, 0x0CF5, 0x0CF6,
+ 0x0CF7, 0x0CF8, 0x0CF9, 0x0CFA, 0x0CFB, 0x0CFC,
+ 0x0CFD, 0x0CFE, 0x0CFF, 0x0D00, 0x0D01, 0x0D02,
+ 0x0D03, 0x0D04, 0x0D05, 0x0D06, 0x0D07, 0x0D08,
+ 0x0D09, 0x0D0A, 0x0D0B, 0x0D0C, 0x0D0D, 0x0DF3,
+ 0x0DF4, 0x0DF5, 0x0DF6, 0x0DF7, 0x0DF8, 0x0DF9,
+ 0x0DFA, 0x0DFB, 0x0DFC, 0x0DFD, 0x0DFE, 0x0DFF,
+ 0xF300, 0xF301, 0xF302, 0xF303, 0xF304, 0xF305,
+ 0xF306, 0xF307, 0xF308, 0xF309, 0xF30A, 0xF30B,
+ 0xF30C, 0xF30D, 0xF3F3, 0xF3F4, 0xF3F5, 0xF3F6,
+ 0xF3F7, 0xF3F8, 0xF3F9, 0xF3FA, 0xF3FB, 0xF3FC,
+ 0xF3FD, 0xF3FE, 0xF3FF, 0xF400, 0xF401, 0xF402,
+ 0xF403, 0xF404, 0xF405, 0xF406, 0xF407, 0xF408,
+ 0xF409, 0xF40A, 0xF40B, 0xF40C, 0xF40D, 0xF4F3,
+ 0xF4F4, 0xF4F5, 0xF4F6, 0xF4F7, 0xF4F8, 0xF4F9,
+ 0xF4FA, 0xF4FB, 0xF4FC, 0xF4FD, 0xF4FE, 0xF4FF,
+ 0xF500, 0xF501, 0xF502, 0xF503, 0xF504, 0xF505,
+ 0xF506, 0xF507, 0xF508, 0xF509, 0xF50A, 0xF50B,
+ 0xF50C, 0xF50D, 0xF5F3, 0xF5F4, 0xF5F5, 0xF5F6,
+ 0xF5F7, 0xF5F8, 0xF5F9, 0xF5FA, 0xF5FB, 0xF5FC,
+ 0xF5FD, 0xF5FE, 0xF5FF, 0xF600, 0xF601, 0xF602,
+ 0xF603, 0xF604, 0xF605, 0xF606, 0xF607, 0xF608,
+ 0xF609, 0xF60A, 0xF60B, 0xF60C, 0xF60D, 0xF6F3,
+ 0xF6F4, 0xF6F5, 0xF6F6, 0xF6F7, 0xF6F8, 0xF6F9,
+ 0xF6FA, 0xF6FB, 0xF6FC, 0xF6FD, 0xF6FE, 0xF6FF,
+ 0xF700, 0xF701, 0xF702, 0xF703, 0xF704, 0xF705,
+ 0xF706, 0xF707, 0xF708, 0xF709, 0xF70A, 0xF70B,
+ 0xF70C, 0xF70D, 0xF7F3, 0xF7F4, 0xF7F5, 0xF7F6,
+ 0xF7F7, 0xF7F8, 0xF7F9, 0xF7FA, 0xF7FB, 0xF7FC,
+ 0xF7FD, 0xF7FE, 0xF7FF, 0xF800, 0xF801, 0xF802,
+ 0xF803, 0xF804, 0xF805, 0xF806, 0xF807, 0xF808,
+ 0xF809, 0xF80A, 0xF80B, 0xF80C, 0xF80D, 0xF8F3,
+ 0xF8F4, 0xF8F5, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9,
+ 0xF8FA, 0xF8FB, 0xF8FC, 0xF8FD, 0xF8FE, 0xF8FF,
+ 0xF900, 0xF901, 0xF902, 0xF903, 0xF904, 0xF905,
+ 0xF906, 0xF907, 0xF908, 0xF909, 0xF90A, 0xF90B,
+ 0xF90C, 0xF90D, 0xF9F3, 0xF9F4, 0xF9F5, 0xF9F6,
+ 0xF9F7, 0xF9F8, 0xF9F9, 0xF9FA, 0xF9FB, 0xF9FC,
+ 0xF9FD, 0xF9FE, 0xF9FF, 0xFA00, 0xFA01, 0xFA02,
+ 0xFA03, 0xFA04, 0xFA05, 0xFA06, 0xFA07, 0xFA08,
+ 0xFA09, 0xFA0A, 0xFA0B, 0xFA0C, 0xFA0D, 0xFAF3,
+ 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9,
+ 0xFAFA, 0xFAFB, 0xFAFC, 0xFAFD, 0xFAFE, 0xFAFF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFB06, 0xFB07, 0xFB08, 0xFB09, 0xFB0A, 0xFB0B,
+ 0xFB0C, 0xFB0D, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
+ 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC,
+ 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00, 0xFC01, 0xFC02,
+ 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
+ 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFCF3,
+ 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9,
+ 0xFCFA, 0xFCFB, 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF,
+ 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04, 0xFD05,
+ 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B,
+ 0xFD0C, 0xFD0D, 0xFDF3, 0xFDF4, 0xFDF5, 0xFDF6,
+ 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08,
+ 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFEF3,
+ 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9,
+ 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0xFEFF,
+ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05,
+ 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B,
+ 0xFF0C, 0xFF0D, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6,
+ 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC,
+ 0xFFFD, 0xFFFE, 0xFFFF,
+};
+
+#define ON2AVC_CB15_CODES 1089
+static const uint16_t on2avc_cb15_codes[ON2AVC_CB15_CODES] = {
+ 0x00000, 0x0000A, 0x00064, 0x00104, 0x0034B, 0x0047B,
+ 0x007D7, 0x00E14, 0x00957, 0x021FD, 0x013B0, 0x03F08,
+ 0x07A01, 0x0E579, 0x00E15, 0x013A1, 0x003A2, 0x00397,
+ 0x0137F, 0x01F96, 0x021FC, 0x034CD, 0x01E97, 0x01A82,
+ 0x013A0, 0x01A83, 0x0089D, 0x00F6B, 0x0076C, 0x0026A,
+ 0x00118, 0x0006E, 0x00008, 0x0000B, 0x00015, 0x00076,
+ 0x000EC, 0x001D2, 0x003A6, 0x00716, 0x00726, 0x01F98,
+ 0x00E77, 0x01BF0, 0x01A84, 0x021FE, 0x021FF, 0x00D93,
+ 0x01A85, 0x0036E, 0x003B4, 0x00FFE, 0x00FDF, 0x07A02,
+ 0x065AF, 0x01E98, 0x01F97, 0x00E16, 0x00F30, 0x00CF0,
+ 0x00846, 0x00398, 0x0020F, 0x000EB, 0x00074, 0x00012,
+ 0x0007C, 0x00049, 0x0009C, 0x00136, 0x00344, 0x0026D,
+ 0x0076E, 0x00847, 0x00F6C, 0x00958, 0x01A86, 0x00F6D,
+ 0x013A3, 0x013B1, 0x009F8, 0x00F31, 0x0032F, 0x00268,
+ 0x00FE0, 0x0076D, 0x01F99, 0x013A2, 0x03D05, 0x0111A,
+ 0x00FFF, 0x00CF1, 0x0080D, 0x004FA, 0x0040B, 0x0023E,
+ 0x0011B, 0x0008E, 0x00077, 0x0010A, 0x000F8, 0x001B0,
+ 0x001D4, 0x003D9, 0x004C6, 0x006AE, 0x007DE, 0x0080E,
+ 0x00F33, 0x00E78, 0x01BF1, 0x0111B, 0x034CE, 0x00959,
+ 0x0111C, 0x00262, 0x001FA, 0x00F32, 0x00FE1, 0x02200,
+ 0x01F9A, 0x013A4, 0x00E17, 0x00FE2, 0x004B7, 0x00FE3,
+ 0x00717, 0x00453, 0x00366, 0x001C6, 0x0011A, 0x0010E,
+ 0x0032B, 0x0023F, 0x00345, 0x0035A, 0x0036F, 0x007B6,
+ 0x00E19, 0x00705, 0x0076F, 0x0111D, 0x00E79, 0x00D57,
+ 0x01BF4, 0x01A87, 0x0095B, 0x0095C, 0x00216, 0x0039A,
+ 0x00F34, 0x0095A, 0x01BF2, 0x01BF3, 0x01000, 0x00F6E,
+ 0x00F6F, 0x00E18, 0x007DF, 0x008F1, 0x007BE, 0x003BD,
+ 0x003EB, 0x00342, 0x0022D, 0x00772, 0x007BF, 0x00454,
+ 0x00455, 0x0071E, 0x004FB, 0x00727, 0x0080F, 0x009E7,
+ 0x00E7C, 0x01BF6, 0x01A89, 0x01001, 0x01BF7, 0x0089E,
+ 0x00E1A, 0x0027F, 0x00334, 0x00F35, 0x00F36, 0x01BF5,
+ 0x01F9B, 0x013A5, 0x00E7A, 0x0095D, 0x00D58, 0x00E7B,
+ 0x01A88, 0x00FE4, 0x006CE, 0x0040E, 0x00687, 0x006D2,
+ 0x00E1C, 0x00706, 0x00747, 0x006B6, 0x0084E, 0x00CF2,
+ 0x006F2, 0x00D59, 0x00CF3, 0x01004, 0x013A6, 0x00F71,
+ 0x01A8B, 0x01E99, 0x00D5A, 0x00D94, 0x00335, 0x0022E,
+ 0x0095E, 0x00E1B, 0x01A8A, 0x01BF8, 0x01BF9, 0x01002,
+ 0x009F9, 0x00F70, 0x01003, 0x00773, 0x00F37, 0x00812,
+ 0x004D2, 0x004A3, 0x0089F, 0x013A9, 0x013AA, 0x00813,
+ 0x0081E, 0x00707, 0x008A0, 0x00E1E, 0x00D95, 0x008F2,
+ 0x009FB, 0x00E7D, 0x00E7E, 0x00F39, 0x01F9C, 0x00CF4,
+ 0x00F75, 0x00346, 0x0026E, 0x01005, 0x00F72, 0x013A7,
+ 0x0111E, 0x01BFA, 0x00F73, 0x013A8, 0x00F38, 0x00F74,
+ 0x009FA, 0x00FE5, 0x0084F, 0x0095F, 0x00E1D, 0x009EA,
+ 0x01A8D, 0x00E20, 0x00E21, 0x007CE, 0x00D96, 0x01008,
+ 0x00E22, 0x00960, 0x01121, 0x00E7F, 0x01122, 0x01A8E,
+ 0x01BFB, 0x01A8F, 0x008A1, 0x01009, 0x0035F, 0x00368,
+ 0x013B2, 0x01A8C, 0x01F9D, 0x02201, 0x01006, 0x0111F,
+ 0x013AB, 0x013AC, 0x01120, 0x00F76, 0x01007, 0x009FC,
+ 0x008F3, 0x00E1F, 0x01E9A, 0x01F9F, 0x013B3, 0x00F3B,
+ 0x00F77, 0x00F78, 0x00FE7, 0x009FD, 0x00FE8, 0x01123,
+ 0x00D97, 0x01BFF, 0x00E80, 0x01A93, 0x01124, 0x00D9E,
+ 0x00D5B, 0x003DA, 0x003A7, 0x00961, 0x01BFC, 0x01F9E,
+ 0x01BFD, 0x01BFE, 0x01A90, 0x01A91, 0x013AD, 0x00F3A,
+ 0x01A92, 0x00FE6, 0x00962, 0x0085E, 0x00963, 0x013AE,
+ 0x03D06, 0x01C01, 0x013B5, 0x00965, 0x01FA2, 0x02202,
+ 0x009FE, 0x00F79, 0x00F7A, 0x00E23, 0x00E26, 0x00966,
+ 0x013B1, 0x01E9C, 0x00F7B, 0x008A2, 0x003FE, 0x003AB,
+ 0x00964, 0x013B4, 0x01C00, 0x01E9B, 0x01FA0, 0x01FA1,
+ 0x0100A, 0x013AF, 0x03F09, 0x00E81, 0x01A94, 0x01125,
+ 0x01126, 0x01A95, 0x013B0, 0x03D08, 0x01E9E, 0x01FA3,
+ 0x013B4, 0x01A99, 0x0100B, 0x013B9, 0x00F3E, 0x00967,
+ 0x00E27, 0x0100C, 0x01E9F, 0x00968, 0x01C05, 0x00F3F,
+ 0x00E82, 0x0039B, 0x00386, 0x01A96, 0x01C02, 0x03D07,
+ 0x013B6, 0x01C03, 0x01E9D, 0x01127, 0x01A97, 0x01C04,
+ 0x013B2, 0x013B3, 0x013B7, 0x01A98, 0x013B8, 0x03F0A,
+ 0x0E57A, 0x07A03, 0x013BB, 0x01FA4, 0x01A9C, 0x01FA5,
+ 0x01FA6, 0x013BC, 0x0100D, 0x01FA7, 0x013B5, 0x0100E,
+ 0x01A9D, 0x0100F, 0x0096A, 0x01128, 0x00328, 0x003FF,
+ 0x00969, 0x01EA0, 0x01C06, 0x013BA, 0x01A9A, 0x034CF,
+ 0x00F7C, 0x02203, 0x034D2, 0x01EA1, 0x01C07, 0x02204,
+ 0x01A9B, 0x01EA2, 0x06982, 0x03D09, 0x0E57B, 0x01FA8,
+ 0x013C2, 0x013C3, 0x01129, 0x01FA9, 0x0112A, 0x01010,
+ 0x01FAA, 0x01EA6, 0x03F0F, 0x013B6, 0x00CF5, 0x0072A,
+ 0x00F7D, 0x00340, 0x0025F, 0x02205, 0x02206, 0x06983,
+ 0x01C08, 0x013BD, 0x013BE, 0x01EA3, 0x013BF, 0x034D3,
+ 0x01EA4, 0x02207, 0x01A9E, 0x01EA5, 0x03F0B, 0x03F0E,
+ 0x01AA2, 0x00E00, 0x00E3E, 0x00D9F, 0x00D5F, 0x00CF7,
+ 0x00CFE, 0x01011, 0x00E85, 0x00E01, 0x00E02, 0x0096B,
+ 0x00CFF, 0x00F92, 0x00D6E, 0x008CA, 0x00359, 0x00456,
+ 0x01CAE, 0x03D0A, 0x01A9F, 0x0112B, 0x00E83, 0x013B7,
+ 0x00F7E, 0x009FF, 0x00E84, 0x00FE9, 0x009EB, 0x00F7F,
+ 0x008A3, 0x00D5E, 0x00CF6, 0x0112E, 0x0112F, 0x01016,
+ 0x00F93, 0x01FAE, 0x00FEA, 0x00FEB, 0x009A6, 0x00E03,
+ 0x01C0A, 0x01017, 0x01C0B, 0x01FAF, 0x00F9E, 0x013BB,
+ 0x0196A, 0x0039C, 0x003F6, 0x0379A, 0x03D0B, 0x01FAB,
+ 0x01EA7, 0x013B8, 0x01012, 0x01AA3, 0x01C09, 0x013B9,
+ 0x01013, 0x00CB4, 0x00E86, 0x01F3E, 0x013BA, 0x00E87,
+ 0x007FB, 0x003CF, 0x0037A, 0x003AD, 0x00387, 0x0038A,
+ 0x003B5, 0x0039E, 0x0026F, 0x0038B, 0x00272, 0x0039F,
+ 0x00399, 0x0038E, 0x00252, 0x0039A, 0x00018, 0x0001B,
+ 0x003CE, 0x00457, 0x003E8, 0x0067E, 0x0041A, 0x003BE,
+ 0x003BF, 0x003EE, 0x00437, 0x0039D, 0x003AC, 0x00464,
+ 0x003C6, 0x003C7, 0x0041B, 0x007F6, 0x0042E, 0x0025C,
+ 0x0038C, 0x003BA, 0x003E9, 0x003EA, 0x00271, 0x003BB,
+ 0x0026A, 0x0025D, 0x0025E, 0x00389, 0x003EE, 0x004F4,
+ 0x00415, 0x0001A, 0x00017, 0x00388, 0x0038E, 0x003FC,
+ 0x00270, 0x00378, 0x0038A, 0x003AE, 0x003AA, 0x00398,
+ 0x003E8, 0x00358, 0x00414, 0x00384, 0x003B8, 0x006D3,
+ 0x01A6B, 0x00FEA, 0x01BCE, 0x009E4, 0x00E56, 0x01BCF,
+ 0x0131D, 0x009E5, 0x01BD8, 0x01BD9, 0x034C0, 0x01F86,
+ 0x01A6C, 0x01F3F, 0x065AC, 0x072BE, 0x00436, 0x0022C,
+ 0x009E0, 0x00F54, 0x009E2, 0x01104, 0x01105, 0x00FE8,
+ 0x009E3, 0x00FE9, 0x00F55, 0x0131C, 0x01A68, 0x01A6A,
+ 0x00E06, 0x01106, 0x01BCC, 0x00E6E, 0x00E3F, 0x00CB7,
+ 0x00F28, 0x00702, 0x0094E, 0x00F29, 0x00FEC, 0x00F2A,
+ 0x0131E, 0x00F56, 0x0131F, 0x00F57, 0x0110A, 0x0134E,
+ 0x01E86, 0x00712, 0x001F6, 0x0081F, 0x00D6F, 0x00FEB,
+ 0x01107, 0x00CB6, 0x0094C, 0x01BDA, 0x01108, 0x01109,
+ 0x009E6, 0x00E6C, 0x01F88, 0x00E6D, 0x00896, 0x0094D,
+ 0x03F00, 0x01E88, 0x0217C, 0x03F01, 0x03F02, 0x01399,
+ 0x01E89, 0x0E578, 0x0139A, 0x01E8A, 0x01F8A, 0x01F8B,
+ 0x01E8B, 0x03D02, 0x01F8C, 0x0139B, 0x00392, 0x0035E,
+ 0x00F58, 0x009DE, 0x0094F, 0x01358, 0x01359, 0x0135A,
+ 0x0134F, 0x01BDB, 0x0135B, 0x0379B, 0x01F89, 0x01398,
+ 0x034C2, 0x065AD, 0x01E87, 0x03F04, 0x07A00, 0x0217D,
+ 0x01A6D, 0x065AE, 0x01E8C, 0x0217E, 0x01BDD, 0x0135C,
+ 0x01A6E, 0x034C4, 0x01E8D, 0x03F05, 0x01E8E, 0x0217F,
+ 0x0139D, 0x003F7, 0x0032C, 0x034C3, 0x00E07, 0x0110B,
+ 0x009E7, 0x00F59, 0x03D03, 0x00D8A, 0x01F8D, 0x00E6F,
+ 0x00FED, 0x03F03, 0x00FEE, 0x01BDC, 0x0139C, 0x072BF,
+ 0x03F06, 0x021F2, 0x01A70, 0x021F3, 0x0135E, 0x0139E,
+ 0x01F8E, 0x01F8F, 0x0139F, 0x01E91, 0x013A0, 0x0135F,
+ 0x034C6, 0x0110E, 0x01A71, 0x021F4, 0x0026C, 0x00206,
+ 0x0110C, 0x009E8, 0x01BDE, 0x00F5A, 0x00FEF, 0x0135D,
+ 0x00FF0, 0x01E8F, 0x021F0, 0x009E9, 0x01E90, 0x021F1,
+ 0x01A6F, 0x0110D, 0x034C5, 0x021F5, 0x01A73, 0x01BE2,
+ 0x01BE3, 0x01F91, 0x01A74, 0x00E70, 0x021F6, 0x034C8,
+ 0x00FF3, 0x01F92, 0x013A1, 0x013A2, 0x013A3, 0x01A75,
+ 0x01372, 0x003BC, 0x00341, 0x034C7, 0x00950, 0x00FF1,
+ 0x00FF2, 0x009EA, 0x00F5B, 0x01370, 0x01BDF, 0x01371,
+ 0x01A72, 0x01BE0, 0x009EB, 0x01F90, 0x0110F, 0x01BE1,
+ 0x01E92, 0x013A6, 0x00D8B, 0x00FD8, 0x01BE5, 0x00FF4,
+ 0x00FF5, 0x01BE6, 0x013A7, 0x00F5F, 0x01BE7, 0x021F7,
+ 0x021F8, 0x034C9, 0x009EC, 0x013A8, 0x003EF, 0x00269,
+ 0x00CD8, 0x00FD6, 0x00F5C, 0x013A4, 0x00F5D, 0x00F2B,
+ 0x00E08, 0x01110, 0x01BE4, 0x00E09, 0x013A5, 0x00F2C,
+ 0x00898, 0x00F5E, 0x01A76, 0x013A9, 0x00D8C, 0x009DF,
+ 0x009E0, 0x00FF8, 0x00D8D, 0x01374, 0x01A78, 0x01112,
+ 0x01BE8, 0x01A79, 0x01F93, 0x01113, 0x01375, 0x00F61,
+ 0x01376, 0x00399, 0x0027C, 0x009ED, 0x00F60, 0x01373,
+ 0x01A77, 0x00951, 0x009EE, 0x00D50, 0x00CD9, 0x00FF6,
+ 0x00FD9, 0x00FF7, 0x00899, 0x007C8, 0x00D52, 0x01111,
+ 0x009EF, 0x007D3, 0x007D4, 0x0071E, 0x00CDB, 0x00746,
+ 0x00E0A, 0x00E0B, 0x021F9, 0x00FF9, 0x01A7A, 0x00952,
+ 0x013AB, 0x01377, 0x009F0, 0x01E93, 0x003AF, 0x0032E,
+ 0x009E1, 0x007CA, 0x013AA, 0x01114, 0x00F62, 0x00E71,
+ 0x008CB, 0x008CC, 0x0089A, 0x008CD, 0x00840, 0x00CDA,
+ 0x007D2, 0x009E2, 0x00E72, 0x00F63, 0x006D6, 0x00841,
+ 0x0079E, 0x00D53, 0x008CE, 0x00955, 0x00E0C, 0x0137A,
+ 0x00E74, 0x01115, 0x01F94, 0x01116, 0x01BEA, 0x00E0D,
+ 0x01A7B, 0x0038D, 0x0033E, 0x00CDC, 0x00D8E, 0x01BE9,
+ 0x01378, 0x01379, 0x00FDA, 0x00E73, 0x00953, 0x00954,
+ 0x009E3, 0x004D6, 0x007B7, 0x007BA, 0x007BB, 0x004A0,
+ 0x0089B, 0x006D7, 0x0047A, 0x00408, 0x007F7, 0x00E0E,
+ 0x009E4, 0x007D5, 0x00842, 0x00D90, 0x009F1, 0x034CA,
+ 0x01A7C, 0x01A7D, 0x00E0F, 0x01A7E, 0x00329, 0x0021E,
+ 0x00F64, 0x01117, 0x021FA, 0x01118, 0x013AC, 0x013AD,
+ 0x00D8F, 0x008CF, 0x008F0, 0x0071F, 0x004A1, 0x00686,
+ 0x00426, 0x00416, 0x007CB, 0x003D8, 0x00264, 0x00347,
+ 0x003DC, 0x004F6, 0x004D7, 0x00F2D, 0x00F65, 0x009F3,
+ 0x00FDB, 0x00E75, 0x009F4, 0x0137B, 0x013AE, 0x009E5,
+ 0x00E10, 0x0027E, 0x0020C, 0x00FFA, 0x00956, 0x01BEB,
+ 0x01E94, 0x01E95, 0x00D91, 0x009F2, 0x00D54, 0x007BC,
+ 0x007BD, 0x0040A, 0x00385, 0x0036A, 0x0022F, 0x0020E,
+ 0x000FC, 0x000F2, 0x001AE, 0x001C8, 0x0034A, 0x004F7,
+ 0x00452, 0x00CDE, 0x00843, 0x00E76, 0x00F2E, 0x00F67,
+ 0x0137C, 0x01A7F, 0x0080C, 0x00FDC, 0x0021A, 0x001FC,
+ 0x00E11, 0x009F5, 0x01BEC, 0x00F66, 0x013AF, 0x00CDD,
+ 0x00E12, 0x00D55, 0x00703, 0x0080A, 0x00394, 0x00265,
+ 0x001F6, 0x001B6, 0x0010C, 0x00078, 0x0004C, 0x000CC,
+ 0x001A4, 0x00212, 0x00396, 0x006C4, 0x0089C, 0x00CDF,
+ 0x01A80, 0x00F68, 0x00FFD, 0x0137D, 0x01F95, 0x00845,
+ 0x00E13, 0x00267, 0x00266, 0x00FFB, 0x009F6, 0x03D04,
+ 0x01BED, 0x01BEE, 0x034CB, 0x00FFC, 0x00844, 0x007D6,
+ 0x00704, 0x003C8, 0x0032A, 0x00130, 0x000CE, 0x00048,
+ 0x0000C, 0x00014, 0x0007A, 0x000F0, 0x001E6, 0x00417,
+ 0x004A2, 0x004B6, 0x00D92, 0x01A81, 0x009F7, 0x0137E,
+ 0x01E96, 0x03F07, 0x009E6, 0x00FDE, 0x003C9, 0x00268,
+ 0x00F2F, 0x00D56, 0x021FB, 0x034CC, 0x01BEF, 0x00F69,
+ 0x01119, 0x00F6A, 0x00FDD, 0x007FA, 0x003E6, 0x001E2,
+ 0x000EA, 0x00072, 0x00016,
+};
+
+static const uint8_t on2avc_cb15_bits[ON2AVC_CB15_CODES] = {
+ 2, 5, 7, 9, 10, 11,
+ 12, 12, 13, 14, 14, 14,
+ 16, 17, 12, 13, 11, 11,
+ 13, 13, 14, 14, 14, 13,
+ 13, 13, 12, 13, 12, 10,
+ 9, 7, 5, 5, 5, 7,
+ 9, 10, 11, 11, 12, 13,
+ 13, 13, 13, 14, 14, 12,
+ 13, 10, 11, 13, 12, 16,
+ 15, 14, 13, 12, 12, 12,
+ 12, 11, 10, 9, 7, 5,
+ 7, 8, 8, 9, 10, 11,
+ 12, 12, 13, 13, 13, 13,
+ 13, 14, 13, 12, 10, 10,
+ 12, 12, 13, 13, 15, 13,
+ 13, 12, 12, 11, 11, 10,
+ 9, 8, 7, 9, 9, 9,
+ 9, 10, 11, 11, 12, 12,
+ 12, 13, 13, 13, 14, 13,
+ 13, 10, 10, 12, 12, 14,
+ 13, 13, 12, 12, 12, 12,
+ 11, 11, 10, 10, 9, 9,
+ 10, 10, 10, 10, 10, 11,
+ 12, 12, 12, 13, 13, 12,
+ 13, 13, 13, 13, 10, 10,
+ 12, 13, 13, 13, 13, 13,
+ 13, 12, 12, 12, 11, 11,
+ 10, 10, 10, 12, 11, 11,
+ 11, 11, 11, 12, 12, 12,
+ 13, 13, 13, 13, 13, 12,
+ 12, 10, 10, 12, 12, 13,
+ 13, 13, 13, 13, 12, 13,
+ 13, 12, 11, 11, 11, 11,
+ 12, 12, 12, 11, 12, 12,
+ 11, 12, 12, 13, 13, 13,
+ 13, 14, 12, 12, 10, 10,
+ 13, 12, 13, 13, 13, 13,
+ 13, 13, 13, 12, 12, 12,
+ 12, 12, 12, 13, 13, 12,
+ 12, 12, 12, 12, 12, 12,
+ 13, 13, 13, 12, 13, 12,
+ 13, 10, 11, 13, 13, 13,
+ 13, 13, 13, 13, 12, 13,
+ 13, 12, 12, 13, 12, 12,
+ 13, 12, 12, 12, 12, 13,
+ 12, 13, 13, 13, 13, 13,
+ 13, 13, 12, 13, 10, 10,
+ 14, 13, 13, 14, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 12, 12, 14, 13, 14, 12,
+ 13, 13, 12, 13, 12, 13,
+ 12, 13, 13, 13, 13, 12,
+ 12, 10, 11, 13, 13, 13,
+ 13, 13, 13, 13, 13, 12,
+ 13, 12, 13, 12, 13, 13,
+ 15, 13, 14, 13, 13, 14,
+ 13, 13, 13, 12, 12, 13,
+ 13, 14, 13, 12, 10, 10,
+ 13, 14, 13, 14, 13, 13,
+ 13, 13, 14, 13, 13, 13,
+ 13, 13, 13, 15, 14, 13,
+ 13, 13, 13, 14, 12, 13,
+ 12, 13, 14, 13, 13, 12,
+ 13, 10, 11, 13, 13, 15,
+ 14, 13, 14, 13, 13, 13,
+ 13, 13, 14, 13, 14, 14,
+ 17, 16, 14, 13, 13, 13,
+ 13, 14, 13, 13, 13, 13,
+ 13, 13, 13, 13, 10, 10,
+ 13, 14, 13, 14, 13, 14,
+ 13, 14, 14, 14, 13, 14,
+ 13, 14, 15, 15, 17, 13,
+ 14, 14, 13, 13, 13, 13,
+ 13, 14, 14, 13, 12, 12,
+ 13, 10, 11, 14, 14, 15,
+ 13, 14, 14, 14, 14, 14,
+ 14, 14, 13, 14, 14, 14,
+ 13, 13, 12, 12, 12, 12,
+ 12, 13, 13, 13, 13, 13,
+ 12, 13, 12, 12, 10, 11,
+ 14, 15, 13, 13, 13, 13,
+ 13, 13, 13, 12, 12, 13,
+ 12, 12, 12, 13, 13, 13,
+ 13, 13, 12, 12, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 13, 10, 11, 14, 15, 13,
+ 14, 13, 13, 13, 13, 13,
+ 13, 12, 13, 14, 13, 13,
+ 11, 11, 10, 10, 11, 11,
+ 11, 10, 11, 11, 11, 10,
+ 11, 11, 11, 11, 5, 6,
+ 11, 11, 11, 11, 11, 11,
+ 11, 10, 11, 10, 10, 11,
+ 11, 11, 11, 11, 11, 11,
+ 10, 11, 10, 10, 11, 11,
+ 11, 11, 11, 11, 11, 11,
+ 11, 6, 5, 11, 10, 10,
+ 11, 10, 10, 10, 10, 10,
+ 10, 10, 11, 11, 11, 11,
+ 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 14, 13,
+ 13, 14, 15, 16, 11, 10,
+ 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 12, 13, 13, 13, 12, 12,
+ 12, 12, 13, 12, 13, 12,
+ 13, 13, 13, 13, 13, 14,
+ 14, 11, 10, 12, 12, 13,
+ 13, 12, 13, 13, 13, 13,
+ 13, 13, 13, 13, 12, 13,
+ 14, 14, 14, 14, 14, 14,
+ 14, 17, 14, 14, 13, 13,
+ 14, 15, 13, 14, 11, 10,
+ 13, 12, 13, 13, 13, 13,
+ 14, 13, 13, 14, 13, 14,
+ 14, 15, 14, 14, 16, 14,
+ 13, 15, 14, 14, 13, 13,
+ 13, 14, 14, 14, 14, 14,
+ 14, 11, 10, 14, 12, 13,
+ 13, 13, 15, 12, 13, 13,
+ 13, 14, 13, 13, 14, 16,
+ 14, 14, 13, 14, 13, 14,
+ 13, 13, 14, 14, 14, 13,
+ 14, 13, 13, 14, 11, 10,
+ 13, 13, 13, 13, 13, 13,
+ 13, 14, 14, 13, 14, 14,
+ 13, 13, 14, 14, 13, 13,
+ 13, 13, 13, 13, 14, 14,
+ 13, 13, 14, 14, 14, 13,
+ 13, 11, 10, 14, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 14, 14, 12, 12, 13, 13,
+ 13, 13, 14, 13, 13, 14,
+ 14, 14, 13, 14, 10, 10,
+ 12, 12, 13, 14, 13, 12,
+ 12, 13, 13, 12, 14, 12,
+ 12, 13, 13, 14, 12, 12,
+ 12, 13, 12, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13,
+ 13, 10, 10, 13, 13, 13,
+ 13, 13, 13, 12, 12, 13,
+ 12, 13, 12, 12, 12, 13,
+ 13, 12, 12, 12, 12, 12,
+ 12, 12, 14, 13, 13, 13,
+ 14, 13, 13, 14, 10, 10,
+ 12, 12, 14, 13, 13, 13,
+ 12, 12, 12, 12, 12, 12,
+ 12, 12, 13, 13, 11, 12,
+ 11, 12, 12, 13, 12, 13,
+ 13, 13, 13, 13, 13, 12,
+ 13, 10, 10, 12, 12, 13,
+ 13, 13, 12, 13, 13, 13,
+ 12, 12, 11, 11, 11, 12,
+ 12, 11, 11, 11, 11, 12,
+ 12, 12, 12, 12, 13, 14,
+ 13, 13, 12, 13, 10, 10,
+ 13, 13, 14, 13, 14, 14,
+ 12, 12, 12, 12, 12, 11,
+ 11, 11, 12, 10, 10, 10,
+ 10, 11, 12, 12, 13, 13,
+ 12, 13, 13, 13, 14, 12,
+ 12, 10, 10, 13, 13, 13,
+ 14, 14, 12, 13, 12, 11,
+ 11, 11, 11, 10, 10, 10,
+ 9, 9, 9, 10, 10, 11,
+ 11, 12, 12, 13, 12, 13,
+ 13, 13, 12, 12, 10, 10,
+ 12, 13, 13, 13, 14, 12,
+ 12, 12, 12, 12, 11, 10,
+ 9, 9, 9, 7, 8, 8,
+ 9, 10, 11, 11, 12, 12,
+ 13, 13, 13, 13, 13, 12,
+ 12, 10, 10, 13, 13, 15,
+ 13, 13, 14, 13, 12, 12,
+ 12, 10, 10, 9, 8, 8,
+ 5, 5, 7, 9, 10, 11,
+ 12, 12, 12, 13, 13, 13,
+ 14, 14, 12, 12, 10, 11,
+ 12, 12, 14, 14, 13, 13,
+ 13, 13, 12, 11, 11, 10,
+ 9, 7, 5,
+};
+
+static const uint16_t on2avc_cb15_syms[ON2AVC_CB15_CODES] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
+ 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B,
+ 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x00F0,
+ 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6,
+ 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC,
+ 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x0101, 0x0102,
+ 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108,
+ 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E,
+ 0x010F, 0x0110, 0x01F0, 0x01F1, 0x01F2, 0x01F3,
+ 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9,
+ 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF,
+ 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205,
+ 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x020B,
+ 0x020C, 0x020D, 0x020E, 0x020F, 0x0210, 0x02F0,
+ 0x02F1, 0x02F2, 0x02F3, 0x02F4, 0x02F5, 0x02F6,
+ 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC,
+ 0x02FD, 0x02FE, 0x02FF, 0x0300, 0x0301, 0x0302,
+ 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308,
+ 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E,
+ 0x030F, 0x0310, 0x03F0, 0x03F1, 0x03F2, 0x03F3,
+ 0x03F4, 0x03F5, 0x03F6, 0x03F7, 0x03F8, 0x03F9,
+ 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF,
+ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405,
+ 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x040B,
+ 0x040C, 0x040D, 0x040E, 0x040F, 0x0410, 0x04F0,
+ 0x04F1, 0x04F2, 0x04F3, 0x04F4, 0x04F5, 0x04F6,
+ 0x04F7, 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC,
+ 0x04FD, 0x04FE, 0x04FF, 0x0500, 0x0501, 0x0502,
+ 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x0508,
+ 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x050E,
+ 0x050F, 0x0510, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
+ 0x05F4, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x05F9,
+ 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF,
+ 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0605,
+ 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, 0x060B,
+ 0x060C, 0x060D, 0x060E, 0x060F, 0x0610, 0x06F0,
+ 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 0x06F6,
+ 0x06F7, 0x06F8, 0x06F9, 0x06FA, 0x06FB, 0x06FC,
+ 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702,
+ 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x0708,
+ 0x0709, 0x070A, 0x070B, 0x070C, 0x070D, 0x070E,
+ 0x070F, 0x0710, 0x07F0, 0x07F1, 0x07F2, 0x07F3,
+ 0x07F4, 0x07F5, 0x07F6, 0x07F7, 0x07F8, 0x07F9,
+ 0x07FA, 0x07FB, 0x07FC, 0x07FD, 0x07FE, 0x07FF,
+ 0x0800, 0x0801, 0x0802, 0x0803, 0x0804, 0x0805,
+ 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
+ 0x080C, 0x080D, 0x080E, 0x080F, 0x0810, 0x08F0,
+ 0x08F1, 0x08F2, 0x08F3, 0x08F4, 0x08F5, 0x08F6,
+ 0x08F7, 0x08F8, 0x08F9, 0x08FA, 0x08FB, 0x08FC,
+ 0x08FD, 0x08FE, 0x08FF, 0x0900, 0x0901, 0x0902,
+ 0x0903, 0x0904, 0x0905, 0x0906, 0x0907, 0x0908,
+ 0x0909, 0x090A, 0x090B, 0x090C, 0x090D, 0x090E,
+ 0x090F, 0x0910, 0x09F0, 0x09F1, 0x09F2, 0x09F3,
+ 0x09F4, 0x09F5, 0x09F6, 0x09F7, 0x09F8, 0x09F9,
+ 0x09FA, 0x09FB, 0x09FC, 0x09FD, 0x09FE, 0x09FF,
+ 0x0A00, 0x0A01, 0x0A02, 0x0A03, 0x0A04, 0x0A05,
+ 0x0A06, 0x0A07, 0x0A08, 0x0A09, 0x0A0A, 0x0A0B,
+ 0x0A0C, 0x0A0D, 0x0A0E, 0x0A0F, 0x0A10, 0x0AF0,
+ 0x0AF1, 0x0AF2, 0x0AF3, 0x0AF4, 0x0AF5, 0x0AF6,
+ 0x0AF7, 0x0AF8, 0x0AF9, 0x0AFA, 0x0AFB, 0x0AFC,
+ 0x0AFD, 0x0AFE, 0x0AFF, 0x0B00, 0x0B01, 0x0B02,
+ 0x0B03, 0x0B04, 0x0B05, 0x0B06, 0x0B07, 0x0B08,
+ 0x0B09, 0x0B0A, 0x0B0B, 0x0B0C, 0x0B0D, 0x0B0E,
+ 0x0B0F, 0x0B10, 0x0BF0, 0x0BF1, 0x0BF2, 0x0BF3,
+ 0x0BF4, 0x0BF5, 0x0BF6, 0x0BF7, 0x0BF8, 0x0BF9,
+ 0x0BFA, 0x0BFB, 0x0BFC, 0x0BFD, 0x0BFE, 0x0BFF,
+ 0x0C00, 0x0C01, 0x0C02, 0x0C03, 0x0C04, 0x0C05,
+ 0x0C06, 0x0C07, 0x0C08, 0x0C09, 0x0C0A, 0x0C0B,
+ 0x0C0C, 0x0C0D, 0x0C0E, 0x0C0F, 0x0C10, 0x0CF0,
+ 0x0CF1, 0x0CF2, 0x0CF3, 0x0CF4, 0x0CF5, 0x0CF6,
+ 0x0CF7, 0x0CF8, 0x0CF9, 0x0CFA, 0x0CFB, 0x0CFC,
+ 0x0CFD, 0x0CFE, 0x0CFF, 0x0D00, 0x0D01, 0x0D02,
+ 0x0D03, 0x0D04, 0x0D05, 0x0D06, 0x0D07, 0x0D08,
+ 0x0D09, 0x0D0A, 0x0D0B, 0x0D0C, 0x0D0D, 0x0D0E,
+ 0x0D0F, 0x0D10, 0x0DF0, 0x0DF1, 0x0DF2, 0x0DF3,
+ 0x0DF4, 0x0DF5, 0x0DF6, 0x0DF7, 0x0DF8, 0x0DF9,
+ 0x0DFA, 0x0DFB, 0x0DFC, 0x0DFD, 0x0DFE, 0x0DFF,
+ 0x0E00, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05,
+ 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B,
+ 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0EF0,
+ 0x0EF1, 0x0EF2, 0x0EF3, 0x0EF4, 0x0EF5, 0x0EF6,
+ 0x0EF7, 0x0EF8, 0x0EF9, 0x0EFA, 0x0EFB, 0x0EFC,
+ 0x0EFD, 0x0EFE, 0x0EFF, 0x0F00, 0x0F01, 0x0F02,
+ 0x0F03, 0x0F04, 0x0F05, 0x0F06, 0x0F07, 0x0F08,
+ 0x0F09, 0x0F0A, 0x0F0B, 0x0F0C, 0x0F0D, 0x0F0E,
+ 0x0F0F, 0x0F10, 0x0FF0, 0x0FF1, 0x0FF2, 0x0FF3,
+ 0x0FF4, 0x0FF5, 0x0FF6, 0x0FF7, 0x0FF8, 0x0FF9,
+ 0x0FFA, 0x0FFB, 0x0FFC, 0x0FFD, 0x0FFE, 0x0FFF,
+ 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005,
+ 0x1006, 0x1007, 0x1008, 0x1009, 0x100A, 0x100B,
+ 0x100C, 0x100D, 0x100E, 0x100F, 0x1010, 0x10F0,
+ 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10F6,
+ 0x10F7, 0x10F8, 0x10F9, 0x10FA, 0x10FB, 0x10FC,
+ 0x10FD, 0x10FE, 0x10FF, 0xF000, 0xF001, 0xF002,
+ 0xF003, 0xF004, 0xF005, 0xF006, 0xF007, 0xF008,
+ 0xF009, 0xF00A, 0xF00B, 0xF00C, 0xF00D, 0xF00E,
+ 0xF00F, 0xF010, 0xF0F0, 0xF0F1, 0xF0F2, 0xF0F3,
+ 0xF0F4, 0xF0F5, 0xF0F6, 0xF0F7, 0xF0F8, 0xF0F9,
+ 0xF0FA, 0xF0FB, 0xF0FC, 0xF0FD, 0xF0FE, 0xF0FF,
+ 0xF100, 0xF101, 0xF102, 0xF103, 0xF104, 0xF105,
+ 0xF106, 0xF107, 0xF108, 0xF109, 0xF10A, 0xF10B,
+ 0xF10C, 0xF10D, 0xF10E, 0xF10F, 0xF110, 0xF1F0,
+ 0xF1F1, 0xF1F2, 0xF1F3, 0xF1F4, 0xF1F5, 0xF1F6,
+ 0xF1F7, 0xF1F8, 0xF1F9, 0xF1FA, 0xF1FB, 0xF1FC,
+ 0xF1FD, 0xF1FE, 0xF1FF, 0xF200, 0xF201, 0xF202,
+ 0xF203, 0xF204, 0xF205, 0xF206, 0xF207, 0xF208,
+ 0xF209, 0xF20A, 0xF20B, 0xF20C, 0xF20D, 0xF20E,
+ 0xF20F, 0xF210, 0xF2F0, 0xF2F1, 0xF2F2, 0xF2F3,
+ 0xF2F4, 0xF2F5, 0xF2F6, 0xF2F7, 0xF2F8, 0xF2F9,
+ 0xF2FA, 0xF2FB, 0xF2FC, 0xF2FD, 0xF2FE, 0xF2FF,
+ 0xF300, 0xF301, 0xF302, 0xF303, 0xF304, 0xF305,
+ 0xF306, 0xF307, 0xF308, 0xF309, 0xF30A, 0xF30B,
+ 0xF30C, 0xF30D, 0xF30E, 0xF30F, 0xF310, 0xF3F0,
+ 0xF3F1, 0xF3F2, 0xF3F3, 0xF3F4, 0xF3F5, 0xF3F6,
+ 0xF3F7, 0xF3F8, 0xF3F9, 0xF3FA, 0xF3FB, 0xF3FC,
+ 0xF3FD, 0xF3FE, 0xF3FF, 0xF400, 0xF401, 0xF402,
+ 0xF403, 0xF404, 0xF405, 0xF406, 0xF407, 0xF408,
+ 0xF409, 0xF40A, 0xF40B, 0xF40C, 0xF40D, 0xF40E,
+ 0xF40F, 0xF410, 0xF4F0, 0xF4F1, 0xF4F2, 0xF4F3,
+ 0xF4F4, 0xF4F5, 0xF4F6, 0xF4F7, 0xF4F8, 0xF4F9,
+ 0xF4FA, 0xF4FB, 0xF4FC, 0xF4FD, 0xF4FE, 0xF4FF,
+ 0xF500, 0xF501, 0xF502, 0xF503, 0xF504, 0xF505,
+ 0xF506, 0xF507, 0xF508, 0xF509, 0xF50A, 0xF50B,
+ 0xF50C, 0xF50D, 0xF50E, 0xF50F, 0xF510, 0xF5F0,
+ 0xF5F1, 0xF5F2, 0xF5F3, 0xF5F4, 0xF5F5, 0xF5F6,
+ 0xF5F7, 0xF5F8, 0xF5F9, 0xF5FA, 0xF5FB, 0xF5FC,
+ 0xF5FD, 0xF5FE, 0xF5FF, 0xF600, 0xF601, 0xF602,
+ 0xF603, 0xF604, 0xF605, 0xF606, 0xF607, 0xF608,
+ 0xF609, 0xF60A, 0xF60B, 0xF60C, 0xF60D, 0xF60E,
+ 0xF60F, 0xF610, 0xF6F0, 0xF6F1, 0xF6F2, 0xF6F3,
+ 0xF6F4, 0xF6F5, 0xF6F6, 0xF6F7, 0xF6F8, 0xF6F9,
+ 0xF6FA, 0xF6FB, 0xF6FC, 0xF6FD, 0xF6FE, 0xF6FF,
+ 0xF700, 0xF701, 0xF702, 0xF703, 0xF704, 0xF705,
+ 0xF706, 0xF707, 0xF708, 0xF709, 0xF70A, 0xF70B,
+ 0xF70C, 0xF70D, 0xF70E, 0xF70F, 0xF710, 0xF7F0,
+ 0xF7F1, 0xF7F2, 0xF7F3, 0xF7F4, 0xF7F5, 0xF7F6,
+ 0xF7F7, 0xF7F8, 0xF7F9, 0xF7FA, 0xF7FB, 0xF7FC,
+ 0xF7FD, 0xF7FE, 0xF7FF, 0xF800, 0xF801, 0xF802,
+ 0xF803, 0xF804, 0xF805, 0xF806, 0xF807, 0xF808,
+ 0xF809, 0xF80A, 0xF80B, 0xF80C, 0xF80D, 0xF80E,
+ 0xF80F, 0xF810, 0xF8F0, 0xF8F1, 0xF8F2, 0xF8F3,
+ 0xF8F4, 0xF8F5, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9,
+ 0xF8FA, 0xF8FB, 0xF8FC, 0xF8FD, 0xF8FE, 0xF8FF,
+ 0xF900, 0xF901, 0xF902, 0xF903, 0xF904, 0xF905,
+ 0xF906, 0xF907, 0xF908, 0xF909, 0xF90A, 0xF90B,
+ 0xF90C, 0xF90D, 0xF90E, 0xF90F, 0xF910, 0xF9F0,
+ 0xF9F1, 0xF9F2, 0xF9F3, 0xF9F4, 0xF9F5, 0xF9F6,
+ 0xF9F7, 0xF9F8, 0xF9F9, 0xF9FA, 0xF9FB, 0xF9FC,
+ 0xF9FD, 0xF9FE, 0xF9FF, 0xFA00, 0xFA01, 0xFA02,
+ 0xFA03, 0xFA04, 0xFA05, 0xFA06, 0xFA07, 0xFA08,
+ 0xFA09, 0xFA0A, 0xFA0B, 0xFA0C, 0xFA0D, 0xFA0E,
+ 0xFA0F, 0xFA10, 0xFAF0, 0xFAF1, 0xFAF2, 0xFAF3,
+ 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9,
+ 0xFAFA, 0xFAFB, 0xFAFC, 0xFAFD, 0xFAFE, 0xFAFF,
+ 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0xFB05,
+ 0xFB06, 0xFB07, 0xFB08, 0xFB09, 0xFB0A, 0xFB0B,
+ 0xFB0C, 0xFB0D, 0xFB0E, 0xFB0F, 0xFB10, 0xFBF0,
+ 0xFBF1, 0xFBF2, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
+ 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC,
+ 0xFBFD, 0xFBFE, 0xFBFF, 0xFC00, 0xFC01, 0xFC02,
+ 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
+ 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFC0E,
+ 0xFC0F, 0xFC10, 0xFCF0, 0xFCF1, 0xFCF2, 0xFCF3,
+ 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9,
+ 0xFCFA, 0xFCFB, 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF,
+ 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04, 0xFD05,
+ 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B,
+ 0xFD0C, 0xFD0D, 0xFD0E, 0xFD0F, 0xFD10, 0xFDF0,
+ 0xFDF1, 0xFDF2, 0xFDF3, 0xFDF4, 0xFDF5, 0xFDF6,
+ 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC,
+ 0xFDFD, 0xFDFE, 0xFDFF, 0xFE00, 0xFE01, 0xFE02,
+ 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08,
+ 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E,
+ 0xFE0F, 0xFE10, 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3,
+ 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9,
+ 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0xFEFF,
+ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05,
+ 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B,
+ 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F, 0xFF10, 0xFFF0,
+ 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6,
+ 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC,
+ 0xFFFD, 0xFFFE, 0xFFFF,
+};
+
+const uint32_t * const ff_on2avc_quad_cb_codes[] = {
+ on2avc_cb1_codes, on2avc_cb2_codes, on2avc_cb3_codes, on2avc_cb4_codes,
+ on2avc_cb5_codes, on2avc_cb6_codes, on2avc_cb7_codes, on2avc_cb8_codes
+};
+
+const uint8_t * const ff_on2avc_quad_cb_bits[] = {
+ on2avc_cb1_bits, on2avc_cb2_bits, on2avc_cb3_bits, on2avc_cb4_bits,
+ on2avc_cb5_bits, on2avc_cb6_bits, on2avc_cb7_bits, on2avc_cb8_bits
+};
+
+const uint16_t * const ff_on2avc_quad_cb_syms[] = {
+ on2avc_cb1_syms, on2avc_cb2_syms, on2avc_cb3_syms, on2avc_cb4_syms,
+ on2avc_cb5_syms, on2avc_cb6_syms, on2avc_cb7_syms, on2avc_cb8_syms
+};
+
+const int ff_on2avc_quad_cb_elems[] = {
+ ON2AVC_CB1_CODES, ON2AVC_CB2_CODES, ON2AVC_CB3_CODES, ON2AVC_CB4_CODES,
+ ON2AVC_CB5_CODES, ON2AVC_CB6_CODES, ON2AVC_CB7_CODES, ON2AVC_CB8_CODES,
+};
+
+const uint16_t * const ff_on2avc_pair_cb_codes[] = {
+ on2avc_cb9_codes, on2avc_cb10_codes, on2avc_cb11_codes, on2avc_cb12_codes,
+ on2avc_cb13_codes, on2avc_cb14_codes, on2avc_cb15_codes
+};
+
+const uint8_t * const ff_on2avc_pair_cb_bits[] = {
+ on2avc_cb9_bits, on2avc_cb10_bits, on2avc_cb11_bits, on2avc_cb12_bits,
+ on2avc_cb13_bits, on2avc_cb14_bits, on2avc_cb15_bits
+};
+
+const uint16_t * const ff_on2avc_pair_cb_syms[] = {
+ on2avc_cb9_syms, on2avc_cb10_syms, on2avc_cb11_syms, on2avc_cb12_syms,
+ on2avc_cb13_syms, on2avc_cb14_syms, on2avc_cb15_syms
+};
+
+const int ff_on2avc_pair_cb_elems[] = {
+ ON2AVC_CB9_CODES, ON2AVC_CB10_CODES, ON2AVC_CB11_CODES, ON2AVC_CB12_CODES,
+ ON2AVC_CB13_CODES, ON2AVC_CB14_CODES, ON2AVC_CB15_CODES,
+};
+
+const float ff_on2avc_window_long_32000[1024] = {
+ 0.0007669903, 0.0023009691, 0.0038349426, 0.005368907,
+ 0.0069028586, 0.0084367944, 0.0099707097, 0.011504602,
+ 0.013038467, 0.014572302, 0.016106103, 0.017639864,
+ 0.019173585, 0.020707261, 0.022240886, 0.023774462,
+ 0.025307981, 0.026841439, 0.028374836, 0.029908165,
+ 0.031441424, 0.032974608, 0.034507714, 0.036040742,
+ 0.037573684, 0.039106537, 0.040639296, 0.042171963,
+ 0.043704528, 0.04523699, 0.046769347, 0.048301592,
+ 0.049833726, 0.051365741, 0.052897636, 0.054429408,
+ 0.05596105, 0.057492562, 0.059023935, 0.060555171,
+ 0.062086266, 0.063617215, 0.065148011, 0.066678658,
+ 0.068209141, 0.069739468, 0.071269631, 0.07279963,
+ 0.074329451, 0.0758591, 0.077388577, 0.078917861,
+ 0.080446966, 0.081975877, 0.083504602, 0.085033126,
+ 0.086561449, 0.08808957, 0.089617483, 0.091145188,
+ 0.092672676, 0.094199941, 0.095726989, 0.097253814,
+ 0.098780409, 0.10030677, 0.1018329, 0.10335878,
+ 0.10488442, 0.10640982, 0.10793497, 0.10945986,
+ 0.11098449, 0.11250886, 0.11403297, 0.11555681,
+ 0.11708038, 0.11860367, 0.12012669, 0.12164942,
+ 0.12317186, 0.12469402, 0.12621588, 0.12773743,
+ 0.12925871, 0.13077965, 0.13230032, 0.13382065,
+ 0.13534068, 0.13686039, 0.13837977, 0.13989884,
+ 0.14141756, 0.14293596, 0.14445402, 0.14597175,
+ 0.14748912, 0.14900614, 0.15052283, 0.15203916,
+ 0.15355512, 0.15507074, 0.15658598, 0.15810084,
+ 0.15961535, 0.16112947, 0.16264322, 0.16415659,
+ 0.16566956, 0.16718215, 0.16869435, 0.17020614,
+ 0.17171754, 0.17322853, 0.17473911, 0.1762493,
+ 0.17775905, 0.17926839, 0.18077731, 0.1822858,
+ 0.18379387, 0.1853015, 0.18680871, 0.18831545,
+ 0.18982176, 0.19132763, 0.19283305, 0.19433801,
+ 0.19584252, 0.19734655, 0.19885014, 0.20035326,
+ 0.2018559, 0.20335805, 0.20485975, 0.20636097,
+ 0.20786168, 0.20936191, 0.21086164, 0.21236089,
+ 0.21385963, 0.21535787, 0.2168556, 0.21835282,
+ 0.21984953, 0.22134572, 0.2228414, 0.22433653,
+ 0.22583115, 0.22732525, 0.22881879, 0.2303118,
+ 0.23180428, 0.2332962, 0.23478758, 0.2362784,
+ 0.23776866, 0.23925838, 0.24074753, 0.24223609,
+ 0.24372411, 0.24521156, 0.24669841, 0.2481847,
+ 0.24967039, 0.2511555, 0.25264001, 0.25412393,
+ 0.25560725, 0.25708997, 0.25857207, 0.2600536,
+ 0.26153448, 0.26301476, 0.26449442, 0.26597348,
+ 0.26745188, 0.26892966, 0.27040681, 0.27188334,
+ 0.27335921, 0.27483445, 0.27630904, 0.27778298,
+ 0.27925625, 0.28072888, 0.28220084, 0.28367215,
+ 0.28514278, 0.28661272, 0.28808203, 0.28955063,
+ 0.29101855, 0.2924858, 0.29395235, 0.29541823,
+ 0.2968834, 0.29834786, 0.29981163, 0.30127469,
+ 0.30273703, 0.30419868, 0.30565959, 0.30711982,
+ 0.3085793, 0.31003806, 0.31149608, 0.31295338,
+ 0.31440994, 0.31586576, 0.31732082, 0.31877515,
+ 0.32022873, 0.32168156, 0.32313362, 0.32458493,
+ 0.32603547, 0.32748523, 0.32893425, 0.33038247,
+ 0.33182994, 0.3332766, 0.33472249, 0.3361676,
+ 0.33761191, 0.33905542, 0.34049815, 0.34194005,
+ 0.34338117, 0.34482148, 0.34626096, 0.34769964,
+ 0.34913751, 0.35057455, 0.35201076, 0.35344613,
+ 0.35488069, 0.35631442, 0.35774729, 0.35917932,
+ 0.36061054, 0.36204088, 0.36347035, 0.36489901,
+ 0.36632678, 0.36775371, 0.36917976, 0.37060493,
+ 0.37202924, 0.37345266, 0.37487522, 0.37629691,
+ 0.3777177, 0.37913758, 0.38055661, 0.3819747,
+ 0.38339192, 0.38480824, 0.38622364, 0.38763815,
+ 0.38905171, 0.3904644, 0.39187613, 0.39328697,
+ 0.39469689, 0.39610586, 0.3975139, 0.39892101,
+ 0.40032718, 0.40173239, 0.40313667, 0.40454,
+ 0.40594238, 0.4073438, 0.40874428, 0.41014379,
+ 0.41154233, 0.41293988, 0.4143365, 0.41573212,
+ 0.41712677, 0.41852042, 0.41991311, 0.42130479,
+ 0.42269549, 0.4240852, 0.4254739, 0.42686161,
+ 0.42824832, 0.429634, 0.43101871, 0.43240237,
+ 0.43378502, 0.43516666, 0.43654725, 0.43792683,
+ 0.43930539, 0.44068289, 0.44205937, 0.44343483,
+ 0.4448092, 0.44618255, 0.44755486, 0.44892609,
+ 0.45029628, 0.45166543, 0.45303348, 0.45440048,
+ 0.45576641, 0.45713127, 0.45849505, 0.45985776,
+ 0.4612194, 0.46257991, 0.46393937, 0.46529773,
+ 0.46665499, 0.46801114, 0.46936622, 0.47072017,
+ 0.47207302, 0.47342476, 0.4747754, 0.47612491,
+ 0.47747329, 0.47882056, 0.4801667, 0.48151168,
+ 0.48285556, 0.4841983, 0.48553991, 0.48688036,
+ 0.48821968, 0.48955783, 0.49089485, 0.49223071,
+ 0.49356541, 0.49489892, 0.49623129, 0.4975625,
+ 0.49889255, 0.50022137, 0.50154907, 0.50287557,
+ 0.50420088, 0.50552505, 0.50684798, 0.50816971,
+ 0.50949025, 0.5108096, 0.51212776, 0.51344472,
+ 0.51476043, 0.51607502, 0.51738828, 0.51870042,
+ 0.52001131, 0.52132094, 0.52262932, 0.52393657,
+ 0.52524251, 0.52654725, 0.52785075, 0.52915299,
+ 0.53045398, 0.53175372, 0.53305221, 0.53434944,
+ 0.53564548, 0.53694022, 0.53823364, 0.53952587,
+ 0.54081678, 0.54210645, 0.5433948, 0.54468191,
+ 0.54596776, 0.5472523, 0.54853553, 0.5498175,
+ 0.55109817, 0.55237752, 0.55365556, 0.55493236,
+ 0.55620778, 0.55748194, 0.5587548, 0.56002629,
+ 0.56129652, 0.56256539, 0.56383294, 0.56509918,
+ 0.56636411, 0.56762767, 0.56888992, 0.57015079,
+ 0.57141036, 0.57266855, 0.57392544, 0.57518095,
+ 0.57643509, 0.57768792, 0.57893938, 0.58018941,
+ 0.58143812, 0.58268547, 0.58393145, 0.58517605,
+ 0.58641928, 0.58766115, 0.58890164, 0.5901407,
+ 0.59137839, 0.59261465, 0.5938496, 0.59508306,
+ 0.59631521, 0.59754586, 0.59877521, 0.60000306,
+ 0.60122955, 0.6024546, 0.60367823, 0.60490048,
+ 0.60612124, 0.60734063, 0.6085586, 0.60977507,
+ 0.61099017, 0.61220378, 0.61341602, 0.61462677,
+ 0.61583608, 0.61704391, 0.61825031, 0.61945528,
+ 0.62065876, 0.6218608, 0.62306136, 0.62426049,
+ 0.62545812, 0.62665427, 0.62784898, 0.62904221,
+ 0.63023394, 0.63142419, 0.63261294, 0.63380021,
+ 0.63498598, 0.63617027, 0.63735306, 0.63853437,
+ 0.63971412, 0.64089245, 0.64206922, 0.6432445,
+ 0.64441824, 0.64559048, 0.64676118, 0.64793038,
+ 0.64909804, 0.6502642, 0.65142882, 0.65259188,
+ 0.6537534, 0.65491343, 0.6560719, 0.65722883,
+ 0.6583842, 0.65953803, 0.66069031, 0.66184098,
+ 0.66299015, 0.66413778, 0.6652838, 0.66642827,
+ 0.66757119, 0.6687125, 0.66985226, 0.67099047,
+ 0.67212707, 0.67326206, 0.6743955, 0.67552739,
+ 0.67665762, 0.67778629, 0.67891335, 0.68003887,
+ 0.68116271, 0.68228501, 0.6834057, 0.68452471,
+ 0.68564218, 0.68675804, 0.68787223, 0.68898487,
+ 0.69009584, 0.6912052, 0.6923129, 0.69341904,
+ 0.69452351, 0.69562632, 0.69672751, 0.6978271,
+ 0.69892502, 0.70002127, 0.70111591, 0.70220888,
+ 0.70330018, 0.70438987, 0.70547789, 0.70656425,
+ 0.70764893, 0.70873195, 0.7098133, 0.71089298,
+ 0.71197098, 0.71304733, 0.714122, 0.71519494,
+ 0.71626627, 0.71733588, 0.71840382, 0.71947002,
+ 0.72053456, 0.72159743, 0.72265857, 0.72371799,
+ 0.72477573, 0.72583181, 0.72688609, 0.72793871,
+ 0.7289896, 0.73003882, 0.73108631, 0.73213202,
+ 0.73317605, 0.73421836, 0.73525894, 0.73629779,
+ 0.73733491, 0.7383703, 0.7394039, 0.74043584,
+ 0.74146599, 0.7424944, 0.74352109, 0.744546,
+ 0.74556917, 0.74659055, 0.74761021, 0.74862814,
+ 0.74964422, 0.75065863, 0.7516712, 0.75268203,
+ 0.75369114, 0.7546984, 0.75570393, 0.75670767,
+ 0.75770962, 0.75870979, 0.75970817, 0.76070476,
+ 0.76169956, 0.76269257, 0.7636838, 0.76467323,
+ 0.76566082, 0.76664668, 0.7676307, 0.76861292,
+ 0.7695933, 0.77057189, 0.77154869, 0.77252364,
+ 0.77349681, 0.77446812, 0.77543765, 0.77640533,
+ 0.77737117, 0.77833521, 0.77929735, 0.78025776,
+ 0.78121626, 0.78217292, 0.78312778, 0.7840808,
+ 0.78503191, 0.78598124, 0.78692871, 0.78787434,
+ 0.78881806, 0.78975999, 0.79070002, 0.7916382,
+ 0.79257452, 0.79350895, 0.79444152, 0.79537225,
+ 0.79630107, 0.79722804, 0.79815316, 0.79907638,
+ 0.79999769, 0.80091715, 0.8018347, 0.80275041,
+ 0.80366421, 0.8045761, 0.80548608, 0.80639422,
+ 0.80730045, 0.80820471, 0.80910712, 0.81000763,
+ 0.81090623, 0.81180298, 0.81269777, 0.81359059,
+ 0.81448156, 0.81537062, 0.81625772, 0.8171429,
+ 0.81802619, 0.81890756, 0.81978697, 0.82066447,
+ 0.82154006, 0.82241368, 0.8232854, 0.82415515,
+ 0.825023, 0.82588887, 0.82675278, 0.82761478,
+ 0.82847482, 0.82933295, 0.83018905, 0.83104324,
+ 0.83189547, 0.83274573, 0.83359408, 0.83444041,
+ 0.83528483, 0.83612722, 0.83696771, 0.83780622,
+ 0.83864272, 0.83947724, 0.84030986, 0.84114045,
+ 0.84196901, 0.84279567, 0.8436203, 0.84444296,
+ 0.84526366, 0.84608233, 0.84689903, 0.84771377,
+ 0.84852648, 0.84933716, 0.85014588, 0.85095257,
+ 0.85175729, 0.85255998, 0.85336071, 0.85415941,
+ 0.85495609, 0.85575074, 0.85654342, 0.85733408,
+ 0.85812265, 0.85890925, 0.85969388, 0.86047643,
+ 0.86125696, 0.86203545, 0.86281192, 0.86358637,
+ 0.86435878, 0.86512917, 0.86589754, 0.86666387,
+ 0.86742812, 0.86819035, 0.86895055, 0.86970872,
+ 0.8704648, 0.8712188, 0.87197083, 0.87272078,
+ 0.8734687, 0.87421453, 0.87495828, 0.8757,
+ 0.87643969, 0.8771773, 0.87791282, 0.87864625,
+ 0.87937766, 0.88010699, 0.88083428, 0.88155943,
+ 0.88228256, 0.88300359, 0.88372254, 0.88443947,
+ 0.88515425, 0.88586694, 0.88657761, 0.88728613,
+ 0.88799256, 0.88869697, 0.88939923, 0.89009941,
+ 0.8907975, 0.8914935, 0.89218742, 0.89287919,
+ 0.89356887, 0.89425647, 0.89494199, 0.89562535,
+ 0.89630663, 0.89698577, 0.89766282, 0.89833778,
+ 0.8990106, 0.89968133, 0.90034992, 0.90101641,
+ 0.90168077, 0.90234298, 0.9030031, 0.90366107,
+ 0.90431696, 0.90497071, 0.9056223, 0.90627176,
+ 0.90691912, 0.90756428, 0.90820736, 0.90884835,
+ 0.90948713, 0.91012377, 0.91075826, 0.91139066,
+ 0.91202086, 0.91264898, 0.91327488, 0.91389865,
+ 0.91452032, 0.91513979, 0.91575712, 0.9163723,
+ 0.91698527, 0.91759616, 0.91820484, 0.91881138,
+ 0.91941577, 0.92001796, 0.92061806, 0.92121589,
+ 0.92181164, 0.92240518, 0.92299652, 0.92358577,
+ 0.92417276, 0.92475766, 0.92534029, 0.92592078,
+ 0.92649913, 0.92707527, 0.92764926, 0.92822099,
+ 0.92879063, 0.92935801, 0.92992324, 0.93048626,
+ 0.93104708, 0.93160576, 0.93216223, 0.93271649,
+ 0.93326855, 0.93381846, 0.93436611, 0.93491161,
+ 0.93545485, 0.93599594, 0.93653482, 0.9370715,
+ 0.93760598, 0.93813825, 0.93866825, 0.93919611,
+ 0.93972176, 0.94024521, 0.94076639, 0.94128537,
+ 0.9418022, 0.94231677, 0.94282907, 0.94333923,
+ 0.94384712, 0.94435281, 0.94485629, 0.94535756,
+ 0.94585657, 0.94635338, 0.94684792, 0.94734025,
+ 0.94783038, 0.94831824, 0.9488039, 0.9492873,
+ 0.94976848, 0.95024747, 0.95072412, 0.95119864,
+ 0.95167089, 0.95214087, 0.95260859, 0.9530741,
+ 0.9535374, 0.95399845, 0.95445722, 0.95491374,
+ 0.95536804, 0.95582008, 0.95626986, 0.95671743,
+ 0.95716268, 0.95760572, 0.9580465, 0.95848507,
+ 0.95892131, 0.95935535, 0.95978713, 0.96021664,
+ 0.96064389, 0.96106887, 0.96149158, 0.96191204,
+ 0.96233022, 0.96274614, 0.9631598, 0.96357119,
+ 0.96398038, 0.96438724, 0.96479183, 0.96519411,
+ 0.96559417, 0.96599197, 0.96638745, 0.96678072,
+ 0.96717167, 0.96756035, 0.96794677, 0.96833086,
+ 0.96871275, 0.96909231, 0.96946961, 0.96984458,
+ 0.97021735, 0.97058779, 0.97095597, 0.97132182,
+ 0.97168541, 0.97204667, 0.97240573, 0.97276247,
+ 0.97311687, 0.97346902, 0.9738189, 0.97416645,
+ 0.97451174, 0.97485471, 0.97519541, 0.97553378,
+ 0.97586989, 0.97620368, 0.9765352, 0.9768644,
+ 0.97719133, 0.97751594, 0.97783822, 0.97815824,
+ 0.97847593, 0.97879136, 0.97910446, 0.97941524,
+ 0.97972369, 0.98002988, 0.98033381, 0.98063534,
+ 0.98093462, 0.98123157, 0.98152626, 0.98181856,
+ 0.98210859, 0.9823963, 0.98268169, 0.98296481,
+ 0.98324561, 0.98352402, 0.98380023, 0.98407406,
+ 0.98434556, 0.98461479, 0.98488164, 0.98514622,
+ 0.98540848, 0.98566842, 0.98592603, 0.98618132,
+ 0.98643428, 0.98668498, 0.98693329, 0.98717928,
+ 0.98742294, 0.98766434, 0.98790336, 0.98814011,
+ 0.98837447, 0.98860651, 0.98883629, 0.98906368,
+ 0.98928875, 0.98951149, 0.98973197, 0.98995006,
+ 0.99016583, 0.99037921, 0.99059033, 0.99079913,
+ 0.9910056, 0.99120969, 0.99141145, 0.99161088,
+ 0.991808, 0.99200279, 0.99219525, 0.99238533,
+ 0.99257314, 0.99275857, 0.99294168, 0.99312246,
+ 0.99330086, 0.99347699, 0.99365073, 0.99382216,
+ 0.9939912, 0.99415797, 0.99432236, 0.99448442,
+ 0.99464417, 0.99480152, 0.99495655, 0.99510926,
+ 0.99525958, 0.99540764, 0.99555331, 0.9956966,
+ 0.99583763, 0.99597627, 0.99611259, 0.99624652,
+ 0.99637812, 0.99650741, 0.9966343, 0.99675888,
+ 0.99688113, 0.99700099, 0.99711853, 0.99723375,
+ 0.99734658, 0.99745709, 0.99756527, 0.99767107,
+ 0.99777448, 0.99787563, 0.9979744, 0.99807078,
+ 0.99816483, 0.99825656, 0.99834591, 0.99843293,
+ 0.99851763, 0.99859995, 0.99867994, 0.99875754,
+ 0.99883282, 0.99890572, 0.99897629, 0.99904448,
+ 0.99911034, 0.99917388, 0.99923503, 0.99929386,
+ 0.99935031, 0.99940443, 0.99945617, 0.99950558,
+ 0.99955267, 0.99959737, 0.99963969, 0.99967968,
+ 0.99971735, 0.99975264, 0.9997856, 0.99981618,
+ 0.99984443, 0.9998703, 0.99989384, 0.999915,
+ 0.99993384, 0.99995029, 0.99996442, 0.99997616,
+ 0.99998558, 0.99999267, 0.99999738, 0.9999997,
+};
+
+const float ff_on2avc_window_long_24000[1024] = {
+ 0.00000102, 0.0000091700003, 0.000025470001, 0.00004993,
+ 0.000082530001, 0.00012328, 0.00017219, 0.00022924,
+ 0.00029443001, 0.00036778001, 0.00044927001, 0.00053890003,
+ 0.00063666998, 0.00074257998, 0.00085662998, 0.00097881001,
+ 0.00110913, 0.00124758, 0.00139415, 0.00154885,
+ 0.00171168, 0.00188262, 0.00206168, 0.00224885,
+ 0.0024441299, 0.00264751, 0.0028589999, 0.0030785799,
+ 0.0033062601, 0.00354202, 0.00378588, 0.00403781,
+ 0.0042978101, 0.0045658899, 0.0048420299, 0.0051262402,
+ 0.0054184902, 0.0057187998, 0.00602715, 0.0063435398,
+ 0.00666796, 0.00700041, 0.0073408699, 0.0076893498,
+ 0.0080458401, 0.0084103197, 0.0087828003, 0.0091632698,
+ 0.0095517104, 0.0099481298, 0.01035251, 0.01076485,
+ 0.01118513, 0.01161336, 0.01204952, 0.0124936,
+ 0.0129456, 0.01340551, 0.01387332, 0.01434902,
+ 0.0148326, 0.01532405, 0.015823361, 0.016330531,
+ 0.01684555, 0.017368389, 0.01789907, 0.018437561,
+ 0.01898385, 0.019537929, 0.020099809, 0.020669449,
+ 0.02124686, 0.021832019, 0.02242492, 0.02302555,
+ 0.023633899, 0.02424995, 0.024873709, 0.02550514,
+ 0.026144249, 0.026791019, 0.02744543, 0.02810749,
+ 0.02877716, 0.029454449, 0.030139331, 0.030831801,
+ 0.031531841, 0.032239441, 0.032954589, 0.033677269,
+ 0.03440747, 0.035145171, 0.035890371, 0.036643039,
+ 0.03740317, 0.038170759, 0.038945779, 0.039728221,
+ 0.040518072, 0.041315299, 0.04211992, 0.042931888,
+ 0.04375121, 0.044577859, 0.045411821, 0.046253089,
+ 0.047101639, 0.04795745, 0.048820522, 0.04969082,
+ 0.05056835, 0.051453069, 0.052344982, 0.053244069,
+ 0.054150298, 0.055063669, 0.055984162, 0.056911752,
+ 0.057846431, 0.058788169, 0.059736971, 0.060692791,
+ 0.061655629, 0.062625468, 0.063602284, 0.064586058,
+ 0.065576769, 0.06657441, 0.067578949, 0.06859038,
+ 0.069608673, 0.070633821, 0.071665794, 0.072704569,
+ 0.073750138, 0.074802481, 0.075861573, 0.076927401,
+ 0.077999942, 0.079079159, 0.080165058, 0.081257619,
+ 0.082356803, 0.083462588, 0.084574983, 0.085693933,
+ 0.086819433, 0.087951459, 0.089089997, 0.090235017,
+ 0.091386512, 0.092544436, 0.093708791, 0.094879538,
+ 0.09605667, 0.097240157, 0.098429978, 0.099626116,
+ 0.10082854, 0.10203723, 0.10325217, 0.10447333,
+ 0.1057007, 0.10693424, 0.10817393, 0.10941976,
+ 0.1106717, 0.11192972, 0.1131938, 0.11446393,
+ 0.11574007, 0.1170222, 0.1183103, 0.11960435,
+ 0.12090432, 0.12221018, 0.12352192, 0.12483951,
+ 0.12616292, 0.12749213, 0.12882711, 0.13016786,
+ 0.13151433, 0.13286649, 0.13422433, 0.13558783,
+ 0.13695695, 0.13833167, 0.13971195, 0.1410978,
+ 0.14248917, 0.14388604, 0.14528839, 0.1466962,
+ 0.14810941, 0.14952803, 0.150952, 0.15238133,
+ 0.15381598, 0.15525591, 0.15670112, 0.15815157,
+ 0.15960722, 0.16106807, 0.16253406, 0.16400519,
+ 0.16548143, 0.16696274, 0.1684491, 0.1699405,
+ 0.17143688, 0.17293824, 0.17444454, 0.17595574,
+ 0.17747185, 0.17899281, 0.1805186, 0.1820492,
+ 0.18358457, 0.18512468, 0.18666951, 0.18821906,
+ 0.18977325, 0.19133207, 0.19289552, 0.19446352,
+ 0.19603609, 0.19761316, 0.19919474, 0.20078079,
+ 0.20237127, 0.20396616, 0.20556541, 0.20716903,
+ 0.20877695, 0.21038917, 0.21200565, 0.21362637,
+ 0.21525128, 0.21688037, 0.21851361, 0.22015095,
+ 0.22179238, 0.22343788, 0.22508739, 0.2267409,
+ 0.22839837, 0.23005977, 0.2317251, 0.23339429,
+ 0.23506732, 0.2367442, 0.23842482, 0.24010922,
+ 0.24179734, 0.24348916, 0.24518465, 0.24688376,
+ 0.24858648, 0.25029278, 0.2520026, 0.25371596,
+ 0.25543278, 0.25715306, 0.25887677, 0.26060385,
+ 0.26233432, 0.26406807, 0.26580516, 0.26754549,
+ 0.26928905, 0.27103582, 0.27278578, 0.27453887,
+ 0.27629507, 0.27805433, 0.27981666, 0.281582,
+ 0.28335032, 0.28512162, 0.28689581, 0.28867289,
+ 0.29045284, 0.29223564, 0.29402119, 0.29580954,
+ 0.2976006, 0.29939437, 0.30119082, 0.3029899,
+ 0.30479157, 0.30659583, 0.30840263, 0.31021196,
+ 0.31202373, 0.31383798, 0.31565461, 0.31747365,
+ 0.31929505, 0.32111874, 0.32294473, 0.32477298,
+ 0.32660347, 0.32843611, 0.33027095, 0.33210787,
+ 0.33394691, 0.33578804, 0.33763117, 0.33947629,
+ 0.34132338, 0.34317243, 0.34502336, 0.34687617,
+ 0.3487308, 0.35058725, 0.35244548, 0.35430545,
+ 0.35616711, 0.35803047, 0.35989544, 0.36176205,
+ 0.36363024, 0.36549997, 0.36737123, 0.36924395,
+ 0.37111813, 0.37299374, 0.37487072, 0.37674904,
+ 0.3786287, 0.38050967, 0.38239187, 0.38427529,
+ 0.38615993, 0.3880457, 0.3899326, 0.39182061,
+ 0.39370969, 0.39559978, 0.39749089, 0.39938298,
+ 0.40127596, 0.40316987, 0.40506464, 0.40696028,
+ 0.40885669, 0.41075388, 0.41265181, 0.41455048,
+ 0.41644979, 0.41834977, 0.42025036, 0.42215151,
+ 0.42405322, 0.42595547, 0.42785817, 0.42976135,
+ 0.43166494, 0.43356892, 0.43547326, 0.43737793,
+ 0.43928292, 0.44118813, 0.4430936, 0.44499925,
+ 0.44690508, 0.44881102, 0.45071709, 0.45262322,
+ 0.4545294, 0.45643559, 0.45834175, 0.46024784,
+ 0.46215388, 0.46405977, 0.46596554, 0.46787113,
+ 0.46977648, 0.47168162, 0.47358647, 0.47549102,
+ 0.47739524, 0.4792991, 0.48120254, 0.48310557,
+ 0.48500812, 0.48691019, 0.48881173, 0.49071273,
+ 0.49261314, 0.49451295, 0.4964121, 0.4983106,
+ 0.50020838, 0.50210541, 0.50400168, 0.50589716,
+ 0.50779182, 0.50968558, 0.5115785, 0.51347047,
+ 0.51536149, 0.51725155, 0.5191406, 0.52102858,
+ 0.52291554, 0.52480137, 0.52668607, 0.52856964,
+ 0.53045195, 0.53233314, 0.53421301, 0.53609163,
+ 0.53796893, 0.53984493, 0.54171956, 0.54359275,
+ 0.54546458, 0.54733491, 0.54920375, 0.55107111,
+ 0.55293691, 0.55480117, 0.55666381, 0.55852479,
+ 0.56038415, 0.56224185, 0.56409782, 0.565952,
+ 0.56780452, 0.56965512, 0.571504, 0.57335097,
+ 0.57519609, 0.57703924, 0.57888049, 0.58071983,
+ 0.58255708, 0.58439237, 0.58622563, 0.58805674,
+ 0.58988583, 0.59171271, 0.59353751, 0.5953601,
+ 0.59718043, 0.59899855, 0.60081446, 0.60262799,
+ 0.60443926, 0.6062482, 0.6080547, 0.60985887,
+ 0.6116606, 0.61345983, 0.61525661, 0.61705089,
+ 0.61884266, 0.62063187, 0.62241846, 0.62420249,
+ 0.62598389, 0.62776262, 0.62953866, 0.63131201,
+ 0.63308257, 0.63485044, 0.63661551, 0.63837773,
+ 0.6401372, 0.64189374, 0.64364743, 0.6453982,
+ 0.64714605, 0.64889091, 0.65063286, 0.6523717,
+ 0.65410763, 0.65584046, 0.65757018, 0.65929681,
+ 0.6610204, 0.66274077, 0.66445798, 0.66617203,
+ 0.6678828, 0.66959041, 0.67129469, 0.67299575,
+ 0.67469347, 0.67638785, 0.67807889, 0.67976654,
+ 0.68145084, 0.68313169, 0.68480909, 0.68648309,
+ 0.68815356, 0.68982053, 0.69148397, 0.69314384,
+ 0.6948002, 0.69645292, 0.69810206, 0.69974756,
+ 0.70138937, 0.70302755, 0.70466202, 0.70629281,
+ 0.70791984, 0.70954311, 0.71116263, 0.71277833,
+ 0.71439022, 0.71599829, 0.71760249, 0.71920282,
+ 0.72079927, 0.72239184, 0.72398043, 0.72556508,
+ 0.72714579, 0.72872251, 0.73029518, 0.73186392,
+ 0.73342854, 0.73498911, 0.73654562, 0.73809808,
+ 0.73964638, 0.74119055, 0.74273056, 0.74426645,
+ 0.74579811, 0.74732566, 0.74884892, 0.75036794,
+ 0.75188273, 0.75339329, 0.75489956, 0.75640148,
+ 0.75789917, 0.75939244, 0.76088142, 0.76236606,
+ 0.76384634, 0.76532215, 0.76679361, 0.76826066,
+ 0.76972324, 0.77118134, 0.77263504, 0.77408427,
+ 0.77552897, 0.77696913, 0.77840483, 0.779836,
+ 0.78126258, 0.78268462, 0.78410208, 0.78551495,
+ 0.78692323, 0.78832692, 0.7897259, 0.79112029,
+ 0.79251003, 0.79389513, 0.79527551, 0.79665124,
+ 0.79802221, 0.79938853, 0.80075008, 0.80210692,
+ 0.80345899, 0.80480635, 0.80614889, 0.80748665,
+ 0.80881965, 0.81014782, 0.81147122, 0.8127898,
+ 0.81410348, 0.8154124, 0.81671643, 0.81801558,
+ 0.81930989, 0.82059932, 0.8218838, 0.82316345,
+ 0.82443815, 0.82570797, 0.82697284, 0.82823282,
+ 0.8294878, 0.83073789, 0.83198297, 0.8332231,
+ 0.83445829, 0.83568847, 0.8369137, 0.83813387,
+ 0.83934909, 0.8405593, 0.84176451, 0.84296465,
+ 0.84415978, 0.84534991, 0.84653497, 0.84771496,
+ 0.84888995, 0.85005987, 0.85122472, 0.85238451,
+ 0.85353923, 0.85468888, 0.85583341, 0.85697287,
+ 0.85810727, 0.85923654, 0.86036074, 0.86147982,
+ 0.86259383, 0.86370265, 0.86480641, 0.86590505,
+ 0.86699861, 0.86808699, 0.86917025, 0.87024838,
+ 0.87132144, 0.87238932, 0.87345207, 0.87450963,
+ 0.87556213, 0.87660944, 0.87765163, 0.87868869,
+ 0.87972057, 0.88074732, 0.88176894, 0.88278538,
+ 0.88379669, 0.88480288, 0.88580388, 0.88679975,
+ 0.88779044, 0.88877606, 0.88975644, 0.89073175,
+ 0.89170188, 0.89266688, 0.89362669, 0.89458138,
+ 0.89553094, 0.89647537, 0.89741462, 0.89834881,
+ 0.89927781, 0.90020168, 0.90112042, 0.90203404,
+ 0.90294254, 0.90384591, 0.90474415, 0.90563726,
+ 0.90652531, 0.90740818, 0.90828604, 0.90915871,
+ 0.91002631, 0.91088885, 0.91174626, 0.91259861,
+ 0.91344583, 0.91428804, 0.91512513, 0.91595721,
+ 0.91678417, 0.91760612, 0.918423, 0.91923481,
+ 0.92004162, 0.92084336, 0.92164016, 0.92243183,
+ 0.92321855, 0.92400026, 0.92477697, 0.92554867,
+ 0.92631537, 0.92707711, 0.92783386, 0.92858565,
+ 0.92933249, 0.93007439, 0.93081135, 0.93154335,
+ 0.93227047, 0.93299264, 0.93370992, 0.93442225,
+ 0.93512976, 0.93583232, 0.93653005, 0.93722296,
+ 0.93791091, 0.9385941, 0.9392724, 0.93994594,
+ 0.94061458, 0.94127852, 0.94193757, 0.94259191,
+ 0.94324142, 0.94388616, 0.9445262, 0.94516146,
+ 0.94579202, 0.94641781, 0.94703895, 0.94765538,
+ 0.9482671, 0.94887418, 0.94947654, 0.95007432,
+ 0.95066744, 0.95125592, 0.9518398, 0.95241904,
+ 0.95299375, 0.95356387, 0.95412946, 0.95469046,
+ 0.95524693, 0.95579892, 0.95634633, 0.95688927,
+ 0.9574278, 0.9579618, 0.95849133, 0.95901644,
+ 0.95953715, 0.96005344, 0.96056533, 0.96107286,
+ 0.96157598, 0.96207482, 0.96256924, 0.96305943,
+ 0.9635452, 0.96402675, 0.96450406, 0.96497703,
+ 0.96544582, 0.96591038, 0.9663707, 0.9668268,
+ 0.96727878, 0.96772653, 0.96817023, 0.96860969,
+ 0.9690451, 0.9694764, 0.96990365, 0.97032678,
+ 0.97074586, 0.97116095, 0.97157204, 0.97197908,
+ 0.97238219, 0.9727813, 0.97317648, 0.97356778,
+ 0.97395509, 0.97433859, 0.97471815, 0.9750939,
+ 0.97546583, 0.97583389, 0.9761982, 0.97655869,
+ 0.97691542, 0.97726846, 0.97761768, 0.97796327,
+ 0.97830516, 0.97864336, 0.97897792, 0.97930884,
+ 0.97963619, 0.97995991, 0.9802801, 0.98059666,
+ 0.98090976, 0.98121929, 0.98152536, 0.98182797,
+ 0.98212707, 0.98242277, 0.98271501, 0.98300391,
+ 0.98328942, 0.98357159, 0.98385036, 0.98412585,
+ 0.98439807, 0.984667, 0.98493266, 0.9851951,
+ 0.98545432, 0.98571032, 0.98596323, 0.98621291,
+ 0.98645949, 0.98670292, 0.9869433, 0.98718059,
+ 0.98741484, 0.98764604, 0.98787427, 0.98809952,
+ 0.98832178, 0.98854107, 0.98875749, 0.98897099,
+ 0.98918158, 0.98938936, 0.98959428, 0.98979634,
+ 0.98999566, 0.99019217, 0.99038595, 0.99057698,
+ 0.99076533, 0.99095094, 0.99113393, 0.99131429,
+ 0.99149197, 0.99166709, 0.99183959, 0.99200952,
+ 0.99217695, 0.99234182, 0.99250424, 0.99266416,
+ 0.99282163, 0.99297667, 0.99312931, 0.99327952,
+ 0.9934274, 0.99357295, 0.99371612, 0.99385703,
+ 0.99399561, 0.99413198, 0.99426609, 0.994398,
+ 0.9945277, 0.99465519, 0.9947806, 0.9949038,
+ 0.99502492, 0.99514401, 0.99526095, 0.99537587,
+ 0.99548876, 0.99559963, 0.99570858, 0.99581552,
+ 0.99592048, 0.9960236, 0.99612474, 0.99622405,
+ 0.9963215, 0.99641711, 0.99651092, 0.99660289,
+ 0.99669313, 0.99678159, 0.99686831, 0.99695337,
+ 0.9970367, 0.99711835, 0.99719834, 0.99727672,
+ 0.99735349, 0.99742872, 0.99750233, 0.99757439,
+ 0.9976449, 0.99771392, 0.99778146, 0.99784756,
+ 0.99791217, 0.99797535, 0.9980371, 0.99809748,
+ 0.99815649, 0.99821413, 0.99827045, 0.99832547,
+ 0.99837923, 0.99843168, 0.99848282, 0.99853277,
+ 0.99858153, 0.99862903, 0.99867541, 0.99872059,
+ 0.99876463, 0.99880755, 0.99884939, 0.9988901,
+ 0.99892974, 0.99896836, 0.99900591, 0.99904245,
+ 0.99907798, 0.99911255, 0.99914616, 0.99917883,
+ 0.99921054, 0.99924135, 0.99927121, 0.99930024,
+ 0.99932843, 0.99935573, 0.9993822, 0.99940789,
+ 0.99943274, 0.99945682, 0.99948019, 0.99950278,
+ 0.99952459, 0.99954569, 0.99956614, 0.99958587,
+ 0.99960488, 0.9996233, 0.99964106, 0.99965817,
+ 0.99967468, 0.99969059, 0.99970591, 0.99972069,
+ 0.99973488, 0.99974853, 0.99976164, 0.99977428,
+ 0.99978638, 0.999798, 0.99980915, 0.99981982,
+ 0.99983001, 0.99983978, 0.99984914, 0.99985808,
+ 0.99986666, 0.99987477, 0.99988258, 0.99988997,
+ 0.99989706, 0.99990374, 0.99991012, 0.9999162,
+ 0.99992198, 0.9999274, 0.99993259, 0.99993742,
+ 0.99994206, 0.99994642, 0.99995053, 0.9999544,
+ 0.99995804, 0.99996144, 0.99996465, 0.99996763,
+ 0.99997044, 0.99997306, 0.9999755, 0.99997777,
+ 0.99997985, 0.99998182, 0.99998367, 0.99998534,
+ 0.99998689, 0.99998826, 0.99998957, 0.99999076,
+ 0.99999183, 0.99999285, 0.99999374, 0.99999452,
+ 0.99999523, 0.99999589, 0.99999648, 0.99999702,
+ 0.9999975, 0.99999785, 0.99999821, 0.99999857,
+ 0.99999881, 0.99999905, 0.99999923, 0.9999994,
+ 0.99999952, 0.99999964, 0.9999997, 0.99999982,
+ 0.99999982, 0.99999988, 0.99999994, 0.99999994,
+ 0.99999994, 1.0, 1.0, 1.0,
+ 1.0, 1.0, 1.0, 1.0,
+};
+
+const float ff_on2avc_window_short[128] = {
+ 1.320684e-12, 1.3218859e-12, 1.324119e-12, 1.3269172e-12,
+ 1.3297907e-12, 1.3316993e-12, 1.3321618e-12, 1.3303409e-12,
+ 1.3297163e-12, 1.3598052e-12, 1.6224489e-12, 3.238457e-12,
+ 1.1376874e-11, 4.6434454e-11, 1.80557e-10, 6.4489758e-10,
+ 2.1179569e-9, 6.4429635e-9, 1.8292885e-8, 4.880043e-8,
+ 1.2303467e-7, 2.946195e-7, 6.729764e-7, 0.0000014718792,
+ 0.0000030924566, 0.0000062596109, 0.000012238012, 0.000023162085,
+ 0.000042523086, 0.000075864329, 0.00013174133, 0.00022300506,
+ 0.00036846122, 0.00059494411, 0.00093981833, 0.001453883,
+ 0.0022046037, 0.0032795328, 0.004789711, 0.0068727732,
+ 0.0096954042, 0.01345476, 0.018378416, 0.02472244,
+ 0.032767218, 0.042810757, 0.055159383, 0.070115872,
+ 0.087965287, 0.10895917, 0.1332987, 0.16111787,
+ 0.19246797, 0.22730421, 0.26547599, 0.30672187,
+ 0.35066974, 0.39684334, 0.44467437, 0.49352086,
+ 0.54269004, 0.59146535, 0.6391356, 0.68502444,
+ 0.72851861, 0.76909274, 0.80632913, 0.83993185,
+ 0.8697328, 0.89569116, 0.91788524, 0.93649811,
+ 0.95179814, 0.96411639, 0.97382277, 0.9813022,
+ 0.98693413, 0.99107492, 0.9940452, 0.99612254,
+ 0.99753785, 0.99847656, 0.99908221, 0.99946207,
+ 0.99969339, 0.99983019, 0.99990857, 0.99995208,
+ 0.9999755, 0.99998766, 0.9999938, 0.99999678,
+ 0.99999821, 0.99999893, 0.99999923, 0.99999946,
+ 0.99999958, 0.9999997, 0.99999982, 0.99999994,
+ 1.0000001, 1.0000002, 1.0000004, 1.0000005,
+ 1.0000006, 1.0000008, 1.000001, 1.000001,
+ 1.0000011, 1.0000012, 1.0000013, 1.0000014,
+ 1.0000014, 1.0000015, 1.0000015, 1.0000015,
+ 1.0000015, 1.0000014, 1.0000014, 1.0000014,
+ 1.0000013, 1.0000013, 1.0000012, 1.0000012,
+ 1.0000011, 1.0000011, 1.0000011, 1.0000011,
+};
+
+const double ff_on2avc_tab_10_1[] = {
+ 0.0033357253, -0.012580752, -0.0062414902, 0.077571494, -0.03224487,
+ -0.24229489, 0.13842815, 0.72430853, 0.60382927, 0.1601024
+};
+
+const double ff_on2avc_tab_10_2[] = {
+ -0.1601024, 0.60382927, -0.72430853, 0.13842815, 0.24229489,
+ -0.03224487, -0.077571494, -0.0062414902, 0.012580752, 0.0033357253,
+ 0.33266699, 0.80689015, 0.45988244, -0.13500994, -0.085442654,
+ 0.035226542, -0.035226543, -0.085442656, 0.13500994, 0.45988246,
+ -0.80689017, 0.332667
+};
+
+const double ff_on2avc_tab_20_1[] = {
+ -0.0014416961, -0.00056214974, 0.020948911, 0.025363335, -0.10427845,
+ -0.2318503, 0.06892613, 0.63810513, 0.6843251, 0.20162185,
+ -0.033582, 0.07313663, 0.08143964, -0.0063137698, -0.012688661,
+ 0.0089685127, 0.0035534843, -0.0016078273, -0.000095677464, 0.0002453756
+};
+
+const double ff_on2avc_tab_20_2[] = {
+ -0.0002453755997325089, -0.00009567746389569924, 0.001607827298247261,
+ 0.003553484296126244, -0.008968512690223166, -0.01268866098616772,
+ 0.006313769793117177, 0.08143963991122029, -0.07313662992027165,
+ -0.03358199996339129, -0.2016218497802062, 0.6843250992539974,
+ -0.6381051293043832, 0.06892612992486163, 0.2318502997472533,
+ -0.1042784498863231, -0.0253633349723507, 0.02094891097716299,
+ 0.0005621497393871844, -0.001441696098428365
+};
+
+const double ff_on2avc_tab_40_1[] = {
+ -0.0000017445457, -0.000001814441, 0.000038676008, 0.000045716169,
+ -0.00041789492, -0.00062315149, 0.0027052457, 0.0053753308,
+ -0.010572396, -0.030726394, 0.01871785, 0.11585315,
+ 0.03958068, -0.25000242, -0.29886274, 0.18287176,
+ 0.65781885, 0.548686, 0.17696839, 0.08330372,
+ 0.14234582, 0.064187778, -0.03396015, -0.013302871,
+ 0.020618859, 0.0018984093, -0.010561246, -0.00010918036,
+ 0.0035190253, -0.00057674024, -0.0010263441, 0.00030131618,
+ 0.00022613687, -0.000089637969, -0.000032248444, 0.00001882641,
+ 0.0000029119687, -0.0000023940844, -1.3944369e-7, 1.3407205e-7,
+};
+
+const double ff_on2avc_tab_40_2[] = {
+ -1.340720502155867e-7, -1.394436902242243e-7, 0.000002394084403849667,
+ 0.000002911968704682421, -0.00001882641003027271, -0.00003224844405185522,
+ 0.00008963796914413709, 0.0002261368703636262, -0.0003013161804845139,
+ -0.001026344101650353, 0.0005767402409273933, 0.003519025305658563,
+ 0.0001091803601755611, -0.01056124601698239, -0.001898409303052626,
+ 0.02061885903315495, 0.0133028710213909, -0.03396015005460763,
+ -0.0641877781032134, 0.1423458202288909, -0.08330372013395167,
+ 0.1769683902845637, -0.5486860008822824, 0.6578188510577671,
+ -0.1828717602940562, -0.2988627404805687, 0.2500024204020018,
+ 0.03958068006364539, -0.1158531501862909, 0.01871785003009814,
+ 0.03072639404940778, -0.01057239601700032, -0.005375330808643486,
+ 0.002705245704350012, 0.0006231514910020222, -0.0004178949206719714,
+ -0.00004571616907351121, 0.00003867600806219069, 0.000001814441002917606,
+ -0.000001744545702805214
+};
+
+const double ff_on2avc_tab_84_1[] = {
+ -0.003834605569340214, -0.01399666493880675, -0.02423522354202532,
+ -0.02098660725909453, -0.003033811991149968, 0.02580968794845409,
+ 0.05022200106698627, 0.05480106279059652, 0.0370527194554745,
+ 0.01293943431893363, 0.012874098608023, 0.06242007669752228,
+ 0.1711674720067008, 0.3168985339332503, 0.4463224645440312,
+ 0.4997307843290636, 0.442680199327905, 0.2862974432523162,
+ 0.08192922995482327, -0.100687848630388, -0.2010749890073668,
+ -0.1970564705797125, -0.1136363541357198, -0.006482554176098804,
+ 0.06983853153253429, 0.08958734697447382, 0.0598384364842016,
+ 0.009627953684538691, -0.02776530291935209, -0.03485384358824609,
+ -0.01638430987962629, 0.01132787970877885, 0.02744697607433038,
+ 0.02280082564277705, 0.003817601656862559, -0.01536124106173835,
+ -0.02070943469222549, -0.01286651718416282, 0.0005632574484435138,
+ 0.007577496599690143, 0.01014022979594007, 0.006400316454349855,
+ -0.001317309067039239, -0.00317940336781777, -0.002405842901164466,
+ -0.001661745856529503, -0.00005380161101133026, 0.0009898316472595594,
+ 0.0007039765787268925, -0.000189661703240109, -0.0001182674960570266,
+ 0.0002115051270037225, -0.00008565649434604059, -0.0001252806220197323,
+ 0.0001500012974557671, 0.00002957208561445737, -0.000118882457357092,
+ -0.000007421996284144832, 0.00004351015061547388, -0.000005737099377545248,
+ -0.0000164747057254053, 0.00001923482660002518, -0.00001093031593938137,
+ -0.00001002792095051621, 0.00001250573423880376, 0.000004127061570609871,
+ -0.000003458244341720683, -0.000003058993334597815, 0.000002160520943418329,
+ 8.907414904197164e-7, -0.000001316252923085336, 3.681255415998394e-7,
+ 6.245867533258108e-7, -1.129925213069921e-7, 3.315839446922364e-7,
+ -1.356572071896963e-7, -4.318309977365961e-7, -1.367503553365523e-7,
+ 4.470828965968303e-8, 9.212902857354196e-8, 3.695547755036224e-8,
+ 1.505766197979149e-8, -6.958994047152974e-9, -8.758631202056997e-9
+};
+
+const double ff_on2avc_tab_84_2[] = {
+ 0.002715349650922232, -0.01033050750152524, -0.01528172942791371,
+ 0.005838722508994047, 0.01599086024371182, -0.01737535183522147,
+ -0.01418596452135431, 0.05969677252151454, 0.07139735966046348,
+ -0.06379927990205171, -0.1516174471801191, 0.008365792873769096,
+ 0.1866714915958021, 0.04432405351099893, -0.2179875184285703,
+ -0.1089585577690529, 0.2761321070772847, 0.294949416655377,
+ -0.1811068533291373, -0.4710662031299601, -0.1397679263799359,
+ 0.3386633432956985, 0.3588950861292916, 0.03198338392910033,
+ -0.1801130026394404, -0.178622266226761, -0.1270863570294224,
+ -0.0332786110926095, 0.1326619748641741, 0.2077421015185226,
+ 0.07027624884033033, -0.1065486044522993, -0.125884731750194,
+ -0.0399897264540468, 0.003687144241560403, 0.01609004681595481,
+ 0.04950212493135606, 0.05748681524682781, 0.004041844771574074,
+ -0.04142122345639772, -0.02559310071302269, 0.002755316641486144,
+ 0.003184997421951853, -0.005531116810971506, 0.008338191103621911,
+ 0.01252616152446114, -0.003312308536298372, -0.007161498814519848,
+ 0.001337745209122465, 0.002343332617933073, -0.001621098790238126,
+ -0.00129682569402033, 0.001491028268251773, 0.0003044153446278188,
+ -0.0007048834926788463, 0.00004445131250124058, 0.0003635790848622476,
+ -0.000143533732887211, -0.00002972390773997905, 0.0001176094971737509,
+ -0.00006171908908217019, -0.0001084231902960109, 0.00007896973444840752,
+ 0.0000499995995843891, -0.00006444906759864038, -0.000018321011061942,
+ 0.00001482481130354497, 0.00001058934262851235, -0.000004798424433342611,
+ -4.761276869473942e-7, 0.00000188617755070578, -0.000001674634418015107,
+ -1.53944330645465e-7, 9.240123633592371e-7, -0.000001235630235014779,
+ 4.925891606823236e-8, 0.000001206615355189743, 3.647623817617871e-7,
+ -1.087267533862797e-7, -2.529052443169693e-7, -1.1961026302477e-7,
+ -4.873569574324943e-8, 2.252351108799612e-8, 2.834822470870021e-8
+};
+
+const double ff_on2avc_tab_84_3[] = {
+ -0.00434676231664159, 0.006714123005267953, 0.008698054407437532,
+ -0.01370846523601941, 0.01012828941725749, -0.007068078935658625,
+ -0.008138346009558437, 0.0467353028783406, -0.0658381497176358,
+ 0.01310067828595943, 0.07269279617480232, -0.1069564909021104,
+ 0.06762691282426264, 0.01034035065310993, -0.1175699606097785,
+ 0.192812157569135, -0.1084409432849384, -0.1353394082449725,
+ 0.290587999391769, -0.1665935202779336, -0.09927986222827791,
+ 0.2394316349364771, -0.196937680294991, 0.04675035632757467,
+ 0.160737603124711, -0.2866953475517299, 0.11533530450257,
+ 0.2313808347485174, -0.285955205900817, -0.07033046899644142,
+ 0.3010809341153604, -0.03711556319204814, -0.2854261021892172,
+ 0.1326266190726841, 0.2334442000696142, -0.2160410554670428,
+ -0.122575309612308, 0.2186808995859664, 0.02544075501374961,
+ -0.1660358993667236, 0.02009196196614523, 0.1162583994153812,
+ -0.03991958608138682, -0.07115975637749203, 0.04270444046513863,
+ 0.03536651879157764, -0.02655940136961219, -0.0166541988800009,
+ 0.01811758653663791, 0.003161066879299114, -0.006590249135122636,
+ 0.0000224660373347443, 0.002764837297017082, -0.001816050098089884,
+ 0.000221385824782758, 0.001325129169916481, -0.0009313048485056467,
+ -0.001002997644614651, 0.0006461390960813223, 0.0005091843808757102,
+ -0.0004981831027749185, -0.0002132118318370338, 0.0001692041329121999,
+ 0.00009203280989519006, -0.0000726634301061485, -0.000003776173954180476,
+ 0.000005650286559057409, 1.015871235188678e-8, 0.000009297695668468626,
+ 0.000008217172691037263, -0.000005352793597674221, -0.000004293043830914206,
+ 0.00000406840557498943, 0.000001957539844881767, -0.000001357985014138161,
+ -7.970430363552399e-7, 5.338776009119553e-7, 1.022190984936616e-7,
+ 7.153181993493103e-9, -9.647767193713991e-8, -1.087063157245304e-7,
+ -4.429283737485961e-8, 2.047021589652069e-8, 2.576393519656189e-8
+};
+
+const double ff_on2avc_tab_84_4[] = {
+ -0.0008804814258974317, 0.001677984795861344, 0.0019438229200474,
+ -0.002374701634816941, 0.002842769830143803, -0.00313020546738317,
+ -0.002246992394582708, 0.01055408593972395, -0.01218520382203817,
+ -0.0006735617784857061, 0.02057268271156303, -0.03472338199007904,
+ 0.02960799007316684, -0.003269335988224603, -0.02972969305167542,
+ 0.05008512160999294, -0.04400487480883553, 0.01713790123047206,
+ 0.001794796985095048, 0.02465108569696885, -0.1185046238791295,
+ 0.2661533909042693, -0.4170434096290337, 0.5056971209966197,
+ -0.4839205146480338, 0.348475120088803, -0.1457287020663733,
+ -0.04963861239550338, 0.1710032440522816, -0.1892135762829684,
+ 0.1231345995813251, -0.02389080306388811, -0.054785057318703,
+ 0.08416222204781872, -0.0666027804409105, 0.02377207113744183,
+ 0.01203829040820619, -0.02516530033022068, 0.01840432198285431,
+ -0.006286010406016099, -0.004035603243854861, 0.006949156667744018,
+ -0.00161215048516293, -0.001828701991824727, 0.0009090589499595256,
+ 0.0009761363135882747, -0.002142429121283414, 0.0004188485015062717,
+ 0.001809279129203381, -0.000932687525032396, -0.0009486028487922317,
+ 0.0009397940062201393, 0.000281183371137153, -0.0009248586848561844,
+ 0.0002152615409451283, 0.0005477801444594987, -0.0002659748756010768,
+ -0.0002773742035095173, 0.0002260622852620992, 0.0001512792970069076,
+ -0.0001768728566277711, -0.00002986876958461399, 0.00005130565743733275,
+ 0.000004374757277468806, -0.00002195539036180244, 0.000002913282980087422,
+ 3.818084416943484e-7, -0.000006288075796943977, 0.000006984829418122699,
+ 0.00000614694006919441, -0.000005946919055089292, -0.000001264733599421358,
+ 0.000004339214975250828, 0.000001188830031229202, -2.565690994853701e-7,
+ -8.929058735983076e-7, -5.618418560386023e-7, -2.216635610199557e-7,
+ 9.901798023372271e-8, 1.312667895662033e-7, 6.845290101279972e-9,
+ 2.7891417275888e-9, -1.289019550645086e-9, -1.62236765541716e-9
+};
+
+static const double tabs_4_10[4 * 2][10] = {
+ { 0.92756648, 0.17727433, -0.31028851, -0.041293536, 0.099339873,
+ -0.0079929986, -0.016111206, 0.004271808, 0.0, 0.0 },
+ { 0.0, 0.0, 0.16008016, 0.60374538, 0.7244924,
+ 0.13948189, -0.24189853, -0.03548063, 0.075736174, 0.0034171261 },
+ { 0.0, 0.0, -2.0495447e-10, -7.6501622e-10, 0.15922493,
+ 0.60051988, 0.72580564, 0.15828764, -0.23272256, -0.089524832 },
+ { 0.0, 0.0, 1.7673448e-10, 6.4163071e-10, 0.000032608112,
+ 0.00012297965, 0.15178394, 0.57192786, 0.73750254, 0.32549984 },
+ { 0.32549984, -0.73750254, 0.57192786, -0.15178394, 0.00012297965,
+ -0.000032608112, 6.4163071e-10, -1.7673448e-10, 0.0, 0.0 },
+ { -0.089524832, 0.23272256, 0.15828764, -0.72580564, 0.60051988,
+ -0.15922493, -7.6501621e-10, 2.0495446e-10, 0.0, 0.0 },
+ { 0.0034171261, -0.075736174, -0.03548063, 0.24189853, 0.13948189,
+ -0.7244924, 0.60374538, -0.16008016, 0.0, 0.0 },
+ { 0.0, 0.0, 0.004271808, 0.016111206, -0.0079929986,
+ -0.099339873, -0.041293536, 0.31028851, 0.17727433, -0.92756648 }
+};
+
+const double * const ff_on2avc_tabs_4_10_1[4] = {
+ tabs_4_10[0], tabs_4_10[1], tabs_4_10[2], tabs_4_10[3]
+};
+
+const double * const ff_on2avc_tabs_4_10_2[4] = {
+ tabs_4_10[4], tabs_4_10[5], tabs_4_10[6], tabs_4_10[7]
+};
+
+static const double tabs_9_20[9 * 2][20] = {
+ { 0.20265566, 0.6892313, 0.64164786, 0.066309055, -0.23597194,
+ -0.10432145, 0.027402007, 0.02147583, -0.0011571443, -0.0016923795,
+ 0.00010941944, 0.000063155164, -0.000012061176, -0.0000094681391, 6.8164837e-7,
+ 8.0672986e-7, -1.2001096e-8, -3.0778157e-8, 0.0, 0.0, },
+ { 0.07340142, -0.033796895, 0.20223772, 0.68677248, 0.64011737,
+ 0.068365159, -0.23333401, -0.10451285, 0.025911516, 0.021156819,
+ -0.00066987817, -0.0015032608, 0.000010536012, 0.000009012748, -4.0880101e-7,
+ -6.3486186e-7, 5.2718557e-9, 1.3520266e-8, 0.0, 0.0, },
+ { -0.0063151262, 0.081450872, 0.073146431, -0.033591262, 0.20164331,
+ 0.68441526, 0.63817515, 0.068893633, -0.23191782, -0.10429366,
+ 0.025382739, 0.020958119, -0.0005645414, -0.0014434993, 1.2043506e-7,
+ 1.5836305e-7, -1.9186041e-9, -4.9204755e-9, 0.0, 0.0, },
+ { 0.0089685824, -0.012688761, -0.0063138246, 0.081440272, 0.073137193,
+ -0.033582316, 0.20162334, 0.68433035, 0.63810986, 0.068926154,
+ -0.23185254, -0.1042793, 0.025363699, 0.020949148, -0.00056217266,
+ -0.0014417225, 4.1287276e-10, 1.0588585e-9, 0.0, 0.0, },
+ { -0.0016078274, 0.0035534844, 0.008968513, -0.012688661, -0.00631377,
+ 0.081439643, 0.073136632, -0.033582001, 0.20162186, 0.68432512,
+ 0.63810515, 0.068926132, -0.23185031, -0.10427845, 0.025363336,
+ 0.020948912, -0.00056214976, -0.0014416961, 0.0, 0.0, },
+ { 0.0, 0.0, 0.00024537589, -0.000095677578, -0.0016078292,
+ 0.0035534886, 0.0089685234, -0.012688676, -0.0063137774, 0.081439737,
+ 0.073136717, -0.03358204, 0.20162209, 0.68432592, 0.63810589,
+ 0.068926212, -0.23185058, -0.10427857, 0.025363365, 0.020948936, },
+ { 0.0, 0.0, -1.091532e-8, 4.2561286e-9, 0.00024558029,
+ -0.000095887463, -0.0016090989, 0.0035559773, 0.0089736609, -0.01269917,
+ -0.0063204498, 0.081485332, 0.073167353, -0.033630667, 0.20170289,
+ 0.68469343, 0.63846175, 0.068968176, -0.23197726, -0.10433598, },
+ { 0.0, 0.0, 7.1344765e-8, -2.7818928e-8, -0.000002528456,
+ 0.0000018368197, 0.00026997937, -0.00013252441, -0.001740633, 0.0038067121,
+ 0.0093531772, -0.013821566, -0.0070879361, 0.084739015, 0.074159694,
+ -0.040471924, 0.20317226, 0.70739793, 0.66214244, 0.072193371, },
+ { 0.0, 0.0, -1.7745724e-7, 6.919457e-8, 0.0000079212679,
+ -0.0000052051852, -0.00011186159, 0.00013087209, 0.0010011907, -0.0014292895,
+ -0.0047484872, 0.010485041, 0.016207683, -0.039758642, -0.022104737,
+ 0.14309317, 0.071659816, -0.21620638, 0.12174763, 0.95412469, },
+ { 0.96811974, -0.066460839, -0.18990589, -0.12699724, 0.074900229,
+ 0.019365102, -0.0094028752, -0.0073225687, 0.0024846173, 0.001133314,
+ -0.000066782094, -0.00017127018, -5.1701849e-12, -2.6883967e-12, 8.4434004e-13,
+ 4.5714433e-13, -2.0336233e-14, -4.8142821e-14, 0.0, 0.0, },
+ { 0.070051015, -0.67622735, 0.69971496, -0.18987268, -0.023601022,
+ -0.073694534, 0.076964926, 0.0049448517, -0.011660957, -0.0084153664,
+ 0.003416879, 0.0015114204, -0.000092440393, -0.00023707381, -7.8278594e-12,
+ -3.4041849e-12, 2.1213123e-13, 5.424444e-13, 0.0, 0.0, },
+ { -0.10400446, 0.23379783, 0.070139677, -0.63985915, 0.68278382,
+ -0.20175657, -0.032740047, -0.072931763, 0.08122816, 0.006212184,
+ -0.012650812, -0.0089459474, 0.0035507517, 0.0016049328, -0.000095625024,
+ -0.00024524111, -5.4947649e-15, -1.3849329e-14, 0.0, 0.0, },
+ { 0.020927727, -0.025453371, -0.10434942, 0.23188113, 0.068987354,
+ -0.63810296, 0.68429767, -0.20162896, -0.033573142, -0.073133229,
+ 0.081437918, 0.006312788, -0.012688459, -0.00896836, 0.0035534757,
+ 0.0016078143, -0.000095677348, -0.0002453753, 0.0, 0.0, },
+ { 0.0, 0.0, -0.001441696, 0.00056214971, 0.020948908,
+ -0.025363333, -0.10427841, 0.23185026, 0.068925853, -0.63810466,
+ 0.68432625, -0.20162446, -0.033584819, -0.073127012, 0.081444767,
+ 0.0062889982, -0.012692356, -0.008907458, 0.0035730328, 0.001494756, },
+ { 0.0, 0.0, -8.891553e-14, 3.465479e-14, -0.0014416744,
+ 0.00056214128, 0.020948423, -0.025362886, -0.10427345, 0.23184342,
+ 0.06889794, -0.63805105, 0.68441106, -0.20186695, -0.033718945,
+ -0.072480772, 0.081576567, 0.0047896878, -0.012951761, -0.0055205304, },
+ { 0.0, 0.0, 3.1384661e-12, -1.2236911e-12, -4.5712737e-11,
+ 5.5252991e-11, -0.0014413395, 0.00056201026, 0.020940121, -0.025355656,
+ -0.10419478, 0.23172734, 0.068557589, -0.63726677, 0.68504332,
+ -0.20430545, -0.034154654, -0.067051635, 0.082518833, -0.0074921348, },
+ { 0.0, 0.0, 2.1591083e-13, -8.4449036e-14, 1.2247511e-13,
+ 2.5428931e-12, -3.0481069e-11, 2.2021003e-11, -0.0014310921, 0.00055801468,
+ 0.020774997, -0.025169051, -0.10308717, 0.22974304, 0.064648504,
+ -0.62768798, 0.69288569, -0.23617203, -0.037952156, 0.0066274123, },
+ { 0.0, 0.0, 6.0226175e-14, -2.3096046e-14, -7.8692048e-13,
+ 1.0072813e-12, 5.1344469e-12, -8.9372637e-12, -3.4167908e-11, 5.4327109e-11,
+ -0.0014266369, 0.00055627748, 0.020644778, -0.025065139, -0.10169917,
+ 0.22783, 0.058894795, -0.61350902, 0.69559873, -0.27013783, }
+};
+
+const double* const ff_on2avc_tabs_9_20_1[9] = {
+ tabs_9_20[0], tabs_9_20[1], tabs_9_20[2], tabs_9_20[3], tabs_9_20[4],
+ tabs_9_20[5], tabs_9_20[6], tabs_9_20[7], tabs_9_20[8]
+};
+
+const double* const ff_on2avc_tabs_9_20_2[9] = {
+ tabs_9_20[ 9], tabs_9_20[10], tabs_9_20[11], tabs_9_20[12], tabs_9_20[13],
+ tabs_9_20[14], tabs_9_20[15], tabs_9_20[16], tabs_9_20[17]
+};
+
+static const double tabs_19_40[19 * 2][40] = {
+ { 0.56930638, 0.68416675, 0.20290636, -0.29270057, -0.25598083, 0.030953821, 0.11394564, 0.022880839,
+ -0.028207704, -0.012215512, 0.003721839, 0.003276676, 0.00026276625, -0.00056233677, -0.00035737156, 0.000045825146,
+ 0.00015152336, 0.000014158357, -0.000048183036, -0.000010022261, 0.000012417808, 0.0000037410435, -0.0000026072561, -0.000001014039,
+ 4.4228357e-7, 2.1030097e-7, -5.993645000000001e-8, -3.3779106e-8, 6.3845155e-9, 4.1681669e-9, -5.2093484e-10, -3.8565026e-10,
+ 3.1069535e-11, 2.5581578e-11, -1.2377426e-12, -1.114565e-12, 2.5948758e-14, 2.4949169e-14, 0.0, 0.0, },
+ { 0.083936735, 0.17821863, 0.5557409800000001, 0.66602779, 0.18178906, -0.30696561, -0.25275335, 0.044259687,
+ 0.11887063, 0.016608155, -0.032850108, -0.009887007200000001, 0.0065059949, 0.0025768587, -0.001107713, -0.00043230142,
+ 0.00021702341, 0.00006287448900000001, -0.000052147048, -0.000013629236, 0.000012262655, 0.0000039527411, -0.0000024594151, -9.9628076e-7,
+ 4.0201906e-7, 1.9618194e-7, -5.2873852e-8, -3.0291222e-8, 5.4982857e-9, 3.6241851e-9, -4.4014692e-10, -3.274108e-10,
+ 2.5877833e-11, 2.1342274e-11, -1.021061e-12, -9.1957797e-13, 2.1361163e-14, 2.0538295e-14, 0.0, 0.0, },
+ { 0.06426235399999999, 0.14252447, 0.08331282299999999, 0.17697664, 0.54915213, 0.65833374, 0.18253037, -0.29973661,
+ -0.2501844, 0.040186639, 0.1162191, 0.01848039, -0.030986232, -0.010520451, 0.0054986371, 0.0027059342,
+ -0.00066811525, -0.00042405191, 0.000058970897, 0.000041824657, -0.0000050297476, -0.0000027888321, 6.4141372e-7, 2.6119558e-7,
+ -1.0436111e-7, -5.1153743e-8, 1.3625299e-8, 7.8592626e-9, -1.3937291e-9, -9.315507e-10, 1.0721353e-10, 8.1948407e-11,
+ -5.7676714e-12, -4.9562407e-12, 1.8554768e-13, 1.7299401e-13, -1.8580814e-15, -1.786505e-15, 0.0, 0.0, },
+ { -0.013307048, -0.033975901, 0.06420919899999999, 0.14239611, 0.083308942, 0.17697702, 0.54882206, 0.65796781,
+ 0.18278485, -0.29910579, -0.25007544, 0.039720818, 0.11595345, 0.018673713, -0.030787294, -0.010566866,
+ 0.0054007477, 0.002707498, -0.0006312670199999999, -0.00041960532, 0.000047781271, 0.000039310002, -0.0000022421464, -0.0000019114661,
+ 7.288871400000001e-8, 3.3940173e-8, -1.0341206e-8, -5.5262517e-9, 1.2264303e-9, 7.3318115e-10, -1.205231e-10, -7.999549799999999e-11,
+ 9.360987e-12, 7.031617e-12, -5.2275601e-13, -4.536133e-13, 1.6843252e-14, 1.6194422e-14, 0.0, 0.0, },
+ { 0.0018985257, 0.020620645, -0.013303786, -0.033963287, 0.064192393, 0.14235646, 0.08330606, 0.176973,
+ 0.5487176499999999, 0.65785432, 0.1828607, -0.29890778, -0.25001974, 0.039603104, 0.11587197, 0.018712544,
+ -0.030736214, -0.010572356, 0.0053789802, 0.002705838, -0.00062416865, -0.00041818516, 0.000045935153, 0.000038762853,
+ -0.0000018498967, -0.0000017627229, 4.1333815e-9, 2.700156e-9, -3.0391538e-10, -2.6291895e-10, 7.6542367e-12, 1.2019785e-11,
+ 9.0469833e-13, 5.0485213e-13, -1.0391267e-13, -9.305248e-14, 2.356875e-15, 2.2660843e-15, 0.0, 0.0, },
+ { -0.0001091778, -0.010561339, 0.0018984228, 0.020619062, -0.013302974, -0.033960505, 0.064188298, 0.14234701,
+ 0.08330394300000001, 0.17696883, 0.54868941, 0.6578225599999999, 0.18287011, -0.29886826, -0.25000476, 0.039583069,
+ 0.11585553, 0.018717708, -0.030727247, -0.010572428, 0.0053756484, 0.0027053082, -0.0006232358500000001, -0.00041792434,
+ 0.000045731688, 0.000038685285, -0.0000018149671, -0.0000017460375, -5.167502e-10, 9.390694299999999e-12, 1.594319e-10, 5.8184529e-11,
+ -2.4161347e-11, -1.4454629e-11, 2.1037566e-12, 1.7321615e-12, -9.986456699999999e-14, -9.6017617e-14, 0.0, 0.0, },
+ { -0.0005767410599999999, 0.0035190291, -0.00010917955, -0.010561258, 0.0018984108, 0.020618888, -0.013302882, -0.033960202,
+ 0.064187838, 0.14234596, 0.083303668, 0.17696827, 0.54868618, 0.65781893, 0.18287097, -0.298864,
+ -0.25000294, 0.039581151, 0.11585376, 0.018718064, -0.03072639, -0.010572378, 0.0053753363, 0.0027052073,
+ -0.00062317825, -0.00041788417, 0.000045733074, 0.000038677454, -0.0000018196051, -0.0000017460967, 9.887897300000001e-10, 4.6848142e-10,
+ -1.2195123e-10, -7.9561868e-11, 9.378916700000001e-12, 7.8791268e-12, -3.9130514e-13, -3.7623141e-13, 0.0, 0.0, },
+ { 0.00030131631, -0.0010263444, -0.00057674065, 0.0035190268, -0.00010917966, -0.010561251, 0.0018984097, 0.020618873,
+ -0.013302874, -0.033960176, 0.064187798, 0.14234586, 0.083303637, 0.17696821, 0.54868588, 0.65781858,
+ 0.182871, -0.29886366, -0.25000278, 0.039580995, 0.11585361, 0.018718039, -0.03072645, -0.010572511,
+ 0.0053752804, 0.0027052669, -0.00062312096, -0.00041789128, 0.000045707579, 0.000038673143, -0.0000018129216, -0.0000017437794,
+ -1.7501699e-10, -1.1843802e-10, 1.2678547e-11, 1.0773126e-11, -4.8703456e-13, -4.6827318e-13, 0.0, 0.0, },
+ { -0.000089637995, 0.00022613691, 0.0003013163, -0.0010263444, -0.00057674064, 0.0035190267, -0.00010917963, -0.010561251,
+ 0.0018984096, 0.020618873, -0.013302874, -0.033960176, 0.06418779600000001, 0.14234586, 0.083303635, 0.1769682,
+ 0.54868587, 0.65781858, 0.18287099, -0.29886369, -0.2500028, 0.039580943, 0.11585345, 0.018717863,
+ -0.030726497, -0.010572431, 0.005375347, 0.002705256, -0.00062315197, -0.00041789626, 0.000045715815, 0.000038675974,
+ -0.0000018143635, -0.0000017445048, -7.806062e-12, -6.3155567e-12, 4.0893858e-13, 3.9318559e-13, 0.0, 0.0, },
+ { 0.000018826413, -0.000032248448, -0.000089637995, 0.00022613691, 0.0003013163, -0.0010263444, -0.00057674066, 0.0035190267,
+ -0.00010917957, -0.010561251, 0.0018984095, 0.020618874, -0.013302874, -0.033960178, 0.06418779600000001, 0.14234587,
+ 0.083303632, 0.17696819, 0.54868589, 0.65781861, 0.18287101, -0.29886365, -0.25000267, 0.039581091,
+ 0.11585349, 0.018717796, -0.030726553, -0.010572422, 0.0053753731, 0.0027052603, -0.00062315889, -0.00041789864,
+ 0.000045717027, 0.000038676583, -0.0000018145039, -0.0000017445989, 2.4971934e-12, 2.4009973e-12, 0.0, 0.0, },
+ { -0.0000023940844, 0.0000029119687, 0.00001882641, -0.000032248444, -0.000089637969, 0.00022613687, 0.00030131618, -0.0010263441,
+ -0.00057674024, 0.0035190253, -0.00010918036, -0.010561246, 0.0018984093, 0.020618859, -0.013302871, -0.03396015,
+ 0.064187778, 0.14234582, 0.08330372, 0.17696839, 0.548686, 0.65781885, 0.18287176, -0.29886274,
+ -0.25000242, 0.03958068, 0.11585315, 0.01871785, -0.030726394, -0.010572396, 0.0053753308, 0.0027052457,
+ -0.00062315149, -0.00041789492, 0.000045716169, 0.000038676008, -0.000001814441, -0.0000017445457, 0.0, 0.0, },
+ { 0.0, 0.0, 1.3407205e-7, -1.3944369e-7, -0.0000023940844, 0.0000029119687, 0.00001882641, -0.000032248444,
+ -0.000089637969, 0.00022613687, 0.00030131618, -0.0010263441, -0.00057674024, 0.0035190253, -0.00010918036, -0.010561246,
+ 0.0018984093, 0.020618859, -0.013302871, -0.03396015, 0.064187778, 0.14234582, 0.08330372, 0.17696839,
+ 0.548686, 0.65781885, 0.18287176, -0.29886274, -0.25000242, 0.03958068, 0.11585315, 0.01871785,
+ -0.030726394, -0.010572396, 0.0053753308, 0.0027052457, -0.00062315149, -0.00041789492, 0.000045716169, 0.000038676008, },
+ { 0.0, 0.0, -1.8454182e-13, 1.9193555e-13, 1.3407535e-7, -1.394477e-7, -0.0000023941103, 0.0000029120131,
+ 0.000018826533, -0.000032248755, -0.000089638384, 0.00022613828, 0.00030131697, -0.0010263489, -0.00057674009, 0.0035190398,
+ -0.00010918297, -0.010561274, 0.0018984276, 0.020618906, -0.013302959, -0.033960346, 0.06418766400000001, 0.14234558,
+ 0.08330296500000001, 0.17696749, 0.54868575, 0.65781926, 0.1828721, -0.2988628, -0.25000258, 0.039580654,
+ 0.11585319, 0.018717865, -0.030726402, -0.0105724, 0.0053753317, 0.0027052463, -0.00062315156, -0.00041789497, },
+ { 0.0, 0.0, -2.9968756e-14, 3.1169464e-14, 3.4461485e-13, -4.5274253e-13, 1.3407128e-7, -1.3944066e-7,
+ -0.0000023940918, 0.0000029119648, 0.000018826475, -0.000032248545, -0.000089638294, 0.00022613761, 0.00030131711, -0.001026347,
+ -0.00057674067, 0.0035190367, -0.00010918012, -0.010561271, 0.0018984144, 0.020618881, -0.013302985, -0.033960402,
+ 0.06418755499999999, 0.14234546, 0.083302923, 0.17696757, 0.54868595, 0.65781945, 0.18287214, -0.29886289,
+ -0.25000265, 0.039580667, 0.11585323, 0.01871787, -0.03072641, -0.010572403, 0.0053753332, 0.0027052471, },
+ { 0.0, 0.0, 3.4053947e-14, -3.541833e-14, -5.9108424e-13, 7.219441e-13, 3.686965e-12, -6.9987332e-12,
+ 1.3406826e-7, -1.3941009e-7, -0.0000023941744, 0.0000029119806, 0.000018827177, -0.000032249608, -0.000089641497, 0.00022614485,
+ 0.00030132559, -0.0010263798, -0.00057675334, 0.0035191463, -0.00010917896, -0.01056153, 0.001898552, 0.020619502,
+ -0.013303345, -0.033961425, 0.06418858299999999, 0.1423474, 0.083301974, 0.17696773, 0.54869501, 0.65783272,
+ 0.18287661, -0.29886847, -0.2500077, 0.039581297, 0.11585546, 0.018718257, -0.030726991, -0.010572606, },
+ { 0.0, 0.0, 3.8851186e-14, -4.0407771e-14, -9.0297499e-13, 1.0614292e-12, 1.2369841e-11, -1.7194763e-11,
+ -1.3889432e-10, 2.127443e-10, 1.3529716e-7, -1.415165e-7, -0.000002401917, 0.0000029279859, 0.000018862624, -0.000032344139,
+ -0.00008976013300000001, 0.00022657145, 0.00030158676, -0.0010279007, -0.00057694943, 0.0035236425, -0.00011001072, -0.010572116,
+ 0.0019036557, 0.020640207, -0.013321797, -0.034004076, 0.064218883, 0.14240437, 0.083244411, 0.17692659,
+ 0.54894337, 0.65823916, 0.1830245, -0.29903361, -0.250163, 0.039598328, 0.11592277, 0.018730262, },
+ { 0.0, 0.0, -2.5424375e-14, 2.6443011e-14, 1.3072139e-12, -1.4396059e-12, -2.9838328e-11, 3.6121355e-11,
+ 4.2808479e-10, -5.8577848e-10, -4.3953309e-9, 6.8915491e-9, 1.6727789e-7, -2.00599e-7, -0.0000025787194, 0.0000033304637,
+ 0.000019584144, -0.000034476114, -0.00009189714, 0.00023541633, 0.00030555578, -0.0010574794, -0.000577822, 0.0036058258,
+ -0.00013178926, -0.010757609, 0.0020075294, 0.020999334, -0.013644546, -0.03471548, 0.0647074, 0.14319792,
+ 0.081890324, 0.17546099, 0.55189921, 0.66398787, 0.18532974, -0.30125552, -0.25236809, 0.039796138, },
+ { 0.0, 0.0, 5.450404e-14, -5.6687762e-14, -2.413723e-12, 2.68197e-12, 5.4122889e-11, -6.597469100000001e-11,
+ -7.9689529e-10, 1.0842539e-9, 8.4827594e-9, -1.309149e-8, -6.848642999999999e-8, 1.2194237e-7, 5.5864479e-7, -0.0000010344816,
+ -0.0000044039463, 0.0000081482122, 0.000025993389, -0.000056794375, -0.0001079834, 0.00031887419, 0.00032752081, -0.0013147952,
+ -0.00055367277, 0.0042710356, -0.00037367267, -0.01217995, 0.0029410132, 0.023714229, -0.016091617, -0.03973309,
+ 0.068419296, 0.14835553, 0.070059102, 0.15950508, 0.56354819, 0.6963379, 0.20020752, -0.31277075, },
+ { 0.0, 0.0, 2.0986643e-14, -2.1827479e-14, -6.2317928e-13, 7.1419835e-13, 4.9978335e-12, -7.9628623e-12,
+ 6.4574499e-11, -3.0391734e-11, -2.093182e-9, 2.2676782e-9, 2.7596774e-8, -3.8208137e-8, -2.3879395e-7, 4.0380176e-7,
+ 0.0000016333254, -0.0000032376466, -0.0000094150001, 0.000021168371, 0.000043315086, -0.00011711363, -0.0001502271, 0.0005427171400000001,
+ 0.00038159158, -0.0019974544, -0.0004777833, 0.0060120078, -0.0010436508, -0.015880165, 0.0054219755, 0.030749996,
+ -0.022330626, -0.052220715, 0.07871199800000001, 0.16235935, 0.039966293, 0.11703729, 0.58925396, 0.77487668, },
+ { 0.76082901, -0.61501045, 0.070732318, -0.076233884, 0.16721565, -0.04604786, -0.038872216, 0.0073908504,
+ 0.018642214, -0.00059960166, -0.009041801, 0.000017181816, 0.0029672586, 0.0004791856, -0.00087051626, -0.0002528999,
+ 0.00019443347, 0.00007609031299999999, -0.000028013417, -0.000016226544, 0.0000025515355, 0.0000020939308, -1.2352758e-7, -1.1871399e-7,
+ 3.7653573e-11, -5.1553467e-12, -1.2189794e-11, -1.0694795e-12, 4.391544e-12, 1.0258575e-12, -1.1546382e-12, -3.8647265e-13,
+ 1.8127896e-13, 1.0023162e-13, -1.7537934e-14, -1.43414e-14, 8.6649097e-16, 8.3311729e-16, 0.0, 0.0, },
+ { -0.29020148, -0.17058579, 0.73009051, -0.54522599, 0.15148724, -0.089863731, 0.14246903, -0.057880136,
+ -0.032908729, 0.011933145, 0.019248716, -0.001642844, -0.009891541, 0.00011758938, 0.0032933357, 0.00053302425,
+ -0.00096384007, -0.00028170914, 0.00021364396, 0.000084221396, -0.000030604054, -0.000017803479, 0.0000027741657, 0.0000022790848,
+ -1.3343692e-7, -1.2837358e-7, -2.8291166e-11, -4.5113932e-12, 9.653859800000001e-12, 2.5188373e-12, -1.9411097e-12, -8.4860379e-13,
+ 2.4055653e-13, 1.6608885e-13, -1.7834093e-14, -1.5689603e-14, 5.0113872e-16, 4.818492e-16, 0.0, 0.0, },
+ { 0.029507585, 0.23915664, -0.31374537, -0.19147782, 0.66761054, -0.54476742, 0.17718214, -0.085893937,
+ 0.14081423, -0.0629847, -0.033056336, 0.013055001, 0.020096625, -0.0018682292, -0.010351996, 0.00012827752,
+ 0.0034538681, 0.00056125575, -0.0010101514, -0.00029566086, 0.00022323168, 0.00008825740999999999, -0.000031896814, -0.000018596176,
+ 0.0000028845736, 0.0000023710501, -1.3832474e-7, -1.3304067e-7, -1.7294869e-11, -2.81197e-12, 6.3974866e-12, 1.5855057e-12,
+ -1.1972211e-12, -5.6338465e-13, 1.3134602e-13, 1.0379039e-13, -7.732033400000001e-15, -7.434189599999999e-15, 0.0, 0.0, },
+ { 0.02137026, -0.11253601, 0.042589994, 0.25148145, -0.29992597, -0.18470705, 0.65790258, -0.54797686,
+ 0.17746938, -0.083682167, 0.14200727, -0.064059583, -0.033780176, 0.013281042, 0.020536256, -0.0019008618,
+ -0.010532156, 0.00011385908, 0.0035109303, 0.00057440761, -0.0010245672, -0.0003006148, 0.00022585476, 0.00008948980099999999,
+ -0.000032218587, -0.000018804752, 0.0000029102318, 0.0000023922344, -1.3952226e-7, -1.3403637e-7, 3.9608302e-11, 1.3905461e-11,
+ -6.1363765e-12, -3.3840174e-12, 5.9012281e-13, 4.7995226e-13, -3.0052643e-14, -2.8894955e-14, 0.0, 0.0, },
+ { -0.01101232, 0.030164564, 0.018237721, -0.11605179, 0.039730974, 0.25027003, -0.29882164, -0.18303474,
+ 0.65775001, -0.54862086, 0.17703165, -0.083330352, 0.1423101, -0.064180839, -0.033943639, 0.013302586,
+ 0.020612508, -0.0018991492, -0.010559265, 0.00010961366, 0.003518543, 0.00057658118, -0.0010262483, -0.00030127666,
+ 0.00022612153, 0.000089630847, -0.000032246277, -0.000018825371, 0.0000029116033, 0.0000023939368, -1.3937709e-7, -1.3404451e-7,
+ -9.1223008e-12, -5.4094957e-12, 8.1321806e-13, 6.7296866e-13, -3.7437071e-14, -3.5994924e-14, 0.0, 0.0, },
+ { 0.0027523866, -0.0053151929, -0.010522001, 0.030746051, 0.018701664, -0.11588024, 0.039576589, 0.25001961,
+ -0.29885452, -0.18288052, 0.65781266, -0.54868261, 0.1769717, -0.08330388900000001, 0.14234344, -0.064187437,
+ -0.03395959, 0.013303046, 0.020618614, -0.0018984637, -0.010561198, 0.00010920031, 0.0035190207, 0.00057673481,
+ -0.0010263442, -0.00030131581, 0.00022613719, 0.000089638071, -0.000032248498, -0.000018826446, 0.0000029119606, 0.0000023940888,
+ -1.3944039e-7, -1.3407106e-7, -4.6440655e-13, -3.5507487e-13, 3.1428853e-14, 3.0218153e-14, 0.0, 0.0, },
+ { -0.000421003, 0.00061919433, 0.0027019638, -0.0053765775, -0.010571322, 0.030728141, 0.018718075, -0.11585434,
+ 0.039580128, 0.25000318, -0.29886234, -0.18287235, 0.6578189800000001, -0.54868567, 0.17696763, -0.083302976,
+ 0.14234552, -0.064187667, -0.033960326, 0.013302963, 0.0206189, -0.0018984291, -0.010561273, 0.00010918342,
+ 0.0035190396, 0.00057673999, -0.0010263489, -0.00030131696, 0.00022613828, 0.000089638382, -0.000032248755, -0.000018826533,
+ 0.0000029120131, 0.0000023941103, -1.394477e-7, -1.3407534e-7, 1.9191457e-13, 1.8452165e-13, 0.0, 0.0, },
+ { 0.000038791283, -0.000045569699, -0.00041777535, 0.00062319501, 0.0027052056, -0.005375393, -0.010572402, 0.030726437,
+ 0.018717868, -0.11585317, 0.039580663, 0.25000243, -0.29886273, -0.18287176, 0.65781885, -0.548686,
+ 0.17696839, -0.08330372, 0.14234582, -0.064187778, -0.03396015, 0.013302871, 0.020618859, -0.0018984093,
+ -0.010561246, 0.00010918036, 0.0035190253, 0.00057674024, -0.0010263441, -0.00030131618, 0.00022613687, 0.000089637969,
+ -0.000032248444, -0.00001882641, 0.0000029119687, 0.0000023940844, -1.3944369e-7, -1.3407205e-7, 0.0, 0.0, },
+ { 0.0, 0.0, -0.0000017445457, 0.000001814441, 0.000038676008, -0.000045716169, -0.00041789492, 0.00062315149,
+ 0.0027052457, -0.0053753308, -0.010572396, 0.030726394, 0.01871785, -0.11585315, 0.03958068, 0.25000242,
+ -0.29886274, -0.18287176, 0.65781885, -0.548686, 0.17696839, -0.08330372, 0.14234582, -0.064187778,
+ -0.03396015, 0.013302872, 0.020618859, -0.0018984103, -0.010561245, 0.00010918227, 0.0035190235, 0.0005767369100000001,
+ -0.0010263409, -0.00030131137, 0.00022613101, 0.000089630778, -0.000032235242, -0.000018797134, 0.0000029311054, 0.0000023933095, },
+ { 0.0, 0.0, 2.400996e-12, -2.497192e-12, -0.0000017445989, 0.0000018145039, 0.000038676583, -0.000045717027,
+ -0.00041789864, 0.00062315889, 0.0027052603, -0.0053753731, -0.010572422, 0.030726553, 0.018717796, -0.11585349,
+ 0.039581091, 0.25000267, -0.29886365, -0.182871, 0.65781861, -0.54868589, 0.17696819, -0.083303628,
+ 0.14234587, -0.064187807, -0.033960174, 0.013302897, 0.020618859, -0.0018984526, -0.010561213, 0.00010925545,
+ 0.0035189544, 0.0005766278600000001, -0.0010262111, -0.00030114598, 0.00022584654, 0.00008902247699999999, -0.000032552144, -0.000018664449, },
+ { 0.0, 0.0, 3.9319783e-13, -4.0895132e-13, -6.3160719e-12, 7.8066363e-12, -0.0000017445047, 0.0000018143635,
+ 0.000038675973, -0.000045715815, -0.00041789626, 0.00062315196, 0.002705256, -0.005375347, -0.010572431, 0.030726497,
+ 0.018717863, -0.11585345, 0.039580944, 0.25000279, -0.29886369, -0.18287097, 0.65781858, -0.54868592,
+ 0.1769682, -0.083303514, 0.14234582, -0.064188067, -0.033960018, 0.013303399, 0.020618438, -0.0018993478,
+ -0.010560376, 0.0001106233, 0.0035173821, 0.0005745302, -0.0010229283, -0.00029453156, 0.00022779928, 0.000085362615, },
+ { 0.0, 0.0, -4.6834912e-13, 4.8711355e-13, 1.0776346e-11, -1.2682135e-11, -1.1850617e-10, 1.751009e-10,
+ -0.0000017437784, 0.0000018129203, 0.000038673133, -0.000045707564, -0.00041789121, 0.0006231208299999999, 0.0027052664, -0.0053752795,
+ -0.010572509, 0.030726445, 0.018718032, -0.11585358, 0.039581016, 0.25000268, -0.2988637, -0.18287068,
+ 0.65781858, -0.54868677, 0.17696847, -0.08330162200000001, 0.14234476, -0.064191787, -0.033957024, 0.013310076,
+ 0.020612258, -0.0019097554, -0.010548644, 0.00012671842, 0.0034937666, 0.00052913399, -0.0010278304, -0.00025627314, },
+ { 0.0, 0.0, -3.7591141e-13, 3.9097232e-13, 7.8654833e-12, -9.3637194e-12, -7.9270845e-11, 1.2159335e-10,
+ 4.6441491e-10, -9.8316498e-10, -0.0000017460554, 0.00000181954, 0.000038677134, -0.000045732491, -0.00041788222, 0.00062317407,
+ 0.0027051979, -0.0053753121, -0.010572343, 0.030726274, 0.018717964, -0.1158533, 0.039581338, 0.25000143,
+ -0.29886407, -0.1828668, 0.65781782, -0.54869588, 0.17697338, -0.083284289, 0.14233111, -0.06422307200000001,
+ -0.033928145, 0.013359197, 0.020557279, -0.0019859605, -0.010440679, 0.00032845982, 0.0034922164, 0.00031950723, },
+ { 0.0, 0.0, -9.7008176e-14, 1.0089481e-13, 1.77473e-12, -2.1511483e-12, -1.5372262e-11, 2.5287645e-11,
+ 7.115903100000001e-11, -1.77311e-10, -1.2348213e-10, 7.2542972e-10, -0.0000017450016, 0.0000018130844, 0.000038678971, -0.00004571817,
+ -0.00041789388, 0.00062315711, 0.0027051921, -0.0053752707, -0.010572087, 0.030725736, 0.018717011, -0.11585044,
+ 0.03958358, 0.24999022, -0.29886524, -0.18283501, 0.65780555, -0.5487611999999999, 0.17702181, -0.083173702,
+ 0.14222973, -0.064399687, -0.033732817, 0.01363355, 0.020184552, -0.0026582356, -0.010334243, 0.0011989638, },
+ { 0.0, 0.0, 4.8096417e-15, -5.0023409e-15, -2.0363605e-13, 2.2693214e-13, 2.9268545e-12, -3.8691566e-12,
+ -2.2830499e-11, 4.010721e-11, 1.0030539e-10, -2.6202135e-10, -1.750769e-10, 1.0448174e-9, -0.0000017449923, 0.000001812272,
+ 0.000038676696, -0.00004571407, -0.0004178554, 0.00062310242, 0.0027048621, -0.0053746982, -0.010570284, 0.03072167,
+ 0.018710471, -0.11582959, 0.039596876, 0.24991347, -0.29886368, -0.18263206, 0.65769914, -0.54914259,
+ 0.17734742, -0.082618805, 0.14162772, -0.06527709199999999, -0.032607813, 0.015574165, 0.01947389, -0.0058478027, },
+ { 0.0, 0.0, 1.1620773e-14, -1.2086359e-14, -2.5281225e-13, 2.9951516e-13, 2.5798868e-12, -3.9238172e-12,
+ -1.5091708e-11, 3.1934537e-11, 4.7586293e-11, -1.6454863e-10, -2.4363315e-11, 5.0961544e-10, -4.3869198e-10, -6.2033089e-10,
+ -0.0000017425281, 0.0000018129976, 0.000038659328, -0.000045695417, -0.00041768461, 0.00062286511, 0.0027034675, -0.0053722734,
+ -0.010562778, 0.030704525, 0.018683973, -0.1157433, 0.039644886, 0.24960502, -0.29882338, -0.18185802,
+ 0.65720216, -0.55036798, 0.17856616, -0.080914163, 0.13954371, -0.06882522000000001, -0.030723701, 0.022700612, },
+ { 0.0, 0.0, 3.3760298e-15, -3.5112922e-15, -6.3206989e-14, 7.636481800000001e-14, 5.5558903e-13, -9.0603035e-13,
+ -2.6533985e-12, 6.4749011e-12, 5.3634022e-12, -2.7507239e-11, 1.1363474e-11, 5.960222e-11, -1.0091373e-10, 2.5808497e-11,
+ 1.3953072e-10, -2.6651685e-10, -0.000001742256, 0.0000018124516, 0.000038611107, -0.000045640594, -0.00041703113, 0.00062197544,
+ 0.0026981501, -0.0053630599, -0.010535085, 0.030640024, 0.018595029, -0.11543077, 0.039765416, 0.24856666,
+ -0.29852909, -0.17958773, 0.6555599600000001, -0.5538587699999999, 0.18206628, -0.07570165600000001, 0.13430764, -0.08408151899999999, },
+ { 0.0, 0.0, 5.9918017e-16, -6.2318032e-16, -9.9379759e-15, 1.2221683e-14, 8.0845727e-14, -1.3829585e-13,
+ -3.7650038e-13, 9.459626799999999e-13, 9.869205499999999e-13, -4.1121055e-12, -1.1120552e-12, 1.2402418e-11, -2.0576524e-12, -2.6724353e-11,
+ 1.4957979e-12, 9.137734800000001e-11, -1.5845915e-9, 1.4784326e-9, -0.0000016861848, 0.0000017493852, 0.000037821856, -0.000044585784,
+ -0.00041031894, 0.00061056275, 0.0026598482, -0.0052790669, -0.010386803, 0.030195423, 0.018217984, -0.11365566,
+ 0.040288546, 0.24321245, -0.29862004, -0.16484799, 0.64946229, -0.58650413, 0.20634045, -0.014365476, },
+ { 0.0, 0.0, 6.6467568e-17, -6.912305e-17, -6.2475603e-16, 8.5867071e-16, 8.7357039e-16, -5.4126396e-15,
+ 2.2202664e-14, -5.4492598e-15, -1.70592e-13, 2.8319481e-13, 6.331548e-13, -1.7748409e-12, -1.7196603e-12, 6.8530479e-12,
+ 2.0919589e-12, -1.9194583e-11, -1.3868107e-8, 1.4507548e-8, 2.4548427e-7, -2.9905628e-7, -0.0000035971494, 0.0000050451109,
+ 0.00004672424, -0.000067456818, -0.00044153822, 0.00071430062, 0.0027532286, -0.0056688462, -0.010727074, 0.031800916,
+ 0.019871848, -0.11989559, 0.036659135, 0.26632201, -0.3057397, -0.23220335, 0.68741352, -0.54024027, }
+};
+
+const double* const ff_on2avc_tabs_19_40_1[19] = {
+ tabs_19_40[ 0], tabs_19_40[ 1], tabs_19_40[ 2], tabs_19_40[ 3],
+ tabs_19_40[ 4], tabs_19_40[ 5], tabs_19_40[ 6], tabs_19_40[ 7],
+ tabs_19_40[ 8], tabs_19_40[ 9], tabs_19_40[10], tabs_19_40[11],
+ tabs_19_40[12], tabs_19_40[13], tabs_19_40[14], tabs_19_40[15],
+ tabs_19_40[16], tabs_19_40[17], tabs_19_40[18],
+};
+
+const double* const ff_on2avc_tabs_19_40_2[19] = {
+ tabs_19_40[19], tabs_19_40[20], tabs_19_40[21], tabs_19_40[22],
+ tabs_19_40[23], tabs_19_40[24], tabs_19_40[25], tabs_19_40[26],
+ tabs_19_40[27], tabs_19_40[28], tabs_19_40[29], tabs_19_40[30],
+ tabs_19_40[31], tabs_19_40[32], tabs_19_40[33], tabs_19_40[34],
+ tabs_19_40[35], tabs_19_40[36], tabs_19_40[37],
+};
+
+static const double tabs_20_84[20 * 4][84] = {
+ { -0.10690582, 0.094662183, 0.31757963, 0.48370235, 0.53678916, 0.46705598, 0.31621123, 0.15326227,
+ 0.038302765, -0.0054998811, 0.0073520352, 0.043879657, 0.067374408, 0.060077687, 0.027405389, -0.009983873000000001,
+ -0.032034985, -0.033515334, -0.017328881, -0.0009890252300000001, 0.0060597434, 0.0056072468, 0.002571725, -0.0007936099700000001,
+ -0.0027018322, -0.0027530703, -0.0014845177, 0.000064203217, 0.0010169666, 0.0011425746, 0.0006388587, -0.0000018624399,
+ -0.0003856745, -0.00043471053, -0.00023808948, -0.0000010996843, 0.00013049299, 0.00014628934, 0.00008690307399999999, 0.000020136779,
+ -0.00001317216, -0.000017142035, -0.0000073231078, 0.0000027043389, 0.0000059557329, 0.0000045096238, 0.0000020887956, 1.9940697e-7,
+ -5.9358256e-7, -7.422066799999999e-7, -7.3570645e-7, -7.3115553e-7, -7.2933999e-7, -6.8435909e-7, -5.0707974e-7, -3.8679328e-7,
+ -3.4522208e-7, -2.8271694e-7, -1.3713424e-7, 8.1184249e-9, 9.007577e-8, 1.0329366e-7, 6.463027099999999e-8, 2.1860912e-8,
+ 5.1066896e-10, -2.670761e-9, -8.5876196e-10, 4.9520519e-9, 1.0149098e-8, 1.0748594e-8, 5.7620398e-9, 1.747266e-12,
+ -3.1210565e-9, -3.4682633e-9, -1.969792e-9, -4.3451013e-10, 2.1837603e-10, 2.5217949e-10, 1.4564222e-10, 3.9900967e-11,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0065157518, -0.11553191, -0.2003235, -0.20418917, -0.10172818, 0.084274311, 0.29189952, 0.4498939,
+ 0.5060534800000001, 0.44955248, 0.316223, 0.16751007, 0.057934971, 0.009822325, 0.01258206, 0.039193775,
+ 0.05803246, 0.052804012, 0.026596935, -0.0041283092, -0.023092596, -0.026167999, -0.014874145, -0.0035171769,
+ 0.0010177737, 0.0010448012, 0.00056458234, -0.00002147272, -0.00037997699, -0.00042776572, -0.00024136656, -0.0000050238535,
+ 0.0001358557, 0.00015438052, 0.000084239467, -1.6787043e-7, -0.000046506822, -0.000051573195, -0.00003026341, -0.0000066056329,
+ 0.0000050707828, 0.0000063933192, 0.0000029272058, -5.6899116e-7, -0.0000017091248, -0.000001263969, -5.570908e-7, -1.1465662e-8,
+ 2.1544169e-7, 2.5116122e-7, 2.3708156e-7, 2.2251093e-7, 2.1287918e-7, 1.9828806e-7, 1.5178343e-7, 1.2339394e-7,
+ 1.1450823e-7, 9.427839099999999e-8, 4.5909852e-8, -2.8333617e-9, -3.0612544e-8, -3.510426e-8, -2.1859204e-8, -6.9884918e-9,
+ 6.0182974e-10, 1.7346196e-9, 7.5210778e-10, -1.6045901e-9, -3.5459042e-9, -3.7642404e-9, -2.0232963e-9, -2.1548766e-11,
+ 1.0548306e-9, 1.1724849e-9, 6.6598834e-10, 1.4716004e-10, -7.3310163e-11, -8.4658191e-11, -4.8892981e-11, -1.3394998e-11,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.009584246100000001, 0.060037953, 0.08995716600000001, 0.07015256, -0.0064981541, -0.11412419, -0.19788136, -0.20183985,
+ -0.10090064, 0.082591928, 0.28777272, 0.44450316, 0.50121997, 0.44689528, 0.31636017, 0.16979842,
+ 0.060835882, 0.011721646, 0.012592987, 0.037481155, 0.055630623, 0.050971284, 0.026138847, -0.0031939983,
+ -0.021447285, -0.024707738, -0.014251364, -0.0038152781, 0.00019304198, 0.00021786771, 0.00012308297, 0.0000035156435,
+ -0.000067129672, -0.000076387194, -0.000041781791, -4.7347618e-7, 0.000021885498, 0.000024212644, 0.000014093384, 0.0000029734778,
+ -0.0000024267734, -0.0000029909187, -0.0000014079434, 1.6425532e-7, 6.695171e-7, 4.7998271e-7, 2.0415765e-7, -5.5631332e-10,
+ -8.1446112e-8, -9.140500800000001e-8, -8.6951648e-8, -8.2795203e-8, -7.961575299999999e-8, -7.5512625e-8, -6.0512776e-8, -5.3113926e-8,
+ -5.1924925e-8, -4.3533669e-8, -2.1569411e-8, 9.781164100000001e-10, 1.3993484e-8, 1.6121335e-8, 9.9502597e-9, 2.8301122e-9,
+ -9.3071063e-10, -1.4828863e-9, -7.242862e-10, 6.7853969e-10, 1.7198254e-9, 1.833935e-9, 9.910411099999999e-10, 3.1189792e-11,
+ -4.7625005e-10, -5.2977179e-10, -3.0102006e-10, -6.6842961e-11, 3.2454035e-11, 3.7477749e-11, 2.1644673e-11, 5.9298973e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.01136632, -0.016408158, -0.0349332, -0.02784739, 0.0096145776, 0.059932587, 0.089753479, 0.069975671,
+ -0.0064946134, -0.11385923, -0.19742994, -0.20142361, -0.10079378, 0.08221251, 0.28695123, 0.44351114,
+ 0.50044723, 0.44666598, 0.31676682, 0.17065633, 0.061771278, 0.012354413, 0.012717225, 0.037140244,
+ 0.05507189, 0.050498426, 0.025957566, -0.0030533473, -0.02111719, -0.024381244, -0.01407801, -0.0038307086,
+ 0.000057284264, 0.000064716373, 0.000035447225, 3.3642675e-7, -0.000018979267, -0.000021222982, -0.000012582227, -0.0000029191463,
+ 0.0000018740006, 0.0000024460463, 0.0000010713877, -3.2487878e-7, -7.6781933e-7, -5.6583195e-7, -2.5068165e-7, -1.2347619e-8,
+ 8.297339600000001e-8, 9.823114000000001e-8, 9.7588203e-8, 9.926988499999999e-8, 1.0070428e-7, 9.5071923e-8, 7.044354799999999e-8, 5.3494703e-8,
+ 4.7613879e-8, 3.8919429e-8, 1.8845507e-8, -1.4101785e-9, -1.3040795e-8, -1.4945684e-8, -9.300971000000001e-9, -2.9841161e-9,
+ 2.2386009e-10, 6.990386e-10, 2.9986977e-10, -6.7535232e-10, -1.4832646e-9, -1.5740818e-9, -8.4577404e-10, -7.8396292e-12,
+ 4.4323404e-10, 4.9265612e-10, 2.7983182e-10, 6.1820257e-11, -3.0829599e-11, -3.5601859e-11, -2.0561283e-11, -5.6330855e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.015370512, 0.0038188528, 0.022815308, 0.027466485, 0.011338678, -0.016392314, -0.034877413, -0.027788336,
+ 0.009626457999999999, 0.059869085, 0.089638544, 0.06987961299999999, -0.0064874855, -0.11370564, -0.19717232, -0.20118491,
+ -0.10072609, 0.08200856400000001, 0.28649294, 0.44293937, 0.49997057, 0.44646556, 0.31690834, 0.17106178,
+ 0.062258998, 0.012728592, 0.012858441, 0.03704681, 0.054844697, 0.050274532, 0.025838622, -0.0030395781,
+ -0.021015878, -0.024267531, -0.014014183, -0.0038334853, 0.000012294908, 0.000013971577, 0.0000084331492, 0.0000021207154,
+ -0.0000010613403, -0.0000014692243, -5.674645600000001e-7, 3.6813259e-7, 6.6471952e-7, 5.0732461e-7, 2.3990309e-7, 3.2527713e-8,
+ -5.2940032e-8, -7.0272097e-8, -7.4243847e-8, -8.004311e-8, -8.432345e-8, -7.9953609e-8, -5.7174812e-8, -4.0198391e-8,
+ -3.3846855e-8, -2.7391787e-8, -1.3164822e-8, 9.3143613e-10, 8.8830013e-9, 1.0178346e-8, 6.3897086e-9, 2.2544123e-9,
+ 2.3155551e-10, -6.9016433e-11, 2.2668746e-11, 5.0194474e-10, 9.691114e-10, 1.0241351e-9, 5.4764968e-10, -5.1352834e-12,
+ -3.0704315e-10, -3.4111839e-10, -1.9371648e-10, -4.2664063e-11, 2.1615536e-11, 2.4961507e-11, 1.4416119e-11, 3.9495215e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0075782552, 0.00056335562, -0.012867845, -0.020711565, -0.015362833, 0.0038178887, 0.022803262, 0.027450127,
+ 0.01132947, -0.016385813, -0.034857713, -0.027768817, 0.009628209800000001, 0.059844065, 0.08959629, 0.069845594,
+ -0.0064833885, -0.11364823, -0.19707655, -0.20109459, -0.10069589, 0.08194085600000001, 0.28632947, 0.44272522,
+ 0.49977611, 0.44635552, 0.31691232, 0.17116302, 0.062405028, 0.012858212, 0.012929921, 0.037051865,
+ 0.054806207, 0.050228229, 0.025812903, -0.0030350316, -0.020990856, -0.02423998, -0.013999649, -0.0038354321,
+ 3.9449016e-7, 6.2546153e-7, 2.2880436e-7, -1.9648504e-7, -3.2799492e-7, -2.4605577e-7, -1.1018746e-7, -3.7855249e-9,
+ 4.0799542e-8, 4.9097347e-8, 4.6905093e-8, 4.6627152e-8, 4.7685199e-8, 4.451826e-8, 3.0728316e-8, 1.9838579e-8,
+ 1.5327733e-8, 1.1920072e-8, 5.4900593e-9, -8.1671795e-10, -4.4234746e-9, -5.0171323e-9, -3.160912e-9, -1.1972669e-9,
+ -2.7582833e-10, -1.3699591e-10, -1.0291296e-10, -2.4784306e-10, -4.2875658e-10, -4.5038598e-10, -2.3901171e-10, 9.433746099999999e-12,
+ 1.480739e-10, 1.6435722e-10, 9.329815700000001e-11, 2.0425522e-11, -1.0664812e-11, -1.2315669e-11, -7.1127172e-12, -1.9486403e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0031794207, -0.0013173157, 0.0064003509, 0.010140285, 0.0075775394, 0.00056326184, -0.012866591, -0.020709553,
+ -0.015361329, 0.00381762, 0.022800959, 0.027447143, 0.011327957, -0.016384398, -0.034854051, -0.027765481,
+ 0.009627986, 0.059838762, 0.089587849, 0.069838924, -0.0064825988, -0.11363701, -0.19705759, -0.2010761,
+ -0.10068835, 0.081929799, 0.28629916, 0.44268271, 0.49973345, 0.44632462, 0.31689976, 0.17116777,
+ 0.062419762, 0.01287363, 0.012939169, 0.037052802, 0.054801411, 0.050222414, 0.025809986, -0.0030336964,
+ -0.020986623, -0.024235277, -0.013996668, -0.0038345525, 6.739720499999999e-8, 4.946956e-8, 2.0815264e-8, -1.3278463e-9,
+ -1.0398185e-8, -1.1792365e-8, -1.0980052e-8, -1.0573121e-8, -1.0506413e-8, -9.6865614e-9, -6.7673913e-9, -4.517767e-9,
+ -3.5747705e-9, -2.7739698e-9, -1.2696313e-9, 2.1657762e-10, 1.0751539e-9, 1.2157822e-9, 7.633168300000001e-10, 2.8106144e-10,
+ 5.1205725e-11, 1.6271833e-11, 1.5300631e-11, 5.7579735e-11, 1.0429514e-10, 1.0968885e-10, 5.8276177e-11, -2.045035e-12,
+ -3.5598539e-11, -3.951248e-11, -2.2429257e-11, -4.9097703e-12, 2.5651279e-12, 2.9621962e-12, 1.7107689e-12, 4.6869195e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0009898319599999999, -0.00005380164, -0.0016617464, -0.0024058437, -0.0031794045, -0.0013173095, 0.0064003186, 0.010140233,
+ 0.0075774991, 0.0005632576800000001, -0.012866521, -0.020709442, -0.015361246, 0.003817603, 0.022800833, 0.027446985,
+ 0.011327883, -0.016384315, -0.034853855, -0.027765311, 0.0096279578, 0.059838456, 0.089587375, 0.069838553,
+ -0.0064825573, -0.11363639, -0.19705653, -0.20107505, -0.10068788, 0.08192925500000001, 0.28629754, 0.44268034,
+ 0.49973095, 0.44632262, 0.31689865, 0.17116753, 0.062420092, 0.012874085, 0.012939407, 0.03705269,
+ 0.054801034, 0.050221973, 0.02580966, -0.0030338396, -0.020986632, -0.024235242, -0.013996676, -0.0038346105,
+ -2.2089352e-9, -9.1397999e-10, 4.1441104e-10, 1.5632064e-9, 2.1674468e-9, 2.2213076e-9, 1.6242991e-9, 1.220069e-9,
+ 1.1433859e-9, 1.0132949e-9, 5.303622e-10, 6.3673309e-11, -1.7092595e-10, -2.0591998e-10, -1.3238559e-10, -5.2482661e-11,
+ -1.557149e-11, -1.0780691e-11, -7.849213899999999e-12, -1.390567e-11, -2.2913106e-11, -2.4240643e-11, -1.3014573e-11, -9.3497669e-14,
+ 6.8837583e-12, 7.660260199999999e-12, 4.3533487e-12, 9.690445799999999e-13, -4.6444337e-13, -5.3633676e-13, -3.097527e-13, -8.486160400000001e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00021150513, -0.0001182675, -0.00018966171, 0.0007039766, 0.0009898316799999999, -0.000053801616, -0.0016617459, -0.002405843,
+ -0.0031794035, -0.0013173091, 0.0064003166, 0.01014023, 0.0075774968, 0.00056325744, -0.012866517, -0.020709435,
+ -0.015361241, 0.0038176018, 0.022800826, 0.027446977, 0.01132788, -0.01638431, -0.034853844, -0.027765303,
+ 0.0096279543, 0.059838438, 0.089587349, 0.06983853299999999, -0.0064825542, -0.11363636, -0.19705648, -0.20107499,
+ -0.10068785, 0.08192923000000001, 0.28629745, 0.44268021, 0.4997308, 0.44632248, 0.31689855, 0.17116749,
+ 0.062420089, 0.012874107, 0.01293944, 0.037052722, 0.054801064, 0.050222001, 0.025809687, -0.0030338132,
+ -0.020986608, -0.024235225, -0.013996666, -0.0038346066, -1.0807056e-9, -9.6194735e-10, -5.8042675e-10, -2.3026093e-10,
+ -5.2462083e-11, 8.934574699999999e-12, 2.8753664e-11, 4.2948201e-11, 5.7629255e-11, 6.1074334e-11, 3.9278999e-11, 2.0849977e-11,
+ 1.506808e-11, 1.3966739e-11, 7.822410799999999e-12, 2.9708823e-12, 1.5662219e-12, 1.4169493e-12, 5.9549711e-13, -6.4389303e-13,
+ -1.5821434e-12, -1.7440449e-12, -9.8694023e-13, -2.0617409e-13, 1.3336526e-13, 1.540095e-13, 8.8945717e-14, 2.4368072e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656495, 0.00021150513, -0.0001182675, -0.00018966171, 0.00070397658,
+ 0.00098983166, -0.000053801612, -0.0016617459, -0.0024058429, -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023,
+ 0.0075774967, 0.00056325745, -0.012866517, -0.020709435, -0.015361241, 0.0038176017, 0.022800826, 0.027446976,
+ 0.01132788, -0.01638431, -0.034853844, -0.027765303, 0.0096279538, 0.059838437, 0.089587348, 0.06983853199999999,
+ -0.0064825542, -0.11363636, -0.19705647, -0.20107499, -0.10068785, 0.08192923000000001, 0.28629745, 0.4426802,
+ 0.49973079, 0.44632247, 0.31689854, 0.17116747, 0.062420078, 0.012874099, 0.012939434, 0.037052719,
+ 0.054801063, 0.050222001, 0.025809688, -0.0030338124, -0.020986608, -0.024235224, -0.013996665, -0.0038346058,
+ -1.7349485e-10, -1.4014027e-10, -6.733694999999999e-11, 2.3535906e-12, 3.9700971e-11, 4.5614905e-11, 2.9175877e-11, 1.2428934e-11,
+ 5.1956468e-12, 4.160356e-12, 2.590853e-12, 2.6563084e-12, 3.7861708e-12, 3.9536444e-12, 2.0858696e-12, -1.2971498e-13,
+ -1.3858912e-12, -1.5382753e-12, -8.7320447e-13, -1.911529e-13, 9.9847212e-14, 1.1530303e-13, 6.6591419e-14, 1.8243762e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246, 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494,
+ 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658, 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429,
+ -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023, 0.0075774966, 0.00056325745, -0.012866517, -0.020709435,
+ -0.015361241, 0.0038176017, 0.022800826, 0.027446976, 0.01132788, -0.01638431, -0.034853844, -0.027765303,
+ 0.009627953700000001, 0.059838437, 0.089587347, 0.06983853199999999, -0.0064825542, -0.11363635, -0.19705647, -0.20107499,
+ -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802, 0.49973078, 0.44632246, 0.31689853, 0.17116747,
+ 0.062420077, 0.012874099, 0.012939434, 0.037052719, 0.054801063, 0.050222001, 0.025809688, -0.003033812,
+ -0.020986607, -0.024235224, -0.013996665, -0.0038346056, 8.9844115e-13, 1.8039035e-12, 1.1116515e-12, -1.2672024e-13,
+ -9.559857e-13, -1.0248827e-12, -5.1382188e-13, 1.808146e-13, 6.3147038e-13, 6.9078155e-13, 3.8644389e-13, 6.3822893e-14,
+ -8.5035914e-14, -9.6170938e-14, -5.5045873e-14, -1.3511746e-14, 3.2585157e-15, 3.7629168e-15, 2.1732123e-15, 5.9538554e-16,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.000010027921, -0.000010930316, 0.000019234827, -0.000016474706, -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246,
+ 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494, 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658,
+ 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429, -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023,
+ 0.0075774966, 0.00056325745, -0.012866517, -0.020709435, -0.015361241, 0.0038176017, 0.022800826, 0.027446976,
+ 0.01132788, -0.01638431, -0.034853844, -0.027765303, 0.009627953700000001, 0.059838436, 0.089587347, 0.06983853199999999,
+ -0.0064825542, -0.11363635, -0.19705647, -0.20107499, -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802,
+ 0.49973078, 0.44632246, 0.31689853, 0.17116747, 0.062420077, 0.012874099, 0.012939434, 0.037052719,
+ 0.054801063, 0.050222001, 0.025809688, -0.003033812, -0.020986607, -0.024235224, -0.013996665, -0.0038346056,
+ -5.2802279e-13, -3.8437399e-13, -2.4041388e-13, -2.8463768e-13, -4.2600563e-13, -4.4368416e-13, -2.3294104e-13, 1.9132449e-14,
+ 1.637729e-13, 1.8161207e-13, 1.0304955e-13, 2.2420723e-14, -1.2069513e-14, -1.393781e-14, -8.0495588e-15, -2.2053027e-15,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000030589933, -0.0000034582443, 0.0000041270616, 0.000012505734, -0.000010027921, -0.000010930316, 0.000019234827, -0.000016474706,
+ -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246, 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494,
+ 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658, 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429,
+ -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023, 0.0075774966, 0.00056325745, -0.012866517, -0.020709435,
+ -0.015361241, 0.0038176017, 0.022800826, 0.027446976, 0.01132788, -0.01638431, -0.034853844, -0.027765303,
+ 0.009627953700000001, 0.059838436, 0.089587347, 0.06983853199999999, -0.0064825542, -0.11363635, -0.19705647, -0.20107499,
+ -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802, 0.49973078, 0.44632246, 0.31689853, 0.17116747,
+ 0.062420077, 0.012874099, 0.012939434, 0.037052719, 0.054801063, 0.050222001, 0.025809688, -0.003033812,
+ -0.020986607, -0.024235224, -0.013996665, -0.0038346056, -6.2170478e-14, -6.383222999999999e-14, -3.2934372e-14, 5.0060707e-15,
+ 2.7669088e-14, 3.0656054e-14, 1.738787e-14, 3.7610419e-15, -2.0823764e-15, -2.4047173e-15, -1.388806e-15, -3.8048514e-16,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 3.6812554e-7, -0.0000013162529, 8.907414900000001e-7, 0.0000021605209, -0.0000030589933, -0.0000034582443, 0.0000041270616, 0.000012505734,
+ -0.000010027921, -0.000010930316, 0.000019234827, -0.000016474706, -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246,
+ 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494, 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658,
+ 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429, -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023,
+ 0.0075774966, 0.00056325745, -0.012866517, -0.020709435, -0.015361241, 0.0038176017, 0.022800826, 0.027446976,
+ 0.01132788, -0.01638431, -0.034853844, -0.027765303, 0.009627953700000001, 0.059838436, 0.089587347, 0.06983853199999999,
+ -0.0064825542, -0.11363635, -0.19705647, -0.20107499, -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802,
+ 0.49973078, 0.44632246, 0.31689853, 0.17116747, 0.062420077, 0.012874099, 0.012939434, 0.037052719,
+ 0.054801063, 0.050222001, 0.025809688, -0.003033812, -0.020986607, -0.024235224, -0.013996665, -0.0038346056,
+ 6.8070256e-15, 7.5939277e-15, 4.3204891e-15, 9.7727649e-16, -4.2864944e-16, -4.9500211e-16, -2.8588054e-16, -7.832144999999999e-17,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -1.3565721e-7, 3.3158394e-7, -1.1299252e-7, 6.2458675e-7, 3.6812554e-7, -0.0000013162529, 8.907414900000001e-7, 0.0000021605209,
+ -0.0000030589933, -0.0000034582443, 0.0000041270616, 0.000012505734, -0.000010027921, -0.000010930316, 0.000019234827, -0.000016474706,
+ -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246, 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494,
+ 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658, 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429,
+ -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023, 0.0075774966, 0.00056325745, -0.012866517, -0.020709435,
+ -0.015361241, 0.0038176017, 0.022800826, 0.027446976, 0.01132788, -0.01638431, -0.034853844, -0.027765303,
+ 0.009627953700000001, 0.059838436, 0.089587347, 0.06983853199999999, -0.0064825542, -0.11363635, -0.19705647, -0.20107499,
+ -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802, 0.49973078, 0.44632246, 0.31689853, 0.17116747,
+ 0.062420077, 0.012874099, 0.012939434, 0.037052719, 0.054801063, 0.050222001, 0.025809688, -0.003033812,
+ -0.020986607, -0.024235224, -0.013996665, -0.0038346056, 4.0075758e-16, 4.6279274e-16, 2.6727853e-16, 7.3225139e-17,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 9.2129029e-8, 4.470829e-8, -1.3675036e-7, -4.31831e-7, -1.3565721e-7, 3.3158394e-7, -1.1299252e-7, 6.2458675e-7,
+ 3.6812554e-7, -0.0000013162529, 8.907414900000001e-7, 0.0000021605209, -0.0000030589933, -0.0000034582443, 0.0000041270616, 0.000012505734,
+ -0.000010027921, -0.000010930316, 0.000019234827, -0.000016474706, -0.0000057370994, 0.000043510151, -0.0000074219963, -0.00011888246,
+ 0.000029572086, 0.0001500013, -0.00012528062, -0.000085656494, 0.00021150513, -0.0001182675, -0.0001896617, 0.00070397658,
+ 0.00098983165, -0.000053801611, -0.0016617459, -0.0024058429, -0.0031794034, -0.0013173091, 0.0064003165, 0.01014023,
+ 0.0075774966, 0.00056325745, -0.012866517, -0.020709435, -0.015361241, 0.0038176017, 0.022800826, 0.027446976,
+ 0.01132788, -0.01638431, -0.034853844, -0.027765303, 0.009627953700000001, 0.059838436, 0.089587347, 0.06983853199999999,
+ -0.0064825542, -0.11363635, -0.19705647, -0.20107499, -0.10068785, 0.08192923000000001, 0.28629744, 0.4426802,
+ 0.49973078, 0.44632246, 0.31689853, 0.17116747, 0.062420077, 0.012874099, 0.012939434, 0.037052719,
+ 0.054801063, 0.050222001, 0.025809688, -0.003033812, -0.020986607, -0.024235224, -0.013996665, -0.0038346056,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0, 0.0, 0.0, 0.0, -8.764059600000001e-9, -6.963307e-9, 1.5066994e-8, 3.6978382e-8,
+ 9.2186128e-8, 4.4735999e-8, -1.3683511e-7, -4.3209863e-7, -1.3574128e-7, 3.3178945e-7, -1.1306255e-7, 6.2497386e-7,
+ 3.683537e-7, -0.0000013170687, 8.9129355e-7, 0.00000216186, -0.0000030608892, -0.0000034603877, 0.0000041296194, 0.000012513485,
+ -0.000010034136, -0.00001093709, 0.000019246748, -0.000016484916, -0.0000057406551, 0.000043537117, -0.0000074265962, -0.00011895614,
+ 0.000029590414, 0.00015009426, -0.00012535827, -0.00008570958199999999, 0.00021163621, -0.0001183408, -0.00018977925, 0.00070441288,
+ 0.0009904451199999999, -0.000053834956, -0.0016627758, -0.002407334, -0.0031813739, -0.0013181255, 0.0064042832, 0.010146514,
+ 0.0075821929, 0.00056360654, -0.012874492, -0.02072227, -0.015370762, 0.0038199677, 0.022814957, 0.027463987,
+ 0.0113349, -0.016394464, -0.034875445, -0.027782511, 0.009633920799999999, 0.059875523, 0.089642871, 0.069881816,
+ -0.0064865719, -0.11370678, -0.1971786, -0.20119961, -0.10075025, 0.08198000699999999, 0.28647488, 0.44295456,
+ 0.5000405, 0.44659908, 0.31709494, 0.17127356, 0.062458763, 0.012882078, 0.012947454, 0.037075684,
+ 0.054835027, 0.050253127, 0.025825684, -0.0030356923, },
+ { 0.0, 0.0, 0.0, 0.0, 2.3914563e-11, 1.9000834e-11, -4.1113434e-11, -1.0090322e-10,
+ -9.0429743e-9, -7.1071213e-9, 1.5487424e-8, 3.8272917e-8, 9.284437599999999e-8, 4.3970329e-8, -1.3695386e-7, -4.3515323e-7,
+ -1.3717026e-7, 3.3641935e-7, -1.1584767e-7, 6.2102624e-7, 3.7785615e-7, -0.0000013117388, 8.8280807e-7, 0.0000021344647,
+ -0.0000030430666, -0.0000034413485, 0.0000040899953, 0.000012597541, -0.000010049803, -0.000011090041, 0.00001932711, -0.000016211794,
+ -0.0000058393238, 0.000043263497, -0.0000071077195, -0.0001190937, 0.000029105316, 0.00015088585, -0.00012523184, -0.00008789934600000001,
+ 0.00020959441, -0.00011856341, -0.0001858346, 0.00071318131, 0.0010022188, -0.000050406274, -0.0016854432, -0.0024425377,
+ -0.0032119973, -0.0013237792, 0.0064594112, 0.010234742, 0.0076478105, 0.00055494281, -0.012976947, -0.020861916,
+ -0.015449686, 0.0038766312, 0.022981361, 0.027625553, 0.011344005, -0.016609039, -0.035228952, -0.028059949,
+ 0.0096817025, 0.060372756, 0.090460822, 0.070649035, -0.006231908, -0.11428553, -0.19857599, -0.20303655,
+ -0.10242931, 0.08101735, 0.28650414, 0.44387032, 0.50143144, 0.44795843, 0.31804973, 0.17170719,
+ 0.062504161, 0.012785176, 0.012917411, 0.037199735, },
+ { 0.0, 0.0, 0.0, 0.0, 1.7208769e-11, 1.3672881e-11, -2.9584969e-11, -7.260932400000001e-11,
+ -1.9502299e-10, -9.8973137e-11, 2.9276962e-10, 9.0756433e-10, -8.4024356e-9, -7.5848188e-9, 1.5160135e-8, 3.5281047e-8,
+ 9.1795739e-8, 4.8119378e-8, -1.3958217e-7, -4.3792198e-7, -1.299519e-7, 3.3845784e-7, -1.2042094e-7, 6.0758667e-7,
+ 3.8536054e-7, -0.000001308981, 8.6541935e-7, 0.0000022271281, -0.0000030839153, -0.0000035840001, 0.0000041996021, 0.000012795353,
+ -0.000010161269, -0.000011227452, 0.000019595831, -0.000016605111, -0.0000061431566, 0.000044269118, -0.0000072986449, -0.00012118588,
+ 0.000028160432, 0.0001509061, -0.00012314444, -0.000080367843, 0.00022072872, -0.00011654453, -0.00020614453, 0.00068484311,
+ 0.00097637937, -0.000057369856, -0.0016371767, -0.0023647844, -0.0031580486, -0.0013325879, 0.0063771053, 0.010119985,
+ 0.0075805926, 0.00060526641, -0.012846336, -0.020747422, -0.015463245, 0.0036989769, 0.022719278, 0.027446179,
+ 0.01143065, -0.016173272, -0.034553004, -0.027441455, 0.009878847, 0.059889938, 0.089299875, 0.06910726,
+ -0.0076681795, -0.11513091, -0.19851945, -0.20202798, -0.10067452, 0.08315763499999999, 0.28866517, 0.44579776,
+ 0.5030154, 0.44918495, 0.31895639, 0.17236043, },
+ { 0.0, 0.0, 0.0, 0.0, 3.6851694e-10, 2.9279771e-10, -6.335468899999999e-10, -1.5548913e-9,
+ -4.6510001e-9, -2.4966087e-9, 7.0855764e-9, 2.1437864e-8, 1.3169401e-8, -1.0542802e-8, -6.1601155e-9, -6.1575439e-8,
+ -3.4073418e-8, 7.724169599999999e-8, -3.4452297e-8, -1.1253081e-8, 2.9592187e-7, 1.2560497e-7, -3.1939331e-7, -9.671230100000001e-7,
+ -3.3711275e-8, 5.7369354e-7, -5.5258612e-7, 0.0000029538269, -3.0498174e-7, -0.0000051446274, 0.0000037421504, 0.000007933204999999999,
+ -0.0000073627242, -0.0000087743051, 0.000012632452, 0.000011519312, -0.000022548551, 0.0000044186995, 0.000026652061, -0.00007250452599999999,
+ -0.000029667452, 0.000072190638, 0.000031608516, -0.000030718401, 0.00028455347, 0.00027795666, -0.00062873194, -0.00071930588,
+ -0.00018882003, -0.00033095544, 0.00067798053, 0.0026897514, 0.0026281934, -0.00029899771, -0.0042160247, -0.0059853387,
+ -0.0062551191, -0.0010063188, 0.012567797, 0.017963467, 0.011342289, -0.0027790647, -0.025355323, -0.035902046,
+ -0.022213305, 0.014809325, 0.049440119, 0.055745988, 0.022283613, -0.034643741, -0.077415581, -0.07472068,
+ -0.015256075, 0.073924579, 0.13781927, 0.12632161, 0.023452078, -0.13385396, -0.26083401, -0.26880791,
+ -0.11637654, 0.16325051, 0.4764406, 0.7149867, },
+ { -0.8535439, -0.35968119, 0.065351407, 0.059333029, -0.1269521, -0.076877898, -0.10933188, 0.15495355,
+ 0.054522357, -0.23877106, -0.00046647111, 0.089122653, -0.026462813, 0.048335133, -0.0079782051, -0.016659518,
+ 0.047159549, -0.037963054, -0.011292312, 0.027672996, -0.018929343, 0.0034709715, 0.0029394227, -0.0041317473,
+ 0.0053664905, -0.0034050512, -0.0026283962, 0.001701639, -1.4621633e-18, -7.386584000000001e-18, -8.5187602e-19, 8.977116299999999e-18,
+ 1.7897277e-18, -9.0759985e-18, 1.7650852e-18, 1.3050953e-18, -1.1888393e-18, 3.6267152e-18, -1.5965868e-18, -2.9834012e-19,
+ 2.6322817e-18, -2.3718141e-18, 6.9968316e-19, 2.1831511e-18, -1.8853562e-18, 1.9795454e-19, 2.0018813e-19, -4.9845616e-19,
+ 7.4533925e-19, -3.7752172e-19, -3.6230857e-19, 3.6040853e-19, -6.196548599999999e-20, -1.1505867e-19, 9.5248123e-20, 3.1535333e-20,
+ -7.2976602e-20, 3.3552326e-20, -3.6298577e-20, -2.6232003e-20, 3.7424549e-20, -4.9240473e-20, -5.6073546e-21, 3.8346556e-20,
+ -2.6796095e-20, 2.3158911e-21, 4.7582374e-21, -2.8967253e-21, 6.5855823e-21, -9.9663562e-21, -5.6020698e-21, 4.1833883e-21,
+ 1.0439859e-21, 1.7132787e-22, -5.812353400000001e-23, 3.0334018e-22, 2.9773051e-22, -3.5694498e-22, -2.5609715e-22, 1.0779825e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0097491326, 0.49799784, 0.49667555, -0.028559998, -0.42222797, -0.18514687, 0.2500187, 0.31609299,
+ -0.068894788, -0.23630869, 0.051357429, 0.18649924, -0.0027572124, -0.13295343, -0.066275158, 0.0590209,
+ 0.064667315, -0.024369346, -0.018853311, 0.022018745, -0.00008582693, -0.012650973, -0.008405076799999999, 0.0012936423,
+ 0.0016217257, -0.0010289889, -0.00079428773, 0.0005142265, 3.837204e-18, -5.1417775e-18, 1.6180876e-18, 1.3329307e-18,
+ -3.4207218e-18, 4.2353711e-18, 1.1016565e-18, -6.9071994e-18, 4.800252e-18, 4.6916197e-18, -3.6758436e-18, -2.1583284e-18,
+ 7.2104057e-19, 2.2650924e-19, 1.4887113e-18, -9.0359689e-19, -1.9341924e-18, 2.0497686e-18, 3.4265221e-19, -1.0853157e-18,
+ 6.8534707e-19, -3.3981292e-19, -5.8153225e-21, 3.4694372e-19, -3.6884567e-19, 2.325747e-19, 1.1847485e-19, -1.9271002e-19,
+ 1.0387854e-19, -4.2515241e-21, -4.4545004e-20, 4.429267e-21, -4.2326837e-21, 4.0949538e-21, 1.7076984e-20, -3.7107451e-21,
+ -1.6750204e-20, 9.3038469e-21, 3.4943875e-21, -4.5159418e-21, 4.0634963e-21, -2.835022e-21, 1.4147726e-22, 2.8528805e-21,
+ -2.5032938e-21, -4.1947499e-22, -1.4819835e-22, -4.270146e-22, 8.2949421e-22, -3.9522162e-22, -3.2534223e-22, 2.5448899e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.043868099, -0.11359779, -0.23884371, -0.31126971, -0.03080143, 0.38884179, 0.3428215, -0.14827109,
+ -0.46703243, -0.19177262, 0.29481908, 0.27261094, -0.11727332, -0.20703374, 0.041159567, 0.17723309,
+ 0.019225426, -0.14351258, -0.060622382, 0.07083052099999999, 0.054619012, -0.014728714, -0.017162395, 0.0148445,
+ 0.0059330378, -0.014589274, -0.009891233100000001, 0.0026891131, -1.4871029e-17, 4.5609802e-18, -6.5993686e-18, -2.0104526e-17,
+ 8.4690133e-18, -4.8460668e-18, -3.5542414e-18, -2.7023903e-18, 1.2011757e-18, 2.8554601e-18, -1.4641397e-19, -5.2258014e-18,
+ 2.1733685e-18, 3.3779312e-18, -1.3649109e-19, -2.1880083e-18, -1.5772341e-19, 1.5069148e-18, 1.3492288e-18, -8.802379500000001e-19,
+ -1.0697808e-18, 6.9070831e-19, 2.3374065e-19, -1.1077769e-19, 1.3077631e-19, -2.8574171e-19, 1.415901e-19, 1.7828577e-19,
+ -1.5396053e-19, 7.5893357e-20, -4.3050603e-20, -8.3679005e-20, 1.3347946e-19, -5.4974401e-20, -1.7493216e-21, 3.3365805e-20,
+ -5.8985959e-20, 1.9211594e-20, 8.331346600000001e-21, -1.0148857e-20, 6.4122352e-21, -1.8011728e-20, -2.2948955e-21, 1.1046082e-20,
+ -6.5384535e-21, -1.9688739e-21, -1.1027418e-21, -7.3109031e-22, 3.475493e-21, -1.7477936e-21, -1.424523e-21, 1.075262e-21,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.11350485, 0.078457191, 0.23123985, 0.16377816, -0.0053257425, -0.11081688, -0.17690723, -0.1882482,
+ 0.024386161, 0.35978077, 0.34619534, -0.13380312, -0.47092927, -0.18321328, 0.29495422, 0.27700897,
+ -0.1107013, -0.2220893, 0.041645458, 0.187296, 0.010609985, -0.14990385, -0.063127034, 0.071396236,
+ 0.059312169, -0.014899249, -0.018035052, 0.015904326, 0.0060997472, -0.01511777, -0.01047208, 0.0025348521,
+ 0.000094772741, 0.00018699728, -0.00009023797399999999, -0.00018613552, 0.000039646997, 0.00012704541, 0.000021476997, -0.00007741941,
+ -0.000031298152, 0.000067956454, 0.000037690455, -0.000029151857, -0.000015545855, 0.000014856125, 0.000015237388, -0.0000027604675,
+ -0.0000057556044, -1.3476965e-8, 0.0000028285011, 9.4403854e-7, -2.2498423e-7, -0.0000015897131, -6.5328073e-7, 6.4520141e-7,
+ 5.13012e-7, -5.7050618e-7, -4.7024882e-7, 1.9002285e-7, 1.6475241e-7, -7.181441e-8, -8.440031899999999e-8, 2.4316993e-8,
+ 5.7585708e-9, 1.4360563e-8, 5.5108486e-9, -4.6057052e-9, -5.3604255e-9, 5.1973797e-9, 4.9569464e-9, -1.6041796e-9,
+ -1.868336e-9, 7.621408200000001e-10, 5.8431354e-10, -4.9659479e-10, 2.442538e-10, -1.5448383e-10, -1.1904637e-10, 7.7304831e-11,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.018943425, -0.00023134148, -0.051032993, -0.14158766, -0.1219561, 0.060207541, 0.20496175, 0.1352868,
+ -0.028897426, -0.12425083, -0.17929974, -0.18396477, 0.0280128, 0.35786456, 0.34036011, -0.13789513,
+ -0.4700605, -0.17977395, 0.29670633, 0.27653234, -0.1105855, -0.21980639, 0.044009223, 0.18725153,
+ 0.008622334299999999, -0.15146531, -0.063196745, 0.07186579, 0.059376049, -0.014785703, -0.017430318, 0.016309961,
+ 0.0058585315, -0.015503177, -0.010351797, 0.0028796789, 0.000030161127, -0.00010871535, -0.000054762367, 0.000049991893,
+ 0.000030931583, -0.000034949267, -0.000026658113, 0.000012548204, 0.0000085226258, -0.0000033484801, -0.000006354489, -6.016628e-7,
+ 0.0000018156312, 0.0000016799919, -2.9269113e-7, -0.0000011148862, -3.2141225e-7, 0.0000011159281, 6.2161289e-7, -4.3728317e-7,
+ -3.2357674e-7, 2.9479843e-7, 2.5855335e-7, -9.861939099999999e-8, -7.7174471e-8, 2.357143e-8, 3.4866513e-8, -7.2848793e-9,
+ 4.1725233e-10, -1.0232913e-8, -5.1858942e-9, 3.493822e-9, 3.2966092e-9, -2.9205056e-9, -2.772405e-9, 9.5707304e-10,
+ 9.349160000000001e-10, -3.607995e-10, -2.7638764e-10, 2.4385053e-10, -1.3420421e-10, 8.4880481e-11, 6.5409521e-11, -4.2474809e-11,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.042099341, 0.0049466918, 0.060032676, 0.053056167, 0.019616496, 0.0062036013, -0.038995874, -0.12624839,
+ -0.10751575, 0.069583591, 0.20780096, 0.13338201, -0.032366324, -0.12649959, -0.17867505, -0.18073608,
+ 0.031238128, 0.35847857, 0.33866999, -0.13958546, -0.47087746, -0.18085881, 0.29523238, 0.27623237,
+ -0.10915239, -0.21827969, 0.044204705, 0.18674789, 0.008460475699999999, -0.15160207, -0.063812811, 0.071407823,
+ 0.059707723, -0.014212698, -0.017418974, 0.015975258, 0.0058538568, -0.015264018, -0.01033238, 0.0027038771,
+ -0.0000012051987, 0.000010834885, 0.0000041549531, -0.0000052634061, -0.0000023429131, 0.0000034400397, 0.0000028289785, -9.1863911e-7,
+ -0.0000012270482, 4.0351997e-7, 7.5101858e-7, 4.7474055e-9, -1.4510685e-7, -1.8989353e-7, -3.8281943e-8, 8.072763899999999e-8,
+ 7.066967400000001e-8, -9.4210763e-8, -7.3956251e-8, 3.115984e-8, 2.9133811e-8, -1.5014384e-8, -1.606001e-8, 5.2321014e-9,
+ 1.7924899e-9, 1.7024681e-9, 3.7814988e-10, -4.778233e-10, -7.9390088e-10, 8.1430637e-10, 7.7594964e-10, -2.4383214e-10,
+ -3.0886716e-10, 1.3001907e-10, 9.9726822e-11, -8.3004062e-11, 3.8036166e-11, -2.4056832e-11, -1.8538371e-11, 1.2038213e-11,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0051186317, 0.0026082139, 0.0011561029, -0.027835056, -0.043654175, 0.0024567809, 0.056866436, 0.049722261,
+ 0.016705706, 0.0041957359, -0.039911418, -0.12626296, -0.10711407, 0.069886621, 0.207737, 0.13299916,
+ -0.032807178, -0.12670819, -0.17850805, -0.18026528, 0.03173076, 0.3587233, 0.33861929, -0.13974791,
+ -0.47100956, -0.18098662, 0.29508412, 0.27616175, -0.10905287, -0.21808239, 0.04432355, 0.18671439,
+ 0.008368981899999999, -0.15163858, -0.063790702, 0.071424185, 0.059696165, -0.014211805, -0.017387543, 0.016000355,
+ 0.0058451304, -0.015287092, -0.010335228, 0.0027174845, 0.0000020768948, -5.7483511e-7, -0.0000013986923, -2.0846925e-7,
+ 3.3989431e-7, 4.6234671e-7, 1.5124727e-8, -2.6644477e-7, -1.0785895e-7, 2.5703709e-7, 1.5722009e-7, -9.7984161e-8,
+ -7.3898702e-8, 6.035174000000001e-8, 5.4781732e-8, -2.0282833e-8, -1.4592424e-8, 3.0544033e-9, 5.8925631e-9, -9.0937458e-10,
+ 5.4095235e-10, -2.3396208e-9, -1.3722115e-9, 7.9084999e-10, 7.5764257e-10, -6.0261359e-10, -5.6187916e-10, 2.161657e-10,
+ 1.5585732e-10, -5.5402911e-11, -4.2385399e-11, 3.9580331e-11, -2.5135395e-11, 1.5897448e-11, 1.225069e-11, -7.9551986e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0071084674, -0.0033836798, 0.012325746, 0.008056183999999999, -0.0058137499, 0.0029806292, 0.0026693637, -0.025573967,
+ -0.041351054, 0.0041008264, 0.057495506, 0.049458219, 0.016024743, 0.0036418724, -0.039989343, -0.12584118,
+ -0.10648721, 0.07032519399999999, 0.20775682, 0.13264239, -0.033314247, -0.12711621, -0.17863318, -0.18010455,
+ 0.032003531, 0.35891666, 0.33867579, -0.13976955, -0.47107608, -0.18111434, 0.29494862, 0.2761335,
+ -0.10895874, -0.21798696, 0.044327136, 0.18667373, 0.0083638593, -0.15162138, -0.063800826, 0.071398434,
+ 0.059697546, -0.0141866, -0.017375994, 0.015991099, 0.005839154, -0.015281732, -0.010330736, 0.0027152827,
+ 6.7571268e-8, 1.0574211e-7, 1.1225055e-8, -5.6939946e-8, -2.7184582e-8, 5.4989418e-8, 3.5491693e-8, -2.0532338e-8,
+ -1.5851011e-8, 1.199146e-8, 1.1153341e-8, -4.0527661e-9, -2.70396e-9, 3.3976271e-10, 9.757715999999999e-10, -9.7092189e-11,
+ 1.7708423e-10, -4.9642505e-10, -3.1843656e-10, 1.6615e-10, 1.6237103e-10, -1.1900391e-10, -1.092032e-10, 4.5808636e-11,
+ 2.4606003e-11, -7.796026e-12, -5.9521785e-12, 6.0340975e-12, -4.5217706e-12, 2.8598959e-12, 2.2038568e-12, -1.4311127e-12,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.001265786, -0.0016609477, 0.00222941, 0.0011762007, -0.0073250731, -0.0034332159, 0.012471328, 0.0083430294,
+ -0.0054961577, 0.003215434, 0.0027593588, -0.025616888, -0.041455975, 0.0040184504, 0.057488632, 0.049527597,
+ 0.016124517, 0.0037132221, -0.039983743, -0.12589765, -0.1065697, 0.070258873, 0.20773562, 0.13266656,
+ -0.033268011, -0.12707599, -0.17861669, -0.18011328, 0.031979675, 0.35889134, 0.33866157, -0.13976776,
+ -0.4710648, -0.18110469, 0.29495129, 0.27613251, -0.10895966, -0.21798881, 0.044323721, 0.18667181,
+ 0.0083658499, -0.15161776, -0.06379945300000001, 0.071397486, 0.059696885, -0.014186055, -0.017375485, 0.015990851,
+ 0.005838785, -0.015281695, -0.010330521, 0.0027153303, -1.3725082e-9, 2.288355e-8, 1.1355676e-8, -8.889336600000001e-9,
+ -7.3277766e-9, 7.1743165e-9, 6.1308246e-9, -2.3901982e-9, -1.9373079e-9, 6.9554647e-10, 9.1814463e-10, -2.40284e-10,
+ -1.9481616e-11, -2.0716003e-10, -1.0771373e-10, 6.454408900000001e-11, 7.9297993e-11, -6.596152699999999e-11, -6.131494e-11, 2.3139144e-11,
+ 1.8220157e-11, -6.889387e-12, -5.2758971e-12, 4.7202158e-12, -2.698161e-12, 1.706513e-12, 1.3150514e-12, -8.5395143e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.000050159503, -0.00071212184, 0.00028363207, 0.0014615066, -0.0013267837, -0.0016433511, 0.0023330548, 0.0013382911,
+ -0.0071554962, -0.0033071427, 0.012526538, 0.0083335545, -0.0055376737, 0.0031805864, 0.0027555735, -0.025588465,
+ -0.041414908, 0.0040466304, 0.057487914, 0.049499743, 0.016086099, 0.0036837639, -0.0399912, -0.12588418,
+ -0.10654688, 0.070278005, 0.20774306, 0.13266193, -0.033279293, -0.1270871, -0.17862262, -0.18011286,
+ 0.031983838, 0.35889559, 0.33866366, -0.13976788, -0.47106632, -0.18110697, 0.29494939, 0.27613212,
+ -0.10895856, -0.21798754, 0.04432405, 0.1866715, 0.008365786, -0.15161747, -0.063799301, 0.07139735799999999,
+ 0.05969678, -0.014185963, -0.017375356, 0.015990858, 0.0058387245, -0.015281726, -0.010330507, 0.0027153486,
+ -7.4751925e-10, 1.1363937e-9, 8.6711229e-10, -3.7268833e-10, -3.6811377e-10, 2.0482729e-10, 2.0980924e-10, -7.258209800000001e-11,
+ -2.7266282e-11, -1.5979419e-11, -9.5719216e-13, 3.8460406e-12, 8.9396574e-12, -9.508538499999999e-12, -9.0540185e-12, 2.7940998e-12,
+ 3.7212707e-12, -1.5943743e-12, -1.2232114e-12, 1.0063401e-12, -4.4202812e-13, 2.7957097e-13, 2.154394e-13, -1.3989921e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00011533996, -0.000026734332, -0.00013506823, 0.00037552805, 0.000056473736, -0.00069611, 0.00030822484, 0.0014903898,
+ -0.001299667, -0.001623524, 0.0023429619, 0.0013395122, -0.0071588879, -0.0033105472, 0.012526018, 0.008336244899999999,
+ -0.0055337618, 0.0031829767, 0.0027548042, -0.025592198, -0.041419704, 0.0040431007, 0.057487257, 0.049501718,
+ 0.016089174, 0.0036863006, -0.039990188, -0.12588473, -0.10654831, 0.070276592, 0.2077423, 0.13266197,
+ -0.033278735, -0.12708649, -0.17862233, -0.18011298, 0.031983453, 0.35889516, 0.33866339, -0.13976791,
+ -0.47106621, -0.18110686, 0.29494942, 0.27613211, -0.10895856, -0.21798752, 0.044324057, 0.1866715,
+ 0.008365790600000001, -0.15161745, -0.063799281, 0.07139736200000001, 0.059696773, -0.014185967, -0.017375353, 0.015990861,
+ 0.0058387231, -0.01528173, -0.010330508, 0.0027153498, 1.2421473e-10, -1.6472405e-11, -4.5499511e-11, 4.6952921e-12,
+ -7.622754700000001e-12, 2.2440782e-11, 1.4394938e-11, -7.4419077e-12, -7.478396099999999e-12, 5.4641676e-12, 5.0064067e-12, -2.1114128e-12,
+ -1.1146915e-12, 3.5181885e-13, 2.6859057e-13, -2.7304861e-13, 2.0563143e-13, -1.3005576e-13, -1.0022199e-13, 6.5081053e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.000048301379, 0.000081244009, -0.00010202271, -0.0000527072, 0.00012665087, -0.000023161991, -0.00014073862, 0.00036301218,
+ 0.000042236451, -0.00070675058, 0.00030414781, 0.0014924293, -0.0012947379, -0.0016196213, 0.002343374, 0.0013363966,
+ -0.0071634301, -0.0033138343, 0.01252572, 0.0083387958, -0.0055300282, 0.0031859358, 0.0027557003, -0.02559331,
+ -0.041421766, 0.0040413078, 0.057486526, 0.049502138, 0.016090249, 0.0036873704, -0.039989605, -0.12588475,
+ -0.1065487, 0.070276145, 0.20774205, 0.13266197, -0.033278579, -0.12708632, -0.17862224, -0.180113,
+ 0.031983382, 0.35889508, 0.33866334, -0.13976793, -0.4710662, -0.18110685, 0.29494942, 0.27613211,
+ -0.10895856, -0.21798752, 0.044324053, 0.18667149, 0.0083657926, -0.15161745, -0.06379928, 0.07139736000000001,
+ 0.059696773, -0.014185965, -0.017375352, 0.01599086, 0.0058387226, -0.015281729, -0.010330508, 0.0027153497,
+ 8.4895945e-13, 8.9873902e-12, 4.4939672e-12, -2.8829398e-12, -3.2827318e-12, 2.8288238e-12, 2.6521985e-12, -9.600575e-13,
+ -8.4408406e-13, 3.2522644e-13, 2.4913156e-13, -2.2004175e-13, 1.2146722e-13, -7.6823174e-14, -5.920069e-14, 3.8443518e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00001049566, 0.000014942095, -0.00001798232, -0.000063966374, 0.000050491712, 0.000079338435, -0.00010824893, -0.000061723045,
+ 0.00011751212, -0.000029813667, -0.00014355097, 0.00036364052, 0.000044544686, -0.00070482097, 0.00030440767, 0.0014909545,
+ -0.0012969238, -0.0016211718, 0.0023433177, 0.0013377839, -0.0071614371, -0.0033122572, 0.012526182, 0.008338179500000001,
+ -0.0055311464, 0.0031849683, 0.0027553009, -0.0255931, -0.041421213, 0.0040418568, 0.057486821, 0.049502123,
+ 0.01609004, 0.0036871372, -0.03998973, -0.12588473, -0.1065486, 0.070276251, 0.2077421, 0.13266198,
+ -0.033278611, -0.12708636, -0.17862227, -0.180113, 0.031983384, 0.35889509, 0.33866334, -0.13976793,
+ -0.4710662, -0.18110685, 0.29494942, 0.27613211, -0.10895856, -0.21798752, 0.044324053, 0.18667149,
+ 0.0083657929, -0.15161745, -0.06379928, 0.07139736000000001, 0.059696773, -0.014185965, -0.017375352, 0.01599086,
+ 0.0058387225, -0.015281729, -0.010330508, 0.0027153497, -2.141137e-13, 1.8621291e-13, 1.7348502e-13, -6.3446602e-14,
+ -5.5329986e-14, 2.1752068e-14, 1.6668418e-14, -1.452183e-14, 7.7079643e-15, -4.8735409e-15, -3.7557779e-15, 2.4394086e-15,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000016862516, 0.0000019060019, -4.248487e-7, -0.0000047292013, 0.000010654859, 0.000014866629, -0.000018311699, -0.000064466384,
+ 0.000049972355, 0.000078950867, -0.00010842286, -0.0000617001, 0.0001176368, -0.000029701701, -0.00014352575, 0.00036357185,
+ 0.000044435351, -0.00070489915, 0.00030440706, 0.0014910288, -0.0012968196, -0.0016210916, 0.0023433373, 0.0013377465,
+ -0.0071614998, -0.0033123101, 0.012526161, 0.0083381915, -0.0055311158, 0.0031849984, 0.0027553172, -0.025593101,
+ -0.041421224, 0.0040418445, 0.057486815, 0.049502125, 0.016090047, 0.003687144, -0.039989727, -0.12588473,
+ -0.1065486, 0.070276249, 0.2077421, 0.13266197, -0.033278611, -0.12708636, -0.17862227, -0.180113,
+ 0.031983384, 0.35889509, 0.33866334, -0.13976793, -0.4710662, -0.18110685, 0.29494942, 0.27613211,
+ -0.10895856, -0.21798752, 0.044324054, 0.18667149, 0.0083657929, -0.15161745, -0.06379928, 0.07139736000000001,
+ 0.059696773, -0.014185965, -0.017375352, 0.01599086, 0.0058387225, -0.015281729, -0.010330508, 0.0027153497,
+ -9.093892299999999e-16, 1.5923447e-15, 1.2350047e-15, -5.1775324e-16, -5.9423787e-16, 3.7692653e-16, 2.903267e-16, -1.8815403e-16,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 8.5507366e-8, -0.0000012851265, 7.857136300000001e-7, -3.4801813e-7, -0.0000018684855, 0.0000017467446, -5.336318e-7, -0.0000047832847,
+ 0.000010639476, 0.00001486632, -0.000018315371, -0.000064480605, 0.000049952572, 0.000078935834, -0.0001084256, -0.000061690695,
+ 0.00011765129, -0.000029690251, -0.00014352319, 0.00036356698, 0.000044428438, -0.00070490357, 0.00030440683, 0.0014910323,
+ -0.0012968146, -0.0016210877, 0.0023433385, 0.0013377449, -0.0071615031, -0.0033123133, 0.012526159, 0.008338191300000001,
+ -0.0055311149, 0.0031849995, 0.0027553178, -0.025593101, -0.041421224, 0.0040418441, 0.057486815, 0.049502125,
+ 0.016090047, 0.0036871443, -0.039989726, -0.12588473, -0.1065486, 0.070276249, 0.2077421, 0.13266197,
+ -0.033278611, -0.12708636, -0.17862227, -0.180113, 0.031983384, 0.35889509, 0.33866334, -0.13976793,
+ -0.4710662, -0.18110685, 0.29494942, 0.27613211, -0.10895856, -0.21798752, 0.044324054, 0.18667149,
+ 0.0083657929, -0.15161745, -0.06379928, 0.07139736000000001, 0.059696773, -0.014185965, -0.017375352, 0.01599086,
+ 0.0058387225, -0.015281729, -0.010330508, 0.0027153497, -2.284982e-15, 1.4420459e-15, 1.1116432e-15, -7.2294759e-16,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -2.565031e-7, -1.0384266e-7, 3.7843906e-7, 0.0000012258276, 6.8475377e-8, -0.0000012217701, 9.2978511e-7, -1.5535891e-7,
+ -0.0000016795333, 0.0000018820924, -4.7671008e-7, -0.0000047953669, 0.000010593913, 0.000014828085, -0.000018320832, -0.000064451905,
+ 0.000049995467, 0.000078966429, -0.0001084242, -0.000061717862, 0.00011761178, -0.000029721923, -0.00014353291, 0.00036357866,
+ 0.000044450187, -0.00070488461, 0.00030441474, 0.0014910283, -0.0012968253, -0.0016210983, 0.0023433329, 0.0013377452,
+ -0.007161499, -0.0033123087, 0.012526161, 0.0083381911, -0.0055311167, 0.0031849975, 0.0027553167, -0.025593101,
+ -0.041421223, 0.0040418448, 0.057486815, 0.049502125, 0.016090047, 0.0036871442, -0.039989726, -0.12588473,
+ -0.1065486, 0.070276249, 0.2077421, 0.13266197, -0.033278611, -0.12708636, -0.17862227, -0.180113,
+ 0.031983384, 0.35889509, 0.33866334, -0.13976793, -0.4710662, -0.18110685, 0.29494942, 0.27613211,
+ -0.10895856, -0.21798752, 0.044324054, 0.18667149, 0.0083657929, -0.15161745, -0.06379928, 0.07139736000000001,
+ 0.059696773, -0.014185965, -0.017375352, 0.01599086, 0.0058387225, -0.015281729, -0.010330508, 0.0027153497,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0, 0.0, 0.0, 0.0, 2.8347963e-8, 2.2523303e-8, -4.8735247e-8, -1.1960916e-7,
+ -2.5287662e-7, -1.0870486e-7, 3.6471382e-7, 0.0000012064933, 4.9010332e-8, -0.0000012357305, 9.2436549e-7, -1.5276658e-7,
+ -0.000001674434, 0.0000018850808, -4.7547238e-7, -0.0000047991778, 0.000010587354, 0.000014826825, -0.00001832123, -0.00006445143200000001,
+ 0.000050010787, 0.000078981352, -0.00010843969, -0.000061781033, 0.00011764661, -0.000029652232, -0.00014362553, 0.00036355273,
+ 0.000044555001, -0.00070494037, 0.00030431608, 0.0014913269, -0.0012968481, -0.0016216969, 0.0023436473, 0.0013391667,
+ -0.0071627289, -0.0033138138, 0.012528415, 0.008339137700000001, -0.0055374361, 0.0031823423, 0.0027663458, -0.025586039,
+ -0.041424124, 0.0040475437, 0.057484017, 0.049470067, 0.016054175, 0.0036921246, -0.039935715, -0.12582517,
+ -0.1064918, 0.07029540300000001, 0.20762795, 0.13246998, -0.033414365, -0.12705281, -0.17833346, -0.1797243,
+ 0.032220064, 0.3587368, 0.33807475, -0.1405286, -0.47145321, -0.18066022, 0.2961133, 0.27732297,
+ -0.10855845, -0.2187329, 0.042752897, 0.18508766, 0.0077641669, -0.15053787, -0.06122282, 0.074228853,
+ 0.06099463, -0.015859301, -0.02241404, 0.008369957900000001, },
+ { 0.0, 0.0, 0.0, 0.0, 3.1104865e-11, 2.4713744e-11, -5.3474856e-11, -1.3124141e-10,
+ 2.8076073e-8, 2.240846e-8, -4.8344655e-8, -1.1830887e-7, -2.5288366e-7, -1.1009094e-7, 3.6581885e-7, 0.0000012066097,
+ 4.7227712e-8, -0.0000012339054, 9.2397559e-7, -1.5830681e-7, -0.0000016623097, 0.000001902708, -4.9736841e-7, -0.0000048746571,
+ 0.000010641936, 0.000014916903, -0.00001844127, -0.000064515498, 0.000050156285, 0.00007894542200000001, -0.00010861116, -0.000061388997,
+ 0.0001176581, -0.000030448803, -0.00014326261, 0.00036539096, 0.000043163251, -0.00070690185, 0.00030701988, 0.0014924274,
+ -0.001304832, -0.0016246302, 0.002357033, 0.0013474944, -0.0071698505, -0.0033108691, 0.012533524, 0.0083162698,
+ -0.0055818492, 0.003181139, 0.0028309669, -0.025523938, -0.041427794, 0.0040395529, 0.057468792, 0.049353567,
+ 0.015859766, 0.0037180721, -0.039555569, -0.12557329, -0.10652434, 0.070261595, 0.20734565, 0.1317388,
+ -0.03404103, -0.12662826, -0.1770882, -0.17860175, 0.032710046, 0.35856033, 0.33678034, -0.14316156,
+ -0.473647, -0.17975323, 0.30028384, 0.28157025, -0.10762441, -0.22181434, 0.037393303, 0.18007816,
+ 0.006253649, -0.14515602, -0.046992144, 0.09621433, },
+ { 0.0, 0.0, 0.0, 0.0, 4.9302209e-11, 3.9172078e-11, -8.4759363e-11, -2.0802185e-10,
+ -8.0623665e-11, 9.6317379e-11, 1.6817782e-11, 5.8283731e-10, 2.5759293e-8, 1.9418005e-8, -4.3417929e-8, -1.0682495e-7,
+ -2.5975641e-7, -1.2300478e-7, 3.8217799e-7, 0.000001218181, 4.4579459e-8, -0.0000012107338, 9.0779212e-7, -3.1709409e-7,
+ -0.0000014767929, 0.0000022412612, -9.1037095e-7, -0.0000058521315, 0.000011594129, 0.00001609105, -0.000020289796, -0.000065763475,
+ 0.000052689099, 0.00007888203399999999, -0.00011191315, -0.000056305446, 0.00011794491, -0.000041636402, -0.00013852035, 0.00039353835,
+ 0.000016087667, -0.00074771176, 0.00036439677, 0.0015550243, -0.001424237, -0.0016912016, 0.0025549356, 0.0014235625,
+ -0.0074529838, -0.0033190717, 0.012908787, 0.0082218319, -0.0061297864, 0.0033308454, 0.003480986, -0.025683031,
+ -0.041995976, 0.0044737841, 0.057981001, 0.048634771, 0.014743331, 0.0040970547, -0.037749205, -0.12495603,
+ -0.10679701, 0.070623223, 0.20681414, 0.12717576, -0.038987624, -0.12484364, -0.16903315, -0.17130917,
+ 0.036125929, 0.35914755, 0.33062642, -0.16026408, -0.49087723, -0.17615148, 0.32895563, 0.31348535,
+ -0.097420887, -0.24067157, -0.0068642378, 0.11219697, },
+ { 0.0, 0.0, 0.0, 0.0, 1.6669958e-11, 1.3244779e-11, -2.8658655e-11, -7.0335904e-11,
+ 2.2814041e-10, 2.3549011e-10, -4.3339335e-10, -8.805498899999999e-10, -1.2935862e-9, -5.515234299999999e-10, 1.8861269e-9, 7.3446094e-9,
+ 1.2543352e-8, 1.545426e-9, -1.5165886e-8, -4.9146175e-8, -2.9234586e-7, -1.7639541e-7, 4.5374829e-7, 0.0000012209487,
+ 1.2278171e-7, -9.685260999999999e-7, 6.4489216e-7, -0.0000015008025, -3.9354283e-7, 0.0000042281365, -0.0000033565057, -0.000010303686,
+ 0.000017012562, 0.000020906574, -0.00002961357, -0.000069633977, 0.000062129587, 0.000073870575, -0.00012292418, -0.00001682869,
+ 0.00010857498, -0.00011195588, -0.00009026875400000001, 0.00053011919, -0.00014608608, -0.00092560829, 0.00067049494, 0.0018019183,
+ -0.0020404998, -0.0019316755, 0.0035226148, 0.0016869094, -0.008693585, -0.0032849721, 0.014554009, 0.0078151739,
+ -0.0084537802, 0.0041605347, 0.0058665682, -0.026774198, -0.045914986, 0.0049123195, 0.063776951, 0.050441966,
+ 0.013630997, 0.0075108398, -0.037034514, -0.1403178, -0.12671833, 0.072889677, 0.2323412, 0.15268124,
+ -0.024786402, -0.12259352, -0.19576372, -0.23414639, -0.010289108, 0.39690249, 0.43370648, -0.089458844,
+ -0.50864478, -0.25076346, 0.23238368, 0.17867278, },
+ { -0.10336098, 0.43698355, -0.05205054, -0.38094273, 0.25644551, 0.2346896, -0.37978468, 0.12285758,
+ 0.11406574, -0.19346287, 0.25076721, -0.1000306, -0.21361052, 0.30863792, -0.1077896, -0.13642263,
+ 0.19131498, -0.10816236, 0.011856046, 0.073645325, -0.10939103, 0.064372891, 0.015456895, -0.058566397,
+ 0.042702958, -0.009002869700000001, -0.0076727162, 0.0096952662, -0.01108636, 0.0070343222, 0.0054298699, -0.0035153294,
+ -2.8212126e-17, 2.9364612e-17, -2.8497598e-18, -6.5598367e-18, 2.2196917e-17, -1.5966312e-17, -6.8415466e-19, 1.0256422e-17,
+ -1.0903092e-17, 6.136113e-18, 1.5503946e-18, -3.4403994e-18, 4.7292107e-18, -3.142732e-18, -1.0747554e-18, 2.4408853e-18,
+ -1.2884504e-18, 7.997105e-20, 4.4808753e-19, -5.2762049e-19, 1.8594686e-19, 1.0847923e-19, -3.3301754e-19, 1.4273141e-19,
+ 2.0535414e-19, -1.8929296e-19, 1.2177378e-20, 7.566992799999999e-20, -1.7612349e-19, 5.9536839e-20, -1.1724752e-20, -8.3718063e-20,
+ 8.1945198e-20, 1.3593323e-21, -1.0939206e-21, 2.7296664e-20, -2.9975079e-20, -5.1646176e-22, 7.0238119e-21, -1.9083712e-21,
+ 1.5417738e-21, -4.847092e-22, -6.900116e-22, 7.7780343e-22, 1.6035611e-21, -1.1671024e-21, -8.809386700000001e-22, 5.1907549e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.2381574, 0.24787821, 0.14738553, -0.31977596, -0.062372762, 0.32513857, -0.068171486, -0.31736026,
+ 0.24711974, 0.14518414, -0.30433735, 0.15030169, 0.051580316, -0.2025471, 0.24903716, -0.097704256,
+ -0.18039066, 0.29862922, -0.1263385, -0.11264106, 0.19168629, -0.12019892, 0.009955064200000001, 0.07220718399999999,
+ -0.10756871, 0.069730504, 0.014077653, -0.063847716, 0.046485607, -0.009319401499999999, -0.0075936564, 0.01014513,
+ -0.012827683, 0.008134040299999999, 0.0063368034, -0.0040889465, -0.0000063505191, 0.000006950383, -0.00001241348, 0.000007111846,
+ -0.0000064631173, 0.0000079486222, -0.0000051804315, 9.788376799999999e-7, -0.0000012868637, 0.0000029161477, -2.1119116e-7, -5.2479358e-7,
+ 1.2924158e-8, 4.5152466e-7, 5.6881144e-7, -1.4409161e-7, -1.6287584e-7, 6.6652555e-8, 1.7433987e-7, -6.663249100000001e-8,
+ 1.629114e-8, -4.3365806e-8, -8.7838571e-9, 1.3558251e-8, -8.1414893e-10, -6.6948214e-9, -7.456150700000001e-9, 8.8064106e-10,
+ 3.8271749e-9, -2.1546977e-9, -2.1125387e-9, 1.2521301e-9, -3.3478394e-10, 2.9664332e-10, 2.5333064e-10, -1.2786898e-10,
+ -8.9606122e-12, 6.8636006e-12, 6.0126818e-12, -3.2434772e-12, 1.7503469e-13, -1.4327545e-13, -1.2368103e-13, 6.4898593e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.16594546, 0.021972375, 0.21257073, -0.13795719, -0.23325892, 0.22979788, 0.13646732, -0.28662031,
+ -0.036960515, 0.3065747, -0.073102404, -0.295528, 0.23381221, 0.12263712, -0.28890599, 0.15882495,
+ 0.047578576, -0.19677918, 0.24338164, -0.098716897, -0.17095421, 0.29074244, -0.13382557, -0.10865891,
+ 0.19302541, -0.11817653, 0.01048866, 0.06894270199999999, -0.10712826, 0.071793709, 0.01314768, -0.065370729,
+ 0.046759544, -0.0084408238, -0.0072321374, 0.010164083, -0.013519027, 0.008576618899999999, 0.0066295855, -0.0042906449,
+ -9.998778500000001e-7, 0.0000015478204, -0.0000017517036, 7.332273e-7, -0.0000010317518, 0.0000016602753, -9.682844000000001e-7, 2.5190377e-7,
+ -3.2823674e-7, 5.8315547e-7, 5.514423999999999e-10, -5.4213323e-8, -7.0818943e-8, 1.1415268e-7, 9.940506e-8, -5.6015297e-8,
+ 5.7225635e-10, 2.8129944e-9, 2.4769282e-8, -5.8898787e-9, -9.4554702e-11, -6.4790772e-9, 3.0551283e-9, 2.0083669e-9,
+ -1.638693e-9, -1.0561361e-9, -1.5904414e-9, -2.499696e-10, 1.3374645e-9, -7.3325746e-10, -6.863901e-10, 4.357945e-10,
+ -1.3965471e-10, 1.0984232e-10, 9.5653262e-11, -5.1031561e-11, 1.6616273e-12, -1.3601326e-12, -1.1741202e-12, 6.1609085e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.069104323, -0.04237214, 0.10967353, 0.011282401, -0.17415051, 0.021403053, 0.21945724, -0.12028611,
+ -0.21523085, 0.23230499, 0.12991487, -0.28748783, -0.035689801, 0.30409908, -0.070474384, -0.28821646,
+ 0.23193231, 0.1174521, -0.28651538, 0.16020319, 0.046143787, -0.19745216, 0.24009639, -0.099156989,
+ -0.16726204, 0.29091257, -0.13494079, -0.10845704, 0.19287637, -0.11779632, 0.01034376, 0.06791125000000001,
+ -0.10701528, 0.07252636899999999, 0.013108627, -0.065758523, 0.046754171, -0.0082023024, -0.0071059064, 0.010140732,
+ -0.013675539, 0.008677084200000001, 0.0066982, -0.0043362722, -4.2928634e-7, 5.5762325e-7, -6.0251197e-7, 2.8545178e-7,
+ -2.4847952e-7, 3.2216043e-7, -1.1454465e-7, -9.7613984e-9, -1.4180537e-8, 6.336785500000001e-8, 3.1840419e-8, -2.378838e-8,
+ -4.0718732e-9, 1.1746141e-8, 1.8788076e-8, -7.626240800000001e-9, 9.9899638e-10, -3.5145479e-9, 3.664563e-9, 1.5251639e-9,
+ -2.2503938e-9, -1.5662936e-10, -5.6682878e-10, -5.3093496e-10, 1.0615418e-9, -6.1065908e-10, -5.6545207e-10, 3.5065135e-10,
+ -9.9709455e-11, 7.8470462e-11, 6.8324958e-11, -3.6442805e-11, 1.1691909e-12, -9.570465999999999e-13, -8.2616046e-13, 4.3350747e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.015911608, -0.027299969, 0.033186044, 0.039995417, -0.07342411, -0.041121331, 0.1163226, 0.020910495,
+ -0.16563933, 0.024714618, 0.21754715, -0.12284876, -0.2152654, 0.23413165, 0.13237649, -0.28594259,
+ -0.036907369, 0.30169717, -0.07026452499999999, -0.2863606, 0.23127057, 0.11548435, -0.28671725, 0.1606467,
+ 0.04670782, -0.19688757, 0.23957645, -0.099297892, -0.16668393, 0.29063735, -0.13529883, -0.10844124,
+ 0.19282211, -0.11760804, 0.01034761, 0.06766707499999999, -0.10697097, 0.072675087, 0.013100453, -0.065832161,
+ 0.046742062, -0.0081473039, -0.0070743643, 0.010131315, -0.013705653, 0.0086962898, 0.0067125396, -0.0043457398,
+ -8.1627608e-8, 8.543780100000001e-8, -5.3712589e-8, 1.327336e-9, 1.9107335e-9, 1.6196752e-8, 3.2215588e-9, -4.4466373e-9,
+ -2.1746539e-9, 5.3420267e-9, 5.952181e-9, -3.0205576e-9, 6.0999665e-10, -9.590371300000001e-10, 1.368256e-9, 5.2928793e-10,
+ -9.1403627e-10, 6.763270499999999e-11, -6.7608191e-11, -2.3474385e-10, 3.5310168e-10, -2.0783083e-10, -1.9147887e-10, 1.1741923e-10,
+ -3.1338961e-11, 2.4671859e-11, 2.1480394e-11, -1.1455478e-11, 3.6436943e-13, -2.9825622e-13, -2.5746655e-13, 1.3509928e-13,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00010953376, -0.0066695294, 0.002925938, 0.017851646, -0.016853728, -0.026665938, 0.035370231, 0.042794613,
+ -0.07111854500000001, -0.040033922, 0.11610379, 0.020099525, -0.16589307, 0.025495639, 0.21858618, -0.12263584,
+ -0.21596224, 0.23352451, 0.13258257, -0.28549906, -0.037093532, 0.30113508, -0.070353631, -0.28601051,
+ 0.23138871, 0.11537757, -0.28669649, 0.16070747, 0.046747369, -0.1969158, 0.2394417, -0.099292696,
+ -0.1665998, 0.29059798, -0.1353337, -0.10844426, 0.19281049, -0.1175694, 0.010342358, 0.067627653,
+ -0.1069576, 0.07269242200000001, 0.013100911, -0.065838073, 0.046735578, -0.008138709100000001, -0.0070683408, 0.010128424,
+ -0.013708364, 0.008697987799999999, 0.0067140604, -0.0043467264, 1.9622188e-9, 1.7406201e-10, -1.672447e-9, 5.4651109e-10,
+ -4.7595869e-10, 9.2437526e-10, 4.7383151e-10, -4.4720428e-10, 1.7140273e-10, -5.2404856e-11, 1.685328e-10, 6.967566999999999e-11,
+ -1.444021e-10, 4.4055443e-11, 3.0290447e-11, -4.1955458e-11, 3.608598e-11, -2.2614881e-11, -2.0559587e-11, 1.2228308e-11,
+ -2.6688281e-12, 2.1036316e-12, 1.8310149e-12, -9.7598049e-13, 3.0073196e-14, -2.4616691e-14, -2.1250116e-14, 1.1150436e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0012742472, 0.00027493115, -0.0016569906, 0.0029734957, 0.00020414488, -0.0064933966, 0.0031591306, 0.018059611,
+ -0.016689805, -0.026524664, 0.035438013, 0.042736753, -0.071193733, -0.039967886, 0.11625315, 0.02011879,
+ -0.16603009, 0.025409457, 0.21865285, -0.12256659, -0.21601375, 0.23345319, 0.13261377, -0.28543431,
+ -0.037106847, 0.30108709, -0.07034105, -0.28596614, 0.23138499, 0.11534424, -0.28669767, 0.16073009,
+ 0.046750734, -0.19693178, 0.23943261, -0.099283807, -0.16659433, 0.29059092, -0.13533815, -0.10844243,
+ 0.19281158, -0.11756903, 0.010340932, 0.067626614, -0.10695672, 0.07269291, 0.013100859, -0.065838181,
+ 0.046735249, -0.008138348300000001, -0.007068071, 0.010128278, -0.013708444, 0.0086980397, 0.006714112, -0.0043467551,
+ 7.6250582e-11, -2.4269293e-10, -4.4500305e-10, 1.6738798e-10, -1.7254536e-11, 8.666511200000001e-11, -8.2471298e-11, -3.5152726e-11,
+ 4.9015492e-11, 6.2600825e-12, 1.5877804e-11, 1.1149878e-11, -2.4816445e-11, 1.4173131e-11, 1.3144982e-11, -8.180377100000001e-12,
+ 2.3708542e-12, -1.8656596e-12, -1.6244826e-12, 8.664931e-13, -2.7867857e-14, 2.2811437e-14, 1.9691784e-14, -1.0332754e-14,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00048543251, 0.00067050041, -0.0009308460499999999, -0.00083948251, 0.001402981, 0.00026296786, -0.0018168877, 0.0027381465,
+ 0.0000065882746, -0.0065710155, 0.0031962766, 0.018128669, -0.016675065, -0.026579325, 0.035371358, 0.0427177,
+ -0.071163305, -0.039936092, 0.11625122, 0.020099619, -0.16602767, 0.025440594, 0.21867805, -0.12257452,
+ -0.21603854, 0.2334434, 0.13262307, -0.28542753, -0.037114116, 0.30108227, -0.070331567, -0.28595691,
+ 0.23138119, 0.11533681, -0.28669552, 0.16073649, 0.046750369, -0.19693692, 0.23943193, -0.09928029300000001,
+ -0.16659375, 0.29058837, -0.13533921, -0.10844109, 0.1928121, -0.11756991, 0.010340415, 0.067626916,
+ -0.10695652, 0.072692795, 0.01310069, -0.065838151, 0.046735307, -0.0081383532, -0.0070680841, 0.010128292,
+ -0.013708463, 0.0086980527, 0.0067141216, -0.0043467614, -2.102711e-11, 3.3417224e-11, -3.8409085e-11, -1.7490935e-11,
+ 2.7166852e-11, -1.5216838e-12, 2.6753955e-12, 6.9083671e-12, -1.0809558e-11, 6.3270183e-12, 5.836294e-12, -3.5887054e-12,
+ 9.731098600000001e-13, -7.6601753e-13, -6.6694169e-13, 3.5569341e-13, -1.1340318e-14, 9.282481500000001e-15, 8.012984599999999e-15, -4.2046742e-15,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00008874163200000001, 0.00017255261, -0.00020334688, -0.00048589084, 0.0005194140799999999, 0.00065162184, -0.0010030955, -0.00093500466,
+ 0.0013229135, 0.00022422489, -0.0018110625, 0.002766036, 0.000019216306, -0.0065926605, 0.0031624642, 0.018119477,
+ -0.016655318, -0.026561899, 0.035366048, 0.042705799, -0.07115904100000001, -0.039919962, 0.11625833, 0.020092471,
+ -0.16603572, 0.025440328, 0.21868056, -0.12257518, -0.2160409, 0.23344412, 0.13262646, -0.28542614,
+ -0.0371155, 0.301081, -0.070330532, -0.28595529, 0.23138086, 0.11533536, -0.28669534, 0.16073756,
+ 0.046750343, -0.19693765, 0.23943165, -0.099279878, -0.16659353, 0.29058801, -0.1353394, -0.10844095,
+ 0.19281216, -0.11756996, 0.010340352, 0.067626914, -0.10695649, 0.072692796, 0.013100678, -0.06583815,
+ 0.046735303, -0.0081383464, -0.0070680792, 0.01012829, -0.013708465, 0.0086980544, 0.006714123, -0.0043467623,
+ 4.1692516e-12, -7.121456e-13, -1.7304044e-13, 1.1302171e-12, -1.37798e-12, 8.2446267e-13, 7.569006e-13, -4.6045708e-13,
+ 1.1710488e-13, -9.2217873e-14, -8.028399700000001e-14, 4.2809906e-14, -1.3535472e-15, 1.1074076e-15, 9.559748499999999e-16, -5.0178012e-16,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 4.9186471e-7, 0.0000051461586, -0.0000052735889, -0.000074617715, 0.000090338235, 0.00016829914, -0.00021319587, -0.00049763725,
+ 0.00050951791, 0.00064579957, -0.0010036791, -0.0009315934, 0.0013254699, 0.00022183375, -0.0018160248, 0.0027645817,
+ 0.000022431098, -0.0065899474, 0.0031613131, 0.01811749, -0.016654443, -0.026559467, 0.035366631, 0.042704497,
+ -0.07115983400000001, -0.039919625, 0.11625849, 0.020092045, -0.16603593, 0.025440686, 0.21868092, -0.12257525,
+ -0.21604106, 0.23344415, 0.13262661, -0.28542607, -0.037115559, 0.30108091, -0.07033048, -0.28595519,
+ 0.23138084, 0.1153353, -0.28669535, 0.16073761, 0.046750358, -0.19693768, 0.23943163, -0.099279862,
+ -0.16659352, 0.290588, -0.13533941, -0.10844094, 0.19281216, -0.11756996, 0.010340351, 0.067626913,
+ -0.10695649, 0.072692796, 0.013100678, -0.06583815, 0.046735303, -0.008138345999999999, -0.0070680789, 0.010128289,
+ -0.013708465, 0.0086980544, 0.006714123, -0.0043467623, 2.3376946e-13, -1.3432021e-13, -1.2440416e-13, 7.7199335e-14,
+ -2.2028344e-14, 1.7343448e-14, 1.5100496e-14, -8.051784e-15, 2.6023509e-16, -2.1274301e-16, -1.8354782e-16, 9.640321599999999e-17,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000040937358, -0.0000055585317, 0.0000076082811, 0.0000085197263, -6.5244263e-7, 0.0000052950016, -0.0000037713108, -0.00007243937499999999,
+ 0.000092169031, 0.00016904946, -0.00021350235, -0.00049827953, 0.00050935188, 0.00064630511, -0.0010030326, -0.00093141393,
+ 0.0013251546, 0.00022152265, -0.0018159844, 0.0027647772, 0.000022393482, -0.0065902524, 0.0031610922, 0.018117583,
+ -0.016654221, -0.026559397, 0.035366549, 0.042704454, -0.071159768, -0.039919598, 0.11625841, 0.020091976,
+ -0.1660359, 0.025440742, 0.2186809, -0.1225753, -0.21604106, 0.23344419, 0.13262662, -0.2854261,
+ -0.037115562, 0.30108093, -0.07033047100000001, -0.2859552, 0.23138084, 0.1153353, -0.28669535, 0.1607376,
+ 0.046750357, -0.19693768, 0.23943163, -0.099279862, -0.16659352, 0.290588, -0.13533941, -0.10844094,
+ 0.19281216, -0.11756996, 0.010340351, 0.067626913, -0.10695649, 0.072692796, 0.013100678, -0.06583815,
+ 0.046735303, -0.008138345999999999, -0.0070680789, 0.010128289, -0.013708465, 0.0086980544, 0.006714123, -0.0043467623,
+ -8.131355e-15, 6.378939e-15, 5.55643e-15, -2.9687905e-15, 9.4777622e-17, -7.491754e-17, -6.5217812e-17, 3.4928497e-17,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -7.6914904e-7, -0.0000013872766, 0.0000018717906, 0.0000039601571, -0.0000043842735, -0.0000054015677, 0.000008218305099999999, 0.000009330314099999999,
+ 3.0916655e-8, 0.0000056292333, -0.0000038169114, -0.000072676369, 0.000092055843, 0.00016922368, -0.00021322119, -0.0004981985,
+ 0.00050919173, 0.00064616029, -0.00100299, -0.0009313142, 0.0013251208, 0.00022138627, -0.0018160486, 0.0027648352,
+ 0.000022464236, -0.0065902472, 0.0031610699, 0.018117587, -0.0166542, -0.026559402, 0.03536652, 0.042704441,
+ -0.071159757, -0.039919587, 0.1162584, 0.020091963, -0.1660359, 0.025440754, 0.2186809, -0.12257531,
+ -0.21604106, 0.2334442, 0.13262662, -0.2854261, -0.037115563, 0.30108093, -0.07033046900000001, -0.28595521,
+ 0.23138083, 0.1153353, -0.28669535, 0.1607376, 0.046750356, -0.19693768, 0.23943163, -0.099279862,
+ -0.16659352, 0.290588, -0.13533941, -0.10844094, 0.19281216, -0.11756996, 0.010340351, 0.067626913,
+ -0.10695649, 0.072692796, 0.013100678, -0.06583815, 0.046735303, -0.008138345999999999, -0.0070680789, 0.010128289,
+ -0.013708465, 0.0086980544, 0.006714123, -0.0043467623, 9.764870899999999e-18, -1.4718019e-17, -1.1346244e-17, 4.1658833e-18,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -1.0208573e-7, 1.3018186e-8, 1.194814e-7, 5.5588767e-7, -7.7832783e-7, -0.000001347968, 0.0000019573526, 0.0000040619503,
+ -0.0000042970883, -0.0000053486099, 0.000008225291299999999, 0.000009300481599999999, 5.6623086e-9, 0.0000056459329, -0.0000037749505, -0.000072660374,
+ 0.000092031895, 0.00016920012, -0.00021321372, -0.00049818143, 0.00050918639, 0.0006461392299999999, -0.0010029982, -0.00093130473,
+ 0.0013251297, 0.00022138567, -0.0018160509, 0.002764837, 0.000022466322, -0.0065902489, 0.0031610667, 0.018117586,
+ -0.016654199, -0.026559401, 0.035366519, 0.04270444, -0.071159756, -0.039919586, 0.1162584, 0.020091962,
+ -0.1660359, 0.025440755, 0.2186809, -0.12257531, -0.21604106, 0.2334442, 0.13262662, -0.2854261,
+ -0.037115563, 0.30108093, -0.07033046900000001, -0.28595521, 0.23138083, 0.1153353, -0.28669535, 0.1607376,
+ 0.046750356, -0.19693768, 0.23943163, -0.099279862, -0.16659352, 0.290588, -0.13533941, -0.10844094,
+ 0.19281216, -0.11756996, 0.010340351, 0.067626913, -0.10695649, 0.072692796, 0.013100678, -0.06583815,
+ 0.046735303, -0.008138345999999999, -0.0070680789, 0.010128289, -0.013708465, 0.0086980544, 0.006714123, -0.0043467623,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0, 0.0, 0.0, 0.0, 2.5759653e-8, 2.0466814e-8, -4.4285476e-8, -1.0868825e-7,
+ -9.6447646e-8, 7.1631101e-9, 1.0217806e-7, 5.3372984e-7, -7.9697132e-7, -0.0000013577621, 0.0000019572844, 0.0000040680546,
+ -0.0000042928595, -0.0000053527451, 0.000008217056199999999, 0.0000092987249, 8.7710696e-9, 0.0000056470119, -0.0000037725847, -0.00007265115,
+ 0.000092025111, 0.00016919001, -0.00021319519, -0.0004981714, 0.00050916083, 0.00064614419, -0.0010029715, -0.00093137957,
+ 0.0013251136, 0.00022150757, -0.001816076, 0.0027646198, 0.000022551485, -0.0065901118, 0.0031609105, 0.018118037,
+ -0.01665361, -0.026559824, 0.03536572, 0.042704521, -0.071159823, -0.039919898, 0.11625875, 0.020089684,
+ -0.16603036, 0.025448944, 0.21867067, -0.12260165, -0.21601898, 0.23347556, 0.13258048, -0.28544691,
+ -0.037013621, 0.30109905, -0.07049103, -0.28599544, 0.23154326, 0.11529805, -0.28686781, 0.16093501,
+ 0.047036544, -0.19708734, 0.2391103, -0.099324941, -0.16644021, 0.29049677, -0.13552768, -0.10796588,
+ 0.193457, -0.11803531, 0.0092231821, 0.0674976, -0.10592521, 0.07331246399999999, 0.012536859, -0.066336276,
+ 0.047126045, -0.0081144835, -0.0086391006, 0.0076846839, },
+ { 0.0, 0.0, 0.0, 0.0, -2.310967e-13, -1.8361323e-13, 3.9729678e-13, 9.750711799999999e-13,
+ 2.5735935e-8, 2.0447217e-8, -4.424413e-8, -1.0858931e-7, -9.6323217e-8, 7.1885059e-9, 1.020196e-7, 5.3307751e-7,
+ -7.9586216e-7, -0.0000013560898, 0.0000019547474, 0.0000040629048, -0.0000042915417, -0.0000053492893, 0.000008213601799999999, 0.0000093049104,
+ -1.7246536e-8, 0.0000056052413, -0.000003712541, -0.00007247102700000001, 0.0000919272, 0.00016897358, -0.00021294943, -0.0004979377,
+ 0.00050890982, 0.00064625727, -0.0010028059, -0.00093287896, 0.0013259411, 0.00022450974, -0.0018185077, 0.0027565327,
+ 0.000028529945, -0.0065815284, 0.0031491404, 0.018115062, -0.016634876, -0.026565874, 0.035342312, 0.042743219,
+ -0.07115894, -0.03999209, 0.11628727, 0.020224178, -0.16612642, 0.025312132, 0.21889516, -0.12262658,
+ -0.21642083, 0.23358692, 0.1330733, -0.28544717, -0.037080723, 0.30159241, -0.070810965, -0.28752889,
+ 0.23108101, 0.11569811, -0.28635917, 0.16342308, 0.049077681, -0.19783438, 0.23674534, -0.10382321,
+ -0.16979763, 0.29279912, -0.12921646, -0.10115504, 0.19504154, -0.1252006, -0.00050619406, 0.062627694,
+ -0.1038641, 0.081254391, 0.025697232, -0.045830207, },
+ { 0.0, 0.0, 0.0, 0.0, 7.9593377e-13, 6.3239315e-13, -1.3683533e-12, -3.3583002e-12,
+ -6.753506499999999e-11, -5.1069531e-11, 1.1413876e-10, 2.8886963e-10, 2.6130704e-8, 2.0529246e-8, -4.474577e-8, -1.1054977e-7,
+ -9.6160198e-8, 9.648097099999999e-9, 9.9857966e-8, 5.312347799999999e-7, -7.8437136e-7, -0.000001350296, 0.0000019393909, 0.0000040340277,
+ -0.0000042756633, -0.0000053244108, 0.0000081703425, 0.0000093387318, -1.5955554e-7, 0.0000053730519, -0.0000033880106, -0.000071543951,
+ 0.00009094828600000001, 0.00016742405, -0.00021075319, -0.0004944841499999999, 0.00050572369, 0.00064373234, -0.00099767183, -0.00093517257,
+ 0.0013226017, 0.00023579616, -0.0018202749, 0.0027128501, 0.00005199085, -0.0065177271, 0.0030889539, 0.018017381,
+ -0.016482816, -0.026474392, 0.035105113, 0.042707457, -0.070871596, -0.040071693, 0.11582208, 0.020809495,
+ -0.16571684, 0.024391395, 0.21913828, -0.1225116, -0.2170174, 0.23390508, 0.13334994, -0.28507333,
+ -0.037333319, 0.30268512, -0.071040561, -0.29189115, 0.23459309, 0.11814362, -0.29366771, 0.168199,
+ 0.055144579, -0.20517408, 0.23406798, -0.10369417, -0.16592475, 0.30024422, -0.13665322, -0.10712787,
+ 0.20336628, -0.12304478, -0.012787691, 0.034758271, },
+ { 0.0, 0.0, 0.0, 0.0, -1.2748221e-12, -1.0128842e-12, 2.1916484e-12, 5.3788837e-12,
+ 1.0921985e-10, 8.2631556e-11, -1.8461942e-10, -4.6710814e-10, -1.2157947e-9, -5.9037309e-10, 1.8031028e-9, 5.6089956e-9,
+ 2.8816076e-8, 1.7242481e-8, -4.5066022e-8, -1.2254137e-7, -1.0212736e-7, 2.8041794e-8, 8.8809173e-8, 5.15863e-7,
+ -7.6703574e-7, -0.0000013448302, 0.0000019407723, 0.0000040046758, -0.0000041631243, -0.0000052761599, 0.000007990014, 0.0000094025477,
+ -3.7236461e-7, 0.0000050912212, -0.0000031816081, -0.000070497896, 0.00009005617, 0.00016543404, -0.00020781314, -0.00049140692,
+ 0.00050388753, 0.00064366586, -0.0009956896499999999, -0.00094188997, 0.0013264845, 0.00025337108, -0.0018357686, 0.0026434454,
+ 0.00010431219, -0.0064094357, 0.0029459426, 0.017888665, -0.016208348, -0.026453452, 0.034900135, 0.042639749,
+ -0.070925263, -0.04027267, 0.11533201, 0.023882331, -0.16561734, 0.020518705, 0.22247747, -0.12340487,
+ -0.2241639, 0.23400827, 0.14119997, -0.2774529, -0.045453944, 0.30578931, -0.060811587, -0.32120566,
+ 0.22629458, 0.14143909, -0.2932926, 0.18901876, 0.059268121, -0.24117229, 0.23667102, -0.10932962,
+ -0.18469158, 0.33038169, -0.098611492, -0.050527617, },
+ { 0.0, 0.0, 0.0, 0.0, -1.1957895e-23, -9.4222313e-24, 2.0608172e-23, 5.0220109e-23,
+ 1.0491953e-22, 4.314021e-23, -1.5016783e-22, -4.9824641e-22, 1.442234e-22, 6.4439341e-22, -6.6049116e-22, -6.2852714e-22,
+ 7.7306433e-22, -1.7153432e-22, -3.6703031e-22, 2.3998726e-21, 2.3787518e-8, 1.8899893e-8, -4.089502e-8, -1.0036718e-7,
+ -9.1381028e-8, 4.773524e-9, 9.8339297e-8, 5.0264551e-7, -6.6787209e-7, -0.0000012072564, 0.0000016961125, 0.0000034579349,
+ -0.0000043011076, -0.0000049521991, 0.0000079675964, 0.000010237278, -6.1866699e-7, 0.0000026148365, -6.6753709e-7, -0.000062941151,
+ 0.00008091389800000001, 0.00015367342, -0.00019217485, -0.00046113989, 0.00047238288, 0.00061502943, -0.00093819179, -0.00095701101,
+ 0.0013112531, 0.00036070637, -0.0018631093, 0.0022451801, 0.00035463833, -0.0057958687, 0.0023086156, 0.016757115,
+ -0.014807134, -0.025281505, 0.032288107, 0.042350832, -0.06623280400000001, -0.040838204, 0.10990365, 0.024012049,
+ -0.16246351, 0.01632983, 0.21889693, -0.10804326, -0.21710906, 0.22495868, 0.13671564, -0.29314566,
+ -0.049448497, 0.30568883, -0.036034483, -0.32110046, 0.24258397, 0.18749043, -0.41990029, 0.17429974,
+ 0.14715901, -0.27307926, 0.27262049, -0.13077844, },
+ { 0.0, 0.0, 0.0, 0.0, -1.1573241e-23, -9.2381678e-24, 1.9865137e-23, 4.8930224e-23,
+ 1.1706339e-22, 5.6286956e-23, -1.7324546e-22, -5.5311775e-22, -1.6848279e-22, 4.316996e-22, -1.5922221e-22, 7.5685334e-22,
+ 3.4316913e-22, -1.7509105e-21, 1.3472139e-21, 3.3351924e-21, -4.5929126e-10, -3.6492062e-10, 7.8960427e-10, 1.9378973e-9,
+ 2.5820175e-8, 1.902087e-8, -4.3254959e-8, -1.1120419e-7, -1.2565313e-7, -8.519962999999999e-9, 1.4601723e-7, 6.3621432e-7,
+ -2.6331083e-7, -0.0000010138949, 0.00000110968, 0.0000016838337, -0.0000035744646, -0.0000026460073, 0.0000053205335, 0.000007853747200000001,
+ 8.9215155e-8, 3.1123563e-7, 0.0000013795845, -0.000044677231, 0.00006865306099999999, 0.00011781359, -0.00015710027, -0.00036064286,
+ 0.00038031484, 0.00050338751, -0.00077590559, -0.0008674142, 0.0010777226, 0.00039442868, -0.0015444235, 0.0016459382,
+ 0.00035101212, -0.0046446429, 0.0018138366, 0.01452449, -0.013180724, -0.022957383, 0.028828912, 0.041597157,
+ -0.061093708, -0.041857191, 0.10188836, 0.033085447, -0.15855498, -0.0034829442, 0.23182062, -0.090326764,
+ -0.24246823, 0.22358741, 0.14781968, -0.26594426, -0.097818221, 0.28723329, 0.07952021200000001, -0.41757914,
+ 0.21073239, 0.2897774, -0.48889789, 0.22573225, },
+ { 0.0, 0.0, 0.0, 0.0, -1.0733383e-23, -8.6079257e-24, 1.872705e-23, 4.5550867e-23,
+ 4.5417363e-23, -1.2189591e-25, -4.7937773e-23, -2.4038838e-22, 2.7755606e-22, 5.4224665e-22, -7.515297e-22, -1.4797002e-21,
+ 1.0502481e-21, 1.4065423e-21, -1.940141e-21, -6.9675157e-22, 1.4806259e-8, 1.1764015e-8, -2.5454621e-8, -6.247236e-8,
+ -1.3486342e-7, -5.8989698e-8, 1.9527931e-7, 6.419069e-7, 1.1234638e-7, -5.855622599999999e-7, 3.4054381e-7, -4.5951567e-7,
+ -0.0000013005443, 9.7272754e-7, 2.3198668e-7, -4.0989736e-7, 0.00000479093, 0.0000044838884, -0.000006090609, -0.000028617073,
+ 0.000020212565, 0.000037572762, -0.000049522919, -0.000030274147, 0.000059032777, 4.0388774e-7, -0.000078724649, 0.00008755813499999999,
+ 0.00012618231, -0.00018340068, -0.000059928571, 0.00036247195, -0.00015621759, -0.00031281978, 0.00022071986, 0.000021631567,
+ -0.0023678938, -0.0016216755, 0.0046514578, 0.0060223091, -0.0016579749, -0.0022419727, 0.00179991, -0.003098703,
+ -0.031223321, -0.015841757, 0.053425774, 0.058517397, -0.03700466, -0.026055767, 0.044009586, -0.030427122,
+ -0.17559441, -0.0033383422, 0.33021097, 0.014343156, -0.23379297, 0.10912792, 0.010642794, -0.24289997,
+ -0.17351534, 0.4024428, 0.46042496, -0.56361982, },
+ { 0.37382874, -0.51867853, 0.47943749, -0.09378391899999999, -0.18905132, 0.29135353, -0.16447188, -0.07414341200000001,
+ 0.26094242, -0.23048843, 0.053840185, 0.12786236, -0.1799737, 0.10120967, 0.0045846861, -0.07467683,
+ 0.08096257900000001, -0.039817601, -0.013746566, 0.036482493, -0.028176001, 0.009026072, 0.0074018258, -0.0070228506,
+ 0.0057997749, -0.0036799712, -0.0028406099, 0.0018390274, 1.0642048e-17, -2.3879718e-17, 1.2954511e-17, 1.4028154e-17,
+ -1.4083962e-17, 7.6461113e-18, 2.0534728e-18, -6.184756e-18, 8.647686299999999e-18, -2.4031171e-18, -3.2001736e-18, 4.6656292e-18,
+ -2.3971523e-19, 3.7425143e-20, 1.7166598e-18, -2.1279204e-19, -6.6740118e-19, 1.5729731e-19, -4.4520642e-19, -4.4010561e-19,
+ 8.861819300000001e-19, -1.5574435e-20, -1.5525456e-19, 3.1233122e-19, -3.2127869e-19, -9.465079100000001e-20, 8.2112468e-20, -6.74227e-20,
+ -2.618406e-20, 9.9322619e-20, -1.5963306e-20, -4.8528886e-20, 1.2366602e-20, -5.19528e-20, -1.0067795e-20, 3.7232067e-20,
+ -2.9793349e-20, 2.8624007e-21, 9.8584485e-21, -1.3461486e-21, 4.4190518e-21, -9.6223827e-21, -6.3801957e-21, 2.9912514e-21,
+ 3.1636145e-21, -2.3855177e-22, -4.4689007e-22, 8.2869664e-22, -7.0758818e-23, -1.2663701e-22, -7.723131e-23, -9.1997408e-24,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.03134196, -0.17628012, 0.35590505, -0.50759131, 0.53725117, -0.45869154, 0.26412691, -0.076134326,
+ -0.007651761, -0.0021413273, 0.022998087, -0.047846877, 0.055539014, -0.025170751, -0.012140822, 0.032370535,
+ -0.029020686, 0.015322765, -0.00035189435, -0.0094576725, 0.0073349447, -0.00025913263, -0.0029728115, 0.00072206717,
+ -0.00059596822, 0.0014931631, 0.00129906, -0.00046872852, -0.00047383082, 0.00030064681, 0.00023207255, -0.00015024512,
+ 8.7917553e-18, 3.9419635e-18, 5.4735481e-19, 2.4625179e-18, -3.8542589e-18, 2.3167755e-19, 1.966174e-18, -1.1347933e-18,
+ -6.7944871e-19, 4.0203463e-19, -1.9518285e-19, -2.2669119e-19, 5.6957285e-19, -3.1249475e-19, 7.4451522e-20, 2.8108751e-19,
+ -4.0423298e-19, -9.275415100000001e-21, 5.3010949e-20, -2.2545586e-20, 1.1869787e-19, -5.9328308e-20, -3.3977341e-20, 5.9668567e-20,
+ -4.12458e-21, -3.107239e-20, -1.4927732e-20, 3.7425643e-21, 1.7937482e-20, 1.4043326e-20, -7.4193836e-22, -3.6709159e-21,
+ 2.4343311e-21, -2.8813358e-22, -7.7778006e-22, -4.9534229e-22, -1.8648303e-21, 2.2475477e-21, 1.3430748e-21, -9.8408921e-22,
+ -2.0997709e-22, 5.6528297e-23, 6.807894400000001e-23, -7.0085213e-23, -6.2883165e-23, 6.8688301e-23, 5.0209405e-23, -2.238441e-23,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.030822248, 0.12957914, -0.18512573, 0.16675695, -0.052857771, -0.13908969, 0.35276876, -0.49791235,
+ 0.51417242, -0.41258809, 0.26195585, -0.11804311, 0.023964219, 0.0010232861, 0.019152748, -0.044474532,
+ 0.047642352, -0.027203395, -0.0031796077, 0.027978106, -0.033547664, 0.020082559, -0.0007510504099999999, -0.011684609,
+ 0.009989718599999999, -0.0019747698, -0.0029026379, 0.0026834211, -0.002285624, 0.0018836202, 0.0016300179, -0.00085116188,
+ -2.7174786e-17, 2.4608677e-17, -5.4277816e-18, -1.5178824e-17, 1.5015794e-17, -4.5329942e-18, 5.0668817e-18, 6.2404078e-18,
+ -9.9984244e-18, 4.9554126e-18, 1.637905e-18, -2.8010555e-18, 3.3434367e-18, -2.1472836e-18, -6.7005628e-19, 1.7342157e-18,
+ -7.3535143e-19, 3.8043225e-19, 2.1005548e-19, -4.6648549e-19, 2.3804352e-19, -6.6845216e-20, -1.9323802e-19, 6.5692847e-20,
+ 2.8876787e-20, -8.108969599999999e-21, 4.8925104e-20, 1.6282379e-20, -7.870229800000001e-20, 1.2005518e-20, -3.4489745e-21, -2.1516959e-20,
+ 2.5544882e-20, -2.6720197e-21, -6.2833653e-22, 1.1517223e-20, -9.406839299999999e-21, -2.564765e-21, 4.7206229e-22, -2.3146181e-22,
+ 1.3258513e-21, -8.4052303e-22, -7.1310092e-22, 5.6324852e-22, 5.6863617e-22, -2.894814e-22, -2.3203236e-22, 1.7479559e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.025421777, -0.067751664, 0.083134478, -0.052379526, -0.022274344, 0.12127978, -0.18958, 0.17343447,
+ -0.05080082, -0.14787227, 0.35019791, -0.48373671, 0.50542054, -0.41685964, 0.26577468, -0.11826206,
+ 0.02521028, 0.00094495453, 0.017027144, -0.043362773, 0.049765927, -0.029643921, -0.0032568805, 0.029534942,
+ -0.034563771, 0.020453298, -0.00076002331, -0.012130441, 0.010544552, -0.0022418113, -0.0031245172, 0.0028394937,
+ -0.0023731879, 0.0019425839, 0.0016769152, -0.00087992019, -5.2958493e-18, -4.0877396e-18, 2.772253e-18, -2.0311297e-18,
+ -2.288765e-18, 7.9289036e-18, 2.5284364e-18, -2.5402696e-18, 9.968205199999999e-19, -5.0944616e-19, 3.9140977e-19, 1.4230412e-18,
+ -1.2705171e-18, -6.1873396e-20, 3.8139103e-19, 1.7084439e-19, 2.5432643e-19, -3.3303833e-19, -1.4171105e-19, 4.2784771e-20,
+ 5.5757122e-20, -2.5390025e-20, -1.0232878e-19, 3.4361784e-20, 7.5020104e-20, -1.3646375e-20, 2.4618801e-20, 1.8847275e-20,
+ -5.9354063e-20, 1.3866702e-20, -4.6895811e-21, -1.278071e-20, 1.7077252e-20, -8.771959499999999e-21, 4.4899158e-22, 1.03643e-20,
+ -1.0025575e-20, -2.4458956e-21, -9.209271300000001e-22, -1.5410242e-21, 3.3222615e-21, -9.566303300000001e-22, -8.9521542e-22, 9.720106e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0071228475, 0.019049761, -0.024644883, 0.010765621, 0.023054686, -0.065592104, 0.084161342, -0.055948254,
+ -0.023192439, 0.12405666, -0.19005779, 0.17094339, -0.04939618, -0.14612657, 0.34892501, -0.48406091,
+ 0.5052392999999999, -0.41645337, 0.26618139, -0.11881742, 0.024890949, 0.0016351911, 0.017138476, -0.043848154,
+ 0.049926304, -0.02967179, -0.0032277214, 0.029567187, -0.034684308, 0.020548686, -0.00069180842, -0.012172774,
+ 0.010553003, -0.0022464053, -0.0031296428, 0.0028424184, -0.0023745904, 0.0019437318, 0.0016779062, -0.00088044017,
+ -1.8475243e-17, 1.4568058e-17, -2.0010569e-18, -1.4842759e-17, 9.308017300000001e-18, 2.7885175e-18, 1.4098213e-18, 7.8711632e-19,
+ -4.1060061e-18, 3.3844641e-18, 1.6399896e-18, -2.4498493e-18, 4.7428963e-19, 8.4630943e-19, -4.6354074e-19, -1.2947061e-19,
+ 2.8272731e-19, 1.5542018e-19, 2.3918721e-19, -2.0130475e-19, -2.9555998e-19, 2.7180211e-19, 9.5026985e-20, -2.3738958e-19,
+ 5.1395559e-20, 1.2154465e-20, 2.7573762e-20, 5.0529356e-20, -7.842936e-20, -2.2160648e-20, 1.9633519e-20, 8.7787609e-21,
+ -2.3803114e-21, -1.0067923e-20, -7.660827199999999e-21, 2.4925729e-21, 9.6896307e-21, -5.5581321e-21, -4.3914061e-21, 3.0391488e-21,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0018057424, -0.0016866646, 0.0069035273, -0.0041188241, -0.0064422689, 0.018372935, -0.025072938, 0.012034045,
+ 0.023684689, -0.066573572, 0.084151978, -0.054928148, -0.023777293, 0.12329836, -0.18937441, 0.17096458,
+ -0.049532242, -0.14576154, 0.3484839, -0.48395708, 0.50564701, -0.41694937, 0.26615718, -0.11857785,
+ 0.024683551, 0.0018054855, 0.017143896, -0.044001563, 0.050065196, -0.029716819, -0.0032594908, 0.029601577,
+ -0.034723419, 0.020572699, -0.00067340378, -0.012185211, 0.010554037, -0.0022469977, -0.0031302016, 0.0028427593,
+ -0.0023746848, 0.0019438091, 0.0016779729, -0.00088047518, -2.0693739e-17, 8.560389100000001e-18, -4.7354788e-18, -1.0263813e-17,
+ 1.0286909e-17, 2.8410305e-18, 2.8973959e-18, 3.0084238e-18, -5.0483408e-18, 6.748686e-19, 1.0579793e-18, -1.0668294e-18,
+ 7.5172508e-19, -8.7941528e-20, -3.5368006e-19, 3.726905e-19, 3.9127407e-19, -2.2086158e-19, -2.5947048e-20, -8.9091678e-20,
+ -2.4548966e-20, 1.9645497e-19, -4.8562499e-20, -1.6401124e-19, 1.1905575e-19, 6.000222099999999e-20, 3.6002571e-20, 1.1443347e-20,
+ -7.0656252e-20, 2.7338021e-20, 2.4165017e-20, -2.1090532e-20, 1.1579904e-21, -4.3668812e-22, -4.3928957e-22, 3.7120868e-22,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00068393172, -0.0023926981, 0.00072610966, 0.0010990308, -0.0018198967, -0.0019500797, 0.0070152584, -0.0036896504,
+ -0.0065067349, 0.018163296, -0.02497928, 0.011948147, 0.023789348, -0.066379495, 0.083933271, -0.054793027,
+ -0.023683757, 0.12297215, -0.18920335, 0.17105637, -0.049743734, -0.14562801, 0.34847623, -0.48400863,
+ 0.50575808, -0.41704877, 0.26614614, -0.118491, 0.024627691, 0.0018094971, 0.017148822, -0.044012176,
+ 0.050085326, -0.029729752, -0.0032694011, 0.029607998, -0.034723337, 0.020572644, -0.00067351244, -0.012185184,
+ 0.010554055, -0.0022469936, -0.0031302016, 0.0028427628, -0.0023746918, 0.0019438149, 0.0016779778, -0.00088047778,
+ -2.3067914e-17, 5.4003058e-18, -1.251809e-18, -5.2066413e-18, 7.792644200000001e-18, -3.7935423e-19, 3.7777487e-19, 3.4931246e-18,
+ -2.7529126e-18, 5.0329172e-19, 1.6457288e-19, -6.692252e-19, 9.4932395e-19, -6.4945309e-19, 1.0398817e-19, 1.9002636e-19,
+ -1.7541128e-19, -3.5753619e-20, -1.0769248e-20, -1.2646435e-19, 9.2812895e-20, -1.1354876e-19, -3.8668441e-20, 5.710273e-20,
+ -3.4373439e-20, 1.9479008e-20, 9.9343437e-21, -9.122147999999999e-21, 6.8532923e-21, -9.546463e-21, -6.5673988e-21, 2.5025079e-21,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0010687183, -0.0010450744, -0.0010070066, 0.0020253044, 0.0005517824499999999, -0.0022959155, 0.00097057671, 0.0010924508,
+ -0.0019312501, -0.0017546407, 0.0070874093, -0.0040113854, -0.006331699, 0.018446531, -0.025235592, 0.012062147,
+ 0.02384824, -0.066697913, 0.084157576, -0.054739183, -0.023923087, 0.12315927, -0.18921469, 0.17097969,
+ -0.049615501, -0.14573626, 0.34846795, -0.48391368, 0.5056902599999999, -0.41703911, 0.26615604, -0.11850642,
+ 0.02465109, 0.0017948116, 0.01713781, -0.044004865, 0.050085147, -0.029729697, -0.0032693156, 0.029607987,
+ -0.03472338, 0.020572672, -0.00067355155, -0.012185201, 0.010554082, -0.0022469952, -0.0031302068, 0.0028427695,
+ -0.0023746995, 0.0019438212, 0.0016779833, -0.00088048065, -2.1000047e-17, 7.565723700000001e-18, 2.5190234e-18, -7.738874199999999e-18,
+ 5.1613258e-18, 1.8630382e-18, 4.7500716e-18, 1.5683656e-18, -3.5332673e-18, 2.0768143e-18, -1.4987312e-18, -3.5413893e-21,
+ 2.4420979e-18, -1.345524e-18, 4.3500825e-20, 6.943662e-19, -6.1374977e-19, 1.0242197e-18, 2.718543e-20, -8.3072249e-19,
+ 5.9251615e-19, -4.9885031e-20, -4.0607809e-20, 1.0117644e-19, -2.4097676e-19, 1.301706e-19, 1.0250316e-19, -7.4365919e-20,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00056402136, 0.00021333467, -0.00091125097, 0.00036685809, 0.0010149448, -0.00096200703, -0.00094793227, 0.0018387994,
+ 0.00040516071, -0.0021710487, 0.0010161009, 0.0009399139400000001, -0.0018566059, -0.0016341052, 0.0069538839, -0.0040202907,
+ -0.0062841631, 0.018383441, -0.02517064, 0.012052401, 0.02377528, -0.066607666, 0.084161445, -0.054781921,
+ -0.02388942, 0.12313141, -0.18921571, 0.17100415, -0.049638042, -0.14572902, 0.34847456, -0.48392014,
+ 0.50569705, -0.41704335, 0.26615332, -0.11850458, 0.02465106, 0.0017948162, 0.0171379, -0.044004883,
+ 0.050085129, -0.029729696, -0.0032693338, 0.029607991, -0.034723382, 0.020572681, -0.00067355989, -0.012185204,
+ 0.010554086, -0.0022469929, -0.0031302058, 0.0028427698, -0.0023747013, 0.0019438227, 0.0016779846, -0.0008804813,
+ -9.379688700000001e-18, 2.6146403e-18, 1.5746634e-18, -1.0728369e-17, 4.5804656e-18, 7.107964500000001e-18, 2.3260764e-18, -1.9169252e-19,
+ -7.0226566e-19, -1.873713e-18, 9.4236304e-19, 4.1572967e-19, -1.2076212e-18, 7.4089255e-19, -2.6527306e-20, -6.578718e-19,
+ 8.7291408e-19, -4.7704746e-21, -8.057007799999999e-20, 1.7753254e-19, -2.2058122e-19, 7.1324509e-20, 6.6889699e-20, -6.6102385e-20,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.00014271253, 0.00023780917, -0.00025714186, -0.00024317058, 0.00057409128, 0.00023010554, -0.00093069112, 0.00027243145,
+ 0.00094306671, -0.00094563757, -0.00092816994, 0.001821437, 0.00041076611, -0.0021577244, 0.00098623583, 0.00091431244,
+ -0.0018365761, -0.0016126829, 0.0069466743, -0.0040339626, -0.0062805659, 0.018399842, -0.025165617, 0.012042197,
+ 0.023770284, -0.066603485, 0.08416202, -0.054785429, -0.023889813, 0.12313399, -0.18921405, 0.17100357,
+ -0.049638649, -0.14572867, 0.34847509, -0.48392049, 0.5056971, -0.4170434, 0.26615338, -0.11850462,
+ 0.024651084, 0.0017947992, 0.017137901, -0.044004876, 0.050085122, -0.029729693, -0.0032693353, 0.02960799,
+ -0.034723382, 0.020572683, -0.00067356152, -0.012185204, 0.010554086, -0.0022469925, -0.0031302055, 0.0028427698,
+ -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048141, -2.8978181e-17, 8.47362e-18, -4.2763004e-18, -6.8278819e-18,
+ 1.0819706e-17, 1.2087701e-18, 1.1162283e-18, 2.1511478e-18, -3.1994618e-18, 5.9178468e-19, 2.1698119e-19, -1.3697938e-18,
+ 9.570426299999999e-19, 1.7932389e-19, 9.624209700000001e-20, 1.6376431e-19, -2.5332735e-19, 9.4050075e-20, 7.611858e-20, -7.3344331e-20,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0000018447549, 0.000053840851, -0.000026051496, -0.00017560402, 0.00015359699, 0.0002298131, -0.00027785099, -0.00026917927,
+ 0.0005488749299999999, 0.00021718602, -0.00092552858, 0.0002822896, 0.00093939925, -0.00095067092, -0.00093089337, 0.0018096997,
+ 0.00041718788, -0.0021417498, 0.00097583578, 0.00090879181, -0.0018277373, -0.0016127741, 0.006949134, -0.0040349802,
+ -0.0062864137, 0.018404312, -0.025165254, 0.012038182, 0.023772235, -0.066602884, 0.084162157, -0.054785014,
+ -0.023890803, 0.1231346, -0.18921358, 0.17100325, -0.049638615, -0.1457287, 0.34847512, -0.48392051,
+ 0.50569712, -0.41704341, 0.26615339, -0.11850462, 0.024651086, 0.0017947971, 0.017137901, -0.044004875,
+ 0.050085122, -0.029729693, -0.0032693359, 0.02960799, -0.034723382, 0.020572683, -0.00067356177, -0.012185204,
+ 0.010554086, -0.0022469924, -0.0031302055, 0.0028427698, -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048143,
+ -3.6791394e-17, 4.052262e-18, -1.969778e-18, -7.0296556e-18, 9.7759458e-18, -3.3222873e-18, 4.6273224e-19, 5.2111855e-18,
+ -4.4401574e-18, -1.2256545e-18, -5.4477758e-19, -6.7353127e-19, 1.469541e-18, -4.7402283e-19, -4.2509837e-19, 4.3223452e-19,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000065232055, 3.1277378e-7, 0.0000025601527, -0.000023637333, 0.0000027834083, 0.000051419076, -0.000029530267, -0.00017738859,
+ 0.00015142412, 0.00022660426, -0.00027806924, -0.00026668364, 0.00054837847, 0.0002158698, -0.00092505622, 0.00028086916,
+ 0.00093984668, -0.00094828387, -0.00093257586, 0.0018090192, 0.00041872951, -0.0021422683, 0.00097615257, 0.00090894629,
+ -0.0018286964, -0.0016120872, 0.0069491938, -0.0040356127, -0.0062860363, 0.018404337, -0.025165282, 0.012038277,
+ 0.023772074, -0.066602783, 0.08416222499999999, -0.05478506, -0.023890801, 0.1231346, -0.18921358, 0.17100324,
+ -0.049638612, -0.1457287, 0.34847512, -0.48392051, 0.50569712, -0.41704341, 0.26615339, -0.11850462,
+ 0.024651086, 0.001794797, 0.017137901, -0.044004875, 0.050085122, -0.029729693, -0.003269336, 0.02960799,
+ -0.034723382, 0.020572683, -0.00067356178, -0.012185204, 0.010554086, -0.0022469924, -0.0031302055, 0.0028427698,
+ -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048143, -1.6713031e-17, 5.5425368e-19, 1.4245021e-18, -1.0072591e-18,
+ 5.3286569e-18, 1.4946097e-18, 2.8736484e-19, 9.387527700000001e-19, -4.2179426e-19, -9.975578300000001e-19, -5.809857e-19, -5.1089939e-20,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -0.0000010713313, -0.0000062302572, 0.0000055244516, 0.0000061175856, -0.0000071482518, 3.4513491e-9, 0.0000030429546, -0.000021759169,
+ 0.0000044190563, 0.000051269961, -0.000030117431, -0.00017718171, 0.00015149658, 0.0002263981, -0.00027757249, -0.00026613844,
+ 0.00054793064, 0.00021538327, -0.00092477868, 0.00028111234, 0.00093967287, -0.00094853506, -0.0009326781, 0.0018092101,
+ 0.00041887081, -0.0021424066, 0.00097614709, 0.00090906261, -0.0018287172, -0.0016121413, 0.0069491642, -0.0040356085,
+ -0.0062860096, 0.018404321, -0.0251653, 0.01203829, 0.023772072, -0.066602781, 0.08416222199999999, -0.054785057,
+ -0.023890803, 0.1231346, -0.18921358, 0.17100324, -0.049638612, -0.1457287, 0.34847512, -0.48392051,
+ 0.50569712, -0.41704341, 0.26615339, -0.11850462, 0.024651086, 0.001794797, 0.017137901, -0.044004875,
+ 0.050085122, -0.029729693, -0.003269336, 0.02960799, -0.034723382, 0.020572683, -0.00067356178, -0.012185204,
+ 0.010554086, -0.0022469924, -0.0031302055, 0.0028427698, -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048143,
+ -1.8941367e-17, 1.5711291e-18, 2.3452836e-18, -3.899545e-18, 3.6296061e-18, -1.9151907e-19, -4.1068595e-19, 9.915058199999999e-19,
+ 0.0, 0.0, 0.0, 0.0, },
+ { -9.0889843e-7, -2.2626776e-7, 0.000001260977, 0.0000044608021, -0.0000011469721, -0.0000059094081, 0.0000061283667, 0.0000069729643,
+ -0.000006297129, 3.7634729e-7, 0.0000029524362, -0.00002191209, 0.0000043424749, 0.000051262029, -0.000029845963, -0.00017685033,
+ 0.00015126363, 0.00022604271, -0.00027738458, -0.00026596286, 0.00054779433, 0.00021525271, -0.0009248599599999999, 0.00028119182,
+ 0.0009397919999999999, -0.00094860626, -0.00093268933, 0.001809279, 0.00041885032, -0.0021424302, 0.00097613531, 0.00090905965,
+ -0.0018287021, -0.0016121504, 0.0069491565, -0.0040356031, -0.0062860105, 0.018404322, -0.0251653, 0.01203829,
+ 0.023772071, -0.06660278, 0.08416222199999999, -0.054785057, -0.023890803, 0.1231346, -0.18921358, 0.17100324,
+ -0.049638612, -0.1457287, 0.34847512, -0.48392051, 0.50569712, -0.41704341, 0.26615339, -0.11850462,
+ 0.024651086, 0.001794797, 0.017137901, -0.044004875, 0.050085122, -0.029729693, -0.003269336, 0.02960799,
+ -0.034723382, 0.020572683, -0.00067356178, -0.012185204, 0.010554086, -0.0022469924, -0.0031302055, 0.0028427698,
+ -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048143, 6.1878754e-18, -3.6655866e-18, -2.9841768e-18, 1.9922148e-18,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 1.3144978e-7, 9.8657161e-8, -2.2253182e-7, -5.6333606e-7, -8.9434942e-7, -2.5701115e-7, 0.0000011890586, 0.0000043393418,
+ -0.0000012646187, -0.0000059468393, 0.0000061464536, 0.0000069842975, -0.000006287677, 3.8234005e-7, 0.000002913009, -0.000021955667,
+ 0.000004374943, 0.000051305901, -0.000029868643, -0.00017687301, 0.00015127913, 0.00022606239, -0.00027737419, -0.00026597498,
+ 0.00054778017, 0.00021526158, -0.00092485866, 0.00028118337, 0.00093979398, -0.00094860284, -0.00093268751, 0.0018092791,
+ 0.0004188485, -0.0021424291, 0.00097613632, 0.00090905895, -0.001828702, -0.0016121505, 0.0069491567, -0.0040356032,
+ -0.0062860104, 0.018404322, -0.0251653, 0.01203829, 0.023772071, -0.06660278, 0.08416222199999999, -0.054785057,
+ -0.023890803, 0.1231346, -0.18921358, 0.17100324, -0.049638612, -0.1457287, 0.34847512, -0.48392051,
+ 0.50569712, -0.41704341, 0.26615339, -0.11850462, 0.024651086, 0.001794797, 0.017137901, -0.044004875,
+ 0.050085122, -0.029729693, -0.003269336, 0.02960799, -0.034723382, 0.020572683, -0.00067356178, -0.012185204,
+ 0.010554086, -0.0022469924, -0.0031302055, 0.0028427698, -0.0023747016, 0.0019438229, 0.0016779848, -0.00088048143,
+ 0.0, 0.0, 0.0, 0.0, },
+ { 0.0, 0.0, 0.0, 0.0, -1.622356e-9, -1.2890103e-9, 2.7891217e-9, 6.845241e-9,
+ 1.3126578e-7, 9.901721900000001e-8, -2.2166186e-7, -5.6183755e-7, -8.9289394e-7, -2.5656308e-7, 0.0000011888122, 0.0000043391602,
+ -0.0000012647803, -0.0000059469017, 0.0000061469773, 0.0000069850389, -0.0000062879678, 3.8158828e-7, 0.0000029133662, -0.000021955518,
+ 0.0000043746943, 0.000051306159, -0.000029869367, -0.00017687376, 0.00015128051, 0.00022606404, -0.00027737624, -0.00026598254,
+ 0.00054778393, 0.00021526722, -0.00092486527, 0.00028119529, 0.00093978004, -0.0009486419, -0.00093265228, 0.0018094229,
+ 0.00041867283, -0.0021426906, 0.00097650436, 0.00090964586, -0.0018293513, -0.0016126855, 0.0069502949, -0.0040354262,
+ -0.0062870574, 0.018405222, -0.025164144, 0.012032827, 0.023774346, -0.066591942, 0.084151854, -0.054804601,
+ -0.023862503, 0.12315689, -0.1892543, 0.17095475, -0.049559377, -0.14567882, 0.3483179, -0.4838932,
+ 0.50588033, -0.41713971, 0.26600252, -0.11841888, 0.024871591, 0.0016210723, 0.016891466, -0.043640211,
+ 0.050057842, -0.03006571, -0.0030367974, 0.029556911, -0.034590027, 0.020929563, -0.0012983588, -0.012419997,
+ 0.010951201, -0.002389025, -0.0031262218, 0.0028105997, },
+ { 0.0, 0.0, 0.0, 0.0, -3.6439133e-24, -2.8986979e-24, 6.2660146e-24, 1.5379692e-23,
+ -1.6222016e-9, -1.2888876e-9, 2.7888562e-9, 6.8445893e-9, 1.312523e-7, 9.9007009e-8, -2.2163906e-7, -5.6177991e-7,
+ -8.9272771e-7, -2.5647732e-7, 0.0000011885618, 0.0000043383995, -0.0000012650025, -0.0000059463278, 0.0000061467672, 0.0000069861743,
+ -0.0000062897555, 3.7727988e-7, 0.0000029191314, -0.000021941306, 0.0000043687192, 0.000051291624, -0.000029855051, -0.00017686176,
+ 0.00015125309, 0.0002260747, -0.00027735745, -0.00026608583, 0.00054791784, 0.00021551982, -0.00092512611, 0.00028035321,
+ 0.00094065862, -0.00094742205, -0.00093450757, 0.0018076545, 0.00042131052, -0.0021417278, 0.00097239854, 0.00091159722,
+ -0.0018264239, -0.0016199728, 0.0069502154, -0.0040114121, -0.0063040316, 0.018365516, -0.025118693, 0.012102578,
+ 0.023644377, -0.066685113, 0.084356401, -0.054595596, -0.024125527, 0.12301898, -0.1887722, 0.17066016,
+ -0.050419921, -0.14528907, 0.34913412, -0.4838335, 0.50558311, -0.41643331, 0.26613447, -0.12101845,
+ 0.024625157, 0.0033560726, 0.016841212, -0.041760408, 0.050984407, -0.03285494, -0.004117546, 0.028617951,
+ -0.035237369, 0.023732977, 0.0015240184, -0.008435701800000001, },
+ { 0.0, 0.0, 0.0, 0.0, -1.0431812e-23, -8.2803737e-24, 1.7939522e-23, 4.4007904e-23,
+ 6.4884103e-23, 1.7524634e-23, -8.5803103e-23, -3.2496948e-22, -1.6203806e-9, -1.2874408e-9, 2.7857256e-9, 6.836906e-9,
+ 1.3109947e-7, 9.889150299999999e-8, -2.2138082e-7, -5.611261e-7, -8.9219889e-7, -2.5658335e-7, 0.0000011880548, 0.0000043354995,
+ -0.0000012608301, -0.000005938918, 0.0000061362301, 0.0000069641375, -0.0000062687907, 4.0459468e-7, 0.0000028787034, -0.000021983378,
+ 0.0000044129115, 0.000051289938, -0.000029905595, -0.00017666359, 0.00015087211, 0.00022542775, -0.0002765433, -0.00026376228,
+ 0.00054507147, 0.00021169912, -0.00091924555, 0.00028840249, 0.00093079662, -0.00095471267, -0.00091771013, 0.0018095019,
+ 0.00040700431, -0.0021236987, 0.0009811498199999999, 0.0008245475, -0.0017754444, -0.0014644008, 0.0068040412, -0.0043451443,
+ -0.0058442993, 0.018818003, -0.025939109, 0.011340895, 0.024930389, -0.0661234, 0.082217785, -0.054081764,
+ -0.020897545, 0.12165048, -0.1920747, 0.17211359, -0.048140833, -0.14851256, 0.3472333, -0.47646397,
+ 0.50599354, -0.42288577, 0.26917601, -0.12432367, 0.022587169, 0.010412511, 0.015359906, -0.041565257,
+ 0.055431988, -0.038165138, -0.009985203099999999, 0.018675575, },
+ { 0.0, 0.0, 0.0, 0.0, 3.2812725e-24, 2.5848368e-24, -5.6275193e-24, -1.3782151e-23,
+ -2.3902558e-23, -8.1365251e-24, 3.3008241e-23, 1.1640815e-22, -7.3250277e-23, -1.8762401e-22, 2.2730087e-22, 3.3780674e-22,
+ -1.616205e-9, -1.2841231e-9, 2.778547e-9, 6.8192879e-9, 1.3237482e-7, 9.9918388e-8, -2.2358368e-7, -5.6648665e-7,
+ -8.9932696e-7, -2.5816482e-7, 0.0000011972154, 0.0000043720435, -0.000001292952, -0.0000060081096, 0.0000062263636, 0.000007122935,
+ -0.0000063986485, 2.6724076e-7, 0.0000030929214, -0.000021946257, 0.0000047207535, 0.000052048986, -0.000030742059, -0.00018076981,
+ 0.00015544318, 0.00023291138, -0.00028644303, -0.00028176127, 0.00056447015, 0.0002311271, -0.00095483998, 0.00027379593,
+ 0.00096725386, -0.0009771671, -0.00095367853, 0.0019658873, 0.00033910824, -0.0024180526, 0.0012134667, 0.0015009697,
+ -0.0026057442, -0.0024276335, 0.0084128255, -0.0028188375, -0.008494489799999999, 0.017721873, -0.021825093, 0.010970745,
+ 0.018597655, -0.064282876, 0.08981873999999999, -0.057812995, -0.02662704, 0.12911772, -0.1885168, 0.15985436,
+ -0.050361919, -0.13554452, 0.34264685, -0.47581746, 0.51144248, -0.43326474, 0.2710083, -0.12265704,
+ 0.015729342, 0.016261307, 0.026089652, -0.029242654, },
+ { 0.0, 0.0, 0.0, 0.0, -2.2778956e-24, -1.8076424e-24, 3.9250879e-24, 9.6136326e-24,
+ 2.5282692e-23, 1.2550767e-23, -3.7660392e-23, -1.1740747e-22, -2.9437921e-23, 9.5145047e-23, -4.2770808e-23, 1.4239399e-22,
+ 1.9286708e-23, -4.034217e-22, 3.6553584e-22, 9.7305538e-22, -1.4431934e-9, -1.1466603e-9, 2.481109e-9, 6.0892965e-9,
+ 1.2633458e-7, 9.568202499999999e-8, -2.136268e-7, -5.4014939e-7, -8.7095084e-7, -2.5802661e-7, 0.000001165696, 0.000004230512,
+ -0.0000012146636, -0.0000057632352, 0.0000059410362, 0.000006652386, -0.0000059549064, 6.5404746e-7, 0.0000024605114, -0.000022134786,
+ 0.0000037026798, 0.000049710525, -0.000028167748, -0.00016723509, 0.00014401584, 0.00021121699, -0.00026020494, -0.00023896016,
+ 0.00052168195, 0.0001958936, -0.00088205854, 0.0002546882, 0.0009008995099999999, -0.00085354557, -0.00092916911, 0.0015016721,
+ 0.00054407697, -0.0017561327, 0.0006602936, 0.00048076711, -0.00071974471, -0.0009798873499999999, 0.0049969489, -0.004765169,
+ -0.0048724692, 0.017594955, -0.026661957, 0.015885895, 0.027476655, -0.070054739, 0.081437923, -0.056044498,
+ -0.027087963, 0.12330761, -0.18331454, 0.17796109, -0.049807749, -0.14814388, 0.33642099, -0.49016986,
+ 0.51434408, -0.41486443, 0.27672635, -0.10432054, },
+};
+
+const double* const ff_on2avc_tabs_20_84_1[20] = {
+ tabs_20_84[ 0], tabs_20_84[ 1], tabs_20_84[ 2], tabs_20_84[ 3],
+ tabs_20_84[ 4], tabs_20_84[ 5], tabs_20_84[ 6], tabs_20_84[ 7],
+ tabs_20_84[ 8], tabs_20_84[ 9], tabs_20_84[10], tabs_20_84[11],
+ tabs_20_84[12], tabs_20_84[13], tabs_20_84[14], tabs_20_84[15],
+ tabs_20_84[16], tabs_20_84[17], tabs_20_84[18], tabs_20_84[19]
+};
+
+const double* const ff_on2avc_tabs_20_84_2[20] = {
+ tabs_20_84[20], tabs_20_84[21], tabs_20_84[22], tabs_20_84[23],
+ tabs_20_84[24], tabs_20_84[25], tabs_20_84[26], tabs_20_84[27],
+ tabs_20_84[28], tabs_20_84[29], tabs_20_84[30], tabs_20_84[31],
+ tabs_20_84[32], tabs_20_84[33], tabs_20_84[34], tabs_20_84[35],
+ tabs_20_84[36], tabs_20_84[37], tabs_20_84[38], tabs_20_84[39]
+};
+
+const double* const ff_on2avc_tabs_20_84_3[20] = {
+ tabs_20_84[40], tabs_20_84[41], tabs_20_84[42], tabs_20_84[43],
+ tabs_20_84[44], tabs_20_84[45], tabs_20_84[46], tabs_20_84[47],
+ tabs_20_84[48], tabs_20_84[49], tabs_20_84[50], tabs_20_84[51],
+ tabs_20_84[52], tabs_20_84[53], tabs_20_84[54], tabs_20_84[55],
+ tabs_20_84[56], tabs_20_84[57], tabs_20_84[58], tabs_20_84[59]
+};
+
+const double* const ff_on2avc_tabs_20_84_4[20] = {
+ tabs_20_84[60], tabs_20_84[61], tabs_20_84[62], tabs_20_84[63],
+ tabs_20_84[64], tabs_20_84[65], tabs_20_84[66], tabs_20_84[67],
+ tabs_20_84[68], tabs_20_84[69], tabs_20_84[70], tabs_20_84[71],
+ tabs_20_84[72], tabs_20_84[73], tabs_20_84[74], tabs_20_84[75],
+ tabs_20_84[76], tabs_20_84[77], tabs_20_84[78], tabs_20_84[79]
+};
+
+const float ff_on2avc_ctab_1[2048] = {
+ 2.0, -4.4408921e-16, 1.998863, -0.067429408, 1.9954522, -0.13479699, 1.9897684, -0.20204064,
+ 1.9818133, -0.26909772, 1.9715892, -0.33590481, 1.9590992, -0.40239748, 1.9443476, -0.46851003,
+ 1.9273404, -0.5341754, 1.9080848, -0.59932488, 1.8865899, -0.66388828, 1.8628675, -0.72779351,
+ 1.8369317, -0.79096675, 1.8087995, -0.85333258, 1.7784914, -0.91481382, 1.7460314, -0.9753319,
+ 1.7114476, -1.0348068, 1.6747727, -1.0931578, 1.6360439, -1.1503029, 1.5953034, -1.2061599,
+ 1.5525988, -1.2606467, 1.5079833, -1.3136812, 1.4615158, -1.3651828, 1.4132608, -1.4150716,
+ 1.3632895, -1.4632699, 1.3116785, -1.5097026, 1.2585107, -1.5542974, 1.2038751, -1.5969861,
+ 1.1478662, -1.637704, 1.0905846, -1.6763921, 1.0321362, -1.7129962, 0.97263169, -1.7474687,
+ 0.9121868, -1.7797679, 0.85092157, -1.8098596, 0.78895974, -1.8377171, 0.72642845, -1.8633214,
+ 0.66345739, -1.8866621, 0.60017854, -1.9077374, 0.5367251, -1.9265541, 0.47323114, -1.9431282,
+ 0.4098306, -1.9574846, 0.34665683, -1.9696577, 0.28384155, -1.9796903, 0.22151428, -1.9876345,
+ 0.15980156, -1.993551, 0.09882611, -1.9975084, 0.038706206, -1.9995835, -0.02044509, -1.99986,
+ -0.078520596, -1.9984288, -0.13541964, -1.9953866, -0.19104865, -1.9908354, -0.24532171, -1.984882,
+ -0.29816103, -1.9776367, -0.34949744, -1.9692125, -0.39927062, -1.9597243, -0.44742957, -1.949288,
+ -0.49393275, -1.938019, -0.5387482, -1.9260317, -0.58185375, -1.9134382, -0.62323707, -1.900347,
+ -0.66289538, -1.8868629, -0.70083576, -1.8730848, -0.73707455, -1.8591057, -0.77163762, -1.8450115,
+ -0.80455959, -1.83088, -0.83588386, -1.8167808, -0.8656621, -1.8027737, -0.89395374, -1.7889093,
+ -0.9208256, -1.7752278, -0.94635135, -1.761759, -0.97061092, -1.7485228, -0.99368966, -1.7355278,
+ -1.0156779, -1.7227728, -1.0366703, -1.710247, -1.0567647, -1.6979295, -1.0760615, -1.6857911,
+ -1.0946627, -1.673794, -1.112671, -1.6618937, -1.1301892, -1.650039, -1.1473182, -1.6381736,
+ -1.164157, -1.6262373, -1.1808009, -1.6141669, -1.1973405, -1.6018976, -1.2138611, -1.5893645,
+ -1.2304406, -1.5765032, -1.2471493, -1.5632517, -1.2640481, -1.5495512, -1.2811878, -1.5353475,
+ -1.2986077, -1.5205914, -1.3163352, -1.5052403, -1.3343842, -1.4892588, -1.3527551, -1.4726188,
+ -1.3714331, -1.4553007, -1.390389, -1.4372933, -1.4095774, -1.4185938, -1.4289376, -1.3992081,
+ -1.4483931, -1.3791504, -1.4678518, -1.3584429, -1.4872066, -1.3371153, -1.5063359, -1.3152039,
+ -1.525104, -1.2927508, -1.5433633, -1.2698036, -1.5609542, -1.2464136, -1.5777074, -1.222635,
+ -1.5934458, -1.198524, -1.6079853, -1.1741376, -1.6211381, -1.1495321, -1.6327139, -1.1247627,
+ -1.6425229, -1.0998815, -1.6503778, -1.0749379, -1.656096, -1.0499765, -1.6595027, -1.0250366,
+ -1.6604328, -1.0001521, -1.6587337, -0.97535098, -1.6542674, -0.95065427, -1.6469128, -0.92607677,
+ -1.6365674, -0.90162659, -1.6231499, -0.87730545, -1.6066011, -0.85310918, -1.5868859, -0.82902807,
+ -1.5639942, -0.80504757, -1.5379412, -0.78114909, -1.5087692, -0.75731099, -1.4765463, -0.73350942,
+ -1.4413673, -0.70971948, -1.4033529, -0.68591642, -1.3626487, -0.66207647, -1.3194243, -0.63817829,
+ -1.2738714, -0.61420387, -1.2262026, -0.59013963, -1.1766489, -0.56597722, -1.1254574, -0.54171461,
+ -1.0728892, -0.51735634, -1.0192158, -0.49291453, -0.96471739, -0.468409, -0.90967888, -0.44386747,
+ -0.85438752, -0.41932571, -0.79912966, -0.39482722, -0.74418765, -0.37042305, -0.68983728, -0.34617117,
+ -0.63634455, -0.32213587, -0.58396345, -0.29838684, -0.53293306, -0.27499828, -0.48347571, -0.25204778,
+ -0.43579489, -0.22961509, -0.39007342, -0.20778094, -0.34647217, -0.18662569, -0.30512896, -0.16622795,
+ -0.26615775, -0.14666332, -0.22964823, -0.12800303, -0.19566566, -0.11031273, -0.1642511, -0.093651295,
+ -0.13542198, -0.078069784, -0.10917274, -0.063610479, -0.085476093, -0.050306138, -0.064284235, -0.038179338,
+ -0.04553042, -0.02724205, -0.029130703, -0.017495384, -0.014985808, -0.0089295385, -0.0029831429, -0.0015239252,
+ 0.0070011336, 0.0047524893, 0.015099987, 0.0099406661, 0.021453392, 0.014090803, 0.026206236, 0.017261485,
+ 0.029506302, 0.019518688, 0.03150234, 0.020934677, 0.032342274, 0.021586809, 0.032171525, 0.021556264,
+ 0.031131554, 0.020926755, 0.029358514, 0.019783208, 0.026982145, 0.018210486, 0.024124846, 0.016292138,
+ 0.020900913, 0.014109233, 0.017415999, 0.011739281, 0.013766737, 0.0092552658, 0.010040524, 0.0067248093,
+ 0.006315473, 0.0042094728, 0.0026604859, 0.0017642101, -0.00086453988, -0.00056303042, -0.004208413, -0.0027315477,
+ -0.0073282644, -0.0047079842, -0.010189103, -0.0064662765, -0.01276332, -0.0079874769, -0.015030168, -0.009259454,
+ -0.016975222, -0.01027649, -0.018589836, -0.01103879, -0.019870605, -0.011551925, -0.020818852, -0.011826212,
+ -0.021440107, -0.011876071, -0.02174365, -0.011719362, -0.021742038, -0.011376713, -0.021450687, -0.010870866,
+ -0.020887457, -0.010226041, -0.020072276, -0.0094673438, -0.019026764, -0.0086202007, -0.017773898, -0.0077098534,
+ -0.016337669, -0.0067608948, -0.014742769, -0.0057968628, -0.013014285, -0.0048398855, -0.011177403, -0.0039103772,
+ -0.0092571331, -0.0030267884, -0.0072780494, -0.002205404, -0.0052640433, -0.0014601871, -0.0032381038, -0.00080267049,
+ -0.0012221149, -0.00024189093, 0.00076331489, 0.00021563418, 0.0026989998, 0.00056588947, 0.0045672944, 0.00080730428,
+ 0.0063521829, 0.00094065693, 0.0080393394, 0.00096894189, 0.0096161636, 0.00089720206, 0.011071794, 0.00073232828,
+ 0.012397096, 0.00048283004, 0.013584645, 0.00015858111, 0.014628679, -0.00022945412, 0.015525063, -0.00066950807,
+ 0.016271239, -0.0011493041, 0.016866164, -0.0016563499, 0.017310271, -0.0021782229, 0.017605407, -0.0027028411,
+ 0.017754791, -0.0032187088, 0.017762953, -0.0037151384, 0.017635692, -0.0041824332, 0.017380001, -0.0046120379,
+ 0.017004017, -0.0049966443, 0.016516931, -0.0053302632, 0.015928905, -0.0056082504, 0.015250954, -0.0058273012,
+ 0.014494829, -0.0059854095, 0.013672867, -0.0060818009, 0.012797831, -0.0061168405, 0.011882732, -0.0060919276,
+ 0.010940637, -0.0060093803, 0.0099844718, -0.0058723139, 0.0090268105, -0.0056845243, 0.0080796788, -0.0054503735,
+ 0.0071543544, -0.005174689, 0.006261189, -0.0048626713, 0.0054094414, -0.0045198193, 0.0046071433, -0.0041518649,
+ 0.0038609891, -0.0037647239, 0.0031762596, -0.0033644575, 0.0025567838, -0.0029572411, 0.0020049347, -0.00254934,
+ 0.0015216633, -0.0021470881, 0.0011065686, -0.0017568644, 0.00075800065, -0.0013850661, 0.0004731935, -0.0010380755,
+ 0.00024842433, -0.00072221586, 0.00007919284, -0.00044369671, -0.000039584535, -0.00020854612, -0.0001133715, -0.000022529672,
+ -0.0001478067, 0.000108944, -0.00014850247, 0.00018093004, -0.0001208542, 0.00018906515, -0.000069866226, 0.00012969374,
+ -2.220446e-16, -5.5511151e-17, 0.000084950341, -0.00020185817, 0.00018195057, -0.00047661722, 0.00028878354, -0.0008237827,
+ 0.00040406833, -0.0012415157, 0.00052723964, -0.0017265369, 0.00065848755, -0.0022740522, 0.00079865806, -0.0028777081,
+ 0.00094911765, -0.0035295789, 0.0011115847, -0.0042201951, 0.0012879343, -0.0049386127, 0.0014799823, -0.0056725289,
+ 0.0016892579, -0.0064084502, 0.0019167721, -0.0071319067, 0.002162795, -0.0078277159, 0.0024266504, -0.0084802955,
+ 0.0027065387, -0.0090740146, 0.0029994014, -0.0095935827, 0.0033008344, -0.010024459, 0.0036050577, -0.01035328,
+ 0.003904952, -0.010568285, 0.0041921646, -0.010659733, 0.0044572824, -0.010620279, 0.0046900786, -0.01044532,
+ 0.0048798202, -0.010133266, 0.0050156307, -0.0096857436, 0.0050868993, -0.0091077117, 0.0050837183, -0.0084074708,
+ 0.0049973316, -0.0075965733, 0.0048205811, -0.0066896221, 0.0045483187, -0.0057039633, 0.0041777813, -0.0046592737,
+ 0.0037088934, -0.0035770566, 0.0031444894, -0.002480061, 0.0024904367, -0.0013916414, 0.0017556528, -0.0003350777,
+ 0.0009520037, 0.00066711544, 0.000094088718, 0.0015938688, -0.00080108939, 0.0024262008, -0.0017145583, 0.0031477951,
+ -0.0026259006, 0.0037454946, -0.00351385, 0.0042096875, -0.0043569384, 0.0045345738, -0.0051341685, 0.0047182986,
+ -0.0058256849, 0.0047629494, -0.0064134183, 0.0046744202, -0.0068816775, 0.0044621397, -0.0072176624, 0.0041386886,
+ -0.0074118823, 0.0037193133, -0.0074584596, 0.0032213603, -0.00735531, 0.0026636559, -0.0071041943, 0.0020658553,
+ -0.006710636, 0.0014477872, -0.0061837193, 0.00082882162, -0.0055357711, 0.00022728172, -0.0047819447, -0.00034007721,
+ -0.0039397213, -0.00085850636, -0.0030283579, -0.0013156059, -0.0020682951, -0.0017015649, -0.0010805541, -0.0020092935,
+ -0.000086142623, -0.0022344531, 0.00089450512, -0.0023753855, 0.0018420418, -0.0024329573, 0.0027386551, -0.0024103273,
+ 0.0035684374, -0.0023126558, 0.0043176766, -0.0021467698, 0.0049750544, -0.0019208054, 0.0055317623, -0.0016438378,
+ 0.0059815329, -0.0013255208, 0.0063205939, -0.00097574567, 0.0065475609, -0.00060433155, 0.0066632666, -0.00022075657,
+ 0.0066705542, 0.00016606481, 0.0065740347, 0.0005479547, 0.0063798288, 0.000917595, 0.0060953014, 0.0012686022,
+ 0.0057287971, 0.0015955586, 0.0052893902, 0.0018940041, 0.0047866534, 0.0021603971, 0.0042304504, 0.0023920508,
+ 0.0036307548, 0.0025870528, 0.0029974992, 0.0027441746, 0.0023404511, 0.0028627797, 0.0016691157, 0.0029427363,
+ 0.00099266251, 0.0029843359, 0.00031987071, 0.0029882274, -0.0003409097, 0.0029553634, -0.00098178594, 0.0028869633,
+ -0.0015953446, 0.0027844929, -0.0021746708, 0.0026496551, -0.0027133694, 0.0024843954, -0.0032055897, 0.0022909143,
+ -0.0036460557, 0.0020716845, -0.0040301029, 0.001829469, -0.0043537221, 0.0015673359, -0.0046136077, 0.0012886674,
+ -0.0048072096, 0.00099715649, -0.0049327859, 0.00069679262, -0.0049894531, 0.000391832, -0.0049772309, 0.000086752072,
+ -0.0048970757, -0.00021380912, -0.0047509046, -0.00050512824, -0.0045416015, -0.00078248454, -0.0042730039, -0.0010412579,
+ -0.0039498731, -0.0012770331, -0.0035778389, -0.0014857076, -0.0031633279, -0.0016635971, -0.0027134682, -0.001807537,
+ -0.0022359758, -0.0019149748, -0.0017390279, -0.0019840484, -0.0012311181, -0.0020136512, -0.00072090683, -0.0020034772,
+ -0.0002170627, -0.0019540484, 0.00027189584, -0.0018667208, 0.00073775765, -0.00174367, 0.0011727696, -0.0015878571,
+ 0.0015697783, -0.0014029766, 0.001922359, -0.0011933852, 0.0022249303, -0.00096401788, 0.0024728517, -0.00072028884,
+ 0.0026625025, -0.00046798357, 0.0027913428, -0.00021314165, 0.0028579531, 0.000038065922, 0.0028620549, 0.00027946298,
+ 0.0028045103, 0.00050499593, 0.0026873015, 0.00070886087, 0.0025134915, 0.00088562793, 0.0022871648, 0.0010303608,
+ 0.0020133494, 0.0011387296, 0.0016979213, 0.0012071145, 0.0013474913, 0.0012326987, 0.00096927787, 0.0012135465,
+ 0.00057096494, 0.001148668, 0.00016054846, 0.0010380625, -0.00025382591, 0.00088274491, -0.00066403102, 0.00068474718,
+ -0.0010621285, 0.0004470984, -0.001440537, 0.00017377918, -0.0017921957, -0.00013034795, -0.0021107141, -0.00045963225,
+ -0.0023905102, -0.00080775097, -0.0026269264, -0.0011678453, -0.0028163234, -0.0015326737, -0.002956148, -0.0018947766,
+ -0.003044971, -0.0022466506, -0.0030824956, -0.0025809242, -0.0030695351, -0.0028905307, -0.003007961, -0.0031688737,
+ -0.0029006239, -0.0034099782, -0.0027512501, -0.0036086228, -0.0025643157, -0.0037604517, -0.0023449084, -0.0038620592,
+ -0.0020985759, -0.0039110477, -0.0018311698, -0.003906057, -0.0015486911, -0.0038467669, -0.0012571397, -0.0037338703,
+ -0.00096237543, -0.0035690248, -0.00066999131, -0.003354782, -0.00038520579, -0.003094499, -0.00011277314, -0.0027922371,
+ 0.00014308578, -0.0024526515, 0.00037873242, -0.0020808775, 0.00059113972, -0.0016824141, 0.0007779033, -0.0012630108,
+ 0.00093723694, -0.00082856242, 0.0010679543, -0.00038500843, 0.0011694405, 0.000061755964, 0.0012416149, 0.00050595973,
+ 0.0012848899, 0.00094202528, 0.0013001257, 0.0013646283, 0.0012885842, 0.0017687485, 0.0012518835, 0.0021497128,
+ 0.0011919539, 0.0025032314, 0.0011109948, 0.0028254308, 0.0010114345, 0.0031128798, 0.00089589041, 0.0033626144,
+ 0.00076713093, 0.0035721601, 0.00062803685, 0.0037395512, 0.00048156266, 0.0038633479, 0.00033069632, 0.0039426503,
+ 0.00017841732, 0.0039771087, 0.000027653001, 0.0039669303, -0.00011876698, 0.0039128768, -0.00025815735, 0.0038162593,
+ -0.00038802426, 0.0036789209, -0.00050611183, 0.0035032146, -0.00061044592, 0.003291968, -0.00069937482, 0.0030484418,
+ -0.00077160395, 0.0027762763, -0.00082622346, 0.0024794317, -0.00086272735, 0.0021621194, -0.0008810226, 0.0018287286,
+ -0.00088142743, 0.0014837491, -0.00086465816, 0.0011316916, -0.00083180465, 0.00077700929, -0.00078429491, 0.0004240229,
+ -0.00072384975, 0.000076850592, -0.00065242866, -0.00026065443, -0.00057216937, -0.00058495684, -0.00048532296, -0.0008928816,
+ -0.00039418644, -0.0011816447, -0.00030103643, -0.0014488718, -0.00020806548, -0.0016926047, -0.0001173238, -0.0019112971,
+ -0.000030668409, -0.0021038, 0.000050278504, -0.0022693386, 0.00012416096, -0.0024074819, 0.00018990933, -0.0025181088,
+ 0.00024674923, -0.0026013714, 0.00029419933, -0.0026576561, 0.00033205902, -0.0026875495, 0.0003603872, -0.0026918037,
+ 0.00037947373, -0.0026713097, 0.00038980544, -0.0026270729, 0.00039202863, -0.0025601962, 0.00038691019, -0.0024718693,
+ 0.00037529902, -0.0023633612, 0.00035808972, -0.0022360198, 0.00033618973, -0.0020912744, 0.00031049116, -0.001930638,
+ 0.00028184787, -0.0017557153, 0.0002510584, -0.0015682059, 0.0002188544, -0.001369908, 0.00018589437, -0.0011627187,
+ 0.00015276202, -0.00094863074, 0.00011996848, -0.00072972412, 0.000087957334, -0.00050815433, 0.000057111374, -0.00028613486,
+ 0.000027760274, -0.00006591557, 1.8815049e-7, 0.00015024227, -0.000025359737, 0.00036009445, -0.000048671653, 0.00056144409,
+ -0.000069565853, 0.0007521729, -0.000087888977, 0.00093027257, -0.00010351629, 0.0010938746, -0.00011635367, 0.0012412785,
+ -0.0001263407, 0.0013709769, -0.0001334548, 0.0014816767, -0.0001377154, 0.001572317, -0.00013918804, 0.0016420815,
+ -0.00013798742, 0.0016904076, -0.00013427943, 0.0017169899, -0.0001282813, 0.0017217799, -0.00012026003, 0.0017049827,
+ -0.00011052855, 0.0016670482, -0.000099440098, 0.0016086611, -0.000087380431, 0.0015307277, -0.000074758427, 0.0014343602,
+ -0.000061995306, 0.0013208598, -0.000049512866, 0.0011916994, -0.000037721158, 0.0010485043, -0.000027006179, 0.00089303311,
+ -0.000017717955, 0.00072715874, -0.000010159566, 0.0005528488, -0.0000045775087, 0.00037214643, -0.0000011537802, 0.00018715112,
+};
+
+const float ff_on2avc_ctab_2[2048] = {
+ 6.1062266e-16, -0.0047176247, 0.000025801086, 0.00017171795, 0.00010278686, 0.00033237049, 0.00022971108, 0.00047108173,
+ 0.00040451737, 0.00057735282, 0.00062436966, 0.00064124417, 0.00088569394, 0.00065355049, 0.0011842304, 0.0006059666,
+ 0.0015150951, 0.00049124041, 0.0018728492, 0.00030331188, 0.0022515757, 0.000037434522, 0.0026449619, -0.00030972183,
+ 0.0030463862, -0.00073999004, 0.003449009, -0.0012536477, 0.0038458654, -0.0018493842, 0.0042299605, -0.0025242937,
+ 0.0045943661, -0.0032738955, 0.0049323193, -0.0040921802, 0.0052373176, -0.0049716844, 0.0055032219, -0.0059035895,
+ 0.0057243509, -0.0068778461, 0.005895582, -0.0078833178, 0.006012449, -0.0089079468, 0.0060712346, -0.0099389348,
+ 0.0060690674, -0.010962932, 0.0060040066, -0.01196624, 0.0058751269, -0.01293501, 0.0056825895, -0.013855449,
+ 0.0054277065, -0.014714016, 0.005112987, -0.015497606, 0.0047421698, -0.016193733, 0.0043202331, -0.016790686,
+ 0.0038533837, -0.017277677, 0.0033490176, -0.017644968, 0.0028156566, -0.017883981, 0.0022628529, -0.017987385,
+ 0.0017010663, -0.017949177, 0.0011415118, -0.017764734, 0.00059597875, -0.017430862, 0.000076625569, -0.016945831,
+ -0.00040424766, -0.016309388, -0.00083444483, -0.015522776, -0.0012021317, -0.014588747, -0.0014961021, -0.013511552,
+ -0.0017060443, -0.012296947, -0.0018228046, -0.010952174, -0.001838639, -0.0094859507, -0.0017474507, -0.0079084486,
+ -0.0015450044, -0.0062312619, -0.0012291165, -0.0044673691, -0.0007998143, -0.0026310843, -0.00025946245, -0.00073799869,
+ 0.00038714762, 0.0011950907, 0.0011327467, 0.003150264, 0.0019675777, 0.0051085735, 0.002879428, 0.007050151,
+ 0.0038537064, 0.0089543248, 0.0048735668, 0.010799746, 0.0059200767, 0.012564532, 0.0069724373, 0.014226408,
+ 0.0080082528, 0.015762862, 0.0090038506, 0.017151318, 0.0099346545, 0.018369311, 0.010775609, 0.019394677,
+ 0.011501653, 0.020205766, 0.012088243, 0.020781681, 0.012511919, 0.021102531, 0.012750908, 0.021149736,
+ 0.012785755, 0.020906361, 0.012599968, 0.020357504, 0.012180677, 0.019490732, 0.011519265, 0.018296573,
+ 0.010611986, 0.016769076, 0.0094605172, 0.014906418, 0.0080724526, 0.012711582, 0.006461692, 0.010193078,
+ 0.0046487241, 0.0073657078, 0.0026607637, 0.0042513679, 0.0005317349, 0.00087985705, -0.0016979208, -0.0027103117,
+ -0.0039816312, -0.0064711315, -0.0062672808, -0.010344372, -0.0084980074, -0.014260936, -0.010613214, -0.018140316,
+ -0.012549785, -0.02189021, -0.0142435, -0.02540629, -0.015630638, -0.028572179, -0.016649729, -0.031259675,
+ -0.017243449, -0.033329193, -0.017360613, -0.034630522, -0.016958216, -0.035003848, -0.016003506, -0.03428109,
+ -0.014476006, -0.032287523, -0.012369478, -0.028843746, -0.0096937334, -0.023767876, -0.0064762742, -0.016878078,
+ -0.0027636932, -0.0079952935, 0.0013771985, 0.0030537986, 0.0058585741, 0.016433664, 0.010571149, 0.032296669,
+ 0.015384134, 0.050779779, 0.020145604, 0.072001241, 0.024683299, 0.096057333, 0.028805861, 0.12301921,
+ 0.032304518, 0.15292998, 0.034955185, 0.18580194, 0.036520973, 0.22161427, 0.036755085, 0.26031092,
+ 0.035404034, 0.30179903, 0.032211188, 0.34594777, 0.026920509, 0.39258778, 0.019280523, 0.44151106,
+ 0.0090483893, 0.49247134, -0.004005983, 0.54518533, -0.020095825, 0.59933424, -0.039413493, 0.65456611,
+ -0.062126629, 0.71049863, -0.088374533, 0.76672238, -0.11826489, 0.82280493, -0.1518708, 0.87829489,
+ -0.18922837, 0.93272704, -0.23033462, 0.98562711, -0.27514613, 1.0365173, -0.32357812, 1.084922,
+ -0.37550423, 1.1303729, -0.43075687, 1.1724157, -0.48912829, 1.210615, -0.55037224, 1.2445599,
+ -0.61420608, 1.2738692, -0.68031394, 1.2981967, -0.74834985, 1.3172354, -0.81794167, 1.330721,
+ -0.8886956, 1.3384365, -0.96020055, 1.3402138, -1.0320334, 1.3359363, -1.1037641, 1.3255405,
+ -1.1749605, 1.3090167, -1.2451944, 1.2864087, -1.3140464, 1.257813, -1.3811105, 1.2233779,
+ -1.4460001, 1.1833013, -1.5083516, 1.1378273, -1.5678285, 1.0872437, -1.6241266, 1.0318775,
+ -1.6769751, 0.97209138, -1.7261413, 0.90827817, -1.7714316, 0.84085637, -1.8126934, 0.77026486,
+ -1.8498163, 0.69695753, -1.882732, 0.62139785, -1.9114146, 0.54405344, -1.9358792, 0.46539098,
+ -1.9561808, 0.38587096, -1.9724123, 0.3059431, -1.9847021, 0.22604167, -1.9932109, 0.14658169,
+ -1.9981292, 0.067955181, -1.9996731, -0.00947183, -1.9980807, -0.085361861, -1.9936082, -0.15940794,
+ -1.9865264, -0.23133504, -1.9771156, -0.30090088, -1.9656627, -0.36789626, -1.952457, -0.43214479,
+ -1.9377865, -0.49350214, -1.9219347, -0.55185497, -1.905178, -0.60711914, -1.8877819, -0.65923816,
+ -1.8699998, -0.70818067, -1.8520706, -0.75393814, -1.8342167, -0.79652262, -1.8166438, -0.83596373,
+ -1.7995393, -0.87230623, -1.7830721, -0.9056074, -1.7673923, -0.93593466, -1.7526317, -0.96336293,
+ -1.7389038, -0.98797268, -1.7263044, -1.0098475, -1.7149128, -1.0290729, -1.7047921, -1.0457342,
+ -1.6959906, -1.0599151, -1.6885422, -1.0716969, -1.6824687, -1.0811574, -1.677779, -1.0883702,
+ -1.6744717, -1.0934039, -1.6725357, -1.0963222, -1.67195, -1.0971831, -1.6726862, -1.0960395,
+ -1.6747082, -1.0929389, -1.6779734, -1.0879233, -1.6824325, -1.08103, -1.6880317, -1.0722916,
+ -1.6947116, -1.0617367, -1.7024086, -1.04939, -1.7110549, -1.0352732, -1.7205796, -1.0194054,
+ -1.730908, -1.0018036, -1.7419629, -0.9824838, -1.7536641, -0.96146131, -1.7659295, -0.93875134,
+ -1.7786744, -0.91437006, -1.7918122, -0.88833487, -1.8052548, -0.86066544, -1.8189124, -0.83138382,
+ -1.8326937, -0.80051541, -1.8465064, -0.76808912, -1.860257, -0.73413789, -1.8738515, -0.69869894,
+ -1.8871957, -0.66181415, -1.9001952, -0.62353003, -1.9127564, -0.58389789, -1.924787, -0.54297411,
+ -1.9361968, -0.50081998, -1.946898, -0.45750189, -1.9568071, -0.41309139, -1.9658449, -0.36766547,
+ -1.9739379, -0.32130671, -1.9810196, -0.27410358, -1.9870309, -0.22615109, -1.9919212, -0.17755121,
+ -1.9956495, -0.12841354, -1.9981841, -0.078856133, -1.9995037, -0.029006185, -1.9995972, 0.020999053,
+ -1.9984629, 0.071011581, -1.9961088, 0.12087195, -1.9925506, 0.17040877, -1.9878117, 0.21943836,
+ -1.9819202, 0.26776481, -1.9749084, 0.31518021, -1.9668094, 0.36146545, -1.9576563, 0.40639135,
+ -1.9474785, 0.44972011, -1.9363006, 0.49120751, -1.9241393, 0.53060538, -1.9110016, 0.5676645,
+ -1.8968834, 0.60213798, -1.8817675, 0.63378489, -1.8656229, 0.6623742, -1.8484042, 0.68768901,
+ -1.8300512, 0.70953059, -1.8104898, 0.7277227, -1.7896332, 0.74211556, -1.7673825, 0.75258982,
+ -1.7436302, 0.75905991, -1.718262, 0.76147729, -1.6911598, 0.75983286, -1.6622057, 0.75415885,
+ -1.6312853, 0.7445302, -1.598292, 0.73106503, -1.5631305, 0.71392417, -1.5257218, 0.69331038,
+ -1.4860063, 0.66946632, -1.4439477, 0.64267194, -1.3995371, 0.6132409, -1.3527952, 0.58151656,
+ -1.3037754, 0.54786724, -1.2525655, 0.51268071, -1.199289, 0.47635838, -1.1441054, 0.43930924,
+ -1.0872105, 0.40194324, -1.0288347, 0.36466473, -0.96924144, 0.32786602, -0.90872473, 0.2919209,
+ -0.84760505, 0.25717854, -0.7862255, 0.22395785, -0.7249468, 0.19254236, -0.66414177, 0.16317582,
+ -0.60418916, 0.13605864, -0.54546744, 0.11134519, -0.4883481, 0.089142092, -0.43318909, 0.069507554,
+ -0.38032803, 0.052451812, -0.33007616, 0.037938587, -0.28271216, 0.025887616, -0.23847705, 0.016178153,
+ -0.19756962, 0.0086534023, -0.16014262, 0.0031256941, -0.12630016, -0.00061766239, -0.096096113, -0.0028080596,
+ -0.069533631, -0.003688961, -0.046565846, -0.0035091597, -0.027097713, -0.0025161188, -0.010989046, -0.00094958977,
+ 0.0019415142, 0.00096430612, 0.011911541, 0.0030183611, 0.019169118, 0.0050287801, 0.023986517, 0.006838772,
+ 0.026653459, 0.0083211483, 0.027470166, 0.0093798656, 0.026740402, 0.0099505046, 0.0247647, 0.0099997027,
+ 0.021834008, 0.0095235975, 0.018223884, 0.0085453819, 0.014189421, 0.0071120788, 0.0099610332, 0.0052907071,
+ 0.0057411729, 0.0031639794, 0.0017020478, 0.00082572823, -0.0020156475, -0.0016237673, -0.0053030066, -0.0040823757,
+ -0.0080822473, -0.0064504636, -0.01030519, -0.0086348522, -0.011950996, -0.010552257, -0.013023298, -0.012132118,
+ -0.013546856, -0.013318742, -0.013563911, -0.014072724, -0.013130371, -0.014371663, -0.012311992, -0.014210164,
+ -0.011180677, -0.013599193, -0.0098110167, -0.012564868, -0.0082771704, -0.011146758, -0.0066501619, -0.0093958043,
+ -0.0049956408, -0.0073719709, -0.0033721365, -0.0051417369, -0.0018298116, -0.0027755348, -0.00040969814, -0.00034523915,
+ 0.00085661822, 0.0020782049, 0.0019469126, 0.004426945, 0.002847892, 0.0066381125, 0.0035544888, 0.0086554019,
+ 0.0040689427, 0.010430313, 0.0043997411, 0.011923047, 0.0045604752, 0.013103063, 0.0045686788, 0.013949312,
+ 0.0044446858, 0.014450175, 0.0042105624, 0.014603134, 0.0038891311, 0.014414242, 0.0035031161, 0.01389739,
+ 0.0030744188, 0.01307346, 0.0026235317, 0.011969374, 0.0021690836, 0.010617082, 0.0017275107, 0.009052542,
+ 0.0013128433, 0.0073146918, 0.00093659078, 0.0054444592, 0.0006077115, 0.0034838144, 0.00033265035, 0.0014748911,
+ 0.00011543075, -0.00054083008, -0.000042213407, -0.0025232558, -0.00014067636, -0.0044343388, -0.00018229883, -0.0062386589,
+ -0.00017117237, -0.0079039233, -0.00011293451, -0.0094013978, -0.000014556788, -0.010706257, 0.00011587302, -0.011797872,
+ 0.00026937437, -0.012660023, 0.00043630364, -0.013281046, 0.0006065903, -0.013653914, 0.00076997973, -0.013776246,
+ 0.00091628113, -0.013650244, 0.0010356199, -0.013282579, 0.0011186899, -0.012684184, 0.0011570023, -0.011869996,
+ 0.0011431255, -0.010858623, 0.0010709089, -0.0096719572, 0.00093568477, -0.0083347168, 0.00073444104, -0.0068739466,
+ 0.00046595652, -0.0053184745, 0.00013089461, -0.0036983292, -0.00026815146, -0.002044142, -0.00072666444, -0.00038653665,
+ -0.001238263, 0.0012444736, -0.0017948141, 0.0028200729, -0.0023865986, 0.0043131965, -0.0030025232, 0.0056990399,
+ -0.0036303743, 0.0069555123, -0.0042571067, 0.0080636218, -0.0048691588, 0.0090077901, -0.0054527833, 0.0097760875,
+ -0.0059943851, 0.010360379, -0.0064808549, 0.010756395, -0.0068998942, 0.010963713, -0.0072403145, 0.010985666,
+ -0.0074923136, 0.010829174, -0.0076477141, 0.010504506, -0.0077001643, 0.010024985, -0.0076453011, 0.0094066458,
+ -0.0074808616, 0.0086678378, -0.0072067594, 0.0078288056, -0.0068251076, 0.0069112377, -0.0063402043, 0.0059377975,
+ -0.0057584713, 0.0049316445, -0.0050883559, 0.0039159562, -0.004340189, 0.0029134497, -0.0035260066, 0.0019459217,
+ -0.002659336, 0.001033804, -0.0017549467, 0.00019574871, -0.00082857109, -0.00055175176, 0.00010340517, -0.0011947021,
+ 0.0010242764, -0.0017218908, 0.0019173701, -0.0021251177, 0.0027664138, -0.0023993575, 0.0035559093, -0.0025428517,
+ 0.0042715017, -0.0025571233, 0.0049003414, -0.0024469129, 0.0054314188, -0.0022200351, 0.0058558695, -0.0018871534,
+ 0.0061672316, -0.0014614828, 0.0063616517, -0.00095842173, 0.0064380248, -0.00039512504, 0.0063980608, 0.00020997033,
+ 0.0062462785, 0.00083765347, 0.0059899129, 0.0014684666, 0.005638747, 0.0020832333, 0.0052048638, 0.0026635726,
+ 0.0047023292, 0.0031923822, 0.0041468102, 0.0036542746, 0.0035551451, 0.0040359539, 0.0029448776, 0.0043265228,
+ 0.0023337679, 0.0045177112, 0.0017393016, 0.0046040174, 0.001178207, 0.0045827716, 0.00066600286, 0.0044541075,
+ 0.00021658542, 0.004220861, -0.0001581293, 0.0038883933, -0.0004484996, 0.0034643558, -0.00064738019, 0.0029584002,
+ -0.00075026811, 0.0023818521, -0.000755371, 0.0017473593, -0.00066359824, 0.0010685247, -0.00047847957, 0.00035953996,
+ -0.00020601597, -0.00036517272, 0.00014552828, -0.0010913002, 0.00056588452, -0.0018049506, 0.001043079, -0.0024929349,
+ 0.0015637625, -0.0031430104, 0.0021135611, -0.003744086, 0.0026774362, -0.0042863889, 0.0032400466, -0.0047615874,
+ 0.0037861052, -0.0051628826, 0.0043007191, -0.005485056, 0.0047697132, -0.0057244869, 0.0051799244, -0.00587914,
+ 0.0055194702, -0.0059485212, 0.0057779811, -0.0059336093, 0.005946802, -0.0058367676, 0.006019149, -0.0056616301,
+ 0.0059902342, -0.0054129749, 0.0058573456, -0.0050965813, 0.0056198868, -0.0047190739, 0.0052793743, -0.0042877593,
+ 0.0048393975, -0.0038104532, 0.0043055299, -0.0032953112, 0.0036852097, -0.0027506526, 0.0029875766, -0.002184795,
+ 0.0022232747, -0.0016058958, 0.0014042265, -0.0010218052, 0.00054337748, -0.00043993912, -0.00034557868, 0.00013282956,
+ -0.0012484904, 0.00069025467, -0.0021510462, 0.0012267748, -0.0030390718, 0.0017375433, -0.0038988206, 0.0022184309,
+ -0.0047172462, 0.0026660003, -0.0054822522, 0.0030774584, -0.0061829095, 0.0034505837, -0.0068096397, 0.0037836414,
+ -0.0073543512, 0.004075285, -0.0078105354, 0.0043244553, -0.008173313, 0.0045302799, -0.0084394356, 0.0046919878,
+ -0.0086072432, 0.004808831, -0.0086765829, 0.00488004, -0.0086486926, 0.0049047922, -0.0085260663, 0.004882222,
+ -0.0083122877, 0.0048114532, -0.0080118719, 0.0046916641, -0.0076300949, 0.0045221797, -0.0071728369, 0.0043025846,
+ -0.0066464432, 0.0040328531, -0.0060576024, 0.0037134863, -0.0054132543, 0.0033456483, -0.0047205254, 0.0029312912,
+ -0.0039866935, 0.0024732621, -0.0032191742, 0.0019753794, -0.0024255351, 0.0014424763, -0.001613521, 0.0008803992,
+ -0.00079109054, 0.00029596357, 0.00003354808, -0.00030313883, 0.00085190887, -0.00090847781, 0.001655216, -0.0015110652,
+ 0.0024344153, -0.0021015715, 0.0031802151, -0.002670571, 0.0038831618, -0.0032088049, 0.00453375, -0.0037074534,
+ 0.0051225699, -0.0041584023, 0.0056404881, -0.0045544938, 0.0060788556, -0.0048897523, 0.0064297421, -0.0051595722,
+ 0.0066861785, -0.005360858, 0.006842406, -0.0054921173, 0.0068941191, -0.0055534914, 0.0068386863, -0.0055467347,
+ 0.0066753477, -0.0054751309, 0.0064053647, -0.005343359, 0.0060321307, -0.0051573105, 0.0055612195, -0.0049238643,
+ 0.0050003757, -0.0046506319, 0.0043594413, -0.0043456783, 0.0036502162, -0.0040172371, 0.002886259, -0.0036734226,
+ 0.0020826256, -0.0033219547, 0.0012555593, -0.002969909, 0.00042213459, -0.0026234936, -0.0004001323, -0.0022878707,
+ -0.0011936954, -0.0019670199, -0.0019414022, -0.0016636539, -0.0026269152, -0.0013791855, -0.0032351194, -0.0011137482,
+ -0.0037525038, -0.00086626812, -0.0041675051, -0.00063458277, -0.0044708052, -0.00041560392, -0.0046555689, -0.00020551546,
+};
+
+const float ff_on2avc_ctab_3[2048] = {
+ -1.6653345e-16, -0.0028429052, -0.000042537456, 0.00019487554, -0.00016862253, 0.00040306276, -0.00037372447, 0.00063729816,
+ -0.0006504606, 0.00090918731, -0.00098884385, 0.0012286865, -0.0013766177, 0.0016036412, -0.0017996682, 0.0020393939,
+ -0.0022425, 0.0025384782, -0.0026887599, 0.0031004087, -0.0031217942, 0.0037215743, -0.0035252157, 0.0043952391,
+ -0.0038834687, 0.0051116538, -0.0041823699, 0.005858277, -0.0044096061, 0.0066200914, -0.0045551774, 0.0073800222,
+ -0.0046117627, 0.0081194276, -0.0045750043, 0.0088186627, -0.0044436962, 0.0094576869, -0.0042198659, 0.010016704,
+ -0.0039087553, 0.010476815, -0.0035186927, 0.010820654, -0.0030608606, 0.011033002, -0.002548967, 0.011101345,
+ -0.001998829, 0.011016356, -0.0014278793, 0.010772308, -0.00085461611, 0.01036737, -0.00029800553, 0.0098037962,
+ 0.00022313831, 0.0090879966, 0.00069077854, 0.0082304832, 0.001088266, 0.0072456878, 0.0014009145, 0.0061516552,
+ 0.0016165223, 0.0049696299, 0.0017258222, 0.0037235275, 0.0017228439, 0.002439322, 0.0016051769, 0.0011443575,
+ 0.0013741244, -0.0001333931, 0.0010347385, -0.001366102, 0.00059573731, -0.0025268681, 0.00006930346, -0.0035904851,
+ -0.00052923308, -0.0045341686, -0.001181817, -0.0053382241, -0.0018681852, -0.0059866291, -0.0025664624, -0.0064675175,
+ -0.0032538211, -0.0067735398, -0.0039071804, -0.0069020987, -0.0045039295, -0.0068554399, -0.0050226445, -0.0066406005,
+ -0.0054437858, -0.0062692142, -0.0057503423, -0.0057571726, -0.0059284149, -0.0051241596, -0.0059677036, -0.0043930644,
+ -0.0058618966, -0.003589293, -0.0056089377, -0.0027400018, -0.0052111652, -0.0018732708, -0.0046753148, -0.0010172459,
+ -0.0040123845, -0.00019927412, -0.0032373657, 0.00055493839, -0.0023688413, 0.0012221204, -0.0014284686, 0.0017821564,
+ -0.00044035583, 0.00221871, 0.00056964607, 0.0025197288, 0.0015747172, 0.002677816, 0.0025478832, 0.0026904519,
+ 0.003462845, 0.0025600623, 0.0042947996, 0.0022939243, 0.0050212229, 0.0019039178, 0.0056225881, 0.0014061241,
+ 0.0060830046, 0.00082028762, 0.0063907388, 0.00016915375, 0.0065386193, -0.00052229298, 0.0065242914, -0.0012276688,
+ 0.0063503282, -0.001920081, 0.00602418, -0.0025730385, 0.0055579683, -0.0031613547, 0.0049681277, -0.0036620118,
+ 0.0042749047, -0.0040549575, 0.0035017261, -0.0043238075, 0.0026744606, -0.0044564288, 0.0018205947, -0.0044453838,
+ 0.00096834335, -0.0042882231, 0.00014573456, -0.0039876048, -0.0006203127, -0.003551251, -0.0013048799, -0.0029917257,
+ -0.0018858829, -0.0023260501, -0.0023448193, -0.0015751625, -0.0026674026, -0.00076324248, -0.0028440619, 0.000083084451,
+ -0.0028702877, 0.00093562948, -0.00274681, 0.0017655863, -0.0024796019, 0.002544506, -0.0020797059, 0.0032452703,
+ -0.001562885, 0.0038430272, -0.00094911043, 0.0043160599, -0.00026189955, 0.0046465569, 0.00047247464, 0.0048212567,
+ 0.001225878, 0.0048319423, 0.0019692846, 0.0046757692, 0.0026737878, 0.0043554134, 0.0033116213, 0.0038790288,
+ 0.0038571535, 0.0032600202, 0.0042878226, 0.0025166313, 0.0045849765, 0.0016713619, 0.004734592, 0.00075023499,
+ 0.0047278423, -0.00021806663, 0.0045614946, -0.0012031641, 0.0042381193, -0.0021740133, 0.003766102, -0.0030999696,
+ 0.0031594534, -0.0039518503, 0.0024374237, -0.0047029546, 0.0016239271, -0.0053300103, 0.00074679783, -0.0058140075,
+ -0.00016310361, -0.0061408947, -0.0010729014, -0.0063021071, -0.0019488039, -0.0062949071, -0.0027572513, -0.0061225249,
+ -0.0034660769, -0.0057940902, -0.0040456373, -0.0053243539, -0.0044698785, -0.0047332067, -0.0047172923, -0.0040450124,
+ -0.0047717378, -0.0032877706, -0.0046230876, -0.0024921419, -0.0042676828, -0.0016903625, -0.0037085724, -0.00091508962,
+ -0.0029555273, -0.0001982145, -0.0020248254, 0.00043031544, -0.00093881134, 0.00094362238, 0.00027475748, 0.0013189322,
+ 0.0015835584, 0.0015384787, 0.0029517193, 0.001590244, 0.0043409695, 0.0014685061, 0.005711888, 0.001174171,
+ 0.0070252069, 0.0007148743, 0.0082431259, 0.00010484495, 0.0093305949, -0.00063546957, 0.010256512, -0.0014800054,
+ 0.010994808, -0.0023978967, 0.011525363, -0.0033544756, 0.01183473, -0.0043124277, 0.011916637, -0.0052330629,
+ 0.011772243, -0.0060776612, 0.011410139, -0.0068088472, 0.010846091, -0.0073919417, 0.010102529, -0.0077962507,
+ 0.0092077944, -0.0079962341, 0.0081951711, -0.0079725226, 0.0071017356, -0.0077127367, 0.0059670559, -0.0072120731,
+ 0.0048317886, -0.0064736474, 0.0037362196, -0.0055085579, 0.0027188035, -0.0043356786, 0.0018147465, -0.0029811764,
+ 0.001054692, -0.0014777631, 0.00046354943, 0.00013628764, 0.000059517231, 0.0018183383, -0.00014666733, 0.0035227551,
+ -0.00015221786, 0.0052024024, 0.000037492653, 0.0068102139, 0.00040901723, 0.008300784, 0.00094121607, 0.0096319281,
+ 0.0016059257, 0.010766147, 0.002368897, 0.011671957, 0.0031909735, 0.012325018, 0.0040294742, 0.012709031,
+ 0.0048397309, 0.012816358, 0.0055767358, 0.012648351, 0.0061968337, 0.01221535, 0.0066594072, 0.011536373,
+ 0.0069284872, 0.010638482, 0.0069742394, 0.0095558539, 0.0067742579, 0.0083285747, 0.0063146283, 0.0070012063,
+ 0.0055907099, 0.0056211669, 0.0046076039, 0.0042369836, 0.0033802853, 0.0028964775, 0.0019333874, 0.0016449478,
+ 0.00030063081, 0.00052342116, -0.0014760793, -0.0004329654, -0.0033478751, -0.0011963865, -0.0052604238, -0.0017474962,
+ -0.0071556596, -0.0020762917, -0.0089736925, -0.0021826318, -0.010654833, -0.0020763816, -0.012141662, -0.0017771672,
+ -0.013381075, -0.0013137354, -0.014326238, -0.00072293397, -0.014938361, -0.000048335231, -0.015188256, 0.00066145579,
+ -0.015057592, 0.0013547561, -0.014539802, 0.0019789573, -0.013640625, 0.0024828047, -0.012378214, 0.002818716,
+ -0.01078283, 0.0029450601, -0.0088961152, 0.0028283037, -0.0067699435, 0.0024449378, -0.0044648955, 0.0017831039,
+ -0.002048397, 0.00084384187, 0.00040742956, -0.00035810683, 0.0028281235, -0.0017939941, 0.0051393877, -0.0034212973,
+ 0.0072696419, -0.0051845112, 0.0091525484, -0.0070165028, 0.010729411, -0.0088404194, 0.011951371, -0.010572106,
+ 0.01278131, -0.012122994, 0.013195385, -0.013403381, 0.013184131, -0.01432602, 0.01275308, -0.014809915,
+ 0.011922853, -0.01478422, 0.010728708, -0.01419212, 0.0092195272, -0.012994564, 0.0074562789, -0.011173738,
+ 0.0055099544, -0.0087361531, 0.0034590533, -0.0057152319, 0.0013866695, -0.0021732997, -0.00062274013, 0.0017971178,
+ -0.0024868115, 0.0060727512, -0.0041288515, 0.010499856, -0.0054814275, 0.014895321, -0.0064898543, 0.019048614,
+ -0.0071154684, 0.022724561, -0.0073385658, 0.025666898, -0.0071609118, 0.027602537, -0.0066077164, 0.028246468,
+ -0.0057289964, 0.027307168, -0.004600253, 0.0244924, -0.0033224206, 0.019515269, -0.0020210496, 0.012100382,
+ -0.00084472145, 0.0019899437, 0.000037296293, -0.01105034, 0.00043811565, -0.027225735, 0.00015696014, -0.046707455,
+ -0.0010165154, -0.069628276, -0.0032974123, -0.096078917, -0.0069003948, -0.12610528, -0.01203424, -0.15970659,
+ -0.018896269, -0.19683464, -0.027666792, -0.23739384, -0.038503725, -0.28124255, -0.051537503, -0.32819515,
+ -0.06686642, -0.3780252, -0.084552586, -0.43046936, -0.10461849, -0.48523226, -0.12704438, -0.54199159,
+ -0.15176651, -0.60040426, -0.17867628, -0.66011244, -0.20762028, -0.72074997, -0.23840135, -0.7819488,
+ -0.27078056, -0.8433454, -0.30448011, -0.90458667, -0.33918688, -0.96533567, -0.37455717, -1.0252765,
+ -0.41022155, -1.0841192, -0.44579068, -1.1416026, -0.48086143, -1.1974978, -0.51502305, -1.2516102,
+ -0.54786384, -1.3037796, -0.57897753, -1.3538816, -0.60796958, -1.4018263, -0.63446349, -1.4475567,
+ -0.65810603, -1.4910469, -0.67857265, -1.5322988, -0.6955719, -1.571339, -0.70884931, -1.6082149,
+ -0.71819037, -1.6429906, -0.72342294, -1.6757429, -0.72441858, -1.7065566, -0.72109336, -1.7355207,
+ -0.71340775, -1.7627244, -0.70136583, -1.7882535, -0.68501353, -1.8121873, -0.664437, -1.8345959,
+ -0.63975936, -1.8555384, -0.61113822, -1.8750609, -0.5787617, -1.8931965, -0.54284513, -1.9099646,
+ -0.50362706, -1.9253712, -0.46136531, -1.9394104, -0.41633323, -1.9520659, -0.36881575, -1.9633123,
+ -0.31910598, -1.9731183, -0.26750168, -1.9814487, -0.21430217, -1.9882675, -0.15980564, -1.9935409,
+ -0.1043066, -1.9972394, -0.048093725, -1.9993412, 0.0085518388, -1.9998351, 0.06535802, -1.9987217,
+ 0.12206294, -1.9960158, 0.17841578, -1.9917485, 0.23417741, -1.9859674, 0.28912079, -1.978738,
+ 0.34303114, -1.9701437, 0.39570591, -1.9602853, 0.44695485, -1.9492812, 0.49659961, -1.9372654,
+ 0.54447347, -1.924387, 0.59042108, -1.9108082, 0.63429779, -1.8967023, 0.6759693, -1.8822519,
+ 0.71531093, -1.8676466, 0.7522071, -1.8530809, 0.78655046, -1.8387512, 0.81824118, -1.8248546,
+ 0.84718591, -1.8115855, 0.87329692, -1.799134, 0.89649087, -1.7876834, 0.91668761, -1.7774082,
+ 0.93380904, -1.7684723, 0.94777751, -1.7610264, 0.95851475, -1.7552065, 0.96594018, -1.7511318,
+ 0.96996975, -1.7489027, 0.9705146, -1.7485988, 0.96748, -1.7502769, 0.96076453, -1.7539688,
+ 0.95025921, -1.7596794, 0.93584764, -1.7673841, 0.91740602, -1.7770265, 0.8948037, -1.788517,
+ 0.86790472, -1.8017294, 0.83656931, -1.8164997, 0.80065662, -1.8326236, 0.76002777, -1.8498554,
+ 0.71454966, -1.8679065, 0.66409934, -1.8864441, 0.60856909, -1.9050918, 0.54787195, -1.9234295,
+ 0.48194784, -1.9409947, 0.41076976, -1.9572846, 0.33435044, -1.9717588, 0.25274888, -1.9838443,
+ 0.16607688, -1.9929391, 0.07450521, -1.9984198, -0.021730689, -1.999648, -0.12232572, -1.9959785,
+ -0.22690098, -1.9867691, -0.33500072, -1.9713904, -0.44609061, -1.9492363, -0.55955714, -1.9197356,
+ -0.67470908, -1.8823639, -0.79077995, -1.8366553, -0.90693277, -1.7822139, -1.0222664, -1.718726,
+ -1.1358232, -1.64597, -1.2465994, -1.5638269, -1.3535558, -1.4722892, -1.4556309, -1.3714676,
+ -1.5517555, -1.2615976, -1.6408671, -1.1430426, -1.7219268, -1.016296, -1.7939352, -0.88198137,
+ -1.8559498, -0.7408486, -1.9071014, -0.59376967, -1.9466108, -0.44173092, -1.9738038, -0.28582337,
+ -1.9881259, -0.12723051, -1.9891552, 0.032785702, -1.976613, 0.19290088, -1.9503736, 0.35174593,
+ -1.9104701, 0.50792599, -1.8570991, 0.6600405, -1.7906219, 0.80670393, -1.7115632, 0.94656676,
+ -1.6206069, 1.0783361, -1.518589, 1.2007964, -1.4064881, 1.3128283, -1.2854123, 1.4134272,
+ -1.1565856, 1.5017194, -1.0213295, 1.5769756, -0.8810457, 1.6386244, -0.73719448, 1.6862605,
+ -0.5912739, 1.7196511, -0.44479746, 1.7387406, -0.2992714, 1.74365, -0.15617253, 1.734675,
+ -0.016926099, 1.7122809, 0.11711492, 1.677093, 0.24468948, 1.629887, 0.36464623, 1.5715742,
+ 0.47595924, 1.5031863, 0.57774144, 1.4258577, 0.66925532, 1.3408059, 0.74992096, 1.2493112,
+ 0.81932145, 1.1526958, 0.87720448, 1.0523019, 0.92348218, 0.94947082, 0.95822722, 0.84552169,
+ 0.98166639, 0.74173182, 0.99417198, 0.63931787, 0.99625009, 0.53941888, 0.98852777, 0.44308114,
+ 0.97173774, 0.35124525, 0.94670212, 0.2647354, 0.91431493, 0.18425134, 0.87552404, 0.11036279,
+ 0.83131295, 0.04350647, 0.78268248, -0.016014282, 0.7306332, -0.068027422, 0.67614836, -0.11248776,
+ 0.62017834, -0.1494704, 0.56362599, -0.17916223, 0.50733423, -0.20185167, 0.45207494, -0.21791716,
+ 0.39854008, -0.22781442, 0.34733471, -0.2320631, 0.29897237, -0.23123281, 0.25387216, -0.22592908,
+ 0.21235825, -0.21677956, 0.17466106, -0.20442055, 0.14092025, -0.1894843, 0.11118954, -0.17258726,
+ 0.085442781, -0.15431944, 0.06358128, -0.13523506, 0.04544213, -0.11584474, 0.030807279, -0.096609004,
+ 0.01941302, -0.077933475, 0.010959785, -0.060165603, 0.005121904, -0.043592878, 0.0015571543, -0.028442509,
+ -0.000084115498, -0.014882491, -0.00015046289, -0.003023857, 0.0010184186, 0.0070759403, 0.0030985889, 0.01540874,
+ 0.0057877772, 0.022010626, 0.0088102622, 0.026956297, 0.011920679, 0.030353062, 0.014906751, 0.032334596,
+ 0.017590966, 0.033054668, 0.019831251, 0.032680977, 0.021520695, 0.031389244, 0.022586443, 0.029357675,
+ 0.022987815, 0.026761938, 0.02271381, 0.023770688, 0.021780089, 0.020541752, 0.020225555, 0.017218968,
+ 0.018108679, 0.013929741, 0.015503671, 0.010783297, 0.012496619, 0.0078696031, 0.0091816904, 0.0052589499,
+ 0.0056575048, 0.0030021123, 0.0020237456, 0.0011310551, -0.0016219205, -0.00033990419, -0.0051865601, -0.0014125451,
+ -0.0085842935, -0.0021028898, -0.011738192, -0.0024391229, -0.01458175, -0.0024593701, -0.017059926, -0.002209408,
+ -0.019129775, -0.001740378, -0.020760702, -0.0011065705, -0.021934342, -0.00036333143, -0.022644157, 0.00043485823,
+ -0.022894738, 0.0012360946, -0.022700895, 0.0019925251, -0.022086568, 0.0026615674, -0.021083612, 0.0032068638,
+ -0.019730492, 0.0035989694, -0.018070942, 0.0038157802, -0.01615262, 0.0038427161, -0.014025783, 0.0036726766,
+ -0.011742038, 0.0033057902, -0.0093531534, 0.0027489865, -0.0069099898, 0.0020154165, -0.0044615306, 0.0011237526,
+ -0.0020540373, 0.000097393946, 0.00026966495, -0.0010363915, 0.0024707811, -0.002247364, 0.0045150127, -0.0035032234,
+ 0.0063729058, -0.0047705099, 0.0080200844, -0.0060154819, 0.0094373813, -0.0072049443, 0.010610872, -0.0083070258,
+ 0.011531814, -0.0092918845, 0.012196518, -0.010132339, 0.01260614, -0.010804415, 0.012766409, -0.011287811,
+ 0.012687304, -0.011566276, 0.01238268, -0.011627889, 0.011869849, -0.011465268, 0.011169123, -0.011075674,
+ 0.010303336, -0.010461045, 0.0092973243, -0.009627942, 0.0081774024, -0.0085874097, 0.00697082, -0.0073547787,
+ 0.0057052155, -0.0059493748, 0.0044080694, -0.0043941792, 0.0031061731, -0.0027154128, 0.0018251112, -0.00094207097,
+ 0.00058877678, 0.00089459657, -0.00058107794, 0.0027616499, -0.0016652432, 0.0046250583, -0.0026473978, 0.0064503294,
+ -0.0035143902, 0.0082031535, -0.0042564487, 0.0098500587, -0.004867312, 0.011359059, -0.0053442805, 0.012700289,
+ -0.0056881784, 0.013846606, -0.005903231, 0.014774157, -0.005996861, 0.015462888, -0.0059794001, 0.015896989,
+ -0.0058637299, 0.01606526, -0.0056648538, 0.015961399, -0.0053994185, 0.01558418, -0.0050851903, 0.014937551,
+ -0.0047405036, 0.014030606, -0.0043836995, 0.012877463, -0.0040325602, 0.011497032, -0.0037037728, 0.0099126762,
+ -0.0034124162, 0.0081517817, -0.0031715068, 0.0062452359, -0.0029916021, 0.0042268233, -0.0028804804, 0.002132565,
+};
+
+const float ff_on2avc_ctab_4[2048] = {
+ 0.0, 1.9999924, -0.0000058932724, -0.00018632905, -0.000023430526, -0.00036967263, -0.000052186413, -0.00054710143,
+ -0.000091459828, -0.00071579742, -0.00014028551, -0.00087310647, -0.00019745006, -0.0010165883, -0.00026151221, -0.0011440613,
+ -0.00033082708, -0.0012536434, -0.00040357397, -0.0013437853, -0.00047778775, -0.0014132988, -0.00055139291, -0.0014613763,
+ -0.0006222403, -0.0014876042, -0.00068814593, -0.0014919674, -0.00074693147, -0.0014748453, -0.00079646555, -0.0014370022,
+ -0.00083470601, -0.0013795681, -0.00085974159, -0.001304013, -0.00086983346, -0.0012121156, -0.00086345506, -0.0011059257,
+ -0.00083932967, -0.00098772196, -0.00079646567, -0.00085996656, -0.00073418743, -0.0007252564, -0.00065216236, -0.00058627356,
+ -0.00055042218, -0.00044573518, -0.0004293785, -0.00030634343, -0.00028983151, -0.00017073752, -0.00013297109, -0.000041447816,
+ 0.000039629722, 0.000079147045, 0.00022602957, 0.00018885947, 0.00042394208, 0.00028572831, 0.00063076714, 0.0003680501,
+ 0.00084363052, 0.00043440601, 0.0010594303, 0.00048368447, 0.0012748899, 0.0005150995, 0.0014866164, 0.0005282049,
+ 0.0016911632, 0.00052290427, 0.0018850935, 0.00049945683, 0.0020650467, 0.00045847919, 0.0022278025, 0.00040094266,
+ 0.0023703419, 0.00032816609, 0.0024899046, 0.00024180381, 0.0025840413, 0.0001438281, 0.0026506572, 0.00003650627,
+ 0.0026880486, -0.000077628843, 0.002694932, -0.00019581451, 0.0026704618, -0.00031510059, 0.002614242, -0.00043239864,
+ 0.0025263282, -0.0005445375, 0.0024072223, -0.00064832467, 0.0022578605, -0.00074061239, 0.0020795963, -0.00081836781,
+ 0.0018741783, -0.00087874458, 0.0016437257, -0.0009191549, 0.0013906998, -0.00093733944, 0.0011178757, -0.0009314327,
+ 0.0008283116, -0.00090002158, 0.0005253178, -0.00084219524, 0.0002124242, -0.00075758353, -0.00010665277, -0.00064638274,
+ -0.0004280459, -0.00050936721, -0.00074777508, -0.00034788603, -0.0010617886, -0.00016384445, -0.0013660089, 0.000040329032,
+ -0.0016563823, 0.00026172952, -0.001928934, 0.0004970344, -0.0021798278, 0.00074257207, -0.0024054295, 0.00099439803,
+ -0.0026023739, 0.0012483762, -0.0027676339, 0.0015002612, -0.0028985876, 0.0017457816, -0.0029930845, 0.0019807185,
+ -0.0030495061, 0.0022009795, -0.0030668175, 0.0024026663, -0.0030446108, 0.002582133, -0.0029831338, 0.0027360369,
+ -0.0028833048, 0.0028613801, -0.0027467103, 0.0029555426, -0.002575587, 0.0030163093, -0.0023727834, 0.0030418884,
+ -0.0021417083, 0.0030309267, -0.00188626, 0.0029825219, -0.001610745, 0.0028962295, -0.0013197823, 0.0027720702,
+ -0.0010182032, 0.002610537, -0.00071094313, 0.0024125993, -0.00040293398, 0.0021797076, -0.000098998527, 0.0019137961,
+ 0.00019625042, 0.0016172826, 0.0004785021, 0.0012930647, 0.00074382918, 0.00094451016, 0.00098875654, 0.00057544146,
+ 0.0012103159, 0.00019011059, 0.0014060856, -0.00020683407, 0.0015742163, -0.00061039196, 0.0017134408, -0.001015265,
+ 0.0018230709, -0.0014159229, 0.0019029821, -0.0018066789, 0.0019535855, -0.0021817745, 0.0019757913, -0.0025354712,
+ 0.0019709636, -0.002862151, 0.0019408683, -0.0031564159, 0.0018876162, -0.0034131943, 0.0018136023, -0.003627843,
+ 0.0017214427, -0.0037962461, 0.0016139107, -0.0039149108, 0.0014938725, -0.0039810524, 0.0013642251, -0.0039926702,
+ 0.0012278357, -0.0039486135, 0.001087485, -0.0038486305, 0.0009458157, -0.0036934058, 0.00080528553, -0.0034845807,
+ 0.00066812726, -0.0032247561, 0.0005363166, -0.0029174781, 0.00041154691, -0.0025672072, 0.00029521331, -0.0021792662,
+ 0.00018840475, -0.0017597722, 0.000091904491, -0.0013155513, 0.0000061986657, -0.00085403392, -0.000068508154, -0.00038313636,
+ -0.00013227122, 0.000088872715, -0.00018537903, 0.00055351778, -0.00022832313, 0.0010022718, -0.00026176605, 0.0014267182,
+ -0.0002865085, 0.0018187162, -0.00030345729, 0.002170566, -0.00031359497, 0.0024751695, -0.00031795207, 0.0027261837,
+ -0.0003175826, 0.0029181617, -0.00031354246, 0.0030466772, -0.00030687143, 0.0031084325, -0.00029857742, 0.0031013431,
+ -0.00028962348, 0.0030245974, -0.00028091561, 0.0028786955, -0.00027329178, 0.0026654552, -0.00026751086, 0.0023879989,
+ -0.00026424107, 0.0020507087, -0.0002640482, 0.0016591615, -0.0002673828, 0.0012200392, -0.00027456757, 0.00074101909,
+ -0.00028578506, 0.00023064682, -0.00030106661, -0.00030180693, -0.00032028355, -0.00084650156, -0.00034314199, -0.0013931919,
+ -0.00036918154, -0.0019314003, -0.00039777948, -0.002450594, -0.00042816071, -0.0029403649, -0.00045941351, -0.0033906079,
+ -0.00049051136, -0.0037916978, -0.00052034017, -0.0041346624, -0.00054773013, -0.0044113463, -0.00057149079, -0.0046145683,
+ -0.00059044833, -0.0047382633, -0.00060348323, -0.0047776136, -0.00060956669, -0.0047291601, -0.00060779473, -0.0045908964,
+ -0.00059741817, -0.0043623378, -0.00057786785, -0.0040445696, -0.00054877391, -0.0036402657, -0.00050997949, -0.0031536825,
+ -0.00046154787, -0.0025906207, -0.0004037637, -0.0019583604, -0.00033712928, -0.0012655669, -0.00026235546, -0.0005221676,
+ -0.0001803489, 0.00026079561, -0.000092195645, 0.0010713381, 8.5773814e-7, 0.001896725, 0.000097425305, 0.0027236806,
+ 0.00019600448, 0.0035386102, 0.00029500009, 0.0043278327, 0.00039274961, 0.0050778165, 0.00048754914, 0.0057754163,
+ 0.00057768018, 0.0064081079, 0.00066143664, 0.0069642127, 0.00073715224, 0.0074331141, 0.00080322672, 0.0078054559,
+ 0.00085815141, 0.0080733243, 0.00090053247, 0.0082304087, 0.00092911115, 0.0082721328, 0.00094278029, 0.0081957681,
+ 0.0009405961, 0.0080005014, 0.00092178461, 0.0076874876, 0.00088574266, 0.0072598509, 0.00083203381, 0.0067226603,
+ 0.00076037919, 0.0060828608, 0.00067064527, 0.0053491686, 0.0005628299, 0.0045319302, 0.00043704818, 0.0036429393,
+ 0.00029352194, 0.0026952275, 0.00013257378, 0.0017028196, -0.000045370962, 0.00068046764, -0.00023977279, -0.00035663525,
+ -0.00044995558, -0.0013931503, -0.00067507266, -0.0024138922, -0.00091406191, -0.0034041218, -0.0011655915, -0.0043498254,
+ -0.0014279993, -0.0052379691, -0.0016992289, -0.0060567264, -0.0019767685, -0.0067956652, -0.0022575972, -0.0074458965,
+ -0.0025381455, -0.0080001755, -0.0028142736, -0.0084529584, -0.0030812761, -0.0088004144, -0.0033339155, -0.0090403967,
+ -0.0035664875, -0.0091723735, -0.0037729202, -0.0091973282, -0.0039469078, -0.0091176452, -0.0040820716, -0.0089369677,
+ -0.004172151, -0.0086600557, -0.0042112102, -0.0082926471, -0.0041938564, -0.0078413244, -0.0041154595, -0.0073133917,
+ -0.0039723613, -0.0067167743, -0.0037620636, -0.0060599349, -0.0034833867, -0.0053518065, -0.0031365866, -0.0046017431,
+ -0.0027234256, -0.0038194789, -0.002247188, -0.0030150977, -0.001712642, -0.0021989932, -0.0011259451, -0.0013818274,
+ -0.00049449678, -0.00057446648, 0.00017325579, 0.00021210148, 0.0008680491, 0.00096687989, 0.0015800633, 0.0016790066,
+ 0.0022991966, 0.0023379293, 0.0030153422, 0.0029336107, 0.0037186535, 0.0034567595, 0.0043997848, 0.0038990804,
+ 0.0050500971, 0.0042535327, 0.0056618182, 0.0045145866, 0.0062281508, 0.0046784664, 0.006743324, 0.0047433623,
+ 0.0072025894, 0.0047096047, 0.0076021603, 0.0045797802, 0.0079391068, 0.0043587871, 0.0082112048, 0.004053812,
+ 0.0084167644, 0.0036742303, 0.0085544325, 0.0032314239, 0.0086230049, 0.0027385168, 0.008621241, 0.0022100355,
+ 0.0085477121, 0.0016615022, 0.008400687, 0.0011089721, 0.0081780711, 0.00056853076, 0.0078773974, 0.000055770324,
+ 0.0074958913, -0.00041473741, 0.007030596, -0.00082994968, 0.006478562, -0.0011788219, 0.0058371006, -0.0014527178,
+ 0.0051040803, -0.0016457422, 0.0042782673, -0.001754979, 0.0033596819, -0.0017806236, 0.0023499657, -0.0017259984,
+ 0.0012527303, -0.001597449, 0.000073873452, -0.0014041185, -0.0011781569, -0.001157607, -0.0024921719, -0.00087152363,
+ -0.0038541388, -0.00056094711, -0.005247179, -0.00024181118, -0.0066516823, 0.000069761314, -0.0080455355, 0.00035815299,
+ -0.0094044767, 0.00060894678, -0.010702565, 0.00080959394, -0.011912759, 0.00095002784, -0.013007595, 0.0010231955,
+ -0.013959945, 0.0010254832, -0.014743825, 0.00095701526, -0.015335241, 0.0008218062, -0.015713034, 0.00062775693,
+ -0.015859697, 0.0003864867, -0.015762128, 0.00011300056, -0.015412294, -0.00017480124, -0.014807777, -0.00045675918,
+ -0.01395216, -0.00071121694, -0.012855255, -0.00091588532, -0.01153313, -0.0010487777, -0.010007947, -0.0010891829,
+ -0.0083075836, -0.0010186376, -0.0064650625, -0.00082186121, -0.0045177857, -0.00048761227, -0.0025065942, -0.0000094309362,
+ -0.00047468659, 0.00061376783, 0.0015335816, 0.0013772795, 0.0034739727, 0.0022703977, 0.0053036748, 0.0032764203,
+ 0.0069826017, 0.0043728831, 0.0084746322, 0.0055320212, 0.0097487466, 0.0067214468, 0.010780025, 0.0079050288,
+ 0.011550448, 0.009043945, 0.012049492, 0.010097877, 0.012274483, 0.011026301, 0.012230681, 0.011789839,
+ 0.011931112, 0.012351614, 0.01139613, 0.012678572, 0.010652733, 0.012742704, 0.0097336508, 0.012522144,
+ 0.0086762328, 0.012002093, 0.0075211856, 0.011175527, 0.0063111861, 0.010043681, 0.0050894427, 0.0086162686,
+ 0.0038982306, 0.006911451, 0.0027774705, 0.0049555404, 0.0017633948, 0.0027824503, 0.00088734273, 0.00043292236,
+ 0.00017473225, -0.0020464575, -0.00035576228, -0.0046044104, -0.00069279957, -0.0071862484, -0.00083271071, -0.009735249,
+ -0.00077958073, -0.012194071, -0.00054507388, -0.01450618, -0.00014801256, -0.016617225, 0.00038627203, -0.018476345,
+ 0.0010267919, -0.020037353, 0.0017379262, -0.021259794, 0.0024805821, -0.022109814, 0.003213454, -0.022560883,
+ 0.0038943416, -0.022594307, 0.004481487, -0.022199562, 0.0049348958, -0.021374447, 0.0052176043, -0.020125058,
+ 0.0052968613, -0.018465608, 0.0051452029, -0.016418114, 0.0047413921, -0.014011954, 0.0040712133, -0.011283341,
+ 0.0031281023, -0.0082747173, 0.0019136185, -0.0050341059, 0.00043774495, -0.001614425, -0.0012809716, 0.0019271988,
+ -0.0032154371, 0.0055301157, -0.0053301733, 0.009130815, -0.0075816144, 0.012663559, -0.0099185258, 0.016060976,
+ -0.012282523, 0.019254617, -0.014608691, 0.022175461, -0.016826265, 0.024754377, -0.018859385, 0.026922559,
+ -0.02062788, 0.028611908, -0.022048112, 0.029755389, -0.023033798, 0.03028737, -0.023496887, 0.030143932,
+ -0.023348402, 0.029263169, -0.022499284, 0.027585492, -0.020861225, 0.025053922, -0.018347459, 0.021614388,
+ -0.014873539, 0.017216032, -0.010358062, 0.011811542, -0.0047233663, 0.0053574666, 0.0021038246, -0.0021854306,
+ 0.010191803, -0.010851817, 0.019603329, -0.020671425, 0.030395132, -0.031668674, 0.04261747, -0.043862291,
+ 0.056313749, -0.057264935, 0.07152018, -0.071882829, 0.088265501, -0.087715395, 0.10657079, -0.10475491,
+ 0.12644924, -0.1229862, 0.14790612, -0.14238638, 0.17093869, -0.16292457, 0.19553615, -0.18456177,
+ 0.22167984, -0.20725067, 0.24934319, -0.23093559, 0.27849197, -0.25555256, 0.3090845, -0.28102925,
+ 0.34107187, -0.30728522, 0.37439832, -0.33423212, 0.40900153, -0.361774, 0.44481304, -0.38980758,
+ 0.48175868, -0.41822296, 0.51975912, -0.44690385, 0.55873019, -0.47572839, 0.59858364, -0.50456971,
+ 0.63922757, -0.53329676, 0.68056691, -0.56177497, 0.72250432, -0.58986712, 0.76494032, -0.61743438,
+ 0.80777425, -0.64433688, 0.8509047, -0.67043501, 0.89423001, -0.69559014, 0.93764895, -0.71966553,
+ 0.98106116, -0.74252748, 1.0243676, -0.76404625, 1.0674711, -0.78409678, 1.1102771, -0.80255991,
+ 1.152693, -0.81932294, 1.1946301, -0.83428079, 1.2360026, -0.84733653, 1.2767284, -0.85840225,
+ 1.3167298, -0.86739963, 1.3559328, -0.87426066, 1.3942684, -0.87892807, 1.4316717, -0.88135582,
+ 1.468083, -0.88150936, 1.5034472, -0.87936598, 1.5377145, -0.87491488, 1.5708399, -0.86815733,
+ 1.6027837, -0.85910636, 1.6335113, -0.84778708, 1.6629931, -0.83423591, 1.6912047, -0.81850064,
+ 1.7181267, -0.80063975, 1.7437447, -0.78072208, 1.7680489, -0.75882602, 1.7910345, -0.73503911,
+ 1.8127009, -0.70945716, 1.833052, -0.68218356, 1.8520958, -0.65332848, 1.8698444, -0.62300795,
+ 1.8863133, -0.59134328, 1.9015219, -0.55845982, 1.9154925, -0.52448642, 1.9282508, -0.48955446,
+ 1.9398252, -0.45379704, 1.9502468, -0.41734815, 1.9595492, -0.38034189, 1.9677683, -0.34291169,
+ 1.9749422, -0.30518964, 1.9811107, -0.26730573, 1.9863157, -0.22938718, 1.9906008, -0.1915579,
+ 1.994011, -0.15393782, 1.9965928, -0.11664244, 1.998394, -0.079782248, 1.9994637, -0.043462355,
+ 1.9998517, -0.0077820257, 1.9996089, 0.027165633, 1.9987869, 0.061293982, 1.997438, 0.094523117,
+ 1.9956142, 0.12678003, 1.9933683, 0.15799879, 1.9907526, 0.18812059, 1.9878191, 0.21709381,
+ 1.9846191, 0.24487394, 1.981203, 0.27142358, 1.97762, 0.29671216, 1.9739178, 0.3207159,
+ 1.9701425, 0.3434175, 1.9663377, 0.36480582, 1.9625452, 0.38487554, 1.9588039, 0.40362692,
+ 1.95515, 0.42106527, 1.9516169, 0.43720058, 1.9482347, 0.45204708, 1.9450303, 0.46562275,
+ 1.9420276, 0.47794896, 1.9392464, 0.48904994, 1.9367039, 0.49895242, 1.9344136, 0.50768507,
+ 1.9323857, 0.51527834, 1.9306273, 0.52176386, 1.929143, 0.52717417, 1.9279337, 0.53154266,
+ 1.9269985, 0.53490293, 1.9263337, 0.5372889, 1.9259334, 0.5387345, 1.9257902, 0.53927344,
+ 1.9258945, 0.53893936, 1.9262359, 0.53776574, 1.9268025, 0.53578556, 1.9275814, 0.53303164,
+ 1.9285592, 0.5295366, 1.9297218, 0.52533281, 1.9310548, 0.52045238, 1.9325439, 0.51492745,
+ 1.9341741, 0.50879002, 1.9359311, 0.50207198, 1.9378004, 0.4948054, 1.9397678, 0.48702216,
+ 1.9418195, 0.47875434, 1.943942, 0.47003385, 1.9461217, 0.46089265, 1.9483463, 0.45136252,
+ 1.9506031, 0.44147509, 1.9528806, 0.43126175, 1.9551672, 0.42075339, 1.9574521, 0.40998054,
+ 1.9597249, 0.39897302, 1.9619763, 0.38775995, 1.964197, 0.37636963, 1.9663788, 0.3648293,
+ 1.968514, 0.35316524, 1.9705957, 0.3414025, 1.9726177, 0.32956493, 1.9745748, 0.31767496,
+ 1.9764622, 0.30575377, 1.9782765, 0.29382104, 1.9800144, 0.28189498, 1.981674, 0.26999241,
+ 1.9832535, 0.25812861, 1.9847524, 0.24631737, 1.9861704, 0.23457102, 1.9875079, 0.22290041,
+ 1.988766, 0.21131492, 1.9899458, 0.1998225, 1.9910489, 0.18842971, 1.9920776, 0.17714165,
+ 1.9930336, 0.16596206, 1.9939193, 0.15489329, 1.9947368, 0.14393641, 1.9954883, 0.13309111,
+ 1.996176, 0.1223558, 1.9968017, 0.11172768, 1.9973674, 0.1012027, 1.9978747, 0.090775654,
+ 1.998325, 0.080440246, 1.9987197, 0.070189148, 1.9990598, 0.060014058, 1.9993461, 0.049905833,
+ 1.9995795, 0.039854541, 1.9997605, 0.029849617, 1.9998894, 0.019879945, 1.9999666, 0.0099340044,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/on2avcdata.h b/chromium/third_party/ffmpeg/libavcodec/on2avcdata.h
new file mode 100644
index 00000000000..7f498e58e4e
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/on2avcdata.h
@@ -0,0 +1,82 @@
+/*
+ * On2 Audio for Video Codec decoder
+ *
+ * Copyright (c) 2013 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_ON2AVC_DATA_H
+#define AVCODEC_ON2AVC_DATA_H
+
+#include <stdint.h>
+
+#define ON2AVC_MAX_BANDS 112
+#define ON2AVC_ESC_CB 15
+
+typedef struct On2AVCMode {
+ int num_windows;
+ int num_bands;
+ const int *band_start;
+} On2AVCMode;
+
+extern const On2AVCMode ff_on2avc_modes_40[8];
+extern const On2AVCMode ff_on2avc_modes_44[8];
+
+#define ON2AVC_SCALE_DIFFS 121
+extern const uint32_t ff_on2avc_scale_diff_codes[];
+extern const uint8_t ff_on2avc_scale_diff_bits[];
+
+extern const uint32_t * const ff_on2avc_quad_cb_codes[];
+extern const uint8_t * const ff_on2avc_quad_cb_bits[];
+extern const uint16_t * const ff_on2avc_quad_cb_syms[];
+extern const int ff_on2avc_quad_cb_elems[];
+extern const uint16_t * const ff_on2avc_pair_cb_codes[];
+extern const uint8_t * const ff_on2avc_pair_cb_bits[];
+extern const uint16_t * const ff_on2avc_pair_cb_syms[];
+extern const int ff_on2avc_pair_cb_elems[];
+
+extern const float ff_on2avc_window_long_32000[1024];
+extern const float ff_on2avc_window_long_24000[1024];
+extern const float ff_on2avc_window_short[128];
+
+extern const double ff_on2avc_tab_10_1[];
+extern const double ff_on2avc_tab_10_2[];
+extern const double ff_on2avc_tab_20_1[];
+extern const double ff_on2avc_tab_20_2[];
+extern const double ff_on2avc_tab_40_1[];
+extern const double ff_on2avc_tab_40_2[];
+extern const double ff_on2avc_tab_84_1[];
+extern const double ff_on2avc_tab_84_2[];
+extern const double ff_on2avc_tab_84_3[];
+extern const double ff_on2avc_tab_84_4[];
+extern const double* const ff_on2avc_tabs_4_10_1[4];
+extern const double* const ff_on2avc_tabs_4_10_2[4];
+extern const double* const ff_on2avc_tabs_9_20_1[9];
+extern const double* const ff_on2avc_tabs_9_20_2[9];
+extern const double* const ff_on2avc_tabs_19_40_1[19];
+extern const double* const ff_on2avc_tabs_19_40_2[19];
+extern const double* const ff_on2avc_tabs_20_84_1[20];
+extern const double* const ff_on2avc_tabs_20_84_2[20];
+extern const double* const ff_on2avc_tabs_20_84_3[20];
+extern const double* const ff_on2avc_tabs_20_84_4[20];
+extern const float ff_on2avc_ctab_1[2048];
+extern const float ff_on2avc_ctab_2[2048];
+extern const float ff_on2avc_ctab_3[2048];
+extern const float ff_on2avc_ctab_4[2048];
+
+#endif /* AVCODEC_ON2AVC_DATA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/options.c b/chromium/third_party/ffmpeg/libavcodec/options.c
index 5ee9d6bd739..b31483baa3a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/options.c
+++ b/chromium/third_party/ffmpeg/libavcodec/options.c
@@ -156,6 +156,9 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
+ const AVCodec *orig_codec = dest->codec;
+ uint8_t *orig_priv_data = dest->priv_data;
+
if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
@@ -168,9 +171,10 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
memcpy(dest, src, sizeof(*dest));
+ dest->priv_data = orig_priv_data;
+ dest->codec = orig_codec;
+
/* set values specific to opened codecs back to their default state */
- dest->priv_data = NULL;
- dest->codec = NULL;
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
@@ -181,6 +185,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
+ dest->subtitle_header = NULL;
if (src->rc_eq) {
dest->rc_eq = av_strdup(src->rc_eq);
if (!dest->rc_eq)
@@ -202,6 +207,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
+ av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
#undef alloc_and_copy_or_fail
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/options_table.h b/chromium/third_party/ffmpeg/libavcodec/options_table.h
index 49af29cbccf..f115ea718fc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/options_table.h
+++ b/chromium/third_party/ffmpeg/libavcodec/options_table.h
@@ -54,16 +54,24 @@ static const AVOption avcodec_options[] = {
{"qpel", "use 1/4-pel motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"},
{"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"},
{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"},
+#if FF_API_GMC
{"gmc", "use gmc", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
+#if FF_API_MV0
{"mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_MV0 }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
+#if FF_API_INPUT_PRESERVED
{"input_preserved", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"},
+#endif
{"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"},
{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"},
{"emu_edge", "do not draw edges", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_EMU_EDGE }, INT_MIN, INT_MAX, 0, "flags"},
{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"},
{"truncated", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, 0, "flags"},
+#if FF_API_NORMALIZE_AQP
{"naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"},
{"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"},
{"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"},
@@ -155,6 +163,7 @@ static const AVOption avcodec_options[] = {
{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_BUFFER }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_EXPLODE }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
+{"ignore_err", "ignore errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_IGNORE_ERR }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
{"careful", "consider things that violate the spec, are fast to check and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CAREFUL }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
{"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
{"aggressive", "consider things that a sane encoder should not do as an error", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
@@ -197,7 +206,9 @@ static const AVOption avcodec_options[] = {
{"simplemmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"arm", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, "idct"},
+#if FF_API_ARCH_SH4
{"sh4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"},
+#endif
{"simplearm", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARM }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"simplearmv5te", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV5TE }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"simplearmv6", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV6 }, INT_MIN, INT_MAX, V|E|D, "idct"},
@@ -212,6 +223,7 @@ static const AVOption avcodec_options[] = {
{"ec", "set error concealment strategy", OFFSET(error_concealment), AV_OPT_TYPE_FLAGS, {.i64 = 3 }, INT_MIN, INT_MAX, V|D, "ec"},
{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_GUESS_MVS }, INT_MIN, INT_MAX, V|D, "ec"},
{"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"},
+{"favor_inter", "favor predicting from the previous frame", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_FAVOR_INTER }, INT_MIN, INT_MAX, V|D, "ec"},
{"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"pred", "prediction method", OFFSET(prediction_method), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"},
{"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},
@@ -238,6 +250,7 @@ static const AVOption avcodec_options[] = {
{"vis_mb_type", "visualize block types", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"},
{"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"},
{"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|A|D, "debug"},
+{"nomc", "skip motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_NOMC }, INT_MIN, INT_MAX, V|A|D, "debug"},
{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|D, "debug_mv"},
{"pf", "forward predicted MVs of P-frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MV_P_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"},
{"bf", "forward predicted MVs of B-frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MV_B_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"},
@@ -386,7 +399,7 @@ static const AVOption avcodec_options[] = {
{"em", "Emergency", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_EMERGENCY }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
{"vo", "Voice Over", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_VOICE_OVER }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
{"ka", "Karaoke", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_KARAOKE }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64=AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"},
+{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64=AV_SAMPLE_FMT_NONE}, -1, INT_MAX, A|D, "request_sample_fmt"},
{"pkt_timebase", NULL, OFFSET(pkt_timebase), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
{"sub_charenc", "set input text subtitles character encoding", OFFSET(sub_charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, S|D},
{"sub_charenc_mode", "set input text subtitles character encoding mode", OFFSET(sub_charenc_mode), AV_OPT_TYPE_FLAGS, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, -1, INT_MAX, S|D, "sub_charenc_mode"},
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus.c b/chromium/third_party/ffmpeg/libavcodec/opus.c
new file mode 100644
index 00000000000..e76c510a775
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus.c
@@ -0,0 +1,428 @@
+/*
+ * Copyright (c) 2012 Andrew D'Addesio
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Opus decoder/parser shared code
+ */
+
+#include <stdint.h>
+
+#include "libavutil/error.h"
+
+#include "opus.h"
+#include "vorbis.h"
+
+static const uint16_t opus_frame_duration[32] = {
+ 480, 960, 1920, 2880,
+ 480, 960, 1920, 2880,
+ 480, 960, 1920, 2880,
+ 480, 960,
+ 480, 960,
+ 120, 240, 480, 960,
+ 120, 240, 480, 960,
+ 120, 240, 480, 960,
+ 120, 240, 480, 960,
+};
+
+/**
+ * Read a 1- or 2-byte frame length
+ */
+static inline int xiph_lacing_16bit(const uint8_t **ptr, const uint8_t *end)
+{
+ int val;
+
+ if (*ptr >= end)
+ return AVERROR_INVALIDDATA;
+ val = *(*ptr)++;
+ if (val >= 252) {
+ if (*ptr >= end)
+ return AVERROR_INVALIDDATA;
+ val += 4 * *(*ptr)++;
+ }
+ return val;
+}
+
+/**
+ * Read a multi-byte length (used for code 3 packet padding size)
+ */
+static inline int xiph_lacing_full(const uint8_t **ptr, const uint8_t *end)
+{
+ int val = 0;
+ int next;
+
+ while (1) {
+ if (*ptr >= end || val > INT_MAX - 254)
+ return AVERROR_INVALIDDATA;
+ next = *(*ptr)++;
+ val += next;
+ if (next < 255)
+ break;
+ else
+ val--;
+ }
+ return val;
+}
+
+/**
+ * Parse Opus packet info from raw packet data
+ */
+int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
+ int self_delimiting)
+{
+ const uint8_t *ptr = buf;
+ const uint8_t *end = buf + buf_size;
+ int padding = 0;
+ int frame_bytes, i;
+
+ if (buf_size < 1)
+ goto fail;
+
+ /* TOC byte */
+ i = *ptr++;
+ pkt->code = (i ) & 0x3;
+ pkt->stereo = (i >> 2) & 0x1;
+ pkt->config = (i >> 3) & 0x1F;
+
+ /* code 2 and code 3 packets have at least 1 byte after the TOC */
+ if (pkt->code >= 2 && buf_size < 2)
+ goto fail;
+
+ switch (pkt->code) {
+ case 0:
+ /* 1 frame */
+ pkt->frame_count = 1;
+ pkt->vbr = 0;
+
+ if (self_delimiting) {
+ int len = xiph_lacing_16bit(&ptr, end);
+ if (len < 0 || len > end - ptr)
+ goto fail;
+ end = ptr + len;
+ buf_size = end - buf;
+ }
+
+ frame_bytes = end - ptr;
+ if (frame_bytes > MAX_FRAME_SIZE)
+ goto fail;
+ pkt->frame_offset[0] = ptr - buf;
+ pkt->frame_size[0] = frame_bytes;
+ break;
+ case 1:
+ /* 2 frames, equal size */
+ pkt->frame_count = 2;
+ pkt->vbr = 0;
+
+ if (self_delimiting) {
+ int len = xiph_lacing_16bit(&ptr, end);
+ if (len < 0 || 2 * len > end - ptr)
+ goto fail;
+ end = ptr + 2 * len;
+ buf_size = end - buf;
+ }
+
+ frame_bytes = end - ptr;
+ if (frame_bytes & 1 || frame_bytes >> 1 > MAX_FRAME_SIZE)
+ goto fail;
+ pkt->frame_offset[0] = ptr - buf;
+ pkt->frame_size[0] = frame_bytes >> 1;
+ pkt->frame_offset[1] = pkt->frame_offset[0] + pkt->frame_size[0];
+ pkt->frame_size[1] = frame_bytes >> 1;
+ break;
+ case 2:
+ /* 2 frames, different sizes */
+ pkt->frame_count = 2;
+ pkt->vbr = 1;
+
+ /* read 1st frame size */
+ frame_bytes = xiph_lacing_16bit(&ptr, end);
+ if (frame_bytes < 0)
+ goto fail;
+
+ if (self_delimiting) {
+ int len = xiph_lacing_16bit(&ptr, end);
+ if (len < 0 || len + frame_bytes > end - ptr)
+ goto fail;
+ end = ptr + frame_bytes + len;
+ buf_size = end - buf;
+ }
+
+ pkt->frame_offset[0] = ptr - buf;
+ pkt->frame_size[0] = frame_bytes;
+
+ /* calculate 2nd frame size */
+ frame_bytes = end - ptr - pkt->frame_size[0];
+ if (frame_bytes < 0 || frame_bytes > MAX_FRAME_SIZE)
+ goto fail;
+ pkt->frame_offset[1] = pkt->frame_offset[0] + pkt->frame_size[0];
+ pkt->frame_size[1] = frame_bytes;
+ break;
+ case 3:
+ /* 1 to 48 frames, can be different sizes */
+ i = *ptr++;
+ pkt->frame_count = (i ) & 0x3F;
+ padding = (i >> 6) & 0x01;
+ pkt->vbr = (i >> 7) & 0x01;
+
+ if (pkt->frame_count == 0 || pkt->frame_count > MAX_FRAMES)
+ goto fail;
+
+ /* read padding size */
+ if (padding) {
+ padding = xiph_lacing_full(&ptr, end);
+ if (padding < 0)
+ goto fail;
+ }
+
+ /* read frame sizes */
+ if (pkt->vbr) {
+ /* for VBR, all frames except the final one have their size coded
+ in the bitstream. the last frame size is implicit. */
+ int total_bytes = 0;
+ for (i = 0; i < pkt->frame_count - 1; i++) {
+ frame_bytes = xiph_lacing_16bit(&ptr, end);
+ if (frame_bytes < 0)
+ goto fail;
+ pkt->frame_size[i] = frame_bytes;
+ total_bytes += frame_bytes;
+ }
+
+ if (self_delimiting) {
+ int len = xiph_lacing_16bit(&ptr, end);
+ if (len < 0 || len + total_bytes + padding > end - ptr)
+ goto fail;
+ end = ptr + total_bytes + len + padding;
+ buf_size = end - buf;
+ }
+
+ frame_bytes = end - ptr - padding;
+ if (total_bytes > frame_bytes)
+ goto fail;
+ pkt->frame_offset[0] = ptr - buf;
+ for (i = 1; i < pkt->frame_count; i++)
+ pkt->frame_offset[i] = pkt->frame_offset[i-1] + pkt->frame_size[i-1];
+ pkt->frame_size[pkt->frame_count-1] = frame_bytes - total_bytes;
+ } else {
+ /* for CBR, the remaining packet bytes are divided evenly between
+ the frames */
+ if (self_delimiting) {
+ frame_bytes = xiph_lacing_16bit(&ptr, end);
+ if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
+ goto fail;
+ end = ptr + pkt->frame_count * frame_bytes + padding;
+ buf_size = end - buf;
+ } else {
+ frame_bytes = end - ptr - padding;
+ if (frame_bytes % pkt->frame_count ||
+ frame_bytes / pkt->frame_count > MAX_FRAME_SIZE)
+ goto fail;
+ frame_bytes /= pkt->frame_count;
+ }
+
+ pkt->frame_offset[0] = ptr - buf;
+ pkt->frame_size[0] = frame_bytes;
+ for (i = 1; i < pkt->frame_count; i++) {
+ pkt->frame_offset[i] = pkt->frame_offset[i-1] + pkt->frame_size[i-1];
+ pkt->frame_size[i] = frame_bytes;
+ }
+ }
+ }
+
+ pkt->packet_size = buf_size;
+ pkt->data_size = pkt->packet_size - padding;
+
+ /* total packet duration cannot be larger than 120ms */
+ pkt->frame_duration = opus_frame_duration[pkt->config];
+ if (pkt->frame_duration * pkt->frame_count > MAX_PACKET_DUR)
+ goto fail;
+
+ /* set mode and bandwidth */
+ if (pkt->config < 12) {
+ pkt->mode = OPUS_MODE_SILK;
+ pkt->bandwidth = pkt->config >> 2;
+ } else if (pkt->config < 16) {
+ pkt->mode = OPUS_MODE_HYBRID;
+ pkt->bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND + (pkt->config >= 14);
+ } else {
+ pkt->mode = OPUS_MODE_CELT;
+ pkt->bandwidth = (pkt->config - 16) >> 2;
+ /* skip mediumband */
+ if (pkt->bandwidth)
+ pkt->bandwidth++;
+ }
+
+ return 0;
+
+fail:
+ memset(pkt, 0, sizeof(*pkt));
+ return AVERROR_INVALIDDATA;
+}
+
+static int channel_reorder_vorbis(int nb_channels, int channel_idx)
+{
+ return ff_vorbis_channel_layout_offsets[nb_channels - 1][channel_idx];
+}
+
+static int channel_reorder_unknown(int nb_channels, int channel_idx)
+{
+ return channel_idx;
+}
+
+av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
+ OpusContext *s)
+{
+ static const uint8_t default_channel_map[2] = { 0, 1 };
+ uint8_t default_extradata[19] = {
+ 'O', 'p', 'u', 's', 'H', 'e', 'a', 'd',
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ };
+
+ int (*channel_reorder)(int, int) = channel_reorder_unknown;
+
+ const uint8_t *extradata, *channel_map;
+ int extradata_size;
+ int version, channels, map_type, streams, stereo_streams, i, j;
+ uint64_t layout;
+
+ if (!avctx->extradata) {
+ if (avctx->channels > 2) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Multichannel configuration without extradata.\n");
+ return AVERROR(EINVAL);
+ }
+ default_extradata[9] = (avctx->channels == 1) ? 1 : 2;
+ extradata = default_extradata;
+ extradata_size = sizeof(default_extradata);
+ } else {
+ extradata = avctx->extradata;
+ extradata_size = avctx->extradata_size;
+ }
+
+ if (extradata_size < 19) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n",
+ extradata_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ version = extradata[8];
+ if (version > 15) {
+ avpriv_request_sample(avctx, "Extradata version %d", version);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ avctx->delay = AV_RL16(extradata + 10);
+
+ channels = extradata[9];
+ if (!channels) {
+ av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extadata\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ s->gain_i = AV_RL16(extradata + 16);
+ if (s->gain_i)
+ s->gain = pow(10, s->gain_i / (20.0 * 256));
+
+ map_type = extradata[18];
+ if (!map_type) {
+ if (channels > 2) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Channel mapping 0 is only specified for up to 2 channels\n");
+ return AVERROR_INVALIDDATA;
+ }
+ layout = (channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+ streams = 1;
+ stereo_streams = channels - 1;
+ channel_map = default_channel_map;
+ } else if (map_type == 1 || map_type == 255) {
+ if (extradata_size < 21 + channels) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n",
+ extradata_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ streams = extradata[19];
+ stereo_streams = extradata[20];
+ if (!streams || stereo_streams > streams ||
+ streams + stereo_streams > 255) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (map_type == 1) {
+ if (channels > 8) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Channel mapping 1 is only specified for up to 8 channels\n");
+ return AVERROR_INVALIDDATA;
+ }
+ layout = ff_vorbis_channel_layouts[channels - 1];
+ channel_reorder = channel_reorder_vorbis;
+ } else
+ layout = 0;
+
+ channel_map = extradata + 21;
+ } else {
+ avpriv_request_sample(avctx, "Mapping type %d", map_type);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ s->channel_maps = av_mallocz_array(channels, sizeof(*s->channel_maps));
+ if (!s->channel_maps)
+ return AVERROR(ENOMEM);
+
+ for (i = 0; i < channels; i++) {
+ ChannelMap *map = &s->channel_maps[i];
+ uint8_t idx = channel_map[channel_reorder(channels, i)];
+
+ if (idx == 255) {
+ map->silence = 1;
+ continue;
+ } else if (idx >= streams + stereo_streams) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid channel map for output channel %d: %d\n", i, idx);
+ return AVERROR_INVALIDDATA;
+ }
+
+ /* check that we din't see this index yet */
+ map->copy = 0;
+ for (j = 0; j < i; j++)
+ if (channel_map[channel_reorder(channels, j)] == idx) {
+ map->copy = 1;
+ map->copy_idx = j;
+ break;
+ }
+
+ if (idx < 2 * stereo_streams) {
+ map->stream_idx = idx / 2;
+ map->channel_idx = idx & 1;
+ } else {
+ map->stream_idx = idx - stereo_streams;
+ map->channel_idx = 0;
+ }
+ }
+
+ avctx->channels = channels;
+ avctx->channel_layout = layout;
+ s->nb_streams = streams;
+ s->nb_stereo_streams = stereo_streams;
+
+ return 0;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus.h b/chromium/third_party/ffmpeg/libavcodec/opus.h
new file mode 100644
index 00000000000..a1e8ed0e18a
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus.h
@@ -0,0 +1,411 @@
+/*
+ * Opus decoder/demuxer common functions
+ * Copyright (c) 2012 Andrew D'Addesio
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_OPUS_H
+#define AVCODEC_OPUS_H
+
+#include <stdint.h>
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/float_dsp.h"
+#include "libavutil/frame.h"
+
+#include "libswresample/swresample.h"
+
+#include "avcodec.h"
+#include "get_bits.h"
+
+#define MAX_FRAME_SIZE 1275
+#define MAX_FRAMES 48
+#define MAX_PACKET_DUR 5760
+
+#define CELT_SHORT_BLOCKSIZE 120
+#define CELT_OVERLAP CELT_SHORT_BLOCKSIZE
+#define CELT_MAX_LOG_BLOCKS 3
+#define CELT_MAX_FRAME_SIZE (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS))
+#define CELT_MAX_BANDS 21
+#define CELT_VECTORS 11
+#define CELT_ALLOC_STEPS 6
+#define CELT_FINE_OFFSET 21
+#define CELT_MAX_FINE_BITS 8
+#define CELT_NORM_SCALE 16384
+#define CELT_QTHETA_OFFSET 4
+#define CELT_QTHETA_OFFSET_TWOPHASE 16
+#define CELT_DEEMPH_COEFF 0.85000610f
+#define CELT_POSTFILTER_MINPERIOD 15
+#define CELT_ENERGY_SILENCE (-28.0f)
+
+#define SILK_HISTORY 322
+#define SILK_MAX_LPC 16
+
+#define ROUND_MULL(a,b,s) (((MUL64(a, b) >> (s - 1)) + 1) >> 1)
+#define ROUND_MUL16(a,b) ((MUL16(a, b) + 16384) >> 15)
+#define opus_ilog(i) (av_log2(i) + !!(i))
+
+enum OpusMode {
+ OPUS_MODE_SILK,
+ OPUS_MODE_HYBRID,
+ OPUS_MODE_CELT
+};
+
+enum OpusBandwidth {
+ OPUS_BANDWIDTH_NARROWBAND,
+ OPUS_BANDWIDTH_MEDIUMBAND,
+ OPUS_BANDWIDTH_WIDEBAND,
+ OPUS_BANDWIDTH_SUPERWIDEBAND,
+ OPUS_BANDWIDTH_FULLBAND
+};
+
+typedef struct RawBitsContext {
+ const uint8_t *position;
+ unsigned int bytes;
+ unsigned int cachelen;
+ unsigned int cacheval;
+} RawBitsContext;
+
+typedef struct OpusRangeCoder {
+ GetBitContext gb;
+ RawBitsContext rb;
+ unsigned int range;
+ unsigned int value;
+ unsigned int total_read_bits;
+} OpusRangeCoder;
+
+typedef struct SilkContext SilkContext;
+
+typedef struct CeltContext CeltContext;
+
+typedef struct OpusPacket {
+ int packet_size; /**< packet size */
+ int data_size; /**< size of the useful data -- packet size - padding */
+ int code; /**< packet code: specifies the frame layout */
+ int stereo; /**< whether this packet is mono or stereo */
+ int vbr; /**< vbr flag */
+ int config; /**< configuration: tells the audio mode,
+ ** bandwidth, and frame duration */
+ int frame_count; /**< frame count */
+ int frame_offset[MAX_FRAMES]; /**< frame offsets */
+ int frame_size[MAX_FRAMES]; /**< frame sizes */
+ int frame_duration; /**< frame duration, in samples @ 48kHz */
+ enum OpusMode mode; /**< mode */
+ enum OpusBandwidth bandwidth; /**< bandwidth */
+} OpusPacket;
+
+typedef struct OpusStreamContext {
+ AVCodecContext *avctx;
+ int output_channels;
+
+ OpusRangeCoder rc;
+ OpusRangeCoder redundancy_rc;
+ SilkContext *silk;
+ CeltContext *celt;
+ AVFloatDSPContext *fdsp;
+
+ float silk_buf[2][960];
+ float *silk_output[2];
+ DECLARE_ALIGNED(32, float, celt_buf)[2][960];
+ float *celt_output[2];
+
+ float redundancy_buf[2][960];
+ float *redundancy_output[2];
+
+ /* data buffers for the final output data */
+ float *out[2];
+ int out_size;
+
+ float *out_dummy;
+ int out_dummy_allocated_size;
+
+ SwrContext *swr;
+ AVAudioFifo *celt_delay;
+ int silk_samplerate;
+ /* number of samples we still want to get from the resampler */
+ int delayed_samples;
+
+ OpusPacket packet;
+
+ int redundancy_idx;
+} OpusStreamContext;
+
+// a mapping between an opus stream and an output channel
+typedef struct ChannelMap {
+ int stream_idx;
+ int channel_idx;
+
+ // when a single decoded channel is mapped to multiple output channels, we
+ // write to the first output directly and copy from it to the others
+ // this field is set to 1 for those copied output channels
+ int copy;
+ // this is the index of the output channel to copy from
+ int copy_idx;
+
+ // this channel is silent
+ int silence;
+} ChannelMap;
+
+typedef struct OpusContext {
+ OpusStreamContext *streams;
+ int nb_streams;
+ int nb_stereo_streams;
+
+ AVFloatDSPContext fdsp;
+ int16_t gain_i;
+ float gain;
+
+ ChannelMap *channel_maps;
+} OpusContext;
+
+static av_always_inline void opus_rc_normalize(OpusRangeCoder *rc)
+{
+ while (rc->range <= 1<<23) {
+ rc->value = ((rc->value << 8) | (get_bits(&rc->gb, 8) ^ 0xFF)) & ((1u << 31) - 1);
+ rc->range <<= 8;
+ rc->total_read_bits += 8;
+ }
+}
+
+static av_always_inline void opus_rc_update(OpusRangeCoder *rc, unsigned int scale,
+ unsigned int low, unsigned int high,
+ unsigned int total)
+{
+ rc->value -= scale * (total - high);
+ rc->range = low ? scale * (high - low)
+ : rc->range - scale * (total - high);
+ opus_rc_normalize(rc);
+}
+
+static av_always_inline unsigned int opus_rc_getsymbol(OpusRangeCoder *rc, const uint16_t *cdf)
+{
+ unsigned int k, scale, total, symbol, low, high;
+
+ total = *cdf++;
+
+ scale = rc->range / total;
+ symbol = rc->value / scale + 1;
+ symbol = total - FFMIN(symbol, total);
+
+ for (k = 0; cdf[k] <= symbol; k++);
+ high = cdf[k];
+ low = k ? cdf[k-1] : 0;
+
+ opus_rc_update(rc, scale, low, high, total);
+
+ return k;
+}
+
+static av_always_inline unsigned int opus_rc_p2model(OpusRangeCoder *rc, unsigned int bits)
+{
+ unsigned int k, scale;
+ scale = rc->range >> bits; // in this case, scale = symbol
+
+ if (rc->value >= scale) {
+ rc->value -= scale;
+ rc->range -= scale;
+ k = 0;
+ } else {
+ rc->range = scale;
+ k = 1;
+ }
+ opus_rc_normalize(rc);
+ return k;
+}
+
+/**
+ * CELT: estimate bits of entropy that have thus far been consumed for the
+ * current CELT frame, to integer and fractional (1/8th bit) precision
+ */
+static av_always_inline unsigned int opus_rc_tell(const OpusRangeCoder *rc)
+{
+ return rc->total_read_bits - av_log2(rc->range) - 1;
+}
+
+static av_always_inline unsigned int opus_rc_tell_frac(const OpusRangeCoder *rc)
+{
+ unsigned int i, total_bits, rcbuffer, range;
+
+ total_bits = rc->total_read_bits << 3;
+ rcbuffer = av_log2(rc->range) + 1;
+ range = rc->range >> (rcbuffer-16);
+
+ for (i = 0; i < 3; i++) {
+ int bit;
+ range = range * range >> 15;
+ bit = range >> 16;
+ rcbuffer = rcbuffer << 1 | bit;
+ range >>= bit;
+ }
+
+ return total_bits - rcbuffer;
+}
+
+/**
+ * CELT: read 1-25 raw bits at the end of the frame, backwards byte-wise
+ */
+static av_always_inline unsigned int opus_getrawbits(OpusRangeCoder *rc, unsigned int count)
+{
+ unsigned int value = 0;
+
+ while (rc->rb.bytes && rc->rb.cachelen < count) {
+ rc->rb.cacheval |= *--rc->rb.position << rc->rb.cachelen;
+ rc->rb.cachelen += 8;
+ rc->rb.bytes--;
+ }
+
+ value = rc->rb.cacheval & ((1<<count)-1);
+ rc->rb.cacheval >>= count;
+ rc->rb.cachelen -= count;
+ rc->total_read_bits += count;
+
+ return value;
+}
+
+/**
+ * CELT: read a uniform distribution
+ */
+static av_always_inline unsigned int opus_rc_unimodel(OpusRangeCoder *rc, unsigned int size)
+{
+ unsigned int bits, k, scale, total;
+
+ bits = opus_ilog(size - 1);
+ total = (bits > 8) ? ((size - 1) >> (bits - 8)) + 1 : size;
+
+ scale = rc->range / total;
+ k = rc->value / scale + 1;
+ k = total - FFMIN(k, total);
+ opus_rc_update(rc, scale, k, k + 1, total);
+
+ if (bits > 8) {
+ k = k << (bits - 8) | opus_getrawbits(rc, bits - 8);
+ return FFMIN(k, size - 1);
+ } else
+ return k;
+}
+
+static av_always_inline int opus_rc_laplace(OpusRangeCoder *rc, unsigned int symbol, int decay)
+{
+ /* extends the range coder to model a Laplace distribution */
+ int value = 0;
+ unsigned int scale, low = 0, center;
+
+ scale = rc->range >> 15;
+ center = rc->value / scale + 1;
+ center = (1 << 15) - FFMIN(center, 1 << 15);
+
+ if (center >= symbol) {
+ value++;
+ low = symbol;
+ symbol = 1 + ((32768 - 32 - symbol) * (16384-decay) >> 15);
+
+ while (symbol > 1 && center >= low + 2 * symbol) {
+ value++;
+ symbol *= 2;
+ low += symbol;
+ symbol = (((symbol - 2) * decay) >> 15) + 1;
+ }
+
+ if (symbol <= 1) {
+ int distance = (center - low) >> 1;
+ value += distance;
+ low += 2 * distance;
+ }
+
+ if (center < low + symbol)
+ value *= -1;
+ else
+ low += symbol;
+ }
+
+ opus_rc_update(rc, scale, low, FFMIN(low + symbol, 32768), 32768);
+
+ return value;
+}
+
+static av_always_inline unsigned int opus_rc_stepmodel(OpusRangeCoder *rc, int k0)
+{
+ /* Use a probability of 3 up to itheta=8192 and then use 1 after */
+ unsigned int k, scale, symbol, total = (k0+1)*3 + k0;
+ scale = rc->range / total;
+ symbol = rc->value / scale + 1;
+ symbol = total - FFMIN(symbol, total);
+
+ k = (symbol < (k0+1)*3) ? symbol/3 : symbol - (k0+1)*2;
+
+ opus_rc_update(rc, scale, (k <= k0) ? 3*(k+0) : (k-1-k0) + 3*(k0+1),
+ (k <= k0) ? 3*(k+1) : (k-0-k0) + 3*(k0+1), total);
+ return k;
+}
+
+static av_always_inline unsigned int opus_rc_trimodel(OpusRangeCoder *rc, int qn)
+{
+ unsigned int k, scale, symbol, total, low, center;
+
+ total = ((qn>>1) + 1) * ((qn>>1) + 1);
+ scale = rc->range / total;
+ center = rc->value / scale + 1;
+ center = total - FFMIN(center, total);
+
+ if (center < total >> 1) {
+ k = (ff_sqrt(8 * center + 1) - 1) >> 1;
+ low = k * (k + 1) >> 1;
+ symbol = k + 1;
+ } else {
+ k = (2*(qn + 1) - ff_sqrt(8*(total - center - 1) + 1)) >> 1;
+ low = total - ((qn + 1 - k) * (qn + 2 - k) >> 1);
+ symbol = qn + 1 - k;
+ }
+
+ opus_rc_update(rc, scale, low, low + symbol, total);
+
+ return k;
+}
+
+int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
+ int self_delimited);
+
+int ff_opus_parse_extradata(AVCodecContext *avctx, OpusContext *s);
+
+int ff_silk_init(AVCodecContext *avctx, SilkContext **ps, int output_channels);
+void ff_silk_free(SilkContext **ps);
+void ff_silk_flush(SilkContext *s);
+
+/**
+ * Decode the LP layer of one Opus frame (which may correspond to several SILK
+ * frames).
+ */
+int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc,
+ float *output[2],
+ enum OpusBandwidth bandwidth, int coded_channels,
+ int duration_ms);
+
+int ff_celt_init(AVCodecContext *avctx, CeltContext **s, int output_channels);
+
+void ff_celt_free(CeltContext **s);
+
+void ff_celt_flush(CeltContext *s);
+
+int ff_celt_decode_frame(CeltContext *s, OpusRangeCoder *rc,
+ float **output, int coded_channels, int frame_size,
+ int startband, int endband);
+
+extern const float ff_celt_window2[120];
+
+#endif /* AVCODEC_OPUS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus_celt.c b/chromium/third_party/ffmpeg/libavcodec/opus_celt.c
new file mode 100644
index 00000000000..26d15392f29
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus_celt.c
@@ -0,0 +1,2221 @@
+/*
+ * Copyright (c) 2012 Andrew D'Addesio
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Opus CELT decoder
+ */
+
+#include <stdint.h>
+
+#include "libavutil/float_dsp.h"
+
+#include "opus.h"
+#include "opus_imdct.h"
+
+enum CeltSpread {
+ CELT_SPREAD_NONE,
+ CELT_SPREAD_LIGHT,
+ CELT_SPREAD_NORMAL,
+ CELT_SPREAD_AGGRESSIVE
+};
+
+typedef struct CeltFrame {
+ float energy[CELT_MAX_BANDS];
+ float prev_energy[2][CELT_MAX_BANDS];
+
+ uint8_t collapse_masks[CELT_MAX_BANDS];
+
+ /* buffer for mdct output + postfilter */
+ DECLARE_ALIGNED(32, float, buf)[2048];
+
+ /* postfilter parameters */
+ int pf_period_new;
+ float pf_gains_new[3];
+ int pf_period;
+ float pf_gains[3];
+ int pf_period_old;
+ float pf_gains_old[3];
+
+ float deemph_coeff;
+} CeltFrame;
+
+struct CeltContext {
+ // constant values that do not change during context lifetime
+ AVCodecContext *avctx;
+ CeltIMDCTContext *imdct[4];
+ AVFloatDSPContext dsp;
+ int output_channels;
+
+ // values that have inter-frame effect and must be reset on flush
+ CeltFrame frame[2];
+ uint32_t seed;
+ int flushed;
+
+ // values that only affect a single frame
+ int coded_channels;
+ int framebits;
+ int duration;
+
+ /* number of iMDCT blocks in the frame */
+ int blocks;
+ /* size of each block */
+ int blocksize;
+
+ int startband;
+ int endband;
+ int codedbands;
+
+ int anticollapse_bit;
+
+ int intensitystereo;
+ int dualstereo;
+ enum CeltSpread spread;
+
+ int remaining;
+ int remaining2;
+ int fine_bits [CELT_MAX_BANDS];
+ int fine_priority[CELT_MAX_BANDS];
+ int pulses [CELT_MAX_BANDS];
+ int tf_change [CELT_MAX_BANDS];
+
+ DECLARE_ALIGNED(32, float, coeffs)[2][CELT_MAX_FRAME_SIZE];
+ DECLARE_ALIGNED(32, float, scratch)[22 * 8]; // MAX(celt_freq_range) * 1<<CELT_MAX_LOG_BLOCKS
+};
+
+static const uint16_t celt_model_tapset[] = { 4, 2, 3, 4 };
+
+static const uint16_t celt_model_spread[] = { 32, 7, 9, 30, 32 };
+
+static const uint16_t celt_model_alloc_trim[] = {
+ 128, 2, 4, 9, 19, 41, 87, 109, 119, 124, 126, 128
+};
+
+static const uint16_t celt_model_energy_small[] = { 4, 2, 3, 4 };
+
+static const uint8_t celt_freq_bands[] = { /* in steps of 200Hz */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100
+};
+
+static const uint8_t celt_freq_range[] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 6, 6, 8, 12, 18, 22
+};
+
+static const uint8_t celt_log_freq_range[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36
+};
+
+static const int8_t celt_tf_select[4][2][2][2] = {
+ { { { 0, -1 }, { 0, -1 } }, { { 0, -1 }, { 0, -1 } } },
+ { { { 0, -1 }, { 0, -2 } }, { { 1, 0 }, { 1, -1 } } },
+ { { { 0, -2 }, { 0, -3 } }, { { 2, 0 }, { 1, -1 } } },
+ { { { 0, -2 }, { 0, -3 } }, { { 3, 0 }, { 1, -1 } } }
+};
+
+static const float celt_mean_energy[] = {
+ 6.437500f, 6.250000f, 5.750000f, 5.312500f, 5.062500f,
+ 4.812500f, 4.500000f, 4.375000f, 4.875000f, 4.687500f,
+ 4.562500f, 4.437500f, 4.875000f, 4.625000f, 4.312500f,
+ 4.500000f, 4.375000f, 4.625000f, 4.750000f, 4.437500f,
+ 3.750000f, 3.750000f, 3.750000f, 3.750000f, 3.750000f
+};
+
+static const float celt_alpha_coef[] = {
+ 29440.0f/32768.0f, 26112.0f/32768.0f, 21248.0f/32768.0f, 16384.0f/32768.0f
+};
+
+static const float celt_beta_coef[] = { /* TODO: precompute 1 minus this if the code ends up neater */
+ 30147.0f/32768.0f, 22282.0f/32768.0f, 12124.0f/32768.0f, 6554.0f/32768.0f
+};
+
+static const uint8_t celt_coarse_energy_dist[4][2][42] = {
+ {
+ { // 120-sample inter
+ 72, 127, 65, 129, 66, 128, 65, 128, 64, 128, 62, 128, 64, 128,
+ 64, 128, 92, 78, 92, 79, 92, 78, 90, 79, 116, 41, 115, 40,
+ 114, 40, 132, 26, 132, 26, 145, 17, 161, 12, 176, 10, 177, 11
+ }, { // 120-sample intra
+ 24, 179, 48, 138, 54, 135, 54, 132, 53, 134, 56, 133, 55, 132,
+ 55, 132, 61, 114, 70, 96, 74, 88, 75, 88, 87, 74, 89, 66,
+ 91, 67, 100, 59, 108, 50, 120, 40, 122, 37, 97, 43, 78, 50
+ }
+ }, {
+ { // 240-sample inter
+ 83, 78, 84, 81, 88, 75, 86, 74, 87, 71, 90, 73, 93, 74,
+ 93, 74, 109, 40, 114, 36, 117, 34, 117, 34, 143, 17, 145, 18,
+ 146, 19, 162, 12, 165, 10, 178, 7, 189, 6, 190, 8, 177, 9
+ }, { // 240-sample intra
+ 23, 178, 54, 115, 63, 102, 66, 98, 69, 99, 74, 89, 71, 91,
+ 73, 91, 78, 89, 86, 80, 92, 66, 93, 64, 102, 59, 103, 60,
+ 104, 60, 117, 52, 123, 44, 138, 35, 133, 31, 97, 38, 77, 45
+ }
+ }, {
+ { // 480-sample inter
+ 61, 90, 93, 60, 105, 42, 107, 41, 110, 45, 116, 38, 113, 38,
+ 112, 38, 124, 26, 132, 27, 136, 19, 140, 20, 155, 14, 159, 16,
+ 158, 18, 170, 13, 177, 10, 187, 8, 192, 6, 175, 9, 159, 10
+ }, { // 480-sample intra
+ 21, 178, 59, 110, 71, 86, 75, 85, 84, 83, 91, 66, 88, 73,
+ 87, 72, 92, 75, 98, 72, 105, 58, 107, 54, 115, 52, 114, 55,
+ 112, 56, 129, 51, 132, 40, 150, 33, 140, 29, 98, 35, 77, 42
+ }
+ }, {
+ { // 960-sample inter
+ 42, 121, 96, 66, 108, 43, 111, 40, 117, 44, 123, 32, 120, 36,
+ 119, 33, 127, 33, 134, 34, 139, 21, 147, 23, 152, 20, 158, 25,
+ 154, 26, 166, 21, 173, 16, 184, 13, 184, 10, 150, 13, 139, 15
+ }, { // 960-sample intra
+ 22, 178, 63, 114, 74, 82, 84, 83, 92, 82, 103, 62, 96, 72,
+ 96, 67, 101, 73, 107, 72, 113, 55, 118, 52, 125, 52, 118, 52,
+ 117, 55, 135, 49, 137, 39, 157, 32, 145, 29, 97, 33, 77, 40
+ }
+ }
+};
+
+static const uint8_t celt_static_alloc[11][21] = { /* 1/32 bit/sample */
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 90, 80, 75, 69, 63, 56, 49, 40, 34, 29, 20, 18, 10, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 110, 100, 90, 84, 78, 71, 65, 58, 51, 45, 39, 32, 26, 20, 12, 0, 0, 0, 0, 0, 0 },
+ { 118, 110, 103, 93, 86, 80, 75, 70, 65, 59, 53, 47, 40, 31, 23, 15, 4, 0, 0, 0, 0 },
+ { 126, 119, 112, 104, 95, 89, 83, 78, 72, 66, 60, 54, 47, 39, 32, 25, 17, 12, 1, 0, 0 },
+ { 134, 127, 120, 114, 103, 97, 91, 85, 78, 72, 66, 60, 54, 47, 41, 35, 29, 23, 16, 10, 1 },
+ { 144, 137, 130, 124, 113, 107, 101, 95, 88, 82, 76, 70, 64, 57, 51, 45, 39, 33, 26, 15, 1 },
+ { 152, 145, 138, 132, 123, 117, 111, 105, 98, 92, 86, 80, 74, 67, 61, 55, 49, 43, 36, 20, 1 },
+ { 162, 155, 148, 142, 133, 127, 121, 115, 108, 102, 96, 90, 84, 77, 71, 65, 59, 53, 46, 30, 1 },
+ { 172, 165, 158, 152, 143, 137, 131, 125, 118, 112, 106, 100, 94, 87, 81, 75, 69, 63, 56, 45, 20 },
+ { 200, 200, 200, 200, 200, 200, 200, 200, 198, 193, 188, 183, 178, 173, 168, 163, 158, 153, 148, 129, 104 }
+};
+
+static const uint8_t celt_static_caps[4][2][21] = {
+ { // 120-sample
+ {224, 224, 224, 224, 224, 224, 224, 224, 160, 160,
+ 160, 160, 185, 185, 185, 178, 178, 168, 134, 61, 37},
+ {224, 224, 224, 224, 224, 224, 224, 224, 240, 240,
+ 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40},
+ }, { // 240-sample
+ {160, 160, 160, 160, 160, 160, 160, 160, 185, 185,
+ 185, 185, 193, 193, 193, 183, 183, 172, 138, 64, 38},
+ {240, 240, 240, 240, 240, 240, 240, 240, 207, 207,
+ 207, 207, 204, 204, 204, 193, 193, 180, 143, 66, 40},
+ }, { // 480-sample
+ {185, 185, 185, 185, 185, 185, 185, 185, 193, 193,
+ 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39},
+ {207, 207, 207, 207, 207, 207, 207, 207, 204, 204,
+ 204, 204, 201, 201, 201, 188, 188, 176, 141, 66, 40},
+ }, { // 960-sample
+ {193, 193, 193, 193, 193, 193, 193, 193, 193, 193,
+ 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39},
+ {204, 204, 204, 204, 204, 204, 204, 204, 201, 201,
+ 201, 201, 198, 198, 198, 187, 187, 175, 140, 66, 40}
+ }
+};
+
+static const uint8_t celt_cache_bits[392] = {
+ 40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28,
+ 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50,
+ 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65,
+ 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61,
+ 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92,
+ 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123,
+ 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94,
+ 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139,
+ 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35,
+ 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149,
+ 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225,
+ 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157,
+ 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63,
+ 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250,
+ 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180,
+ 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89,
+ 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41,
+ 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138,
+ 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214,
+ 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49,
+ 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47,
+ 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57,
+ 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187,
+ 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127,
+ 182, 234
+};
+
+static const int16_t celt_cache_index[105] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41,
+ 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41,
+ 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41,
+ 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305,
+ 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240,
+ 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240,
+ 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387,
+};
+
+static const uint8_t celt_log2_frac[] = {
+ 0, 8, 13, 16, 19, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 37
+};
+
+static const uint8_t celt_bit_interleave[] = {
+ 0, 1, 1, 1, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3
+};
+
+static const uint8_t celt_bit_deinterleave[] = {
+ 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F,
+ 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF
+};
+
+static const uint8_t celt_hadamard_ordery[] = {
+ 1, 0,
+ 3, 0, 2, 1,
+ 7, 0, 4, 3, 6, 1, 5, 2,
+ 15, 0, 8, 7, 12, 3, 11, 4, 14, 1, 9, 6, 13, 2, 10, 5
+};
+
+static const uint16_t celt_qn_exp2[] = {
+ 16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048
+};
+
+static const uint32_t celt_pvq_u[1272] = {
+ /* N = 0, K = 0...176 */
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ /* N = 1, K = 1...176 */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ /* N = 2, K = 2...176 */
+ 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41,
+ 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79,
+ 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113,
+ 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143,
+ 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173,
+ 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203,
+ 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233,
+ 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263,
+ 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293,
+ 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323,
+ 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351,
+ /* N = 3, K = 3...176 */
+ 13, 25, 41, 61, 85, 113, 145, 181, 221, 265, 313, 365, 421, 481, 545, 613,
+ 685, 761, 841, 925, 1013, 1105, 1201, 1301, 1405, 1513, 1625, 1741, 1861,
+ 1985, 2113, 2245, 2381, 2521, 2665, 2813, 2965, 3121, 3281, 3445, 3613, 3785,
+ 3961, 4141, 4325, 4513, 4705, 4901, 5101, 5305, 5513, 5725, 5941, 6161, 6385,
+ 6613, 6845, 7081, 7321, 7565, 7813, 8065, 8321, 8581, 8845, 9113, 9385, 9661,
+ 9941, 10225, 10513, 10805, 11101, 11401, 11705, 12013, 12325, 12641, 12961,
+ 13285, 13613, 13945, 14281, 14621, 14965, 15313, 15665, 16021, 16381, 16745,
+ 17113, 17485, 17861, 18241, 18625, 19013, 19405, 19801, 20201, 20605, 21013,
+ 21425, 21841, 22261, 22685, 23113, 23545, 23981, 24421, 24865, 25313, 25765,
+ 26221, 26681, 27145, 27613, 28085, 28561, 29041, 29525, 30013, 30505, 31001,
+ 31501, 32005, 32513, 33025, 33541, 34061, 34585, 35113, 35645, 36181, 36721,
+ 37265, 37813, 38365, 38921, 39481, 40045, 40613, 41185, 41761, 42341, 42925,
+ 43513, 44105, 44701, 45301, 45905, 46513, 47125, 47741, 48361, 48985, 49613,
+ 50245, 50881, 51521, 52165, 52813, 53465, 54121, 54781, 55445, 56113, 56785,
+ 57461, 58141, 58825, 59513, 60205, 60901, 61601,
+ /* N = 4, K = 4...176 */
+ 63, 129, 231, 377, 575, 833, 1159, 1561, 2047, 2625, 3303, 4089, 4991, 6017,
+ 7175, 8473, 9919, 11521, 13287, 15225, 17343, 19649, 22151, 24857, 27775,
+ 30913, 34279, 37881, 41727, 45825, 50183, 54809, 59711, 64897, 70375, 76153,
+ 82239, 88641, 95367, 102425, 109823, 117569, 125671, 134137, 142975, 152193,
+ 161799, 171801, 182207, 193025, 204263, 215929, 228031, 240577, 253575,
+ 267033, 280959, 295361, 310247, 325625, 341503, 357889, 374791, 392217,
+ 410175, 428673, 447719, 467321, 487487, 508225, 529543, 551449, 573951,
+ 597057, 620775, 645113, 670079, 695681, 721927, 748825, 776383, 804609,
+ 833511, 863097, 893375, 924353, 956039, 988441, 1021567, 1055425, 1090023,
+ 1125369, 1161471, 1198337, 1235975, 1274393, 1313599, 1353601, 1394407,
+ 1436025, 1478463, 1521729, 1565831, 1610777, 1656575, 1703233, 1750759,
+ 1799161, 1848447, 1898625, 1949703, 2001689, 2054591, 2108417, 2163175,
+ 2218873, 2275519, 2333121, 2391687, 2451225, 2511743, 2573249, 2635751,
+ 2699257, 2763775, 2829313, 2895879, 2963481, 3032127, 3101825, 3172583,
+ 3244409, 3317311, 3391297, 3466375, 3542553, 3619839, 3698241, 3777767,
+ 3858425, 3940223, 4023169, 4107271, 4192537, 4278975, 4366593, 4455399,
+ 4545401, 4636607, 4729025, 4822663, 4917529, 5013631, 5110977, 5209575,
+ 5309433, 5410559, 5512961, 5616647, 5721625, 5827903, 5935489, 6044391,
+ 6154617, 6266175, 6379073, 6493319, 6608921, 6725887, 6844225, 6963943,
+ 7085049, 7207551,
+ /* N = 5, K = 5...176 */
+ 321, 681, 1289, 2241, 3649, 5641, 8361, 11969, 16641, 22569, 29961, 39041,
+ 50049, 63241, 78889, 97281, 118721, 143529, 172041, 204609, 241601, 283401,
+ 330409, 383041, 441729, 506921, 579081, 658689, 746241, 842249, 947241,
+ 1061761, 1186369, 1321641, 1468169, 1626561, 1797441, 1981449, 2179241,
+ 2391489, 2618881, 2862121, 3121929, 3399041, 3694209, 4008201, 4341801,
+ 4695809, 5071041, 5468329, 5888521, 6332481, 6801089, 7295241, 7815849,
+ 8363841, 8940161, 9545769, 10181641, 10848769, 11548161, 12280841, 13047849,
+ 13850241, 14689089, 15565481, 16480521, 17435329, 18431041, 19468809,
+ 20549801, 21675201, 22846209, 24064041, 25329929, 26645121, 28010881,
+ 29428489, 30899241, 32424449, 34005441, 35643561, 37340169, 39096641,
+ 40914369, 42794761, 44739241, 46749249, 48826241, 50971689, 53187081,
+ 55473921, 57833729, 60268041, 62778409, 65366401, 68033601, 70781609,
+ 73612041, 76526529, 79526721, 82614281, 85790889, 89058241, 92418049,
+ 95872041, 99421961, 103069569, 106816641, 110664969, 114616361, 118672641,
+ 122835649, 127107241, 131489289, 135983681, 140592321, 145317129, 150160041,
+ 155123009, 160208001, 165417001, 170752009, 176215041, 181808129, 187533321,
+ 193392681, 199388289, 205522241, 211796649, 218213641, 224775361, 231483969,
+ 238341641, 245350569, 252512961, 259831041, 267307049, 274943241, 282741889,
+ 290705281, 298835721, 307135529, 315607041, 324252609, 333074601, 342075401,
+ 351257409, 360623041, 370174729, 379914921, 389846081, 399970689, 410291241,
+ 420810249, 431530241, 442453761, 453583369, 464921641, 476471169, 488234561,
+ 500214441, 512413449, 524834241, 537479489, 550351881, 563454121, 576788929,
+ 590359041, 604167209, 618216201, 632508801,
+ /* N = 6, K = 6...96 (technically V(109,5) fits in 32 bits, but that can't be
+ achieved by splitting an Opus band) */
+ 1683, 3653, 7183, 13073, 22363, 36365, 56695, 85305, 124515, 177045, 246047,
+ 335137, 448427, 590557, 766727, 982729, 1244979, 1560549, 1937199, 2383409,
+ 2908411, 3522221, 4235671, 5060441, 6009091, 7095093, 8332863, 9737793,
+ 11326283, 13115773, 15124775, 17372905, 19880915, 22670725, 25765455,
+ 29189457, 32968347, 37129037, 41699767, 46710137, 52191139, 58175189,
+ 64696159, 71789409, 79491819, 87841821, 96879431, 106646281, 117185651,
+ 128542501, 140763503, 153897073, 167993403, 183104493, 199284183, 216588185,
+ 235074115, 254801525, 275831935, 298228865, 322057867, 347386557, 374284647,
+ 402823977, 433078547, 465124549, 499040399, 534906769, 572806619, 612825229,
+ 655050231, 699571641, 746481891, 795875861, 847850911, 902506913, 959946283,
+ 1020274013, 1083597703, 1150027593, 1219676595, 1292660325, 1369097135,
+ 1449108145, 1532817275, 1620351277, 1711839767, 1807415257, 1907213187,
+ 2011371957, 2120032959,
+ /* N = 7, K = 7...54 (technically V(60,6) fits in 32 bits, but that can't be
+ achieved by splitting an Opus band) */
+ 8989, 19825, 40081, 75517, 134245, 227305, 369305, 579125, 880685, 1303777,
+ 1884961, 2668525, 3707509, 5064793, 6814249, 9041957, 11847485, 15345233,
+ 19665841, 24957661, 31388293, 39146185, 48442297, 59511829, 72616013,
+ 88043969, 106114625, 127178701, 151620757, 179861305, 212358985, 249612805,
+ 292164445, 340600625, 395555537, 457713341, 527810725, 606639529, 695049433,
+ 793950709, 904317037, 1027188385, 1163673953, 1314955181, 1482288821,
+ 1667010073, 1870535785, 2094367717,
+ /* N = 8, K = 8...37 (technically V(40,7) fits in 32 bits, but that can't be
+ achieved by splitting an Opus band) */
+ 48639, 108545, 224143, 433905, 795455, 1392065, 2340495, 3800305, 5984767,
+ 9173505, 13726991, 20103025, 28875327, 40754369, 56610575, 77500017,
+ 104692735, 139703809, 184327311, 240673265, 311207743, 398796225, 506750351,
+ 638878193, 799538175, 993696769, 1226990095, 1505789553, 1837271615,
+ 2229491905,
+ /* N = 9, K = 9...28 (technically V(29,8) fits in 32 bits, but that can't be
+ achieved by splitting an Opus band) */
+ 265729, 598417, 1256465, 2485825, 4673345, 8405905, 14546705, 24331777,
+ 39490049, 62390545, 96220561, 145198913, 214828609, 312193553, 446304145,
+ 628496897, 872893441, 1196924561, 1621925137, 2173806145,
+ /* N = 10, K = 10...24 */
+ 1462563, 3317445, 7059735, 14218905, 27298155, 50250765, 89129247, 152951073,
+ 254831667, 413442773, 654862247, 1014889769, 1541911931, 2300409629,
+ 3375210671,
+ /* N = 11, K = 11...19 (technically V(20,10) fits in 32 bits, but that can't be
+ achieved by splitting an Opus band) */
+ 8097453, 18474633, 39753273, 81270333, 158819253, 298199265, 540279585,
+ 948062325, 1616336765,
+ /* N = 12, K = 12...18 */
+ 45046719, 103274625, 224298231, 464387817, 921406335, 1759885185,
+ 3248227095,
+ /* N = 13, K = 13...16 */
+ 251595969, 579168825, 1267854873, 2653649025,
+ /* N = 14, K = 14 */
+ 1409933619
+};
+
+DECLARE_ALIGNED(32, static const float, celt_window)[120] = {
+ 6.7286966e-05f, 0.00060551348f, 0.0016815970f, 0.0032947962f, 0.0054439943f,
+ 0.0081276923f, 0.011344001f, 0.015090633f, 0.019364886f, 0.024163635f,
+ 0.029483315f, 0.035319905f, 0.041668911f, 0.048525347f, 0.055883718f,
+ 0.063737999f, 0.072081616f, 0.080907428f, 0.090207705f, 0.099974111f,
+ 0.11019769f, 0.12086883f, 0.13197729f, 0.14351214f, 0.15546177f,
+ 0.16781389f, 0.18055550f, 0.19367290f, 0.20715171f, 0.22097682f,
+ 0.23513243f, 0.24960208f, 0.26436860f, 0.27941419f, 0.29472040f,
+ 0.31026818f, 0.32603788f, 0.34200931f, 0.35816177f, 0.37447407f,
+ 0.39092462f, 0.40749142f, 0.42415215f, 0.44088423f, 0.45766484f,
+ 0.47447104f, 0.49127978f, 0.50806798f, 0.52481261f, 0.54149077f,
+ 0.55807973f, 0.57455701f, 0.59090049f, 0.60708841f, 0.62309951f,
+ 0.63891306f, 0.65450896f, 0.66986776f, 0.68497077f, 0.69980010f,
+ 0.71433873f, 0.72857055f, 0.74248043f, 0.75605424f, 0.76927895f,
+ 0.78214257f, 0.79463430f, 0.80674445f, 0.81846456f, 0.82978733f,
+ 0.84070669f, 0.85121779f, 0.86131698f, 0.87100183f, 0.88027111f,
+ 0.88912479f, 0.89756398f, 0.90559094f, 0.91320904f, 0.92042270f,
+ 0.92723738f, 0.93365955f, 0.93969656f, 0.94535671f, 0.95064907f,
+ 0.95558353f, 0.96017067f, 0.96442171f, 0.96834849f, 0.97196334f,
+ 0.97527906f, 0.97830883f, 0.98106616f, 0.98356480f, 0.98581869f,
+ 0.98784191f, 0.98964856f, 0.99125274f, 0.99266849f, 0.99390969f,
+ 0.99499004f, 0.99592297f, 0.99672162f, 0.99739874f, 0.99796667f,
+ 0.99843728f, 0.99882195f, 0.99913147f, 0.99937606f, 0.99956527f,
+ 0.99970802f, 0.99981248f, 0.99988613f, 0.99993565f, 0.99996697f,
+ 0.99998518f, 0.99999457f, 0.99999859f, 0.99999982f, 1.0000000f,
+};
+
+/* square of the window, used for the postfilter */
+const float ff_celt_window2[120] = {
+ 4.5275357e-09f, 3.66647e-07f, 2.82777e-06f, 1.08557e-05f, 2.96371e-05f, 6.60594e-05f,
+ 0.000128686f, 0.000227727f, 0.000374999f, 0.000583881f, 0.000869266f, 0.0012475f,
+ 0.0017363f, 0.00235471f, 0.00312299f, 0.00406253f, 0.00519576f, 0.00654601f,
+ 0.00813743f, 0.00999482f, 0.0121435f, 0.0146093f, 0.017418f, 0.0205957f, 0.0241684f,
+ 0.0281615f, 0.0326003f, 0.0375092f, 0.0429118f, 0.0488308f, 0.0552873f, 0.0623012f,
+ 0.0698908f, 0.0780723f, 0.0868601f, 0.0962664f, 0.106301f, 0.11697f, 0.12828f,
+ 0.140231f, 0.152822f, 0.166049f, 0.179905f, 0.194379f, 0.209457f, 0.225123f, 0.241356f,
+ 0.258133f, 0.275428f, 0.293212f, 0.311453f, 0.330116f, 0.349163f, 0.368556f, 0.388253f,
+ 0.40821f, 0.428382f, 0.448723f, 0.469185f, 0.48972f, 0.51028f, 0.530815f, 0.551277f,
+ 0.571618f, 0.59179f, 0.611747f, 0.631444f, 0.650837f, 0.669884f, 0.688547f, 0.706788f,
+ 0.724572f, 0.741867f, 0.758644f, 0.774877f, 0.790543f, 0.805621f, 0.820095f, 0.833951f,
+ 0.847178f, 0.859769f, 0.87172f, 0.88303f, 0.893699f, 0.903734f, 0.91314f, 0.921928f,
+ 0.930109f, 0.937699f, 0.944713f, 0.951169f, 0.957088f, 0.962491f, 0.9674f, 0.971838f,
+ 0.975832f, 0.979404f, 0.982582f, 0.985391f, 0.987857f, 0.990005f, 0.991863f, 0.993454f,
+ 0.994804f, 0.995937f, 0.996877f, 0.997645f, 0.998264f, 0.998753f, 0.999131f, 0.999416f,
+ 0.999625f, 0.999772f, 0.999871f, 0.999934f, 0.99997f, 0.999989f, 0.999997f, 0.99999964f, 1.0f,
+};
+
+static const uint32_t * const celt_pvq_u_row[15] = {
+ celt_pvq_u + 0, celt_pvq_u + 176, celt_pvq_u + 351,
+ celt_pvq_u + 525, celt_pvq_u + 698, celt_pvq_u + 870,
+ celt_pvq_u + 1041, celt_pvq_u + 1131, celt_pvq_u + 1178,
+ celt_pvq_u + 1207, celt_pvq_u + 1226, celt_pvq_u + 1240,
+ celt_pvq_u + 1248, celt_pvq_u + 1254, celt_pvq_u + 1257
+};
+
+static inline int16_t celt_cos(int16_t x)
+{
+ x = (MUL16(x, x) + 4096) >> 13;
+ x = (32767-x) + ROUND_MUL16(x, (-7651 + ROUND_MUL16(x, (8277 + ROUND_MUL16(-626, x)))));
+ return 1+x;
+}
+
+static inline int celt_log2tan(int isin, int icos)
+{
+ int lc, ls;
+ lc = opus_ilog(icos);
+ ls = opus_ilog(isin);
+ icos <<= 15 - lc;
+ isin <<= 15 - ls;
+ return (ls << 11) - (lc << 11) +
+ ROUND_MUL16(isin, ROUND_MUL16(isin, -2597) + 7932) -
+ ROUND_MUL16(icos, ROUND_MUL16(icos, -2597) + 7932);
+}
+
+static inline uint32_t celt_rng(CeltContext *s)
+{
+ s->seed = 1664525 * s->seed + 1013904223;
+ return s->seed;
+}
+
+static void celt_decode_coarse_energy(CeltContext *s, OpusRangeCoder *rc)
+{
+ int i, j;
+ float prev[2] = {0};
+ float alpha, beta;
+ const uint8_t *model;
+
+ /* use the 2D z-transform to apply prediction in both */
+ /* the time domain (alpha) and the frequency domain (beta) */
+
+ if (opus_rc_tell(rc)+3 <= s->framebits && opus_rc_p2model(rc, 3)) {
+ /* intra frame */
+ alpha = 0;
+ beta = 1.0f - 4915.0f/32768.0f;
+ model = celt_coarse_energy_dist[s->duration][1];
+ } else {
+ alpha = celt_alpha_coef[s->duration];
+ beta = 1.0f - celt_beta_coef[s->duration];
+ model = celt_coarse_energy_dist[s->duration][0];
+ }
+
+ for (i = 0; i < CELT_MAX_BANDS; i++) {
+ for (j = 0; j < s->coded_channels; j++) {
+ CeltFrame *frame = &s->frame[j];
+ float value;
+ int available;
+
+ if (i < s->startband || i >= s->endband) {
+ frame->energy[i] = 0.0;
+ continue;
+ }
+
+ available = s->framebits - opus_rc_tell(rc);
+ if (available >= 15) {
+ /* decode using a Laplace distribution */
+ int k = FFMIN(i, 20) << 1;
+ value = opus_rc_laplace(rc, model[k] << 7, model[k+1] << 6);
+ } else if (available >= 2) {
+ int x = opus_rc_getsymbol(rc, celt_model_energy_small);
+ value = (x>>1) ^ -(x&1);
+ } else if (available >= 1) {
+ value = -(float)opus_rc_p2model(rc, 1);
+ } else value = -1;
+
+ frame->energy[i] = FFMAX(-9.0f, frame->energy[i]) * alpha + prev[j] + value;
+ prev[j] += beta * value;
+ }
+ }
+}
+
+static void celt_decode_fine_energy(CeltContext *s, OpusRangeCoder *rc)
+{
+ int i;
+ for (i = s->startband; i < s->endband; i++) {
+ int j;
+ if (!s->fine_bits[i])
+ continue;
+
+ for (j = 0; j < s->coded_channels; j++) {
+ CeltFrame *frame = &s->frame[j];
+ int q2;
+ float offset;
+ q2 = opus_getrawbits(rc, s->fine_bits[i]);
+ offset = (q2 + 0.5f) * (1 << (14 - s->fine_bits[i])) / 16384.0f - 0.5f;
+ frame->energy[i] += offset;
+ }
+ }
+}
+
+static void celt_decode_final_energy(CeltContext *s, OpusRangeCoder *rc,
+ int bits_left)
+{
+ int priority, i, j;
+
+ for (priority = 0; priority < 2; priority++) {
+ for (i = s->startband; i < s->endband && bits_left >= s->coded_channels; i++) {
+ if (s->fine_priority[i] != priority || s->fine_bits[i] >= CELT_MAX_FINE_BITS)
+ continue;
+
+ for (j = 0; j < s->coded_channels; j++) {
+ int q2;
+ float offset;
+ q2 = opus_getrawbits(rc, 1);
+ offset = (q2 - 0.5f) * (1 << (14 - s->fine_bits[i] - 1)) / 16384.0f;
+ s->frame[j].energy[i] += offset;
+ bits_left--;
+ }
+ }
+ }
+}
+
+static void celt_decode_tf_changes(CeltContext *s, OpusRangeCoder *rc,
+ int transient)
+{
+ int i, diff = 0, tf_select = 0, tf_changed = 0, tf_select_bit;
+ int consumed, bits = transient ? 2 : 4;
+
+ consumed = opus_rc_tell(rc);
+ tf_select_bit = (s->duration != 0 && consumed+bits+1 <= s->framebits);
+
+ for (i = s->startband; i < s->endband; i++) {
+ if (consumed+bits+tf_select_bit <= s->framebits) {
+ diff ^= opus_rc_p2model(rc, bits);
+ consumed = opus_rc_tell(rc);
+ tf_changed |= diff;
+ }
+ s->tf_change[i] = diff;
+ bits = transient ? 4 : 5;
+ }
+
+ if (tf_select_bit && celt_tf_select[s->duration][transient][0][tf_changed] !=
+ celt_tf_select[s->duration][transient][1][tf_changed])
+ tf_select = opus_rc_p2model(rc, 1);
+
+ for (i = s->startband; i < s->endband; i++) {
+ s->tf_change[i] = celt_tf_select[s->duration][transient][tf_select][s->tf_change[i]];
+ }
+}
+
+static void celt_decode_allocation(CeltContext *s, OpusRangeCoder *rc)
+{
+ // approx. maximum bit allocation for each band before boost/trim
+ int cap[CELT_MAX_BANDS];
+ int boost[CELT_MAX_BANDS];
+ int threshold[CELT_MAX_BANDS];
+ int bits1[CELT_MAX_BANDS];
+ int bits2[CELT_MAX_BANDS];
+ int trim_offset[CELT_MAX_BANDS];
+
+ int skip_startband = s->startband;
+ int dynalloc = 6;
+ int alloctrim = 5;
+ int extrabits = 0;
+
+ int skip_bit = 0;
+ int intensitystereo_bit = 0;
+ int dualstereo_bit = 0;
+
+ int remaining, bandbits;
+ int low, high, total, done;
+ int totalbits;
+ int consumed;
+ int i, j;
+
+ consumed = opus_rc_tell(rc);
+
+ /* obtain spread flag */
+ s->spread = CELT_SPREAD_NORMAL;
+ if (consumed + 4 <= s->framebits)
+ s->spread = opus_rc_getsymbol(rc, celt_model_spread);
+
+ /* generate static allocation caps */
+ for (i = 0; i < CELT_MAX_BANDS; i++) {
+ cap[i] = (celt_static_caps[s->duration][s->coded_channels - 1][i] + 64)
+ * celt_freq_range[i] << (s->coded_channels - 1) << s->duration >> 2;
+ }
+
+ /* obtain band boost */
+ totalbits = s->framebits << 3; // convert to 1/8 bits
+ consumed = opus_rc_tell_frac(rc);
+ for (i = s->startband; i < s->endband; i++) {
+ int quanta, band_dynalloc;
+
+ boost[i] = 0;
+
+ quanta = celt_freq_range[i] << (s->coded_channels - 1) << s->duration;
+ quanta = FFMIN(quanta << 3, FFMAX(6 << 3, quanta));
+ band_dynalloc = dynalloc;
+ while (consumed + (band_dynalloc<<3) < totalbits && boost[i] < cap[i]) {
+ int add = opus_rc_p2model(rc, band_dynalloc);
+ consumed = opus_rc_tell_frac(rc);
+ if (!add)
+ break;
+
+ boost[i] += quanta;
+ totalbits -= quanta;
+ band_dynalloc = 1;
+ }
+ /* dynalloc is more likely to occur if it's already been used for earlier bands */
+ if (boost[i])
+ dynalloc = FFMAX(2, dynalloc - 1);
+ }
+
+ /* obtain allocation trim */
+ if (consumed + (6 << 3) <= totalbits)
+ alloctrim = opus_rc_getsymbol(rc, celt_model_alloc_trim);
+
+ /* anti-collapse bit reservation */
+ totalbits = (s->framebits << 3) - opus_rc_tell_frac(rc) - 1;
+ s->anticollapse_bit = 0;
+ if (s->blocks > 1 && s->duration >= 2 &&
+ totalbits >= ((s->duration + 2) << 3))
+ s->anticollapse_bit = 1 << 3;
+ totalbits -= s->anticollapse_bit;
+
+ /* band skip bit reservation */
+ if (totalbits >= 1 << 3)
+ skip_bit = 1 << 3;
+ totalbits -= skip_bit;
+
+ /* intensity/dual stereo bit reservation */
+ if (s->coded_channels == 2) {
+ intensitystereo_bit = celt_log2_frac[s->endband - s->startband];
+ if (intensitystereo_bit <= totalbits) {
+ totalbits -= intensitystereo_bit;
+ if (totalbits >= 1 << 3) {
+ dualstereo_bit = 1 << 3;
+ totalbits -= 1 << 3;
+ }
+ } else
+ intensitystereo_bit = 0;
+ }
+
+ for (i = s->startband; i < s->endband; i++) {
+ int trim = alloctrim - 5 - s->duration;
+ int band = celt_freq_range[i] * (s->endband - i - 1);
+ int duration = s->duration + 3;
+ int scale = duration + s->coded_channels - 1;
+
+ /* PVQ minimum allocation threshold, below this value the band is
+ * skipped */
+ threshold[i] = FFMAX(3 * celt_freq_range[i] << duration >> 4,
+ s->coded_channels << 3);
+
+ trim_offset[i] = trim * (band << scale) >> 6;
+
+ if (celt_freq_range[i] << s->duration == 1)
+ trim_offset[i] -= s->coded_channels << 3;
+ }
+
+ /* bisection */
+ low = 1;
+ high = CELT_VECTORS - 1;
+ while (low <= high) {
+ int center = (low + high) >> 1;
+ done = total = 0;
+
+ for (i = s->endband - 1; i >= s->startband; i--) {
+ bandbits = celt_freq_range[i] * celt_static_alloc[center][i]
+ << (s->coded_channels - 1) << s->duration >> 2;
+
+ if (bandbits)
+ bandbits = FFMAX(0, bandbits + trim_offset[i]);
+ bandbits += boost[i];
+
+ if (bandbits >= threshold[i] || done) {
+ done = 1;
+ total += FFMIN(bandbits, cap[i]);
+ } else if (bandbits >= s->coded_channels << 3)
+ total += s->coded_channels << 3;
+ }
+
+ if (total > totalbits)
+ high = center - 1;
+ else
+ low = center + 1;
+ }
+ high = low--;
+
+ for (i = s->startband; i < s->endband; i++) {
+ bits1[i] = celt_freq_range[i] * celt_static_alloc[low][i]
+ << (s->coded_channels - 1) << s->duration >> 2;
+ bits2[i] = high >= CELT_VECTORS ? cap[i] :
+ celt_freq_range[i] * celt_static_alloc[high][i]
+ << (s->coded_channels - 1) << s->duration >> 2;
+
+ if (bits1[i])
+ bits1[i] = FFMAX(0, bits1[i] + trim_offset[i]);
+ if (bits2[i])
+ bits2[i] = FFMAX(0, bits2[i] + trim_offset[i]);
+ if (low)
+ bits1[i] += boost[i];
+ bits2[i] += boost[i];
+
+ if (boost[i])
+ skip_startband = i;
+ bits2[i] = FFMAX(0, bits2[i] - bits1[i]);
+ }
+
+ /* bisection */
+ low = 0;
+ high = 1 << CELT_ALLOC_STEPS;
+ for (i = 0; i < CELT_ALLOC_STEPS; i++) {
+ int center = (low + high) >> 1;
+ done = total = 0;
+
+ for (j = s->endband - 1; j >= s->startband; j--) {
+ bandbits = bits1[j] + (center * bits2[j] >> CELT_ALLOC_STEPS);
+
+ if (bandbits >= threshold[j] || done) {
+ done = 1;
+ total += FFMIN(bandbits, cap[j]);
+ } else if (bandbits >= s->coded_channels << 3)
+ total += s->coded_channels << 3;
+ }
+ if (total > totalbits)
+ high = center;
+ else
+ low = center;
+ }
+
+ done = total = 0;
+ for (i = s->endband - 1; i >= s->startband; i--) {
+ bandbits = bits1[i] + (low * bits2[i] >> CELT_ALLOC_STEPS);
+
+ if (bandbits >= threshold[i] || done)
+ done = 1;
+ else
+ bandbits = (bandbits >= s->coded_channels << 3) ?
+ s->coded_channels << 3 : 0;
+
+ bandbits = FFMIN(bandbits, cap[i]);
+ s->pulses[i] = bandbits;
+ total += bandbits;
+ }
+
+ /* band skipping */
+ for (s->codedbands = s->endband; ; s->codedbands--) {
+ int allocation;
+ j = s->codedbands - 1;
+
+ if (j == skip_startband) {
+ /* all remaining bands are not skipped */
+ totalbits += skip_bit;
+ break;
+ }
+
+ /* determine the number of bits available for coding "do not skip" markers */
+ remaining = totalbits - total;
+ bandbits = remaining / (celt_freq_bands[j+1] - celt_freq_bands[s->startband]);
+ remaining -= bandbits * (celt_freq_bands[j+1] - celt_freq_bands[s->startband]);
+ allocation = s->pulses[j] + bandbits * celt_freq_range[j]
+ + FFMAX(0, remaining - (celt_freq_bands[j] - celt_freq_bands[s->startband]));
+
+ /* a "do not skip" marker is only coded if the allocation is
+ above the chosen threshold */
+ if (allocation >= FFMAX(threshold[j], (s->coded_channels + 1) <<3 )) {
+ if (opus_rc_p2model(rc, 1))
+ break;
+
+ total += 1 << 3;
+ allocation -= 1 << 3;
+ }
+
+ /* the band is skipped, so reclaim its bits */
+ total -= s->pulses[j];
+ if (intensitystereo_bit) {
+ total -= intensitystereo_bit;
+ intensitystereo_bit = celt_log2_frac[j - s->startband];
+ total += intensitystereo_bit;
+ }
+
+ total += s->pulses[j] = (allocation >= s->coded_channels << 3) ?
+ s->coded_channels << 3 : 0;
+ }
+
+ /* obtain stereo flags */
+ s->intensitystereo = 0;
+ s->dualstereo = 0;
+ if (intensitystereo_bit)
+ s->intensitystereo = s->startband +
+ opus_rc_unimodel(rc, s->codedbands + 1 - s->startband);
+ if (s->intensitystereo <= s->startband)
+ totalbits += dualstereo_bit; /* no intensity stereo means no dual stereo */
+ else if (dualstereo_bit)
+ s->dualstereo = opus_rc_p2model(rc, 1);
+
+ /* supply the remaining bits in this frame to lower bands */
+ remaining = totalbits - total;
+ bandbits = remaining / (celt_freq_bands[s->codedbands] - celt_freq_bands[s->startband]);
+ remaining -= bandbits * (celt_freq_bands[s->codedbands] - celt_freq_bands[s->startband]);
+ for (i = s->startband; i < s->codedbands; i++) {
+ int bits = FFMIN(remaining, celt_freq_range[i]);
+
+ s->pulses[i] += bits + bandbits * celt_freq_range[i];
+ remaining -= bits;
+ }
+
+ for (i = s->startband; i < s->codedbands; i++) {
+ int N = celt_freq_range[i] << s->duration;
+ int prev_extra = extrabits;
+ s->pulses[i] += extrabits;
+
+ if (N > 1) {
+ int dof; // degrees of freedom
+ int temp; // dof * channels * log(dof)
+ int offset; // fine energy quantization offset, i.e.
+ // extra bits assigned over the standard
+ // totalbits/dof
+ int fine_bits, max_bits;
+
+ extrabits = FFMAX(0, s->pulses[i] - cap[i]);
+ s->pulses[i] -= extrabits;
+
+ /* intensity stereo makes use of an extra degree of freedom */
+ dof = N * s->coded_channels
+ + (s->coded_channels == 2 && N > 2 && !s->dualstereo && i < s->intensitystereo);
+ temp = dof * (celt_log_freq_range[i] + (s->duration<<3));
+ offset = (temp >> 1) - dof * CELT_FINE_OFFSET;
+ if (N == 2) /* dof=2 is the only case that doesn't fit the model */
+ offset += dof<<1;
+
+ /* grant an additional bias for the first and second pulses */
+ if (s->pulses[i] + offset < 2 * (dof << 3))
+ offset += temp >> 2;
+ else if (s->pulses[i] + offset < 3 * (dof << 3))
+ offset += temp >> 3;
+
+ fine_bits = (s->pulses[i] + offset + (dof << 2)) / (dof << 3);
+ max_bits = FFMIN((s->pulses[i]>>3) >> (s->coded_channels - 1),
+ CELT_MAX_FINE_BITS);
+
+ max_bits = FFMAX(max_bits, 0);
+
+ s->fine_bits[i] = av_clip(fine_bits, 0, max_bits);
+
+ /* if fine_bits was rounded down or capped,
+ give priority for the final fine energy pass */
+ s->fine_priority[i] = (s->fine_bits[i] * (dof<<3) >= s->pulses[i] + offset);
+
+ /* the remaining bits are assigned to PVQ */
+ s->pulses[i] -= s->fine_bits[i] << (s->coded_channels - 1) << 3;
+ } else {
+ /* all bits go to fine energy except for the sign bit */
+ extrabits = FFMAX(0, s->pulses[i] - (s->coded_channels << 3));
+ s->pulses[i] -= extrabits;
+ s->fine_bits[i] = 0;
+ s->fine_priority[i] = 1;
+ }
+
+ /* hand back a limited number of extra fine energy bits to this band */
+ if (extrabits > 0) {
+ int fineextra = FFMIN(extrabits >> (s->coded_channels + 2),
+ CELT_MAX_FINE_BITS - s->fine_bits[i]);
+ s->fine_bits[i] += fineextra;
+
+ fineextra <<= s->coded_channels + 2;
+ s->fine_priority[i] = (fineextra >= extrabits - prev_extra);
+ extrabits -= fineextra;
+ }
+ }
+ s->remaining = extrabits;
+
+ /* skipped bands dedicate all of their bits for fine energy */
+ for (; i < s->endband; i++) {
+ s->fine_bits[i] = s->pulses[i] >> (s->coded_channels - 1) >> 3;
+ s->pulses[i] = 0;
+ s->fine_priority[i] = s->fine_bits[i] < 1;
+ }
+}
+
+static inline int celt_bits2pulses(const uint8_t *cache, int bits)
+{
+ // TODO: Find the size of cache and make it into an array in the parameters list
+ int i, low = 0, high;
+
+ high = cache[0];
+ bits--;
+
+ for (i = 0; i < 6; i++) {
+ int center = (low + high + 1) >> 1;
+ if (cache[center] >= bits)
+ high = center;
+ else
+ low = center;
+ }
+
+ return (bits - (low == 0 ? -1 : cache[low]) <= cache[high] - bits) ? low : high;
+}
+
+static inline int celt_pulses2bits(const uint8_t *cache, int pulses)
+{
+ // TODO: Find the size of cache and make it into an array in the parameters list
+ return (pulses == 0) ? 0 : cache[pulses] + 1;
+}
+
+static inline void celt_normalize_residual(const int * restrict iy, float * restrict X,
+ int N, float g)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ X[i] = g * iy[i];
+}
+
+static void celt_exp_rotation1(float *X, unsigned int len, unsigned int stride,
+ float c, float s)
+{
+ float *Xptr;
+ int i;
+
+ Xptr = X;
+ for (i = 0; i < len - stride; i++) {
+ float x1, x2;
+ x1 = Xptr[0];
+ x2 = Xptr[stride];
+ Xptr[stride] = c * x2 + s * x1;
+ *Xptr++ = c * x1 - s * x2;
+ }
+
+ Xptr = &X[len - 2 * stride - 1];
+ for (i = len - 2 * stride - 1; i >= 0; i--) {
+ float x1, x2;
+ x1 = Xptr[0];
+ x2 = Xptr[stride];
+ Xptr[stride] = c * x2 + s * x1;
+ *Xptr-- = c * x1 - s * x2;
+ }
+}
+
+static inline void celt_exp_rotation(float *X, unsigned int len,
+ unsigned int stride, unsigned int K,
+ enum CeltSpread spread)
+{
+ unsigned int stride2 = 0;
+ float c, s;
+ float gain, theta;
+ int i;
+
+ if (2*K >= len || spread == CELT_SPREAD_NONE)
+ return;
+
+ gain = (float)len / (len + (20 - 5*spread) * K);
+ theta = M_PI * gain * gain / 4;
+
+ c = cos(theta);
+ s = sin(theta);
+
+ if (len >= stride << 3) {
+ stride2 = 1;
+ /* This is just a simple (equivalent) way of computing sqrt(len/stride) with rounding.
+ It's basically incrementing long as (stride2+0.5)^2 < len/stride. */
+ while ((stride2 * stride2 + stride2) * stride + (stride >> 2) < len)
+ stride2++;
+ }
+
+ /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for
+ extract_collapse_mask().*/
+ len /= stride;
+ for (i = 0; i < stride; i++) {
+ if (stride2)
+ celt_exp_rotation1(X + i * len, len, stride2, s, c);
+ celt_exp_rotation1(X + i * len, len, 1, c, s);
+ }
+}
+
+static inline unsigned int celt_extract_collapse_mask(const int *iy,
+ unsigned int N,
+ unsigned int B)
+{
+ unsigned int collapse_mask;
+ int N0;
+ int i, j;
+
+ if (B <= 1)
+ return 1;
+
+ /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for
+ exp_rotation().*/
+ N0 = N/B;
+ collapse_mask = 0;
+ for (i = 0; i < B; i++)
+ for (j = 0; j < N0; j++)
+ collapse_mask |= (iy[i*N0+j]!=0)<<i;
+ return collapse_mask;
+}
+
+static inline void celt_renormalize_vector(float *X, int N, float gain)
+{
+ int i;
+ float g = 1e-15f;
+ for (i = 0; i < N; i++)
+ g += X[i] * X[i];
+ g = gain / sqrtf(g);
+
+ for (i = 0; i < N; i++)
+ X[i] *= g;
+}
+
+static inline void celt_stereo_merge(float *X, float *Y, float mid, int N)
+{
+ int i;
+ float xp = 0, side = 0;
+ float E[2];
+ float mid2;
+ float t, gain[2];
+
+ /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */
+ for (i = 0; i < N; i++) {
+ xp += X[i] * Y[i];
+ side += Y[i] * Y[i];
+ }
+
+ /* Compensating for the mid normalization */
+ xp *= mid;
+ mid2 = mid;
+ E[0] = mid2 * mid2 + side - 2 * xp;
+ E[1] = mid2 * mid2 + side + 2 * xp;
+ if (E[0] < 6e-4f || E[1] < 6e-4f) {
+ for (i = 0; i < N; i++)
+ Y[i] = X[i];
+ return;
+ }
+
+ t = E[0];
+ gain[0] = 1.0f / sqrtf(t);
+ t = E[1];
+ gain[1] = 1.0f / sqrtf(t);
+
+ for (i = 0; i < N; i++) {
+ float value[2];
+ /* Apply mid scaling (side is already scaled) */
+ value[0] = mid * X[i];
+ value[1] = Y[i];
+ X[i] = gain[0] * (value[0] - value[1]);
+ Y[i] = gain[1] * (value[0] + value[1]);
+ }
+}
+
+static void celt_interleave_hadamard(float *tmp, float *X, int N0,
+ int stride, int hadamard)
+{
+ int i, j;
+ int N = N0*stride;
+
+ if (hadamard) {
+ const uint8_t *ordery = celt_hadamard_ordery + stride - 2;
+ for (i = 0; i < stride; i++)
+ for (j = 0; j < N0; j++)
+ tmp[j*stride+i] = X[ordery[i]*N0+j];
+ } else {
+ for (i = 0; i < stride; i++)
+ for (j = 0; j < N0; j++)
+ tmp[j*stride+i] = X[i*N0+j];
+ }
+
+ for (i = 0; i < N; i++)
+ X[i] = tmp[i];
+}
+
+static void celt_deinterleave_hadamard(float *tmp, float *X, int N0,
+ int stride, int hadamard)
+{
+ int i, j;
+ int N = N0*stride;
+
+ if (hadamard) {
+ const uint8_t *ordery = celt_hadamard_ordery + stride - 2;
+ for (i = 0; i < stride; i++)
+ for (j = 0; j < N0; j++)
+ tmp[ordery[i]*N0+j] = X[j*stride+i];
+ } else {
+ for (i = 0; i < stride; i++)
+ for (j = 0; j < N0; j++)
+ tmp[i*N0+j] = X[j*stride+i];
+ }
+
+ for (i = 0; i < N; i++)
+ X[i] = tmp[i];
+}
+
+static void celt_haar1(float *X, int N0, int stride)
+{
+ int i, j;
+ N0 >>= 1;
+ for (i = 0; i < stride; i++) {
+ for (j = 0; j < N0; j++) {
+ float x0 = X[stride * (2 * j + 0) + i];
+ float x1 = X[stride * (2 * j + 1) + i];
+ X[stride * (2 * j + 0) + i] = (x0 + x1) * M_SQRT1_2;
+ X[stride * (2 * j + 1) + i] = (x0 - x1) * M_SQRT1_2;
+ }
+ }
+}
+
+static inline int celt_compute_qn(int N, int b, int offset, int pulse_cap,
+ int dualstereo)
+{
+ int qn, qb;
+ int N2 = 2 * N - 1;
+ if (dualstereo && N == 2)
+ N2--;
+
+ /* The upper limit ensures that in a stereo split with itheta==16384, we'll
+ * always have enough bits left over to code at least one pulse in the
+ * side; otherwise it would collapse, since it doesn't get folded. */
+ qb = FFMIN3(b - pulse_cap - (4 << 3), (b + N2 * offset) / N2, 8 << 3);
+ qn = (qb < (1 << 3 >> 1)) ? 1 : ((celt_qn_exp2[qb & 0x7] >> (14 - (qb >> 3))) + 1) >> 1 << 1;
+ return qn;
+}
+
+// this code was adapted from libopus
+static inline uint64_t celt_cwrsi(unsigned int N, unsigned int K, unsigned int i, int *y)
+{
+ uint64_t norm = 0;
+ uint32_t p;
+ int s, val;
+ int k0;
+
+ while (N > 2) {
+ uint32_t q;
+
+ /*Lots of pulses case:*/
+ if (K >= N) {
+ const uint32_t *row = celt_pvq_u_row[N];
+
+ /* Are the pulses in this dimension negative? */
+ p = row[K + 1];
+ s = -(i >= p);
+ i -= p & s;
+
+ /*Count how many pulses were placed in this dimension.*/
+ k0 = K;
+ q = row[N];
+ if (q > i) {
+ K = N;
+ do {
+ p = celt_pvq_u_row[--K][N];
+ } while (p > i);
+ } else
+ for (p = row[K]; p > i; p = row[K])
+ K--;
+
+ i -= p;
+ val = (k0 - K + s) ^ s;
+ norm += val * val;
+ *y++ = val;
+ } else { /*Lots of dimensions case:*/
+ /*Are there any pulses in this dimension at all?*/
+ p = celt_pvq_u_row[K ][N];
+ q = celt_pvq_u_row[K + 1][N];
+
+ if (p <= i && i < q) {
+ i -= p;
+ *y++ = 0;
+ } else {
+ /*Are the pulses in this dimension negative?*/
+ s = -(i >= q);
+ i -= q & s;
+
+ /*Count how many pulses were placed in this dimension.*/
+ k0 = K;
+ do p = celt_pvq_u_row[--K][N];
+ while (p > i);
+
+ i -= p;
+ val = (k0 - K + s) ^ s;
+ norm += val * val;
+ *y++ = val;
+ }
+ }
+ N--;
+ }
+
+ /* N == 2 */
+ p = 2 * K + 1;
+ s = -(i >= p);
+ i -= p & s;
+ k0 = K;
+ K = (i + 1) / 2;
+
+ if (K)
+ i -= 2 * K - 1;
+
+ val = (k0 - K + s) ^ s;
+ norm += val * val;
+ *y++ = val;
+
+ /* N==1 */
+ s = -i;
+ val = (K + s) ^ s;
+ norm += val * val;
+ *y = val;
+
+ return norm;
+}
+
+static inline float celt_decode_pulses(OpusRangeCoder *rc, int *y, unsigned int N, unsigned int K)
+{
+ unsigned int idx;
+#define CELT_PVQ_U(n, k) (celt_pvq_u_row[FFMIN(n, k)][FFMAX(n, k)])
+#define CELT_PVQ_V(n, k) (CELT_PVQ_U(n, k) + CELT_PVQ_U(n, k + 1))
+ idx = opus_rc_unimodel(rc, CELT_PVQ_V(N, K));
+ return celt_cwrsi(N, K, idx, y);
+}
+
+/** Decode pulse vector and combine the result with the pitch vector to produce
+ the final normalised signal in the current band. */
+static inline unsigned int celt_alg_unquant(OpusRangeCoder *rc, float *X,
+ unsigned int N, unsigned int K,
+ enum CeltSpread spread,
+ unsigned int blocks, float gain)
+{
+ int y[176];
+
+ gain /= sqrtf(celt_decode_pulses(rc, y, N, K));
+ celt_normalize_residual(y, X, N, gain);
+ celt_exp_rotation(X, N, blocks, K, spread);
+ return celt_extract_collapse_mask(y, N, blocks);
+}
+
+static unsigned int celt_decode_band(CeltContext *s, OpusRangeCoder *rc,
+ const int band, float *X, float *Y,
+ int N, int b, unsigned int blocks,
+ float *lowband, int duration,
+ float *lowband_out, int level,
+ float gain, float *lowband_scratch,
+ int fill)
+{
+ const uint8_t *cache;
+ int dualstereo, split;
+ int imid = 0, iside = 0;
+ unsigned int N0 = N;
+ int N_B;
+ int N_B0;
+ int B0 = blocks;
+ int time_divide = 0;
+ int recombine = 0;
+ int inv = 0;
+ float mid = 0, side = 0;
+ int longblocks = (B0 == 1);
+ unsigned int cm = 0;
+
+ N_B0 = N_B = N / blocks;
+ split = dualstereo = (Y != NULL);
+
+ if (N == 1) {
+ /* special case for one sample */
+ int i;
+ float *x = X;
+ for (i = 0; i <= dualstereo; i++) {
+ int sign = 0;
+ if (s->remaining2 >= 1<<3) {
+ sign = opus_getrawbits(rc, 1);
+ s->remaining2 -= 1 << 3;
+ b -= 1 << 3;
+ }
+ x[0] = sign ? -1.0f : 1.0f;
+ x = Y;
+ }
+ if (lowband_out)
+ lowband_out[0] = X[0];
+ return 1;
+ }
+
+ if (!dualstereo && level == 0) {
+ int tf_change = s->tf_change[band];
+ int k;
+ if (tf_change > 0)
+ recombine = tf_change;
+ /* Band recombining to increase frequency resolution */
+
+ if (lowband &&
+ (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0 > 1)) {
+ int j;
+ for (j = 0; j < N; j++)
+ lowband_scratch[j] = lowband[j];
+ lowband = lowband_scratch;
+ }
+
+ for (k = 0; k < recombine; k++) {
+ if (lowband)
+ celt_haar1(lowband, N >> k, 1 << k);
+ fill = celt_bit_interleave[fill & 0xF] | celt_bit_interleave[fill >> 4] << 2;
+ }
+ blocks >>= recombine;
+ N_B <<= recombine;
+
+ /* Increasing the time resolution */
+ while ((N_B & 1) == 0 && tf_change < 0) {
+ if (lowband)
+ celt_haar1(lowband, N_B, blocks);
+ fill |= fill << blocks;
+ blocks <<= 1;
+ N_B >>= 1;
+ time_divide++;
+ tf_change++;
+ }
+ B0 = blocks;
+ N_B0 = N_B;
+
+ /* Reorganize the samples in time order instead of frequency order */
+ if (B0 > 1 && lowband)
+ celt_deinterleave_hadamard(s->scratch, lowband, N_B >> recombine,
+ B0 << recombine, longblocks);
+ }
+
+ /* If we need 1.5 more bit than we can produce, split the band in two. */
+ cache = celt_cache_bits +
+ celt_cache_index[(duration + 1) * CELT_MAX_BANDS + band];
+ if (!dualstereo && duration >= 0 && b > cache[cache[0]] + 12 && N > 2) {
+ N >>= 1;
+ Y = X + N;
+ split = 1;
+ duration -= 1;
+ if (blocks == 1)
+ fill = (fill & 1) | (fill << 1);
+ blocks = (blocks + 1) >> 1;
+ }
+
+ if (split) {
+ int qn;
+ int itheta = 0;
+ int mbits, sbits, delta;
+ int qalloc;
+ int pulse_cap;
+ int offset;
+ int orig_fill;
+ int tell;
+
+ /* Decide on the resolution to give to the split parameter theta */
+ pulse_cap = celt_log_freq_range[band] + duration * 8;
+ offset = (pulse_cap >> 1) - (dualstereo && N == 2 ? CELT_QTHETA_OFFSET_TWOPHASE :
+ CELT_QTHETA_OFFSET);
+ qn = (dualstereo && band >= s->intensitystereo) ? 1 :
+ celt_compute_qn(N, b, offset, pulse_cap, dualstereo);
+ tell = opus_rc_tell_frac(rc);
+ if (qn != 1) {
+ /* Entropy coding of the angle. We use a uniform pdf for the
+ time split, a step for stereo, and a triangular one for the rest. */
+ if (dualstereo && N > 2)
+ itheta = opus_rc_stepmodel(rc, qn/2);
+ else if (dualstereo || B0 > 1)
+ itheta = opus_rc_unimodel(rc, qn+1);
+ else
+ itheta = opus_rc_trimodel(rc, qn);
+ itheta = itheta * 16384 / qn;
+ /* NOTE: Renormalising X and Y *may* help fixed-point a bit at very high rate.
+ Let's do that at higher complexity */
+ } else if (dualstereo) {
+ inv = (b > 2 << 3 && s->remaining2 > 2 << 3) ? opus_rc_p2model(rc, 2) : 0;
+ itheta = 0;
+ }
+ qalloc = opus_rc_tell_frac(rc) - tell;
+ b -= qalloc;
+
+ orig_fill = fill;
+ if (itheta == 0) {
+ imid = 32767;
+ iside = 0;
+ fill &= (1 << blocks) - 1;
+ delta = -16384;
+ } else if (itheta == 16384) {
+ imid = 0;
+ iside = 32767;
+ fill &= ((1 << blocks) - 1) << blocks;
+ delta = 16384;
+ } else {
+ imid = celt_cos(itheta);
+ iside = celt_cos(16384-itheta);
+ /* This is the mid vs side allocation that minimizes squared error
+ in that band. */
+ delta = ROUND_MUL16((N - 1) << 7, celt_log2tan(iside, imid));
+ }
+
+ mid = imid / 32768.0f;
+ side = iside / 32768.0f;
+
+ /* This is a special case for N=2 that only works for stereo and takes
+ advantage of the fact that mid and side are orthogonal to encode
+ the side with just one bit. */
+ if (N == 2 && dualstereo) {
+ int c;
+ int sign = 0;
+ float tmp;
+ float *x2, *y2;
+ mbits = b;
+ /* Only need one bit for the side */
+ sbits = (itheta != 0 && itheta != 16384) ? 1 << 3 : 0;
+ mbits -= sbits;
+ c = (itheta > 8192);
+ s->remaining2 -= qalloc+sbits;
+
+ x2 = c ? Y : X;
+ y2 = c ? X : Y;
+ if (sbits)
+ sign = opus_getrawbits(rc, 1);
+ sign = 1 - 2 * sign;
+ /* We use orig_fill here because we want to fold the side, but if
+ itheta==16384, we'll have cleared the low bits of fill. */
+ cm = celt_decode_band(s, rc, band, x2, NULL, N, mbits, blocks,
+ lowband, duration, lowband_out, level, gain,
+ lowband_scratch, orig_fill);
+ /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse),
+ and there's no need to worry about mixing with the other channel. */
+ y2[0] = -sign * x2[1];
+ y2[1] = sign * x2[0];
+ X[0] *= mid;
+ X[1] *= mid;
+ Y[0] *= side;
+ Y[1] *= side;
+ tmp = X[0];
+ X[0] = tmp - Y[0];
+ Y[0] = tmp + Y[0];
+ tmp = X[1];
+ X[1] = tmp - Y[1];
+ Y[1] = tmp + Y[1];
+ } else {
+ /* "Normal" split code */
+ float *next_lowband2 = NULL;
+ float *next_lowband_out1 = NULL;
+ int next_level = 0;
+ int rebalance;
+
+ /* Give more bits to low-energy MDCTs than they would
+ * otherwise deserve */
+ if (B0 > 1 && !dualstereo && (itheta & 0x3fff)) {
+ if (itheta > 8192)
+ /* Rough approximation for pre-echo masking */
+ delta -= delta >> (4 - duration);
+ else
+ /* Corresponds to a forward-masking slope of
+ * 1.5 dB per 10 ms */
+ delta = FFMIN(0, delta + (N << 3 >> (5 - duration)));
+ }
+ mbits = av_clip((b - delta) / 2, 0, b);
+ sbits = b - mbits;
+ s->remaining2 -= qalloc;
+
+ if (lowband && !dualstereo)
+ next_lowband2 = lowband + N; /* >32-bit split case */
+
+ /* Only stereo needs to pass on lowband_out.
+ * Otherwise, it's handled at the end */
+ if (dualstereo)
+ next_lowband_out1 = lowband_out;
+ else
+ next_level = level + 1;
+
+ rebalance = s->remaining2;
+ if (mbits >= sbits) {
+ /* In stereo mode, we do not apply a scaling to the mid
+ * because we need the normalized mid for folding later */
+ cm = celt_decode_band(s, rc, band, X, NULL, N, mbits, blocks,
+ lowband, duration, next_lowband_out1,
+ next_level, dualstereo ? 1.0f : (gain * mid),
+ lowband_scratch, fill);
+
+ rebalance = mbits - (rebalance - s->remaining2);
+ if (rebalance > 3 << 3 && itheta != 0)
+ sbits += rebalance - (3 << 3);
+
+ /* For a stereo split, the high bits of fill are always zero,
+ * so no folding will be done to the side. */
+ cm |= celt_decode_band(s, rc, band, Y, NULL, N, sbits, blocks,
+ next_lowband2, duration, NULL,
+ next_level, gain * side, NULL,
+ fill >> blocks) << ((B0 >> 1) & (dualstereo - 1));
+ } else {
+ /* For a stereo split, the high bits of fill are always zero,
+ * so no folding will be done to the side. */
+ cm = celt_decode_band(s, rc, band, Y, NULL, N, sbits, blocks,
+ next_lowband2, duration, NULL,
+ next_level, gain * side, NULL,
+ fill >> blocks) << ((B0 >> 1) & (dualstereo - 1));
+
+ rebalance = sbits - (rebalance - s->remaining2);
+ if (rebalance > 3 << 3 && itheta != 16384)
+ mbits += rebalance - (3 << 3);
+
+ /* In stereo mode, we do not apply a scaling to the mid because
+ * we need the normalized mid for folding later */
+ cm |= celt_decode_band(s, rc, band, X, NULL, N, mbits, blocks,
+ lowband, duration, next_lowband_out1,
+ next_level, dualstereo ? 1.0f : (gain * mid),
+ lowband_scratch, fill);
+ }
+ }
+ } else {
+ /* This is the basic no-split case */
+ unsigned int q = celt_bits2pulses(cache, b);
+ unsigned int curr_bits = celt_pulses2bits(cache, q);
+ s->remaining2 -= curr_bits;
+
+ /* Ensures we can never bust the budget */
+ while (s->remaining2 < 0 && q > 0) {
+ s->remaining2 += curr_bits;
+ curr_bits = celt_pulses2bits(cache, --q);
+ s->remaining2 -= curr_bits;
+ }
+
+ if (q != 0) {
+ /* Finally do the actual quantization */
+ cm = celt_alg_unquant(rc, X, N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1),
+ s->spread, blocks, gain);
+ } else {
+ /* If there's no pulse, fill the band anyway */
+ int j;
+ unsigned int cm_mask = (1 << blocks) - 1;
+ fill &= cm_mask;
+ if (!fill) {
+ for (j = 0; j < N; j++)
+ X[j] = 0.0f;
+ } else {
+ if (lowband == NULL) {
+ /* Noise */
+ for (j = 0; j < N; j++)
+ X[j] = (((int32_t)celt_rng(s)) >> 20);
+ cm = cm_mask;
+ } else {
+ /* Folded spectrum */
+ for (j = 0; j < N; j++) {
+ /* About 48 dB below the "normal" folding level */
+ X[j] = lowband[j] + (((celt_rng(s)) & 0x8000) ? 1.0f / 256 : -1.0f / 256);
+ }
+ cm = fill;
+ }
+ celt_renormalize_vector(X, N, gain);
+ }
+ }
+ }
+
+ /* This code is used by the decoder and by the resynthesis-enabled encoder */
+ if (dualstereo) {
+ int j;
+ if (N != 2)
+ celt_stereo_merge(X, Y, mid, N);
+ if (inv) {
+ for (j = 0; j < N; j++)
+ Y[j] *= -1;
+ }
+ } else if (level == 0) {
+ int k;
+
+ /* Undo the sample reorganization going from time order to frequency order */
+ if (B0 > 1)
+ celt_interleave_hadamard(s->scratch, X, N_B>>recombine,
+ B0<<recombine, longblocks);
+
+ /* Undo time-freq changes that we did earlier */
+ N_B = N_B0;
+ blocks = B0;
+ for (k = 0; k < time_divide; k++) {
+ blocks >>= 1;
+ N_B <<= 1;
+ cm |= cm >> blocks;
+ celt_haar1(X, N_B, blocks);
+ }
+
+ for (k = 0; k < recombine; k++) {
+ cm = celt_bit_deinterleave[cm];
+ celt_haar1(X, N0>>k, 1<<k);
+ }
+ blocks <<= recombine;
+
+ /* Scale output for later folding */
+ if (lowband_out) {
+ int j;
+ float n = sqrtf(N0);
+ for (j = 0; j < N0; j++)
+ lowband_out[j] = n * X[j];
+ }
+ cm &= (1 << blocks) - 1;
+ }
+ return cm;
+}
+
+static void celt_denormalize(CeltContext *s, CeltFrame *frame, float *data)
+{
+ int i, j;
+
+ for (i = s->startband; i < s->endband; i++) {
+ float *dst = data + (celt_freq_bands[i] << s->duration);
+ float norm = pow(2, frame->energy[i] + celt_mean_energy[i]);
+
+ for (j = 0; j < celt_freq_range[i] << s->duration; j++)
+ dst[j] *= norm;
+ }
+}
+
+static void celt_postfilter_apply_transition(CeltFrame *frame, float *data)
+{
+ const int T0 = frame->pf_period_old;
+ const int T1 = frame->pf_period;
+
+ float g00, g01, g02;
+ float g10, g11, g12;
+
+ float x0, x1, x2, x3, x4;
+
+ int i;
+
+ if (frame->pf_gains[0] == 0.0 &&
+ frame->pf_gains_old[0] == 0.0)
+ return;
+
+ g00 = frame->pf_gains_old[0];
+ g01 = frame->pf_gains_old[1];
+ g02 = frame->pf_gains_old[2];
+ g10 = frame->pf_gains[0];
+ g11 = frame->pf_gains[1];
+ g12 = frame->pf_gains[2];
+
+ x1 = data[-T1 + 1];
+ x2 = data[-T1];
+ x3 = data[-T1 - 1];
+ x4 = data[-T1 - 2];
+
+ for (i = 0; i < CELT_OVERLAP; i++) {
+ float w = ff_celt_window2[i];
+ x0 = data[i - T1 + 2];
+
+ data[i] += (1.0 - w) * g00 * data[i - T0] +
+ (1.0 - w) * g01 * (data[i - T0 - 1] + data[i - T0 + 1]) +
+ (1.0 - w) * g02 * (data[i - T0 - 2] + data[i - T0 + 2]) +
+ w * g10 * x2 +
+ w * g11 * (x1 + x3) +
+ w * g12 * (x0 + x4);
+ x4 = x3;
+ x3 = x2;
+ x2 = x1;
+ x1 = x0;
+ }
+}
+
+static void celt_postfilter_apply(CeltFrame *frame,
+ float *data, int len)
+{
+ const int T = frame->pf_period;
+ float g0, g1, g2;
+ float x0, x1, x2, x3, x4;
+ int i;
+
+ if (frame->pf_gains[0] == 0.0 || len <= 0)
+ return;
+
+ g0 = frame->pf_gains[0];
+ g1 = frame->pf_gains[1];
+ g2 = frame->pf_gains[2];
+
+ x4 = data[-T - 2];
+ x3 = data[-T - 1];
+ x2 = data[-T];
+ x1 = data[-T + 1];
+
+ for (i = 0; i < len; i++) {
+ x0 = data[i - T + 2];
+ data[i] += g0 * x2 +
+ g1 * (x1 + x3) +
+ g2 * (x0 + x4);
+ x4 = x3;
+ x3 = x2;
+ x2 = x1;
+ x1 = x0;
+ }
+}
+
+static void celt_postfilter(CeltContext *s, CeltFrame *frame)
+{
+ int len = s->blocksize * s->blocks;
+
+ celt_postfilter_apply_transition(frame, frame->buf + 1024);
+
+ frame->pf_period_old = frame->pf_period;
+ memcpy(frame->pf_gains_old, frame->pf_gains, sizeof(frame->pf_gains));
+
+ frame->pf_period = frame->pf_period_new;
+ memcpy(frame->pf_gains, frame->pf_gains_new, sizeof(frame->pf_gains));
+
+ if (len > CELT_OVERLAP) {
+ celt_postfilter_apply_transition(frame, frame->buf + 1024 + CELT_OVERLAP);
+ celt_postfilter_apply(frame, frame->buf + 1024 + 2 * CELT_OVERLAP,
+ len - 2 * CELT_OVERLAP);
+
+ frame->pf_period_old = frame->pf_period;
+ memcpy(frame->pf_gains_old, frame->pf_gains, sizeof(frame->pf_gains));
+ }
+
+ memmove(frame->buf, frame->buf + len, (1024 + CELT_OVERLAP / 2) * sizeof(float));
+}
+
+static int parse_postfilter(CeltContext *s, OpusRangeCoder *rc, int consumed)
+{
+ static const float postfilter_taps[3][3] = {
+ { 0.3066406250f, 0.2170410156f, 0.1296386719f },
+ { 0.4638671875f, 0.2680664062f, 0.0 },
+ { 0.7998046875f, 0.1000976562f, 0.0 }
+ };
+ int i;
+
+ memset(s->frame[0].pf_gains_new, 0, sizeof(s->frame[0].pf_gains_new));
+ memset(s->frame[1].pf_gains_new, 0, sizeof(s->frame[1].pf_gains_new));
+
+ if (s->startband == 0 && consumed + 16 <= s->framebits) {
+ int has_postfilter = opus_rc_p2model(rc, 1);
+ if (has_postfilter) {
+ float gain;
+ int tapset, octave, period;
+
+ octave = opus_rc_unimodel(rc, 6);
+ period = (16 << octave) + opus_getrawbits(rc, 4 + octave) - 1;
+ gain = 0.09375f * (opus_getrawbits(rc, 3) + 1);
+ tapset = (opus_rc_tell(rc) + 2 <= s->framebits) ?
+ opus_rc_getsymbol(rc, celt_model_tapset) : 0;
+
+ for (i = 0; i < 2; i++) {
+ CeltFrame *frame = &s->frame[i];
+
+ frame->pf_period_new = FFMAX(period, CELT_POSTFILTER_MINPERIOD);
+ frame->pf_gains_new[0] = gain * postfilter_taps[tapset][0];
+ frame->pf_gains_new[1] = gain * postfilter_taps[tapset][1];
+ frame->pf_gains_new[2] = gain * postfilter_taps[tapset][2];
+ }
+ }
+
+ consumed = opus_rc_tell(rc);
+ }
+
+ return consumed;
+}
+
+static void process_anticollapse(CeltContext *s, CeltFrame *frame, float *X)
+{
+ int i, j, k;
+
+ for (i = s->startband; i < s->endband; i++) {
+ int renormalize = 0;
+ float *xptr;
+ float prev[2];
+ float Ediff, r;
+ float thresh, sqrt_1;
+ int depth;
+
+ /* depth in 1/8 bits */
+ depth = (1 + s->pulses[i]) / (celt_freq_range[i] << s->duration);
+ thresh = pow(2, -1.0 - 0.125f * depth);
+ sqrt_1 = 1.0f / sqrtf(celt_freq_range[i] << s->duration);
+
+ xptr = X + (celt_freq_bands[i] << s->duration);
+
+ prev[0] = frame->prev_energy[0][i];
+ prev[1] = frame->prev_energy[1][i];
+ if (s->coded_channels == 1) {
+ CeltFrame *frame1 = &s->frame[1];
+
+ prev[0] = FFMAX(prev[0], frame1->prev_energy[0][i]);
+ prev[1] = FFMAX(prev[1], frame1->prev_energy[1][i]);
+ }
+ Ediff = frame->energy[i] - FFMIN(prev[0], prev[1]);
+ Ediff = FFMAX(0, Ediff);
+
+ /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM because
+ short blocks don't have the same energy as long */
+ r = pow(2, 1 - Ediff);
+ if (s->duration == 3)
+ r *= M_SQRT2;
+ r = FFMIN(thresh, r) * sqrt_1;
+ for (k = 0; k < 1 << s->duration; k++) {
+ /* Detect collapse */
+ if (!(frame->collapse_masks[i] & 1 << k)) {
+ /* Fill with noise */
+ for (j = 0; j < celt_freq_range[i]; j++)
+ xptr[(j << s->duration) + k] = (celt_rng(s) & 0x8000) ? r : -r;
+ renormalize = 1;
+ }
+ }
+
+ /* We just added some energy, so we need to renormalize */
+ if (renormalize)
+ celt_renormalize_vector(xptr, celt_freq_range[i] << s->duration, 1.0f);
+ }
+}
+
+static void celt_decode_bands(CeltContext *s, OpusRangeCoder *rc)
+{
+ float lowband_scratch[8 * 22];
+ float norm[2 * 8 * 100];
+
+ int totalbits = (s->framebits << 3) - s->anticollapse_bit;
+
+ int update_lowband = 1;
+ int lowband_offset = 0;
+
+ int i, j;
+
+ memset(s->coeffs, 0, sizeof(s->coeffs));
+
+ for (i = s->startband; i < s->endband; i++) {
+ int band_offset = celt_freq_bands[i] << s->duration;
+ int band_size = celt_freq_range[i] << s->duration;
+ float *X = s->coeffs[0] + band_offset;
+ float *Y = (s->coded_channels == 2) ? s->coeffs[1] + band_offset : NULL;
+
+ int consumed = opus_rc_tell_frac(rc);
+ float *norm2 = norm + 8 * 100;
+ int effective_lowband = -1;
+ unsigned int cm[2];
+ int b;
+
+ /* Compute how many bits we want to allocate to this band */
+ if (i != s->startband)
+ s->remaining -= consumed;
+ s->remaining2 = totalbits - consumed - 1;
+ if (i <= s->codedbands - 1) {
+ int curr_balance = s->remaining / FFMIN(3, s->codedbands-i);
+ b = av_clip(FFMIN(s->remaining2 + 1, s->pulses[i] + curr_balance), 0, 16383);
+ } else
+ b = 0;
+
+ if (celt_freq_bands[i] - celt_freq_range[i] >= celt_freq_bands[s->startband] &&
+ (update_lowband || lowband_offset == 0))
+ lowband_offset = i;
+
+ /* Get a conservative estimate of the collapse_mask's for the bands we're
+ going to be folding from. */
+ if (lowband_offset != 0 && (s->spread != CELT_SPREAD_AGGRESSIVE ||
+ s->blocks > 1 || s->tf_change[i] < 0)) {
+ int foldstart, foldend;
+
+ /* This ensures we never repeat spectral content within one band */
+ effective_lowband = FFMAX(celt_freq_bands[s->startband],
+ celt_freq_bands[lowband_offset] - celt_freq_range[i]);
+ foldstart = lowband_offset;
+ while (celt_freq_bands[--foldstart] > effective_lowband);
+ foldend = lowband_offset - 1;
+ while (celt_freq_bands[++foldend] < effective_lowband + celt_freq_range[i]);
+
+ cm[0] = cm[1] = 0;
+ for (j = foldstart; j < foldend; j++) {
+ cm[0] |= s->frame[0].collapse_masks[j];
+ cm[1] |= s->frame[s->coded_channels - 1].collapse_masks[j];
+ }
+ } else
+ /* Otherwise, we'll be using the LCG to fold, so all blocks will (almost
+ always) be non-zero.*/
+ cm[0] = cm[1] = (1 << s->blocks) - 1;
+
+ if (s->dualstereo && i == s->intensitystereo) {
+ /* Switch off dual stereo to do intensity */
+ s->dualstereo = 0;
+ for (j = celt_freq_bands[s->startband] << s->duration; j < band_offset; j++)
+ norm[j] = (norm[j] + norm2[j]) / 2;
+ }
+
+ if (s->dualstereo) {
+ cm[0] = celt_decode_band(s, rc, i, X, NULL, band_size, b / 2, s->blocks,
+ effective_lowband != -1 ? norm + (effective_lowband << s->duration) : NULL, s->duration,
+ norm + band_offset, 0, 1.0f, lowband_scratch, cm[0]);
+
+ cm[1] = celt_decode_band(s, rc, i, Y, NULL, band_size, b/2, s->blocks,
+ effective_lowband != -1 ? norm2 + (effective_lowband << s->duration) : NULL, s->duration,
+ norm2 + band_offset, 0, 1.0f, lowband_scratch, cm[1]);
+ } else {
+ cm[0] = celt_decode_band(s, rc, i, X, Y, band_size, b, s->blocks,
+ effective_lowband != -1 ? norm + (effective_lowband << s->duration) : NULL, s->duration,
+ norm + band_offset, 0, 1.0f, lowband_scratch, cm[0]|cm[1]);
+
+ cm[1] = cm[0];
+ }
+
+ s->frame[0].collapse_masks[i] = (uint8_t)cm[0];
+ s->frame[s->coded_channels - 1].collapse_masks[i] = (uint8_t)cm[1];
+ s->remaining += s->pulses[i] + consumed;
+
+ /* Update the folding position only as long as we have 1 bit/sample depth */
+ update_lowband = (b > band_size << 3);
+ }
+}
+
+int ff_celt_decode_frame(CeltContext *s, OpusRangeCoder *rc,
+ float **output, int coded_channels, int frame_size,
+ int startband, int endband)
+{
+ int i, j;
+
+ int consumed; // bits of entropy consumed thus far for this frame
+ int silence = 0;
+ int transient = 0;
+ int anticollapse = 0;
+ CeltIMDCTContext *imdct;
+ float imdct_scale = 1.0;
+
+ if (coded_channels != 1 && coded_channels != 2) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid number of coded channels: %d\n",
+ coded_channels);
+ return AVERROR_INVALIDDATA;
+ }
+ if (startband < 0 || startband > endband || endband > CELT_MAX_BANDS) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid start/end band: %d %d\n",
+ startband, endband);
+ return AVERROR_INVALIDDATA;
+ }
+
+ s->flushed = 0;
+ s->coded_channels = coded_channels;
+ s->startband = startband;
+ s->endband = endband;
+ s->framebits = rc->rb.bytes * 8;
+
+ s->duration = av_log2(frame_size / CELT_SHORT_BLOCKSIZE);
+ if (s->duration > CELT_MAX_LOG_BLOCKS ||
+ frame_size != CELT_SHORT_BLOCKSIZE * (1 << s->duration)) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid CELT frame size: %d\n",
+ frame_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!s->output_channels)
+ s->output_channels = coded_channels;
+
+ memset(s->frame[0].collapse_masks, 0, sizeof(s->frame[0].collapse_masks));
+ memset(s->frame[1].collapse_masks, 0, sizeof(s->frame[1].collapse_masks));
+
+ consumed = opus_rc_tell(rc);
+
+ /* obtain silence flag */
+ if (consumed >= s->framebits)
+ silence = 1;
+ else if (consumed == 1)
+ silence = opus_rc_p2model(rc, 15);
+
+
+ if (silence) {
+ consumed = s->framebits;
+ rc->total_read_bits += s->framebits - opus_rc_tell(rc);
+ }
+
+ /* obtain post-filter options */
+ consumed = parse_postfilter(s, rc, consumed);
+
+ /* obtain transient flag */
+ if (s->duration != 0 && consumed+3 <= s->framebits)
+ transient = opus_rc_p2model(rc, 3);
+
+ s->blocks = transient ? 1 << s->duration : 1;
+ s->blocksize = frame_size / s->blocks;
+
+ imdct = s->imdct[transient ? 0 : s->duration];
+
+ if (coded_channels == 1) {
+ for (i = 0; i < CELT_MAX_BANDS; i++)
+ s->frame[0].energy[i] = FFMAX(s->frame[0].energy[i], s->frame[1].energy[i]);
+ }
+
+ celt_decode_coarse_energy(s, rc);
+ celt_decode_tf_changes (s, rc, transient);
+ celt_decode_allocation (s, rc);
+ celt_decode_fine_energy (s, rc);
+ celt_decode_bands (s, rc);
+
+ if (s->anticollapse_bit)
+ anticollapse = opus_getrawbits(rc, 1);
+
+ celt_decode_final_energy(s, rc, s->framebits - opus_rc_tell(rc));
+
+ /* apply anti-collapse processing and denormalization to
+ * each coded channel */
+ for (i = 0; i < s->coded_channels; i++) {
+ CeltFrame *frame = &s->frame[i];
+
+ if (anticollapse)
+ process_anticollapse(s, frame, s->coeffs[i]);
+
+ celt_denormalize(s, frame, s->coeffs[i]);
+ }
+
+ /* stereo -> mono downmix */
+ if (s->output_channels < s->coded_channels) {
+ s->dsp.vector_fmac_scalar(s->coeffs[0], s->coeffs[1], 1.0, FFALIGN(frame_size, 16));
+ imdct_scale = 0.5;
+ } else if (s->output_channels > s->coded_channels)
+ memcpy(s->coeffs[1], s->coeffs[0], frame_size * sizeof(float));
+
+ if (silence) {
+ for (i = 0; i < 2; i++) {
+ CeltFrame *frame = &s->frame[i];
+
+ for (j = 0; j < FF_ARRAY_ELEMS(frame->energy); j++)
+ frame->energy[j] = CELT_ENERGY_SILENCE;
+ }
+ memset(s->coeffs, 0, sizeof(s->coeffs));
+ }
+
+ /* transform and output for each output channel */
+ for (i = 0; i < s->output_channels; i++) {
+ CeltFrame *frame = &s->frame[i];
+ float m = frame->deemph_coeff;
+
+ /* iMDCT and overlap-add */
+ for (j = 0; j < s->blocks; j++) {
+ float *dst = frame->buf + 1024 + j * s->blocksize;
+
+ imdct->imdct_half(imdct, dst + CELT_OVERLAP / 2, s->coeffs[i] + j,
+ s->blocks, imdct_scale);
+ s->dsp.vector_fmul_window(dst, dst, dst + CELT_OVERLAP / 2,
+ celt_window, CELT_OVERLAP / 2);
+ }
+
+ /* postfilter */
+ celt_postfilter(s, frame);
+
+ /* deemphasis and output scaling */
+ for (j = 0; j < frame_size; j++) {
+ float tmp = frame->buf[1024 - frame_size + j] + m;
+ m = tmp * CELT_DEEMPH_COEFF;
+ output[i][j] = tmp / 32768.;
+ }
+ frame->deemph_coeff = m;
+ }
+
+ if (coded_channels == 1)
+ memcpy(s->frame[1].energy, s->frame[0].energy, sizeof(s->frame[0].energy));
+
+ for (i = 0; i < 2; i++ ) {
+ CeltFrame *frame = &s->frame[i];
+
+ if (!transient) {
+ memcpy(frame->prev_energy[1], frame->prev_energy[0], sizeof(frame->prev_energy[0]));
+ memcpy(frame->prev_energy[0], frame->energy, sizeof(frame->prev_energy[0]));
+ } else {
+ for (j = 0; j < CELT_MAX_BANDS; j++)
+ frame->prev_energy[0][j] = FFMIN(frame->prev_energy[0][j], frame->energy[j]);
+ }
+
+ for (j = 0; j < s->startband; j++) {
+ frame->prev_energy[0][j] = CELT_ENERGY_SILENCE;
+ frame->energy[j] = 0.0;
+ }
+ for (j = s->endband; j < CELT_MAX_BANDS; j++) {
+ frame->prev_energy[0][j] = CELT_ENERGY_SILENCE;
+ frame->energy[j] = 0.0;
+ }
+ }
+
+ s->seed = rc->range;
+
+ return 0;
+}
+
+void ff_celt_flush(CeltContext *s)
+{
+ int i, j;
+
+ if (s->flushed)
+ return;
+
+ for (i = 0; i < 2; i++) {
+ CeltFrame *frame = &s->frame[i];
+
+ for (j = 0; j < CELT_MAX_BANDS; j++)
+ frame->prev_energy[0][j] = frame->prev_energy[1][j] = CELT_ENERGY_SILENCE;
+
+ memset(frame->energy, 0, sizeof(frame->energy));
+ memset(frame->buf, 0, sizeof(frame->buf));
+
+ memset(frame->pf_gains, 0, sizeof(frame->pf_gains));
+ memset(frame->pf_gains_old, 0, sizeof(frame->pf_gains_old));
+ memset(frame->pf_gains_new, 0, sizeof(frame->pf_gains_new));
+
+ frame->deemph_coeff = 0.0;
+ }
+ s->seed = 0;
+
+ s->flushed = 1;
+}
+
+void ff_celt_free(CeltContext **ps)
+{
+ CeltContext *s = *ps;
+ int i;
+
+ if (!s)
+ return;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++)
+ ff_celt_imdct_uninit(&s->imdct[i]);
+
+ av_freep(ps);
+}
+
+int ff_celt_init(AVCodecContext *avctx, CeltContext **ps, int output_channels)
+{
+ CeltContext *s;
+ int i, ret;
+
+ if (output_channels != 1 && output_channels != 2) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid number of output channels: %d\n",
+ output_channels);
+ return AVERROR(EINVAL);
+ }
+
+ s = av_mallocz(sizeof(*s));
+ if (!s)
+ return AVERROR(ENOMEM);
+
+ s->avctx = avctx;
+ s->output_channels = output_channels;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++) {
+ ret = ff_celt_imdct_init(&s->imdct[i], i + 3);
+ if (ret < 0)
+ goto fail;
+ }
+
+ avpriv_float_dsp_init(&s->dsp, avctx->flags & CODEC_FLAG_BITEXACT);
+
+ ff_celt_flush(s);
+
+ *ps = s;
+
+ return 0;
+fail:
+ ff_celt_free(&s);
+ return ret;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus_imdct.c b/chromium/third_party/ffmpeg/libavcodec/opus_imdct.c
new file mode 100644
index 00000000000..0a6fca994ec
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus_imdct.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Celt non-power of 2 iMDCT
+ */
+
+#include <float.h>
+#include <math.h>
+#include <stddef.h>
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+
+#include "avfft.h"
+#include "opus.h"
+#include "opus_imdct.h"
+
+// minimal iMDCT size to make SIMD opts easier
+#define CELT_MIN_IMDCT_SIZE 120
+
+// complex c = a * b
+#define CMUL3(cre, cim, are, aim, bre, bim) \
+do { \
+ cre = are * bre - aim * bim; \
+ cim = are * bim + aim * bre; \
+} while (0)
+
+#define CMUL(c, a, b) CMUL3((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
+
+// complex c = a * b
+// d = a * conjugate(b)
+#define CMUL2(c, d, a, b) \
+do { \
+ float are = (a).re; \
+ float aim = (a).im; \
+ float bre = (b).re; \
+ float bim = (b).im; \
+ float rr = are * bre; \
+ float ri = are * bim; \
+ float ir = aim * bre; \
+ float ii = aim * bim; \
+ (c).re = rr - ii; \
+ (c).im = ri + ir; \
+ (d).re = rr + ii; \
+ (d).im = -ri + ir; \
+} while (0)
+
+av_cold void ff_celt_imdct_uninit(CeltIMDCTContext **ps)
+{
+ CeltIMDCTContext *s = *ps;
+ int i;
+
+ if (!s)
+ return;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(s->exptab); i++)
+ av_freep(&s->exptab[i]);
+
+ av_freep(&s->twiddle_exptab);
+
+ av_freep(&s->tmp);
+
+ av_freep(ps);
+}
+
+static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src,
+ ptrdiff_t stride, float scale);
+
+av_cold int ff_celt_imdct_init(CeltIMDCTContext **ps, int N)
+{
+ CeltIMDCTContext *s;
+ int len2 = 15 * (1 << N);
+ int len = 2 * len2;
+ int i, j;
+
+ if (len2 > CELT_MAX_FRAME_SIZE || len2 < CELT_MIN_IMDCT_SIZE)
+ return AVERROR(EINVAL);
+
+ s = av_mallocz(sizeof(*s));
+ if (!s)
+ return AVERROR(ENOMEM);
+
+ s->fft_n = N - 1;
+ s->len4 = len2 / 2;
+ s->len2 = len2;
+
+ s->tmp = av_malloc(len * 2 * sizeof(*s->tmp));
+ if (!s->tmp)
+ goto fail;
+
+ s->twiddle_exptab = av_malloc(s->len4 * sizeof(*s->twiddle_exptab));
+ if (!s->twiddle_exptab)
+ goto fail;
+
+ for (i = 0; i < s->len4; i++) {
+ s->twiddle_exptab[i].re = cos(2 * M_PI * (i + 0.125 + s->len4) / len);
+ s->twiddle_exptab[i].im = sin(2 * M_PI * (i + 0.125 + s->len4) / len);
+ }
+
+ for (i = 0; i < FF_ARRAY_ELEMS(s->exptab); i++) {
+ int N = 15 * (1 << i);
+ s->exptab[i] = av_malloc(sizeof(*s->exptab[i]) * FFMAX(N, 19));
+ if (!s->exptab[i])
+ goto fail;
+
+ for (j = 0; j < N; j++) {
+ s->exptab[i][j].re = cos(2 * M_PI * j / N);
+ s->exptab[i][j].im = sin(2 * M_PI * j / N);
+ }
+ }
+
+ // wrap around to simplify fft15
+ for (j = 15; j < 19; j++)
+ s->exptab[0][j] = s->exptab[0][j - 15];
+
+ s->imdct_half = celt_imdct_half;
+
+ if (ARCH_AARCH64)
+ ff_celt_imdct_init_aarch64(s);
+
+ *ps = s;
+
+ return 0;
+fail:
+ ff_celt_imdct_uninit(&s);
+ return AVERROR(ENOMEM);
+}
+
+static void fft5(FFTComplex *out, const FFTComplex *in, ptrdiff_t stride)
+{
+ // [0] = exp(2 * i * pi / 5), [1] = exp(2 * i * pi * 2 / 5)
+ static const FFTComplex fact[] = { { 0.30901699437494745, 0.95105651629515353 },
+ { -0.80901699437494734, 0.58778525229247325 } };
+
+ FFTComplex z[4][4];
+
+ CMUL2(z[0][0], z[0][3], in[1 * stride], fact[0]);
+ CMUL2(z[0][1], z[0][2], in[1 * stride], fact[1]);
+ CMUL2(z[1][0], z[1][3], in[2 * stride], fact[0]);
+ CMUL2(z[1][1], z[1][2], in[2 * stride], fact[1]);
+ CMUL2(z[2][0], z[2][3], in[3 * stride], fact[0]);
+ CMUL2(z[2][1], z[2][2], in[3 * stride], fact[1]);
+ CMUL2(z[3][0], z[3][3], in[4 * stride], fact[0]);
+ CMUL2(z[3][1], z[3][2], in[4 * stride], fact[1]);
+
+ out[0].re = in[0].re + in[stride].re + in[2 * stride].re + in[3 * stride].re + in[4 * stride].re;
+ out[0].im = in[0].im + in[stride].im + in[2 * stride].im + in[3 * stride].im + in[4 * stride].im;
+
+ out[1].re = in[0].re + z[0][0].re + z[1][1].re + z[2][2].re + z[3][3].re;
+ out[1].im = in[0].im + z[0][0].im + z[1][1].im + z[2][2].im + z[3][3].im;
+
+ out[2].re = in[0].re + z[0][1].re + z[1][3].re + z[2][0].re + z[3][2].re;
+ out[2].im = in[0].im + z[0][1].im + z[1][3].im + z[2][0].im + z[3][2].im;
+
+ out[3].re = in[0].re + z[0][2].re + z[1][0].re + z[2][3].re + z[3][1].re;
+ out[3].im = in[0].im + z[0][2].im + z[1][0].im + z[2][3].im + z[3][1].im;
+
+ out[4].re = in[0].re + z[0][3].re + z[1][2].re + z[2][1].re + z[3][0].re;
+ out[4].im = in[0].im + z[0][3].im + z[1][2].im + z[2][1].im + z[3][0].im;
+}
+
+static void fft15(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in, ptrdiff_t stride)
+{
+ const FFTComplex *exptab = s->exptab[0];
+ FFTComplex tmp[5];
+ FFTComplex tmp1[5];
+ FFTComplex tmp2[5];
+ int k;
+
+ fft5(tmp, in, stride * 3);
+ fft5(tmp1, in + stride, stride * 3);
+ fft5(tmp2, in + 2 * stride, stride * 3);
+
+ for (k = 0; k < 5; k++) {
+ FFTComplex t1, t2;
+
+ CMUL(t1, tmp1[k], exptab[k]);
+ CMUL(t2, tmp2[k], exptab[2 * k]);
+ out[k].re = tmp[k].re + t1.re + t2.re;
+ out[k].im = tmp[k].im + t1.im + t2.im;
+
+ CMUL(t1, tmp1[k], exptab[k + 5]);
+ CMUL(t2, tmp2[k], exptab[2 * (k + 5)]);
+ out[k + 5].re = tmp[k].re + t1.re + t2.re;
+ out[k + 5].im = tmp[k].im + t1.im + t2.im;
+
+ CMUL(t1, tmp1[k], exptab[k + 10]);
+ CMUL(t2, tmp2[k], exptab[2 * k + 5]);
+ out[k + 10].re = tmp[k].re + t1.re + t2.re;
+ out[k + 10].im = tmp[k].im + t1.im + t2.im;
+ }
+}
+
+/*
+ * FFT of the length 15 * (2^N)
+ */
+static void fft_calc(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in,
+ int N, ptrdiff_t stride)
+{
+ if (N) {
+ const FFTComplex *exptab = s->exptab[N];
+ const int len2 = 15 * (1 << (N - 1));
+ int k;
+
+ fft_calc(s, out, in, N - 1, stride * 2);
+ fft_calc(s, out + len2, in + stride, N - 1, stride * 2);
+
+ for (k = 0; k < len2; k++) {
+ FFTComplex t;
+
+ CMUL(t, out[len2 + k], exptab[k]);
+
+ out[len2 + k].re = out[k].re - t.re;
+ out[len2 + k].im = out[k].im - t.im;
+
+ out[k].re += t.re;
+ out[k].im += t.im;
+ }
+ } else
+ fft15(s, out, in, stride);
+}
+
+static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src,
+ ptrdiff_t stride, float scale)
+{
+ FFTComplex *z = (FFTComplex *)dst;
+ const int len8 = s->len4 / 2;
+ const float *in1 = src;
+ const float *in2 = src + (s->len2 - 1) * stride;
+ int i;
+
+ for (i = 0; i < s->len4; i++) {
+ FFTComplex tmp = { *in2, *in1 };
+ CMUL(s->tmp[i], tmp, s->twiddle_exptab[i]);
+ in1 += 2 * stride;
+ in2 -= 2 * stride;
+ }
+
+ fft_calc(s, z, s->tmp, s->fft_n, 1);
+
+ for (i = 0; i < len8; i++) {
+ float r0, i0, r1, i1;
+
+ CMUL3(r0, i1, z[len8 - i - 1].im, z[len8 - i - 1].re, s->twiddle_exptab[len8 - i - 1].im, s->twiddle_exptab[len8 - i - 1].re);
+ CMUL3(r1, i0, z[len8 + i].im, z[len8 + i].re, s->twiddle_exptab[len8 + i].im, s->twiddle_exptab[len8 + i].re);
+ z[len8 - i - 1].re = scale * r0;
+ z[len8 - i - 1].im = scale * i0;
+ z[len8 + i].re = scale * r1;
+ z[len8 + i].im = scale * i1;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus_imdct.h b/chromium/third_party/ffmpeg/libavcodec/opus_imdct.h
new file mode 100644
index 00000000000..0ca4d973d0e
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus_imdct.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_OPUS_IMDCT_H
+#define AVCODEC_OPUS_IMDCT_H
+
+#include <stddef.h>
+
+#include "avfft.h"
+
+typedef struct CeltIMDCTContext {
+ int fft_n;
+ int len2;
+ int len4;
+
+ FFTComplex *tmp;
+
+ FFTComplex *twiddle_exptab;
+
+ FFTComplex *exptab[6];
+
+ /**
+ * Calculate the middle half of the iMDCT
+ */
+ void (*imdct_half)(struct CeltIMDCTContext *s, float *dst, const float *src,
+ ptrdiff_t src_stride, float scale);
+} CeltIMDCTContext;
+
+/**
+ * Init an iMDCT of the length 2 * 15 * (2^N)
+ */
+int ff_celt_imdct_init(CeltIMDCTContext **s, int N);
+
+/**
+ * Free an iMDCT.
+ */
+void ff_celt_imdct_uninit(CeltIMDCTContext **s);
+
+
+void ff_celt_imdct_init_aarch64(CeltIMDCTContext *s);
+
+#endif /* AVCODEC_OPUS_IMDCT_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus_parser.c b/chromium/third_party/ffmpeg/libavcodec/opus_parser.c
new file mode 100644
index 00000000000..7eb72f9c34a
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus_parser.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Opus parser
+ *
+ * Determines the duration for each packet.
+ */
+
+#include "avcodec.h"
+#include "opus.h"
+
+typedef struct OpusParseContext {
+ OpusContext ctx;
+ OpusPacket pkt;
+ int extradata_parsed;
+} OpusParseContext;
+
+static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+ OpusParseContext *s = ctx->priv_data;
+ int ret;
+
+ if (!buf_size)
+ return 0;
+
+ if (avctx->extradata && !s->extradata_parsed) {
+ ret = ff_opus_parse_extradata(avctx, &s->ctx);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error parsing Ogg extradata.\n");
+ goto fail;
+ }
+ av_freep(&s->ctx.channel_maps);
+ s->extradata_parsed = 1;
+ }
+
+ ret = ff_opus_parse_packet(&s->pkt, buf, buf_size, s->ctx.nb_streams > 1);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error parsing Opus packet header.\n");
+ goto fail;
+ }
+
+ ctx->duration = s->pkt.frame_count * s->pkt.frame_duration;
+
+fail:
+ *poutbuf = buf;
+ *poutbuf_size = buf_size;
+ return buf_size;
+}
+
+AVCodecParser ff_opus_parser = {
+ .codec_ids = { AV_CODEC_ID_OPUS },
+ .priv_data_size = sizeof(OpusParseContext),
+ .parser_parse = opus_parse,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/opus_silk.c b/chromium/third_party/ffmpeg/libavcodec/opus_silk.c
new file mode 100644
index 00000000000..7a89479fb93
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opus_silk.c
@@ -0,0 +1,1597 @@
+/*
+ * Copyright (c) 2012 Andrew D'Addesio
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Opus SILK decoder
+ */
+
+#include <stdint.h>
+
+#include "opus.h"
+
+typedef struct SilkFrame {
+ int coded;
+ int log_gain;
+ int16_t nlsf[16];
+ float lpc[16];
+
+ float output [2 * SILK_HISTORY];
+ float lpc_history[2 * SILK_HISTORY];
+ int primarylag;
+
+ int prev_voiced;
+} SilkFrame;
+
+struct SilkContext {
+ AVCodecContext *avctx;
+ int output_channels;
+
+ int midonly;
+ int subframes;
+ int sflength;
+ int flength;
+ int nlsf_interp_factor;
+
+ enum OpusBandwidth bandwidth;
+ int wb;
+
+ SilkFrame frame[2];
+ float prev_stereo_weights[2];
+ float stereo_weights[2];
+
+ int prev_coded_channels;
+};
+
+static const uint16_t silk_model_stereo_s1[] = {
+ 256, 7, 9, 10, 11, 12, 22, 46, 54, 55, 56, 59, 82, 174, 197, 200,
+ 201, 202, 210, 234, 244, 245, 246, 247, 249, 256
+};
+
+static const uint16_t silk_model_stereo_s2[] = {256, 85, 171, 256};
+
+static const uint16_t silk_model_stereo_s3[] = {256, 51, 102, 154, 205, 256};
+
+static const uint16_t silk_model_mid_only[] = {256, 192, 256};
+
+static const uint16_t silk_model_frame_type_inactive[] = {256, 26, 256};
+
+static const uint16_t silk_model_frame_type_active[] = {256, 24, 98, 246, 256};
+
+static const uint16_t silk_model_gain_highbits[3][9] = {
+ {256, 32, 144, 212, 241, 253, 254, 255, 256},
+ {256, 2, 19, 64, 124, 186, 233, 252, 256},
+ {256, 1, 4, 30, 101, 195, 245, 254, 256}
+};
+
+static const uint16_t silk_model_gain_lowbits[] = {256, 32, 64, 96, 128, 160, 192, 224, 256};
+
+static const uint16_t silk_model_gain_delta[] = {
+ 256, 6, 11, 22, 53, 185, 206, 214, 218, 221, 223, 225, 227, 228, 229, 230,
+ 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
+ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256
+};
+static const uint16_t silk_model_lsf_s1[2][2][33] = {
+ {
+ { // NB or MB, unvoiced
+ 256, 44, 78, 108, 127, 148, 160, 171, 174, 177, 179, 195, 197, 199, 200, 205,
+ 207, 208, 211, 214, 215, 216, 218, 220, 222, 225, 226, 235, 244, 246, 253, 255, 256
+ }, { // NB or MB, voiced
+ 256, 1, 11, 12, 20, 23, 31, 39, 53, 66, 80, 81, 95, 107, 120, 131,
+ 142, 154, 165, 175, 185, 196, 204, 213, 221, 228, 236, 237, 238, 244, 245, 251, 256
+ }
+ }, {
+ { // WB, unvoiced
+ 256, 31, 52, 55, 72, 73, 81, 98, 102, 103, 121, 137, 141, 143, 146, 147,
+ 157, 158, 161, 177, 188, 204, 206, 208, 211, 213, 224, 225, 229, 238, 246, 253, 256
+ }, { // WB, voiced
+ 256, 1, 5, 21, 26, 44, 55, 60, 74, 89, 90, 93, 105, 118, 132, 146,
+ 152, 166, 178, 180, 186, 187, 199, 211, 222, 232, 235, 245, 250, 251, 252, 253, 256
+ }
+ }
+};
+
+static const uint16_t silk_model_lsf_s2[32][10] = {
+ // NB, MB
+ { 256, 1, 2, 3, 18, 242, 253, 254, 255, 256 },
+ { 256, 1, 2, 4, 38, 221, 253, 254, 255, 256 },
+ { 256, 1, 2, 6, 48, 197, 252, 254, 255, 256 },
+ { 256, 1, 2, 10, 62, 185, 246, 254, 255, 256 },
+ { 256, 1, 4, 20, 73, 174, 248, 254, 255, 256 },
+ { 256, 1, 4, 21, 76, 166, 239, 254, 255, 256 },
+ { 256, 1, 8, 32, 85, 159, 226, 252, 255, 256 },
+ { 256, 1, 2, 20, 83, 161, 219, 249, 255, 256 },
+
+ // WB
+ { 256, 1, 2, 3, 12, 244, 253, 254, 255, 256 },
+ { 256, 1, 2, 4, 32, 218, 253, 254, 255, 256 },
+ { 256, 1, 2, 5, 47, 199, 252, 254, 255, 256 },
+ { 256, 1, 2, 12, 61, 187, 252, 254, 255, 256 },
+ { 256, 1, 5, 24, 72, 172, 249, 254, 255, 256 },
+ { 256, 1, 2, 16, 70, 170, 242, 254, 255, 256 },
+ { 256, 1, 2, 17, 78, 165, 226, 251, 255, 256 },
+ { 256, 1, 8, 29, 79, 156, 237, 254, 255, 256 }
+};
+
+static const uint16_t silk_model_lsf_s2_ext[] = { 256, 156, 216, 240, 249, 253, 255, 256 };
+
+static const uint16_t silk_model_lsf_interpolation_offset[] = { 256, 13, 35, 64, 75, 256 };
+
+static const uint16_t silk_model_pitch_highbits[] = {
+ 256, 3, 6, 12, 23, 44, 74, 106, 125, 136, 146, 158, 171, 184, 196, 207,
+ 216, 224, 231, 237, 241, 243, 245, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256
+};
+
+static const uint16_t silk_model_pitch_lowbits_nb[]= { 256, 64, 128, 192, 256 };
+
+static const uint16_t silk_model_pitch_lowbits_mb[]= { 256, 43, 85, 128, 171, 213, 256 };
+
+static const uint16_t silk_model_pitch_lowbits_wb[]= { 256, 32, 64, 96, 128, 160, 192, 224, 256 };
+
+static const uint16_t silk_model_pitch_delta[] = {
+ 256, 46, 48, 50, 53, 57, 63, 73, 88, 114, 152, 182, 204, 219, 229, 236,
+ 242, 246, 250, 252, 254, 256
+};
+
+static const uint16_t silk_model_pitch_contour_nb10ms[] = { 256, 143, 193, 256 };
+
+static const uint16_t silk_model_pitch_contour_nb20ms[] = {
+ 256, 68, 80, 101, 118, 137, 159, 189, 213, 230, 246, 256
+};
+
+static const uint16_t silk_model_pitch_contour_mbwb10ms[] = {
+ 256, 91, 137, 176, 195, 209, 221, 229, 236, 242, 247, 252, 256
+};
+
+static const uint16_t silk_model_pitch_contour_mbwb20ms[] = {
+ 256, 33, 55, 73, 89, 104, 118, 132, 145, 158, 168, 177, 186, 194, 200, 206,
+ 212, 217, 221, 225, 229, 232, 235, 238, 240, 242, 244, 246, 248, 250, 252, 253,
+ 254, 255, 256
+};
+
+static const uint16_t silk_model_ltp_filter[] = { 256, 77, 157, 256 };
+
+static const uint16_t silk_model_ltp_filter0_sel[] = {
+ 256, 185, 200, 213, 226, 235, 244, 250, 256
+};
+
+static const uint16_t silk_model_ltp_filter1_sel[] = {
+ 256, 57, 91, 112, 132, 147, 160, 172, 185, 195, 205, 214, 224, 233, 241, 248, 256
+};
+
+static const uint16_t silk_model_ltp_filter2_sel[] = {
+ 256, 15, 31, 45, 57, 69, 81, 92, 103, 114, 124, 133, 142, 151, 160, 168,
+ 176, 184, 192, 199, 206, 212, 218, 223, 227, 232, 236, 240, 244, 247, 251, 254, 256
+};
+
+static const uint16_t silk_model_ltp_scale_index[] = { 256, 128, 192, 256 };
+
+static const uint16_t silk_model_lcg_seed[] = { 256, 64, 128, 192, 256 };
+
+static const uint16_t silk_model_exc_rate[2][10] = {
+ { 256, 15, 66, 78, 124, 169, 182, 215, 242, 256 }, // unvoiced
+ { 256, 33, 63, 99, 116, 150, 199, 217, 238, 256 } // voiced
+};
+
+static const uint16_t silk_model_pulse_count[11][19] = {
+ { 256, 131, 205, 230, 238, 241, 244, 245, 246,
+ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256 },
+ { 256, 58, 151, 211, 234, 241, 244, 245, 246,
+ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256 },
+ { 256, 43, 94, 140, 173, 197, 213, 224, 232,
+ 238, 241, 244, 247, 249, 250, 251, 253, 254, 256 },
+ { 256, 17, 69, 140, 197, 228, 240, 245, 246,
+ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256 },
+ { 256, 6, 27, 68, 121, 170, 205, 226, 237,
+ 243, 246, 248, 250, 251, 252, 253, 254, 255, 256 },
+ { 256, 7, 21, 43, 71, 100, 128, 153, 173,
+ 190, 203, 214, 223, 230, 235, 239, 243, 246, 256 },
+ { 256, 2, 7, 21, 50, 92, 138, 179, 210,
+ 229, 240, 246, 249, 251, 252, 253, 254, 255, 256 },
+ { 256, 1, 3, 7, 17, 36, 65, 100, 137,
+ 171, 199, 219, 233, 241, 246, 250, 252, 254, 256 },
+ { 256, 1, 3, 5, 10, 19, 33, 53, 77,
+ 104, 132, 158, 181, 201, 216, 227, 235, 241, 256 },
+ { 256, 1, 2, 3, 9, 36, 94, 150, 189,
+ 214, 228, 238, 244, 247, 250, 252, 253, 254, 256 },
+ { 256, 2, 3, 9, 36, 94, 150, 189, 214,
+ 228, 238, 244, 247, 250, 252, 253, 254, 256, 256 }
+};
+
+static const uint16_t silk_model_pulse_location[4][168] = {
+ {
+ 256, 126, 256,
+ 256, 56, 198, 256,
+ 256, 25, 126, 230, 256,
+ 256, 12, 72, 180, 244, 256,
+ 256, 7, 42, 126, 213, 250, 256,
+ 256, 4, 24, 83, 169, 232, 253, 256,
+ 256, 3, 15, 53, 125, 200, 242, 254, 256,
+ 256, 2, 10, 35, 89, 162, 221, 248, 255, 256,
+ 256, 2, 7, 24, 63, 126, 191, 233, 251, 255, 256,
+ 256, 1, 5, 17, 45, 94, 157, 211, 241, 252, 255, 256,
+ 256, 1, 5, 13, 33, 70, 125, 182, 223, 245, 253, 255, 256,
+ 256, 1, 4, 11, 26, 54, 98, 151, 199, 232, 248, 254, 255, 256,
+ 256, 1, 3, 9, 21, 42, 77, 124, 172, 212, 237, 249, 254, 255, 256,
+ 256, 1, 2, 6, 16, 33, 60, 97, 144, 187, 220, 241, 250, 254, 255, 256,
+ 256, 1, 2, 3, 11, 25, 47, 80, 120, 163, 201, 229, 245, 253, 254, 255, 256,
+ 256, 1, 2, 3, 4, 17, 35, 62, 98, 139, 180, 214, 238, 252, 253, 254, 255, 256
+ },{
+ 256, 127, 256,
+ 256, 53, 202, 256,
+ 256, 22, 127, 233, 256,
+ 256, 11, 72, 183, 246, 256,
+ 256, 6, 41, 127, 215, 251, 256,
+ 256, 4, 24, 83, 170, 232, 253, 256,
+ 256, 3, 16, 56, 127, 200, 241, 254, 256,
+ 256, 3, 12, 39, 92, 162, 218, 246, 255, 256,
+ 256, 3, 11, 30, 67, 124, 185, 229, 249, 255, 256,
+ 256, 3, 10, 25, 53, 97, 151, 200, 233, 250, 255, 256,
+ 256, 1, 8, 21, 43, 77, 123, 171, 209, 237, 251, 255, 256,
+ 256, 1, 2, 13, 35, 62, 97, 139, 186, 219, 244, 254, 255, 256,
+ 256, 1, 2, 8, 22, 48, 85, 128, 171, 208, 234, 248, 254, 255, 256,
+ 256, 1, 2, 6, 16, 36, 67, 107, 149, 189, 220, 240, 250, 254, 255, 256,
+ 256, 1, 2, 5, 13, 29, 55, 90, 128, 166, 201, 227, 243, 251, 254, 255, 256,
+ 256, 1, 2, 4, 10, 22, 43, 73, 109, 147, 183, 213, 234, 246, 252, 254, 255, 256
+ },{
+ 256, 127, 256,
+ 256, 49, 206, 256,
+ 256, 20, 127, 236, 256,
+ 256, 11, 71, 184, 246, 256,
+ 256, 7, 43, 127, 214, 250, 256,
+ 256, 6, 30, 87, 169, 229, 252, 256,
+ 256, 5, 23, 62, 126, 194, 236, 252, 256,
+ 256, 6, 20, 49, 96, 157, 209, 239, 253, 256,
+ 256, 1, 16, 39, 74, 125, 175, 215, 245, 255, 256,
+ 256, 1, 2, 23, 55, 97, 149, 195, 236, 254, 255, 256,
+ 256, 1, 7, 23, 50, 86, 128, 170, 206, 233, 249, 255, 256,
+ 256, 1, 6, 18, 39, 70, 108, 148, 186, 217, 238, 250, 255, 256,
+ 256, 1, 4, 13, 30, 56, 90, 128, 166, 200, 226, 243, 252, 255, 256,
+ 256, 1, 4, 11, 25, 47, 76, 110, 146, 180, 209, 231, 245, 252, 255, 256,
+ 256, 1, 3, 8, 19, 37, 62, 93, 128, 163, 194, 219, 237, 248, 253, 255, 256,
+ 256, 1, 2, 6, 15, 30, 51, 79, 111, 145, 177, 205, 226, 241, 250, 254, 255, 256
+ },{
+ 256, 128, 256,
+ 256, 42, 214, 256,
+ 256, 21, 128, 235, 256,
+ 256, 12, 72, 184, 245, 256,
+ 256, 8, 42, 128, 214, 249, 256,
+ 256, 8, 31, 86, 176, 231, 251, 256,
+ 256, 5, 20, 58, 130, 202, 238, 253, 256,
+ 256, 6, 18, 45, 97, 174, 221, 241, 251, 256,
+ 256, 6, 25, 53, 88, 128, 168, 203, 231, 250, 256,
+ 256, 4, 18, 40, 71, 108, 148, 185, 216, 238, 252, 256,
+ 256, 3, 13, 31, 57, 90, 128, 166, 199, 225, 243, 253, 256,
+ 256, 2, 10, 23, 44, 73, 109, 147, 183, 212, 233, 246, 254, 256,
+ 256, 1, 6, 16, 33, 58, 90, 128, 166, 198, 223, 240, 250, 255, 256,
+ 256, 1, 5, 12, 25, 46, 75, 110, 146, 181, 210, 231, 244, 251, 255, 256,
+ 256, 1, 3, 8, 18, 35, 60, 92, 128, 164, 196, 221, 238, 248, 253, 255, 256,
+ 256, 1, 3, 7, 14, 27, 48, 76, 110, 146, 180, 208, 229, 242, 249, 253, 255, 256
+ }
+};
+
+static const uint16_t silk_model_excitation_lsb[] = {256, 136, 256};
+
+static const uint16_t silk_model_excitation_sign[3][2][7][3] = {
+ { // Inactive
+ { // Low offset
+ {256, 2, 256},
+ {256, 207, 256},
+ {256, 189, 256},
+ {256, 179, 256},
+ {256, 174, 256},
+ {256, 163, 256},
+ {256, 157, 256}
+ }, { // High offset
+ {256, 58, 256},
+ {256, 245, 256},
+ {256, 238, 256},
+ {256, 232, 256},
+ {256, 225, 256},
+ {256, 220, 256},
+ {256, 211, 256}
+ }
+ }, { // Unvoiced
+ { // Low offset
+ {256, 1, 256},
+ {256, 210, 256},
+ {256, 190, 256},
+ {256, 178, 256},
+ {256, 169, 256},
+ {256, 162, 256},
+ {256, 152, 256}
+ }, { // High offset
+ {256, 48, 256},
+ {256, 242, 256},
+ {256, 235, 256},
+ {256, 224, 256},
+ {256, 214, 256},
+ {256, 205, 256},
+ {256, 190, 256}
+ }
+ }, { // Voiced
+ { // Low offset
+ {256, 1, 256},
+ {256, 162, 256},
+ {256, 152, 256},
+ {256, 147, 256},
+ {256, 144, 256},
+ {256, 141, 256},
+ {256, 138, 256}
+ }, { // High offset
+ {256, 8, 256},
+ {256, 203, 256},
+ {256, 187, 256},
+ {256, 176, 256},
+ {256, 168, 256},
+ {256, 161, 256},
+ {256, 154, 256}
+ }
+ }
+};
+
+static const int16_t silk_stereo_weights[] = {
+ -13732, -10050, -8266, -7526, -6500, -5000, -2950, -820,
+ 820, 2950, 5000, 6500, 7526, 8266, 10050, 13732
+};
+
+static const uint8_t silk_lsf_s2_model_sel_nbmb[32][10] = {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 3, 1, 2, 2, 1, 2, 1, 1, 1 },
+ { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+ { 1, 2, 2, 2, 2, 1, 2, 1, 1, 1 },
+ { 2, 3, 3, 3, 3, 2, 2, 2, 2, 2 },
+ { 0, 5, 3, 3, 2, 2, 2, 2, 1, 1 },
+ { 0, 2, 2, 2, 2, 2, 2, 2, 2, 1 },
+ { 2, 3, 6, 4, 4, 4, 5, 4, 5, 5 },
+ { 2, 4, 5, 5, 4, 5, 4, 6, 4, 4 },
+ { 2, 4, 4, 7, 4, 5, 4, 5, 5, 4 },
+ { 4, 3, 3, 3, 2, 3, 2, 2, 2, 2 },
+ { 1, 5, 5, 6, 4, 5, 4, 5, 5, 5 },
+ { 2, 7, 4, 6, 5, 5, 5, 5, 5, 5 },
+ { 2, 7, 5, 5, 5, 5, 5, 6, 5, 4 },
+ { 3, 3, 5, 4, 4, 5, 4, 5, 4, 4 },
+ { 2, 3, 3, 5, 5, 4, 4, 4, 4, 4 },
+ { 2, 4, 4, 6, 4, 5, 4, 5, 5, 5 },
+ { 2, 5, 4, 6, 5, 5, 5, 4, 5, 4 },
+ { 2, 7, 4, 5, 4, 5, 4, 5, 5, 5 },
+ { 2, 5, 4, 6, 7, 6, 5, 6, 5, 4 },
+ { 3, 6, 7, 4, 6, 5, 5, 6, 4, 5 },
+ { 2, 7, 6, 4, 4, 4, 5, 4, 5, 5 },
+ { 4, 5, 5, 4, 6, 6, 5, 6, 5, 4 },
+ { 2, 5, 5, 6, 5, 6, 4, 6, 4, 4 },
+ { 4, 5, 5, 5, 3, 7, 4, 5, 5, 4 },
+ { 2, 3, 4, 5, 5, 6, 4, 5, 5, 4 },
+ { 2, 3, 2, 3, 3, 4, 2, 3, 3, 3 },
+ { 1, 1, 2, 2, 2, 2, 2, 3, 2, 2 },
+ { 4, 5, 5, 6, 6, 6, 5, 6, 4, 5 },
+ { 3, 5, 5, 4, 4, 4, 4, 3, 3, 2 },
+ { 2, 5, 3, 7, 5, 5, 4, 4, 5, 4 },
+ { 4, 4, 5, 4, 5, 6, 5, 6, 5, 4 }
+};
+
+static const uint8_t silk_lsf_s2_model_sel_wb[32][16] = {
+ { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+ { 10, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 8, 11 },
+ { 10, 13, 13, 11, 15, 12, 12, 13, 10, 13, 12, 13, 13, 12, 11, 11 },
+ { 8, 10, 9, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9 },
+ { 8, 14, 13, 12, 14, 12, 15, 13, 12, 12, 12, 13, 13, 12, 12, 11 },
+ { 8, 11, 13, 13, 12, 11, 11, 13, 11, 11, 11, 11, 11, 11, 10, 12 },
+ { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+ { 8, 10, 14, 11, 15, 10, 13, 11, 12, 13, 13, 12, 11, 11, 10, 11 },
+ { 8, 14, 10, 14, 14, 12, 13, 12, 14, 13, 12, 12, 13, 11, 11, 11 },
+ { 10, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+ { 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9 },
+ { 10, 10, 11, 12, 13, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 11 },
+ { 10, 10, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 10, 9, 11 },
+ { 11, 12, 12, 12, 14, 12, 12, 13, 11, 13, 12, 12, 13, 12, 11, 12 },
+ { 8, 14, 12, 13, 12, 15, 13, 10, 14, 13, 15, 12, 12, 11, 13, 11 },
+ { 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, 8 },
+ { 9, 14, 13, 15, 13, 12, 13, 11, 12, 13, 12, 12, 12, 11, 11, 12 },
+ { 9, 11, 11, 12, 12, 11, 11, 13, 10, 11, 11, 13, 13, 13, 11, 12 },
+ { 10, 11, 11, 10, 10, 10, 11, 10, 9, 10, 9, 10, 9, 9, 9, 12 },
+ { 8, 10, 11, 13, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 8 },
+ { 11, 12, 11, 13, 11, 11, 10, 10, 9, 9, 9, 9, 9, 10, 10, 12 },
+ { 10, 14, 11, 15, 15, 12, 13, 12, 13, 11, 13, 11, 11, 10, 11, 11 },
+ { 10, 11, 13, 14, 14, 11, 13, 11, 12, 12, 11, 11, 11, 11, 10, 12 },
+ { 9, 11, 11, 12, 12, 12, 12, 11, 13, 13, 13, 11, 9, 9, 9, 9 },
+ { 10, 13, 11, 14, 14, 12, 15, 12, 12, 13, 11, 12, 12, 11, 11, 11 },
+ { 8, 14, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
+ { 8, 14, 14, 11, 13, 10, 13, 13, 11, 12, 12, 15, 15, 12, 12, 12 },
+ { 11, 11, 15, 11, 13, 12, 11, 11, 11, 10, 10, 11, 11, 11, 10, 11 },
+ { 8, 8, 9, 8, 8, 8, 10, 9, 10, 9, 9, 10, 10, 10, 9, 9 },
+ { 8, 11, 10, 13, 11, 11, 10, 11, 10, 9, 8, 8, 9, 8, 8, 9 },
+ { 11, 13, 13, 12, 15, 13, 11, 11, 10, 11, 10, 10, 9, 8, 9, 8 },
+ { 10, 11, 13, 11, 12, 11, 11, 11, 10, 9, 10, 14, 12, 8, 8, 8 }
+};
+
+static const uint8_t silk_lsf_pred_weights_nbmb[2][9] = {
+ {179, 138, 140, 148, 151, 149, 153, 151, 163},
+ {116, 67, 82, 59, 92, 72, 100, 89, 92}
+};
+
+static const uint8_t silk_lsf_pred_weights_wb[2][15] = {
+ {175, 148, 160, 176, 178, 173, 174, 164, 177, 174, 196, 182, 198, 192, 182},
+ { 68, 62, 66, 60, 72, 117, 85, 90, 118, 136, 151, 142, 160, 142, 155}
+};
+
+static const uint8_t silk_lsf_weight_sel_nbmb[32][9] = {
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 1, 1, 0, 0, 0, 0, 1, 0 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 0, 1, 1, 0, 0, 0, 1, 0 },
+ { 0, 1, 1, 0, 0, 1, 1, 0, 0 },
+ { 0, 0, 1, 1, 0, 1, 0, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 1, 1, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 1, 0, 1, 1, 1, 1, 1, 0 },
+ { 0, 1, 0, 1, 1, 1, 1, 1, 0 },
+ { 0, 1, 1, 1, 1, 1, 1, 1, 0 },
+ { 1, 0, 1, 1, 0, 1, 1, 1, 1 },
+ { 0, 1, 1, 1, 1, 1, 0, 1, 0 },
+ { 0, 0, 1, 1, 0, 1, 0, 1, 0 },
+ { 0, 0, 1, 1, 1, 0, 1, 1, 1 },
+ { 0, 1, 1, 0, 0, 1, 1, 1, 0 },
+ { 0, 0, 0, 1, 1, 1, 0, 1, 0 },
+ { 0, 1, 1, 0, 0, 1, 0, 1, 0 },
+ { 0, 1, 1, 0, 0, 0, 1, 1, 0 },
+ { 0, 0, 0, 0, 0, 1, 1, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 0, 1, 1 },
+ { 0, 0, 0, 1, 0, 1, 1, 1, 1 },
+ { 0, 1, 1, 1, 1, 1, 1, 1, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 1, 0, 1, 1, 0, 1, 0 },
+ { 1, 0, 0, 1, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 1, 1, 0, 1, 0, 1 },
+ { 1, 0, 1, 1, 0, 1, 1, 1, 1 }
+};
+
+static const uint8_t silk_lsf_weight_sel_wb[32][15] = {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
+ { 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0 },
+ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 },
+ { 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 },
+ { 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 },
+ { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 },
+ { 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0 },
+ { 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
+ { 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0 },
+ { 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0 },
+ { 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0 },
+ { 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0 },
+ { 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1 },
+ { 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
+ { 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0 }
+};
+
+static const uint8_t silk_lsf_codebook_nbmb[32][10] = {
+ { 12, 35, 60, 83, 108, 132, 157, 180, 206, 228 },
+ { 15, 32, 55, 77, 101, 125, 151, 175, 201, 225 },
+ { 19, 42, 66, 89, 114, 137, 162, 184, 209, 230 },
+ { 12, 25, 50, 72, 97, 120, 147, 172, 200, 223 },
+ { 26, 44, 69, 90, 114, 135, 159, 180, 205, 225 },
+ { 13, 22, 53, 80, 106, 130, 156, 180, 205, 228 },
+ { 15, 25, 44, 64, 90, 115, 142, 168, 196, 222 },
+ { 19, 24, 62, 82, 100, 120, 145, 168, 190, 214 },
+ { 22, 31, 50, 79, 103, 120, 151, 170, 203, 227 },
+ { 21, 29, 45, 65, 106, 124, 150, 171, 196, 224 },
+ { 30, 49, 75, 97, 121, 142, 165, 186, 209, 229 },
+ { 19, 25, 52, 70, 93, 116, 143, 166, 192, 219 },
+ { 26, 34, 62, 75, 97, 118, 145, 167, 194, 217 },
+ { 25, 33, 56, 70, 91, 113, 143, 165, 196, 223 },
+ { 21, 34, 51, 72, 97, 117, 145, 171, 196, 222 },
+ { 20, 29, 50, 67, 90, 117, 144, 168, 197, 221 },
+ { 22, 31, 48, 66, 95, 117, 146, 168, 196, 222 },
+ { 24, 33, 51, 77, 116, 134, 158, 180, 200, 224 },
+ { 21, 28, 70, 87, 106, 124, 149, 170, 194, 217 },
+ { 26, 33, 53, 64, 83, 117, 152, 173, 204, 225 },
+ { 27, 34, 65, 95, 108, 129, 155, 174, 210, 225 },
+ { 20, 26, 72, 99, 113, 131, 154, 176, 200, 219 },
+ { 34, 43, 61, 78, 93, 114, 155, 177, 205, 229 },
+ { 23, 29, 54, 97, 124, 138, 163, 179, 209, 229 },
+ { 30, 38, 56, 89, 118, 129, 158, 178, 200, 231 },
+ { 21, 29, 49, 63, 85, 111, 142, 163, 193, 222 },
+ { 27, 48, 77, 103, 133, 158, 179, 196, 215, 232 },
+ { 29, 47, 74, 99, 124, 151, 176, 198, 220, 237 },
+ { 33, 42, 61, 76, 93, 121, 155, 174, 207, 225 },
+ { 29, 53, 87, 112, 136, 154, 170, 188, 208, 227 },
+ { 24, 30, 52, 84, 131, 150, 166, 186, 203, 229 },
+ { 37, 48, 64, 84, 104, 118, 156, 177, 201, 230 }
+};
+
+static const uint8_t silk_lsf_codebook_wb[32][16] = {
+ { 7, 23, 38, 54, 69, 85, 100, 116, 131, 147, 162, 178, 193, 208, 223, 239 },
+ { 13, 25, 41, 55, 69, 83, 98, 112, 127, 142, 157, 171, 187, 203, 220, 236 },
+ { 15, 21, 34, 51, 61, 78, 92, 106, 126, 136, 152, 167, 185, 205, 225, 240 },
+ { 10, 21, 36, 50, 63, 79, 95, 110, 126, 141, 157, 173, 189, 205, 221, 237 },
+ { 17, 20, 37, 51, 59, 78, 89, 107, 123, 134, 150, 164, 184, 205, 224, 240 },
+ { 10, 15, 32, 51, 67, 81, 96, 112, 129, 142, 158, 173, 189, 204, 220, 236 },
+ { 8, 21, 37, 51, 65, 79, 98, 113, 126, 138, 155, 168, 179, 192, 209, 218 },
+ { 12, 15, 34, 55, 63, 78, 87, 108, 118, 131, 148, 167, 185, 203, 219, 236 },
+ { 16, 19, 32, 36, 56, 79, 91, 108, 118, 136, 154, 171, 186, 204, 220, 237 },
+ { 11, 28, 43, 58, 74, 89, 105, 120, 135, 150, 165, 180, 196, 211, 226, 241 },
+ { 6, 16, 33, 46, 60, 75, 92, 107, 123, 137, 156, 169, 185, 199, 214, 225 },
+ { 11, 19, 30, 44, 57, 74, 89, 105, 121, 135, 152, 169, 186, 202, 218, 234 },
+ { 12, 19, 29, 46, 57, 71, 88, 100, 120, 132, 148, 165, 182, 199, 216, 233 },
+ { 17, 23, 35, 46, 56, 77, 92, 106, 123, 134, 152, 167, 185, 204, 222, 237 },
+ { 14, 17, 45, 53, 63, 75, 89, 107, 115, 132, 151, 171, 188, 206, 221, 240 },
+ { 9, 16, 29, 40, 56, 71, 88, 103, 119, 137, 154, 171, 189, 205, 222, 237 },
+ { 16, 19, 36, 48, 57, 76, 87, 105, 118, 132, 150, 167, 185, 202, 218, 236 },
+ { 12, 17, 29, 54, 71, 81, 94, 104, 126, 136, 149, 164, 182, 201, 221, 237 },
+ { 15, 28, 47, 62, 79, 97, 115, 129, 142, 155, 168, 180, 194, 208, 223, 238 },
+ { 8, 14, 30, 45, 62, 78, 94, 111, 127, 143, 159, 175, 192, 207, 223, 239 },
+ { 17, 30, 49, 62, 79, 92, 107, 119, 132, 145, 160, 174, 190, 204, 220, 235 },
+ { 14, 19, 36, 45, 61, 76, 91, 108, 121, 138, 154, 172, 189, 205, 222, 238 },
+ { 12, 18, 31, 45, 60, 76, 91, 107, 123, 138, 154, 171, 187, 204, 221, 236 },
+ { 13, 17, 31, 43, 53, 70, 83, 103, 114, 131, 149, 167, 185, 203, 220, 237 },
+ { 17, 22, 35, 42, 58, 78, 93, 110, 125, 139, 155, 170, 188, 206, 224, 240 },
+ { 8, 15, 34, 50, 67, 83, 99, 115, 131, 146, 162, 178, 193, 209, 224, 239 },
+ { 13, 16, 41, 66, 73, 86, 95, 111, 128, 137, 150, 163, 183, 206, 225, 241 },
+ { 17, 25, 37, 52, 63, 75, 92, 102, 119, 132, 144, 160, 175, 191, 212, 231 },
+ { 19, 31, 49, 65, 83, 100, 117, 133, 147, 161, 174, 187, 200, 213, 227, 242 },
+ { 18, 31, 52, 68, 88, 103, 117, 126, 138, 149, 163, 177, 192, 207, 223, 239 },
+ { 16, 29, 47, 61, 76, 90, 106, 119, 133, 147, 161, 176, 193, 209, 224, 240 },
+ { 15, 21, 35, 50, 61, 73, 86, 97, 110, 119, 129, 141, 175, 198, 218, 237 }
+};
+
+static const uint16_t silk_lsf_min_spacing_nbmb[] = {
+ 250, 3, 6, 3, 3, 3, 4, 3, 3, 3, 461
+};
+
+static const uint16_t silk_lsf_min_spacing_wb[] = {
+ 100, 3, 40, 3, 3, 3, 5, 14, 14, 10, 11, 3, 8, 9, 7, 3, 347
+};
+
+static const uint8_t silk_lsf_ordering_nbmb[] = {
+ 0, 9, 6, 3, 4, 5, 8, 1, 2, 7
+};
+
+static const uint8_t silk_lsf_ordering_wb[] = {
+ 0, 15, 8, 7, 4, 11, 12, 3, 2, 13, 10, 5, 6, 9, 14, 1
+};
+
+static const int16_t silk_cosine[] = { /* (0.12) */
+ 4096, 4095, 4091, 4085,
+ 4076, 4065, 4052, 4036,
+ 4017, 3997, 3973, 3948,
+ 3920, 3889, 3857, 3822,
+ 3784, 3745, 3703, 3659,
+ 3613, 3564, 3513, 3461,
+ 3406, 3349, 3290, 3229,
+ 3166, 3102, 3035, 2967,
+ 2896, 2824, 2751, 2676,
+ 2599, 2520, 2440, 2359,
+ 2276, 2191, 2106, 2019,
+ 1931, 1842, 1751, 1660,
+ 1568, 1474, 1380, 1285,
+ 1189, 1093, 995, 897,
+ 799, 700, 601, 501,
+ 401, 301, 201, 101,
+ 0, -101, -201, -301,
+ -401, -501, -601, -700,
+ -799, -897, -995, -1093,
+ -1189, -1285, -1380, -1474,
+ -1568, -1660, -1751, -1842,
+ -1931, -2019, -2106, -2191,
+ -2276, -2359, -2440, -2520,
+ -2599, -2676, -2751, -2824,
+ -2896, -2967, -3035, -3102,
+ -3166, -3229, -3290, -3349,
+ -3406, -3461, -3513, -3564,
+ -3613, -3659, -3703, -3745,
+ -3784, -3822, -3857, -3889,
+ -3920, -3948, -3973, -3997,
+ -4017, -4036, -4052, -4065,
+ -4076, -4085, -4091, -4095,
+ -4096
+};
+
+static const uint16_t silk_pitch_scale[] = { 4, 6, 8};
+
+static const uint16_t silk_pitch_min_lag[] = { 16, 24, 32};
+
+static const uint16_t silk_pitch_max_lag[] = {144, 216, 288};
+
+static const int8_t silk_pitch_offset_nb10ms[3][2] = {
+ { 0, 0},
+ { 1, 0},
+ { 0, 1}
+};
+
+static const int8_t silk_pitch_offset_nb20ms[11][4] = {
+ { 0, 0, 0, 0},
+ { 2, 1, 0, -1},
+ {-1, 0, 1, 2},
+ {-1, 0, 0, 1},
+ {-1, 0, 0, 0},
+ { 0, 0, 0, 1},
+ { 0, 0, 1, 1},
+ { 1, 1, 0, 0},
+ { 1, 0, 0, 0},
+ { 0, 0, 0, -1},
+ { 1, 0, 0, -1}
+};
+
+static const int8_t silk_pitch_offset_mbwb10ms[12][2] = {
+ { 0, 0},
+ { 0, 1},
+ { 1, 0},
+ {-1, 1},
+ { 1, -1},
+ {-1, 2},
+ { 2, -1},
+ {-2, 2},
+ { 2, -2},
+ {-2, 3},
+ { 3, -2},
+ {-3, 3}
+};
+
+static const int8_t silk_pitch_offset_mbwb20ms[34][4] = {
+ { 0, 0, 0, 0},
+ { 0, 0, 1, 1},
+ { 1, 1, 0, 0},
+ {-1, 0, 0, 0},
+ { 0, 0, 0, 1},
+ { 1, 0, 0, 0},
+ {-1, 0, 0, 1},
+ { 0, 0, 0, -1},
+ {-1, 0, 1, 2},
+ { 1, 0, 0, -1},
+ {-2, -1, 1, 2},
+ { 2, 1, 0, -1},
+ {-2, 0, 0, 2},
+ {-2, 0, 1, 3},
+ { 2, 1, -1, -2},
+ {-3, -1, 1, 3},
+ { 2, 0, 0, -2},
+ { 3, 1, 0, -2},
+ {-3, -1, 2, 4},
+ {-4, -1, 1, 4},
+ { 3, 1, -1, -3},
+ {-4, -1, 2, 5},
+ { 4, 2, -1, -3},
+ { 4, 1, -1, -4},
+ {-5, -1, 2, 6},
+ { 5, 2, -1, -4},
+ {-6, -2, 2, 6},
+ {-5, -2, 2, 5},
+ { 6, 2, -1, -5},
+ {-7, -2, 3, 8},
+ { 6, 2, -2, -6},
+ { 5, 2, -2, -5},
+ { 8, 3, -2, -7},
+ {-9, -3, 3, 9}
+};
+
+static const int8_t silk_ltp_filter0_taps[8][5] = {
+ { 4, 6, 24, 7, 5},
+ { 0, 0, 2, 0, 0},
+ { 12, 28, 41, 13, -4},
+ { -9, 15, 42, 25, 14},
+ { 1, -2, 62, 41, -9},
+ {-10, 37, 65, -4, 3},
+ { -6, 4, 66, 7, -8},
+ { 16, 14, 38, -3, 33}
+};
+
+static const int8_t silk_ltp_filter1_taps[16][5] = {
+ { 13, 22, 39, 23, 12},
+ { -1, 36, 64, 27, -6},
+ { -7, 10, 55, 43, 17},
+ { 1, 1, 8, 1, 1},
+ { 6, -11, 74, 53, -9},
+ {-12, 55, 76, -12, 8},
+ { -3, 3, 93, 27, -4},
+ { 26, 39, 59, 3, -8},
+ { 2, 0, 77, 11, 9},
+ { -8, 22, 44, -6, 7},
+ { 40, 9, 26, 3, 9},
+ { -7, 20, 101, -7, 4},
+ { 3, -8, 42, 26, 0},
+ {-15, 33, 68, 2, 23},
+ { -2, 55, 46, -2, 15},
+ { 3, -1, 21, 16, 41}
+};
+
+static const int8_t silk_ltp_filter2_taps[32][5] = {
+ { -6, 27, 61, 39, 5},
+ {-11, 42, 88, 4, 1},
+ { -2, 60, 65, 6, -4},
+ { -1, -5, 73, 56, 1},
+ { -9, 19, 94, 29, -9},
+ { 0, 12, 99, 6, 4},
+ { 8, -19, 102, 46, -13},
+ { 3, 2, 13, 3, 2},
+ { 9, -21, 84, 72, -18},
+ {-11, 46, 104, -22, 8},
+ { 18, 38, 48, 23, 0},
+ {-16, 70, 83, -21, 11},
+ { 5, -11, 117, 22, -8},
+ { -6, 23, 117, -12, 3},
+ { 3, -8, 95, 28, 4},
+ {-10, 15, 77, 60, -15},
+ { -1, 4, 124, 2, -4},
+ { 3, 38, 84, 24, -25},
+ { 2, 13, 42, 13, 31},
+ { 21, -4, 56, 46, -1},
+ { -1, 35, 79, -13, 19},
+ { -7, 65, 88, -9, -14},
+ { 20, 4, 81, 49, -29},
+ { 20, 0, 75, 3, -17},
+ { 5, -9, 44, 92, -8},
+ { 1, -3, 22, 69, 31},
+ { -6, 95, 41, -12, 5},
+ { 39, 67, 16, -4, 1},
+ { 0, -6, 120, 55, -36},
+ {-13, 44, 122, 4, -24},
+ { 81, 5, 11, 3, 7},
+ { 2, 0, 9, 10, 88}
+};
+
+static const uint16_t silk_ltp_scale_factor[] = {15565, 12288, 8192};
+
+static const uint8_t silk_shell_blocks[3][2] = {
+ { 5, 10}, // NB
+ { 8, 15}, // MB
+ {10, 20} // WB
+};
+
+static const uint8_t silk_quant_offset[2][2] = { /* (0.23) */
+ {25, 60}, // Inactive or Unvoiced
+ { 8, 25} // Voiced
+};
+
+static const int silk_stereo_interp_len[3] = {
+ 64, 96, 128
+};
+
+static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
+{
+ int pass, i;
+ for (pass = 0; pass < 20; pass++) {
+ int k, min_diff = 0;
+ for (i = 0; i < order+1; i++) {
+ int low = i != 0 ? nlsf[i-1] : 0;
+ int high = i != order ? nlsf[i] : 32768;
+ int diff = (high - low) - (min_delta[i]);
+
+ if (diff < min_diff) {
+ min_diff = diff;
+ k = i;
+
+ if (pass == 20)
+ break;
+ }
+ }
+ if (min_diff == 0) /* no issues; stabilized */
+ return;
+
+ /* wiggle one or two LSFs */
+ if (k == 0) {
+ /* repel away from lower bound */
+ nlsf[0] = min_delta[0];
+ } else if (k == order) {
+ /* repel away from higher bound */
+ nlsf[order-1] = 32768 - min_delta[order];
+ } else {
+ /* repel away from current position */
+ int min_center = 0, max_center = 32768, center_val;
+
+ /* lower extent */
+ for (i = 0; i < k; i++)
+ min_center += min_delta[i];
+ min_center += min_delta[k] >> 1;
+
+ /* upper extent */
+ for (i = order; i > k; i--)
+ max_center -= min_delta[k];
+ max_center -= min_delta[k] >> 1;
+
+ /* move apart */
+ center_val = nlsf[k - 1] + nlsf[k];
+ center_val = (center_val >> 1) + (center_val & 1); // rounded divide by 2
+ center_val = FFMIN(max_center, FFMAX(min_center, center_val));
+
+ nlsf[k - 1] = center_val - (min_delta[k] >> 1);
+ nlsf[k] = nlsf[k - 1] + min_delta[k];
+ }
+ }
+
+ /* resort to the fall-back method, the standard method for LSF stabilization */
+
+ /* sort; as the LSFs should be nearly sorted, use insertion sort */
+ for (i = 1; i < order; i++) {
+ int j, value = nlsf[i];
+ for (j = i - 1; j >= 0 && nlsf[j] > value; j--)
+ nlsf[j + 1] = nlsf[j];
+ nlsf[j + 1] = value;
+ }
+
+ /* push forwards to increase distance */
+ if (nlsf[0] < min_delta[0])
+ nlsf[0] = min_delta[0];
+ for (i = 1; i < order; i++)
+ if (nlsf[i] < nlsf[i - 1] + min_delta[i])
+ nlsf[i] = nlsf[i - 1] + min_delta[i];
+
+ /* push backwards to increase distance */
+ if (nlsf[order-1] > 32768 - min_delta[order])
+ nlsf[order-1] = 32768 - min_delta[order];
+ for (i = order-2; i >= 0; i--)
+ if (nlsf[i] > nlsf[i + 1] - min_delta[i+1])
+ nlsf[i] = nlsf[i + 1] - min_delta[i+1];
+
+ return;
+}
+
+static inline int silk_is_lpc_stable(const int16_t lpc[16], int order)
+{
+ int k, j, DC_resp = 0;
+ int32_t lpc32[2][16]; // Q24
+ int totalinvgain = 1 << 30; // 1.0 in Q30
+ int32_t *row = lpc32[0], *prevrow;
+
+ /* initialize the first row for the Levinson recursion */
+ for (k = 0; k < order; k++) {
+ DC_resp += lpc[k];
+ row[k] = lpc[k] * 4096;
+ }
+
+ if (DC_resp >= 4096)
+ return 0;
+
+ /* check if prediction gain pushes any coefficients too far */
+ for (k = order - 1; 1; k--) {
+ int rc; // Q31; reflection coefficient
+ int gaindiv; // Q30; inverse of the gain (the divisor)
+ int gain; // gain for this reflection coefficient
+ int fbits; // fractional bits used for the gain
+ int error; // Q29; estimate of the error of our partial estimate of 1/gaindiv
+
+ if (FFABS(row[k]) > 16773022)
+ return 0;
+
+ rc = -(row[k] * 128);
+ gaindiv = (1 << 30) - MULH(rc, rc);
+
+ totalinvgain = MULH(totalinvgain, gaindiv) << 2;
+ if (k == 0)
+ return (totalinvgain >= 107374);
+
+ /* approximate 1.0/gaindiv */
+ fbits = opus_ilog(gaindiv);
+ gain = ((1 << 29) - 1) / (gaindiv >> (fbits + 1 - 16)); // Q<fbits-16>
+ error = (1 << 29) - MULL(gaindiv << (15 + 16 - fbits), gain, 16);
+ gain = ((gain << 16) + (error * gain >> 13));
+
+ /* switch to the next row of the LPC coefficients */
+ prevrow = row;
+ row = lpc32[k & 1];
+
+ for (j = 0; j < k; j++) {
+ int x = prevrow[j] - ROUND_MULL(prevrow[k - j - 1], rc, 31);
+ row[j] = ROUND_MULL(x, gain, fbits);
+ }
+ }
+}
+
+static void silk_lsp2poly(const int32_t lsp[16], int32_t pol[16], int half_order)
+{
+ int i, j;
+
+ pol[0] = 65536; // 1.0 in Q16
+ pol[1] = -lsp[0];
+
+ for (i = 1; i < half_order; i++) {
+ pol[i + 1] = pol[i - 1] * 2 - ROUND_MULL(lsp[2 * i], pol[i], 16);
+ for (j = i; j > 1; j--)
+ pol[j] += pol[j - 2] - ROUND_MULL(lsp[2 * i], pol[j - 1], 16);
+
+ pol[1] -= lsp[2 * i];
+ }
+}
+
+static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
+{
+ int i, k;
+ int32_t lsp[16]; // Q17; 2*cos(LSF)
+ int32_t p[9], q[9]; // Q16
+ int32_t lpc32[16]; // Q17
+ int16_t lpc[16]; // Q12
+
+ /* convert the LSFs to LSPs, i.e. 2*cos(LSF) */
+ for (k = 0; k < order; k++) {
+ int index = nlsf[k] >> 8;
+ int offset = nlsf[k] & 255;
+ int k2 = (order == 10) ? silk_lsf_ordering_nbmb[k] : silk_lsf_ordering_wb[k];
+
+ /* interpolate and round */
+ lsp[k2] = silk_cosine[index] * 256;
+ lsp[k2] += (silk_cosine[index + 1] - silk_cosine[index]) * offset;
+ lsp[k2] = (lsp[k2] + 4) >> 3;
+ }
+
+ silk_lsp2poly(lsp , p, order >> 1);
+ silk_lsp2poly(lsp + 1, q, order >> 1);
+
+ /* reconstruct A(z) */
+ for (k = 0; k < order>>1; k++) {
+ lpc32[k] = -p[k + 1] - p[k] - q[k + 1] + q[k];
+ lpc32[order-k-1] = -p[k + 1] - p[k] + q[k + 1] - q[k];
+ }
+
+ /* limit the range of the LPC coefficients to each fit within an int16_t */
+ for (i = 0; i < 10; i++) {
+ int j;
+ unsigned int maxabs = 0;
+ for (j = 0, k = 0; j < order; j++) {
+ unsigned int x = FFABS(lpc32[k]);
+ if (x > maxabs) {
+ maxabs = x; // Q17
+ k = j;
+ }
+ }
+
+ maxabs = (maxabs + 16) >> 5; // convert to Q12
+
+ if (maxabs > 32767) {
+ /* perform bandwidth expansion */
+ unsigned int chirp, chirp_base; // Q16
+ maxabs = FFMIN(maxabs, 163838); // anything above this overflows chirp's numerator
+ chirp_base = chirp = 65470 - ((maxabs - 32767) << 14) / ((maxabs * (k+1)) >> 2);
+
+ for (k = 0; k < order; k++) {
+ lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
+ chirp = (chirp_base * chirp + 32768) >> 16;
+ }
+ } else break;
+ }
+
+ if (i == 10) {
+ /* time's up: just clamp */
+ for (k = 0; k < order; k++) {
+ int x = (lpc32[k] + 16) >> 5;
+ lpc[k] = av_clip_int16(x);
+ lpc32[k] = lpc[k] << 5; // shortcut mandated by the spec; drops lower 5 bits
+ }
+ } else {
+ for (k = 0; k < order; k++)
+ lpc[k] = (lpc32[k] + 16) >> 5;
+ }
+
+ /* if the prediction gain causes the LPC filter to become unstable,
+ apply further bandwidth expansion on the Q17 coefficients */
+ for (i = 1; i <= 16 && !silk_is_lpc_stable(lpc, order); i++) {
+ unsigned int chirp, chirp_base;
+ chirp_base = chirp = 65536 - (1 << i);
+
+ for (k = 0; k < order; k++) {
+ lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
+ lpc[k] = (lpc32[k] + 16) >> 5;
+ chirp = (chirp_base * chirp + 32768) >> 16;
+ }
+ }
+
+ for (i = 0; i < order; i++)
+ lpcf[i] = lpc[i] / 4096.0f;
+}
+
+static inline void silk_decode_lpc(SilkContext *s, SilkFrame *frame,
+ OpusRangeCoder *rc,
+ float lpc_leadin[16], float lpc[16],
+ int *lpc_order, int *has_lpc_leadin, int voiced)
+{
+ int i;
+ int order; // order of the LP polynomial; 10 for NB/MB and 16 for WB
+ int8_t lsf_i1, lsf_i2[16]; // stage-1 and stage-2 codebook indices
+ int16_t lsf_res[16]; // residual as a Q10 value
+ int16_t nlsf[16]; // Q15
+
+ *lpc_order = order = s->wb ? 16 : 10;
+
+ /* obtain LSF stage-1 and stage-2 indices */
+ lsf_i1 = opus_rc_getsymbol(rc, silk_model_lsf_s1[s->wb][voiced]);
+ for (i = 0; i < order; i++) {
+ int index = s->wb ? silk_lsf_s2_model_sel_wb [lsf_i1][i] :
+ silk_lsf_s2_model_sel_nbmb[lsf_i1][i];
+ lsf_i2[i] = opus_rc_getsymbol(rc, silk_model_lsf_s2[index]) - 4;
+ if (lsf_i2[i] == -4)
+ lsf_i2[i] -= opus_rc_getsymbol(rc, silk_model_lsf_s2_ext);
+ else if (lsf_i2[i] == 4)
+ lsf_i2[i] += opus_rc_getsymbol(rc, silk_model_lsf_s2_ext);
+ }
+
+ /* reverse the backwards-prediction step */
+ for (i = order - 1; i >= 0; i--) {
+ int qstep = s->wb ? 9830 : 11796;
+
+ lsf_res[i] = lsf_i2[i] * 1024;
+ if (lsf_i2[i] < 0) lsf_res[i] += 102;
+ else if (lsf_i2[i] > 0) lsf_res[i] -= 102;
+ lsf_res[i] = (lsf_res[i] * qstep) >> 16;
+
+ if (i + 1 < order) {
+ int weight = s->wb ? silk_lsf_pred_weights_wb [silk_lsf_weight_sel_wb [lsf_i1][i]][i] :
+ silk_lsf_pred_weights_nbmb[silk_lsf_weight_sel_nbmb[lsf_i1][i]][i];
+ lsf_res[i] += (lsf_res[i+1] * weight) >> 8;
+ }
+ }
+
+ /* reconstruct the NLSF coefficients from the supplied indices */
+ for (i = 0; i < order; i++) {
+ const uint8_t * codebook = s->wb ? silk_lsf_codebook_wb [lsf_i1] :
+ silk_lsf_codebook_nbmb[lsf_i1];
+ int cur, prev, next, weight_sq, weight, ipart, fpart, y, value;
+
+ /* find the weight of the residual */
+ /* TODO: precompute */
+ cur = codebook[i];
+ prev = i ? codebook[i - 1] : 0;
+ next = i + 1 < order ? codebook[i + 1] : 256;
+ weight_sq = (1024 / (cur - prev) + 1024 / (next - cur)) << 16;
+
+ /* approximate square-root with mandated fixed-point arithmetic */
+ ipart = opus_ilog(weight_sq);
+ fpart = (weight_sq >> (ipart-8)) & 127;
+ y = ((ipart & 1) ? 32768 : 46214) >> ((32 - ipart)>>1);
+ weight = y + ((213 * fpart * y) >> 16);
+
+ value = cur * 128 + (lsf_res[i] * 16384) / weight;
+ nlsf[i] = av_clip(value, 0, 32767);
+ }
+
+ /* stabilize the NLSF coefficients */
+ silk_stabilize_lsf(nlsf, order, s->wb ? silk_lsf_min_spacing_wb :
+ silk_lsf_min_spacing_nbmb);
+
+ /* produce an interpolation for the first 2 subframes, */
+ /* and then convert both sets of NLSFs to LPC coefficients */
+ *has_lpc_leadin = 0;
+ if (s->subframes == 4) {
+ int offset = opus_rc_getsymbol(rc, silk_model_lsf_interpolation_offset);
+ if (offset != 4 && frame->coded) {
+ *has_lpc_leadin = 1;
+ if (offset != 0) {
+ int16_t nlsf_leadin[16];
+ for (i = 0; i < order; i++)
+ nlsf_leadin[i] = frame->nlsf[i] +
+ ((nlsf[i] - frame->nlsf[i]) * offset >> 2);
+ silk_lsf2lpc(nlsf_leadin, lpc_leadin, order);
+ } else /* avoid re-computation for a (roughly) 1-in-4 occurrence */
+ memcpy(lpc_leadin, frame->lpc, 16 * sizeof(float));
+ } else
+ offset = 4;
+ s->nlsf_interp_factor = offset;
+
+ silk_lsf2lpc(nlsf, lpc, order);
+ } else {
+ s->nlsf_interp_factor = 4;
+ silk_lsf2lpc(nlsf, lpc, order);
+ }
+
+ memcpy(frame->nlsf, nlsf, order * sizeof(nlsf[0]));
+ memcpy(frame->lpc, lpc, order * sizeof(lpc[0]));
+}
+
+static inline void silk_count_children(OpusRangeCoder *rc, int model, int32_t total,
+ int32_t child[2])
+{
+ if (total != 0) {
+ child[0] = opus_rc_getsymbol(rc,
+ silk_model_pulse_location[model] + (((total - 1 + 5) * (total - 1)) >> 1));
+ child[1] = total - child[0];
+ } else {
+ child[0] = 0;
+ child[1] = 0;
+ }
+}
+
+static inline void silk_decode_excitation(SilkContext *s, OpusRangeCoder *rc,
+ float* excitationf,
+ int qoffset_high, int active, int voiced)
+{
+ int i;
+ uint32_t seed;
+ int shellblocks;
+ int ratelevel;
+ uint8_t pulsecount[20]; // total pulses in each shell block
+ uint8_t lsbcount[20] = {0}; // raw lsbits defined for each pulse in each shell block
+ int32_t excitation[320]; // Q23
+
+ /* excitation parameters */
+ seed = opus_rc_getsymbol(rc, silk_model_lcg_seed);
+ shellblocks = silk_shell_blocks[s->bandwidth][s->subframes >> 2];
+ ratelevel = opus_rc_getsymbol(rc, silk_model_exc_rate[voiced]);
+
+ for (i = 0; i < shellblocks; i++) {
+ pulsecount[i] = opus_rc_getsymbol(rc, silk_model_pulse_count[ratelevel]);
+ if (pulsecount[i] == 17) {
+ while (pulsecount[i] == 17 && ++lsbcount[i] != 10)
+ pulsecount[i] = opus_rc_getsymbol(rc, silk_model_pulse_count[9]);
+ if (lsbcount[i] == 10)
+ pulsecount[i] = opus_rc_getsymbol(rc, silk_model_pulse_count[10]);
+ }
+ }
+
+ /* decode pulse locations using PVQ */
+ for (i = 0; i < shellblocks; i++) {
+ if (pulsecount[i] != 0) {
+ int a, b, c, d;
+ int32_t * location = excitation + 16*i;
+ int32_t branch[4][2];
+ branch[0][0] = pulsecount[i];
+
+ /* unrolled tail recursion */
+ for (a = 0; a < 1; a++) {
+ silk_count_children(rc, 0, branch[0][a], branch[1]);
+ for (b = 0; b < 2; b++) {
+ silk_count_children(rc, 1, branch[1][b], branch[2]);
+ for (c = 0; c < 2; c++) {
+ silk_count_children(rc, 2, branch[2][c], branch[3]);
+ for (d = 0; d < 2; d++) {
+ silk_count_children(rc, 3, branch[3][d], location);
+ location += 2;
+ }
+ }
+ }
+ }
+ } else
+ memset(excitation + 16*i, 0, 16*sizeof(int32_t));
+ }
+
+ /* decode least significant bits */
+ for (i = 0; i < shellblocks << 4; i++) {
+ int bit;
+ for (bit = 0; bit < lsbcount[i >> 4]; bit++)
+ excitation[i] = (excitation[i] << 1) |
+ opus_rc_getsymbol(rc, silk_model_excitation_lsb);
+ }
+
+ /* decode signs */
+ for (i = 0; i < shellblocks << 4; i++) {
+ if (excitation[i] != 0) {
+ int sign = opus_rc_getsymbol(rc, silk_model_excitation_sign[active +
+ voiced][qoffset_high][FFMIN(pulsecount[i >> 4], 6)]);
+ if (sign == 0)
+ excitation[i] *= -1;
+ }
+ }
+
+ /* assemble the excitation */
+ for (i = 0; i < shellblocks << 4; i++) {
+ int value = excitation[i];
+ excitation[i] = value * 256 | silk_quant_offset[voiced][qoffset_high];
+ if (value < 0) excitation[i] += 20;
+ else if (value > 0) excitation[i] -= 20;
+
+ /* invert samples pseudorandomly */
+ seed = 196314165 * seed + 907633515;
+ if (seed & 0x80000000)
+ excitation[i] *= -1;
+ seed += value;
+
+ excitationf[i] = excitation[i] / 8388608.0f;
+ }
+}
+
+/** Maximum residual history according to 4.2.7.6.1 */
+#define SILK_MAX_LAG (288 + LTP_ORDER / 2)
+
+/** Order of the LTP filter */
+#define LTP_ORDER 5
+
+static void silk_decode_frame(SilkContext *s, OpusRangeCoder *rc,
+ int frame_num, int channel, int coded_channels, int active, int active1)
+{
+ /* per frame */
+ int voiced; // combines with active to indicate inactive, active, or active+voiced
+ int qoffset_high;
+ int order; // order of the LPC coefficients
+ float lpc_leadin[16], lpc_body[16], residual[SILK_MAX_LAG + SILK_HISTORY];
+ int has_lpc_leadin;
+ float ltpscale;
+
+ /* per subframe */
+ struct {
+ float gain;
+ int pitchlag;
+ float ltptaps[5];
+ } sf[4];
+
+ SilkFrame * const frame = s->frame + channel;
+
+ int i;
+
+ /* obtain stereo weights */
+ if (coded_channels == 2 && channel == 0) {
+ int n, wi[2], ws[2], w[2];
+ n = opus_rc_getsymbol(rc, silk_model_stereo_s1);
+ wi[0] = opus_rc_getsymbol(rc, silk_model_stereo_s2) + 3 * (n / 5);
+ ws[0] = opus_rc_getsymbol(rc, silk_model_stereo_s3);
+ wi[1] = opus_rc_getsymbol(rc, silk_model_stereo_s2) + 3 * (n % 5);
+ ws[1] = opus_rc_getsymbol(rc, silk_model_stereo_s3);
+
+ for (i = 0; i < 2; i++)
+ w[i] = silk_stereo_weights[wi[i]] +
+ (((silk_stereo_weights[wi[i] + 1] - silk_stereo_weights[wi[i]]) * 6554) >> 16)
+ * (ws[i]*2 + 1);
+
+ s->stereo_weights[0] = (w[0] - w[1]) / 8192.0;
+ s->stereo_weights[1] = w[1] / 8192.0;
+
+ /* and read the mid-only flag */
+ s->midonly = active1 ? 0 : opus_rc_getsymbol(rc, silk_model_mid_only);
+ }
+
+ /* obtain frame type */
+ if (!active) {
+ qoffset_high = opus_rc_getsymbol(rc, silk_model_frame_type_inactive);
+ voiced = 0;
+ } else {
+ int type = opus_rc_getsymbol(rc, silk_model_frame_type_active);
+ qoffset_high = type & 1;
+ voiced = type >> 1;
+ }
+
+ /* obtain subframe quantization gains */
+ for (i = 0; i < s->subframes; i++) {
+ int log_gain; //Q7
+ int ipart, fpart, lingain;
+
+ if (i == 0 && (frame_num == 0 || !frame->coded)) {
+ /* gain is coded absolute */
+ int x = opus_rc_getsymbol(rc, silk_model_gain_highbits[active + voiced]);
+ log_gain = (x<<3) | opus_rc_getsymbol(rc, silk_model_gain_lowbits);
+
+ if (frame->coded)
+ log_gain = FFMAX(log_gain, frame->log_gain - 16);
+ } else {
+ /* gain is coded relative */
+ int delta_gain = opus_rc_getsymbol(rc, silk_model_gain_delta);
+ log_gain = av_clip(FFMAX((delta_gain<<1) - 16,
+ frame->log_gain + delta_gain - 4), 0, 63);
+ }
+
+ frame->log_gain = log_gain;
+
+ /* approximate 2**(x/128) with a Q7 (i.e. non-integer) input */
+ log_gain = (log_gain * 0x1D1C71 >> 16) + 2090;
+ ipart = log_gain >> 7;
+ fpart = log_gain & 127;
+ lingain = (1 << ipart) + ((-174 * fpart * (128-fpart) >>16) + fpart) * ((1<<ipart) >> 7);
+ sf[i].gain = lingain / 65536.0f;
+ }
+
+ /* obtain LPC filter coefficients */
+ silk_decode_lpc(s, frame, rc, lpc_leadin, lpc_body, &order, &has_lpc_leadin, voiced);
+
+ /* obtain pitch lags, if this is a voiced frame */
+ if (voiced) {
+ int lag_absolute = (!frame_num || !frame->prev_voiced);
+ int primarylag; // primary pitch lag for the entire SILK frame
+ int ltpfilter;
+ const int8_t * offsets;
+
+ if (!lag_absolute) {
+ int delta = opus_rc_getsymbol(rc, silk_model_pitch_delta);
+ if (delta)
+ primarylag = frame->primarylag + delta - 9;
+ else
+ lag_absolute = 1;
+ }
+
+ if (lag_absolute) {
+ /* primary lag is coded absolute */
+ int highbits, lowbits;
+ const uint16_t *model[] = {
+ silk_model_pitch_lowbits_nb, silk_model_pitch_lowbits_mb,
+ silk_model_pitch_lowbits_wb
+ };
+ highbits = opus_rc_getsymbol(rc, silk_model_pitch_highbits);
+ lowbits = opus_rc_getsymbol(rc, model[s->bandwidth]);
+
+ primarylag = silk_pitch_min_lag[s->bandwidth] +
+ highbits*silk_pitch_scale[s->bandwidth] + lowbits;
+ }
+ frame->primarylag = primarylag;
+
+ if (s->subframes == 2)
+ offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
+ ? silk_pitch_offset_nb10ms[opus_rc_getsymbol(rc,
+ silk_model_pitch_contour_nb10ms)]
+ : silk_pitch_offset_mbwb10ms[opus_rc_getsymbol(rc,
+ silk_model_pitch_contour_mbwb10ms)];
+ else
+ offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
+ ? silk_pitch_offset_nb20ms[opus_rc_getsymbol(rc,
+ silk_model_pitch_contour_nb20ms)]
+ : silk_pitch_offset_mbwb20ms[opus_rc_getsymbol(rc,
+ silk_model_pitch_contour_mbwb20ms)];
+
+ for (i = 0; i < s->subframes; i++)
+ sf[i].pitchlag = av_clip(primarylag + offsets[i],
+ silk_pitch_min_lag[s->bandwidth],
+ silk_pitch_max_lag[s->bandwidth]);
+
+ /* obtain LTP filter coefficients */
+ ltpfilter = opus_rc_getsymbol(rc, silk_model_ltp_filter);
+ for (i = 0; i < s->subframes; i++) {
+ int index, j;
+ const uint16_t *filter_sel[] = {
+ silk_model_ltp_filter0_sel, silk_model_ltp_filter1_sel,
+ silk_model_ltp_filter2_sel
+ };
+ const int8_t (*filter_taps[])[5] = {
+ silk_ltp_filter0_taps, silk_ltp_filter1_taps, silk_ltp_filter2_taps
+ };
+ index = opus_rc_getsymbol(rc, filter_sel[ltpfilter]);
+ for (j = 0; j < 5; j++)
+ sf[i].ltptaps[j] = filter_taps[ltpfilter][index][j] / 128.0f;
+ }
+ }
+
+ /* obtain LTP scale factor */
+ if (voiced && frame_num == 0)
+ ltpscale = silk_ltp_scale_factor[opus_rc_getsymbol(rc,
+ silk_model_ltp_scale_index)] / 16384.0f;
+ else ltpscale = 15565.0f/16384.0f;
+
+ /* generate the excitation signal for the entire frame */
+ silk_decode_excitation(s, rc, residual + SILK_MAX_LAG, qoffset_high,
+ active, voiced);
+
+ /* skip synthesising the side channel if we want mono-only */
+ if (s->output_channels == channel)
+ return;
+
+ /* generate the output signal */
+ for (i = 0; i < s->subframes; i++) {
+ const float * lpc_coeff = (i < 2 && has_lpc_leadin) ? lpc_leadin : lpc_body;
+ float *dst = frame->output + SILK_HISTORY + i * s->sflength;
+ float *resptr = residual + SILK_MAX_LAG + i * s->sflength;
+ float *lpc = frame->lpc_history + SILK_HISTORY + i * s->sflength;
+ float sum;
+ int j, k;
+
+ if (voiced) {
+ int out_end;
+ float scale;
+
+ if (i < 2 || s->nlsf_interp_factor == 4) {
+ out_end = -i * s->sflength;
+ scale = ltpscale;
+ } else {
+ out_end = -(i - 2) * s->sflength;
+ scale = 1.0f;
+ }
+
+ /* when the LPC coefficients change, a re-whitening filter is used */
+ /* to produce a residual that accounts for the change */
+ for (j = - sf[i].pitchlag - LTP_ORDER/2; j < out_end; j++) {
+ sum = dst[j];
+ for (k = 0; k < order; k++)
+ sum -= lpc_coeff[k] * dst[j - k - 1];
+ resptr[j] = av_clipf(sum, -1.0f, 1.0f) * scale / sf[i].gain;
+ }
+
+ if (out_end) {
+ float rescale = sf[i-1].gain / sf[i].gain;
+ for (j = out_end; j < 0; j++)
+ resptr[j] *= rescale;
+ }
+
+ /* LTP synthesis */
+ for (j = 0; j < s->sflength; j++) {
+ sum = resptr[j];
+ for (k = 0; k < LTP_ORDER; k++)
+ sum += sf[i].ltptaps[k] * resptr[j - sf[i].pitchlag + LTP_ORDER/2 - k];
+ resptr[j] = sum;
+ }
+ }
+
+ /* LPC synthesis */
+ for (j = 0; j < s->sflength; j++) {
+ sum = resptr[j] * sf[i].gain;
+ for (k = 1; k <= order; k++)
+ sum += lpc_coeff[k - 1] * lpc[j - k];
+
+ lpc[j] = sum;
+ dst[j] = av_clipf(sum, -1.0f, 1.0f);
+ }
+ }
+
+ frame->prev_voiced = voiced;
+ memmove(frame->lpc_history, frame->lpc_history + s->flength, SILK_HISTORY * sizeof(float));
+ memmove(frame->output, frame->output + s->flength, SILK_HISTORY * sizeof(float));
+
+ frame->coded = 1;
+}
+
+static void silk_unmix_ms(SilkContext *s, float *l, float *r)
+{
+ float *mid = s->frame[0].output + SILK_HISTORY - s->flength;
+ float *side = s->frame[1].output + SILK_HISTORY - s->flength;
+ float w0_prev = s->prev_stereo_weights[0];
+ float w1_prev = s->prev_stereo_weights[1];
+ float w0 = s->stereo_weights[0];
+ float w1 = s->stereo_weights[1];
+ int n1 = silk_stereo_interp_len[s->bandwidth];
+ int i;
+
+ for (i = 0; i < n1; i++) {
+ float interp0 = w0_prev + i * (w0 - w0_prev) / n1;
+ float interp1 = w1_prev + i * (w1 - w1_prev) / n1;
+ float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
+
+ l[i] = av_clipf((1 + interp1) * mid[i - 1] + side[i - 1] + interp0 * p0, -1.0, 1.0);
+ r[i] = av_clipf((1 - interp1) * mid[i - 1] - side[i - 1] - interp0 * p0, -1.0, 1.0);
+ }
+
+ for (; i < s->flength; i++) {
+ float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
+
+ l[i] = av_clipf((1 + w1) * mid[i - 1] + side[i - 1] + w0 * p0, -1.0, 1.0);
+ r[i] = av_clipf((1 - w1) * mid[i - 1] - side[i - 1] - w0 * p0, -1.0, 1.0);
+ }
+
+ memcpy(s->prev_stereo_weights, s->stereo_weights, sizeof(s->stereo_weights));
+}
+
+static void silk_flush_frame(SilkFrame *frame)
+{
+ if (!frame->coded)
+ return;
+
+ memset(frame->output, 0, sizeof(frame->output));
+ memset(frame->lpc_history, 0, sizeof(frame->lpc_history));
+
+ memset(frame->lpc, 0, sizeof(frame->lpc));
+ memset(frame->nlsf, 0, sizeof(frame->nlsf));
+
+ frame->log_gain = 0;
+
+ frame->primarylag = 0;
+ frame->prev_voiced = 0;
+ frame->coded = 0;
+}
+
+int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc,
+ float *output[2],
+ enum OpusBandwidth bandwidth,
+ int coded_channels,
+ int duration_ms)
+{
+ int active[2][6], redundancy[2];
+ int nb_frames, i, j;
+
+ if (bandwidth > OPUS_BANDWIDTH_WIDEBAND ||
+ coded_channels > 2 || duration_ms > 60) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid parameters passed "
+ "to the SILK decoder.\n");
+ return AVERROR(EINVAL);
+ }
+
+ nb_frames = 1 + (duration_ms > 20) + (duration_ms > 40);
+ s->subframes = duration_ms / nb_frames / 5; // 5ms subframes
+ s->sflength = 20 * (bandwidth + 2);
+ s->flength = s->sflength * s->subframes;
+ s->bandwidth = bandwidth;
+ s->wb = bandwidth == OPUS_BANDWIDTH_WIDEBAND;
+
+ /* make sure to flush the side channel when switching from mono to stereo */
+ if (coded_channels > s->prev_coded_channels)
+ silk_flush_frame(&s->frame[1]);
+ s->prev_coded_channels = coded_channels;
+
+ /* read the LP-layer header bits */
+ for (i = 0; i < coded_channels; i++) {
+ for (j = 0; j < nb_frames; j++)
+ active[i][j] = opus_rc_p2model(rc, 1);
+
+ redundancy[i] = opus_rc_p2model(rc, 1);
+ if (redundancy[i]) {
+ av_log(s->avctx, AV_LOG_ERROR, "LBRR frames present; this is unsupported\n");
+ return AVERROR_PATCHWELCOME;
+ }
+ }
+
+ for (i = 0; i < nb_frames; i++) {
+ for (j = 0; j < coded_channels && !s->midonly; j++)
+ silk_decode_frame(s, rc, i, j, coded_channels, active[j][i], active[1][i]);
+
+ /* reset the side channel if it is not coded */
+ if (s->midonly && s->frame[1].coded)
+ silk_flush_frame(&s->frame[1]);
+
+ if (coded_channels == 1 || s->output_channels == 1) {
+ for (j = 0; j < s->output_channels; j++) {
+ memcpy(output[j] + i * s->flength,
+ s->frame[0].output + SILK_HISTORY - s->flength - 2,
+ s->flength * sizeof(float));
+ }
+ } else {
+ silk_unmix_ms(s, output[0] + i * s->flength, output[1] + i * s->flength);
+ }
+
+ s->midonly = 0;
+ }
+
+ return nb_frames * s->flength;
+}
+
+void ff_silk_free(SilkContext **ps)
+{
+ av_freep(ps);
+}
+
+void ff_silk_flush(SilkContext *s)
+{
+ silk_flush_frame(&s->frame[0]);
+ silk_flush_frame(&s->frame[1]);
+
+ memset(s->prev_stereo_weights, 0, sizeof(s->prev_stereo_weights));
+}
+
+int ff_silk_init(AVCodecContext *avctx, SilkContext **ps, int output_channels)
+{
+ SilkContext *s;
+
+ if (output_channels != 1 && output_channels != 2) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid number of output channels: %d\n",
+ output_channels);
+ return AVERROR(EINVAL);
+ }
+
+ s = av_mallocz(sizeof(*s));
+ if (!s)
+ return AVERROR(ENOMEM);
+
+ s->avctx = avctx;
+ s->output_channels = output_channels;
+
+ ff_silk_flush(s);
+
+ *ps = s;
+
+ return 0;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/opusdec.c b/chromium/third_party/ffmpeg/libavcodec/opusdec.c
new file mode 100644
index 00000000000..1a994c46437
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/opusdec.c
@@ -0,0 +1,673 @@
+/*
+ * Opus decoder
+ * Copyright (c) 2012 Andrew D'Addesio
+ * Copyright (c) 2013-2014 Mozilla Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Opus decoder
+ * @author Andrew D'Addesio, Anton Khirnov
+ *
+ * Codec homepage: http://opus-codec.org/
+ * Specification: http://tools.ietf.org/html/rfc6716
+ * Ogg Opus specification: https://tools.ietf.org/html/draft-ietf-codec-oggopus-03
+ *
+ * Ogg-contained .opus files can be produced with opus-tools:
+ * http://git.xiph.org/?p=opus-tools.git
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/audio_fifo.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+
+#include "libswresample/swresample.h"
+
+#include "avcodec.h"
+#include "celp_filters.h"
+#include "fft.h"
+#include "get_bits.h"
+#include "internal.h"
+#include "mathops.h"
+#include "opus.h"
+
+static const uint16_t silk_frame_duration_ms[16] = {
+ 10, 20, 40, 60,
+ 10, 20, 40, 60,
+ 10, 20, 40, 60,
+ 10, 20,
+ 10, 20,
+};
+
+/* number of samples of silence to feed to the resampler
+ * at the beginning */
+static const int silk_resample_delay[] = {
+ 4, 8, 11, 11, 11
+};
+
+static const uint8_t celt_band_end[] = { 13, 17, 17, 19, 21 };
+
+static int get_silk_samplerate(int config)
+{
+ if (config < 4)
+ return 8000;
+ else if (config < 8)
+ return 12000;
+ return 16000;
+}
+
+/**
+ * Range decoder
+ */
+static int opus_rc_init(OpusRangeCoder *rc, const uint8_t *data, int size)
+{
+ int ret = init_get_bits8(&rc->gb, data, size);
+ if (ret < 0)
+ return ret;
+
+ rc->range = 128;
+ rc->value = 127 - get_bits(&rc->gb, 7);
+ rc->total_read_bits = 9;
+ opus_rc_normalize(rc);
+
+ return 0;
+}
+
+static void opus_raw_init(OpusRangeCoder *rc, const uint8_t *rightend,
+ unsigned int bytes)
+{
+ rc->rb.position = rightend;
+ rc->rb.bytes = bytes;
+ rc->rb.cachelen = 0;
+ rc->rb.cacheval = 0;
+}
+
+static void opus_fade(float *out,
+ const float *in1, const float *in2,
+ const float *window, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ out[i] = in2[i] * window[i] + in1[i] * (1.0 - window[i]);
+}
+
+static int opus_flush_resample(OpusStreamContext *s, int nb_samples)
+{
+ int celt_size = av_audio_fifo_size(s->celt_delay);
+ int ret, i;
+ ret = swr_convert(s->swr,
+ (uint8_t**)s->out, nb_samples,
+ NULL, 0);
+ if (ret < 0)
+ return ret;
+ else if (ret != nb_samples) {
+ av_log(s->avctx, AV_LOG_ERROR, "Wrong number of flushed samples: %d\n",
+ ret);
+ return AVERROR_BUG;
+ }
+
+ if (celt_size) {
+ if (celt_size != nb_samples) {
+ av_log(s->avctx, AV_LOG_ERROR, "Wrong number of CELT delay samples.\n");
+ return AVERROR_BUG;
+ }
+ av_audio_fifo_read(s->celt_delay, (void**)s->celt_output, nb_samples);
+ for (i = 0; i < s->output_channels; i++) {
+ s->fdsp->vector_fmac_scalar(s->out[i],
+ s->celt_output[i], 1.0,
+ nb_samples);
+ }
+ }
+
+ if (s->redundancy_idx) {
+ for (i = 0; i < s->output_channels; i++)
+ opus_fade(s->out[i], s->out[i],
+ s->redundancy_output[i] + 120 + s->redundancy_idx,
+ ff_celt_window2 + s->redundancy_idx, 120 - s->redundancy_idx);
+ s->redundancy_idx = 0;
+ }
+
+ s->out[0] += nb_samples;
+ s->out[1] += nb_samples;
+ s->out_size -= nb_samples * sizeof(float);
+
+ return 0;
+}
+
+static int opus_init_resample(OpusStreamContext *s)
+{
+ float delay[16] = { 0.0 };
+ uint8_t *delayptr[2] = { (uint8_t*)delay, (uint8_t*)delay };
+ int ret;
+
+ av_opt_set_int(s->swr, "in_sample_rate", s->silk_samplerate, 0);
+ ret = swr_init(s->swr);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error opening the resampler.\n");
+ return ret;
+ }
+
+ ret = swr_convert(s->swr,
+ NULL, 0,
+ delayptr, silk_resample_delay[s->packet.bandwidth]);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Error feeding initial silence to the resampler.\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int opus_decode_redundancy(OpusStreamContext *s, const uint8_t *data, int size)
+{
+ int ret;
+ enum OpusBandwidth bw = s->packet.bandwidth;
+
+ if (s->packet.mode == OPUS_MODE_SILK &&
+ bw == OPUS_BANDWIDTH_MEDIUMBAND)
+ bw = OPUS_BANDWIDTH_WIDEBAND;
+
+ ret = opus_rc_init(&s->redundancy_rc, data, size);
+ if (ret < 0)
+ goto fail;
+ opus_raw_init(&s->redundancy_rc, data + size, size);
+
+ ret = ff_celt_decode_frame(s->celt, &s->redundancy_rc,
+ s->redundancy_output,
+ s->packet.stereo + 1, 240,
+ 0, celt_band_end[s->packet.bandwidth]);
+ if (ret < 0)
+ goto fail;
+
+ return 0;
+fail:
+ av_log(s->avctx, AV_LOG_ERROR, "Error decoding the redundancy frame.\n");
+ return ret;
+}
+
+static int opus_decode_frame(OpusStreamContext *s, const uint8_t *data, int size)
+{
+ int samples = s->packet.frame_duration;
+ int redundancy = 0;
+ int redundancy_size, redundancy_pos;
+ int ret, i, consumed;
+ int delayed_samples = s->delayed_samples;
+
+ ret = opus_rc_init(&s->rc, data, size);
+ if (ret < 0)
+ return ret;
+
+ /* decode the silk frame */
+ if (s->packet.mode == OPUS_MODE_SILK || s->packet.mode == OPUS_MODE_HYBRID) {
+ if (!swr_is_initialized(s->swr)) {
+ ret = opus_init_resample(s);
+ if (ret < 0)
+ return ret;
+ }
+
+ samples = ff_silk_decode_superframe(s->silk, &s->rc, s->silk_output,
+ FFMIN(s->packet.bandwidth, OPUS_BANDWIDTH_WIDEBAND),
+ s->packet.stereo + 1,
+ silk_frame_duration_ms[s->packet.config]);
+ if (samples < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error decoding a SILK frame.\n");
+ return samples;
+ }
+ samples = swr_convert(s->swr,
+ (uint8_t**)s->out, s->packet.frame_duration,
+ (uint8_t**)s->silk_output, samples);
+ if (samples < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error resampling SILK data.\n");
+ return samples;
+ }
+ s->delayed_samples += s->packet.frame_duration - samples;
+ } else
+ ff_silk_flush(s->silk);
+
+ // decode redundancy information
+ consumed = opus_rc_tell(&s->rc);
+ if (s->packet.mode == OPUS_MODE_HYBRID && consumed + 37 <= size * 8)
+ redundancy = opus_rc_p2model(&s->rc, 12);
+ else if (s->packet.mode == OPUS_MODE_SILK && consumed + 17 <= size * 8)
+ redundancy = 1;
+
+ if (redundancy) {
+ redundancy_pos = opus_rc_p2model(&s->rc, 1);
+
+ if (s->packet.mode == OPUS_MODE_HYBRID)
+ redundancy_size = opus_rc_unimodel(&s->rc, 256) + 2;
+ else
+ redundancy_size = size - (consumed + 7) / 8;
+ size -= redundancy_size;
+ if (size < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid redundancy frame size.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (redundancy_pos) {
+ ret = opus_decode_redundancy(s, data + size, redundancy_size);
+ if (ret < 0)
+ return ret;
+ ff_celt_flush(s->celt);
+ }
+ }
+
+ /* decode the CELT frame */
+ if (s->packet.mode == OPUS_MODE_CELT || s->packet.mode == OPUS_MODE_HYBRID) {
+ float *out_tmp[2] = { s->out[0], s->out[1] };
+ float **dst = (s->packet.mode == OPUS_MODE_CELT) ?
+ out_tmp : s->celt_output;
+ int celt_output_samples = samples;
+ int delay_samples = av_audio_fifo_size(s->celt_delay);
+
+ if (delay_samples) {
+ if (s->packet.mode == OPUS_MODE_HYBRID) {
+ av_audio_fifo_read(s->celt_delay, (void**)s->celt_output, delay_samples);
+
+ for (i = 0; i < s->output_channels; i++) {
+ s->fdsp->vector_fmac_scalar(out_tmp[i], s->celt_output[i], 1.0,
+ delay_samples);
+ out_tmp[i] += delay_samples;
+ }
+ celt_output_samples -= delay_samples;
+ } else {
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Spurious CELT delay samples present.\n");
+ av_audio_fifo_drain(s->celt_delay, delay_samples);
+ if (s->avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR_BUG;
+ }
+ }
+
+ opus_raw_init(&s->rc, data + size, size);
+
+ ret = ff_celt_decode_frame(s->celt, &s->rc, dst,
+ s->packet.stereo + 1,
+ s->packet.frame_duration,
+ (s->packet.mode == OPUS_MODE_HYBRID) ? 17 : 0,
+ celt_band_end[s->packet.bandwidth]);
+ if (ret < 0)
+ return ret;
+
+ if (s->packet.mode == OPUS_MODE_HYBRID) {
+ int celt_delay = s->packet.frame_duration - celt_output_samples;
+ void *delaybuf[2] = { s->celt_output[0] + celt_output_samples,
+ s->celt_output[1] + celt_output_samples };
+
+ for (i = 0; i < s->output_channels; i++) {
+ s->fdsp->vector_fmac_scalar(out_tmp[i],
+ s->celt_output[i], 1.0,
+ celt_output_samples);
+ }
+
+ ret = av_audio_fifo_write(s->celt_delay, delaybuf, celt_delay);
+ if (ret < 0)
+ return ret;
+ }
+ } else
+ ff_celt_flush(s->celt);
+
+ if (s->redundancy_idx) {
+ for (i = 0; i < s->output_channels; i++)
+ opus_fade(s->out[i], s->out[i],
+ s->redundancy_output[i] + 120 + s->redundancy_idx,
+ ff_celt_window2 + s->redundancy_idx, 120 - s->redundancy_idx);
+ s->redundancy_idx = 0;
+ }
+ if (redundancy) {
+ if (!redundancy_pos) {
+ ff_celt_flush(s->celt);
+ ret = opus_decode_redundancy(s, data + size, redundancy_size);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < s->output_channels; i++) {
+ opus_fade(s->out[i] + samples - 120 + delayed_samples,
+ s->out[i] + samples - 120 + delayed_samples,
+ s->redundancy_output[i] + 120,
+ ff_celt_window2, 120 - delayed_samples);
+ if (delayed_samples)
+ s->redundancy_idx = 120 - delayed_samples;
+ }
+ } else {
+ for (i = 0; i < s->output_channels; i++) {
+ memcpy(s->out[i] + delayed_samples, s->redundancy_output[i], 120 * sizeof(float));
+ opus_fade(s->out[i] + 120 + delayed_samples,
+ s->redundancy_output[i] + 120,
+ s->out[i] + 120 + delayed_samples,
+ ff_celt_window2, 120);
+ }
+ }
+ }
+
+ return samples;
+}
+
+static int opus_decode_subpacket(OpusStreamContext *s,
+ const uint8_t *buf, int buf_size,
+ int nb_samples)
+{
+ int output_samples = 0;
+ int flush_needed = 0;
+ int i, j, ret;
+
+ /* check if we need to flush the resampler */
+ if (swr_is_initialized(s->swr)) {
+ if (buf) {
+ int64_t cur_samplerate;
+ av_opt_get_int(s->swr, "in_sample_rate", 0, &cur_samplerate);
+ flush_needed = (s->packet.mode == OPUS_MODE_CELT) || (cur_samplerate != s->silk_samplerate);
+ } else {
+ flush_needed = !!s->delayed_samples;
+ }
+ }
+
+ if (!buf && !flush_needed)
+ return 0;
+
+ /* use dummy output buffers if the channel is not mapped to anything */
+ if (!s->out[0] ||
+ (s->output_channels == 2 && !s->out[1])) {
+ av_fast_malloc(&s->out_dummy, &s->out_dummy_allocated_size, s->out_size);
+ if (!s->out_dummy)
+ return AVERROR(ENOMEM);
+ if (!s->out[0])
+ s->out[0] = s->out_dummy;
+ if (!s->out[1])
+ s->out[1] = s->out_dummy;
+ }
+
+ /* flush the resampler if necessary */
+ if (flush_needed) {
+ ret = opus_flush_resample(s, s->delayed_samples);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error flushing the resampler.\n");
+ return ret;
+ }
+ swr_close(s->swr);
+ output_samples += s->delayed_samples;
+ s->delayed_samples = 0;
+
+ if (!buf)
+ goto finish;
+ }
+
+ /* decode all the frames in the packet */
+ for (i = 0; i < s->packet.frame_count; i++) {
+ int size = s->packet.frame_size[i];
+ int samples = opus_decode_frame(s, buf + s->packet.frame_offset[i], size);
+
+ if (samples < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error decoding an Opus frame.\n");
+ if (s->avctx->err_recognition & AV_EF_EXPLODE)
+ return samples;
+
+ for (j = 0; j < s->output_channels; j++)
+ memset(s->out[j], 0, s->packet.frame_duration * sizeof(float));
+ samples = s->packet.frame_duration;
+ }
+ output_samples += samples;
+
+ for (j = 0; j < s->output_channels; j++)
+ s->out[j] += samples;
+ s->out_size -= samples * sizeof(float);
+ }
+
+finish:
+ s->out[0] = s->out[1] = NULL;
+ s->out_size = 0;
+
+ return output_samples;
+}
+
+static int opus_decode_packet(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
+{
+ OpusContext *c = avctx->priv_data;
+ AVFrame *frame = data;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ int coded_samples = 0;
+ int decoded_samples = 0;
+ int i, ret;
+
+ /* decode the header of the first sub-packet to find out the sample count */
+ if (buf) {
+ OpusPacket *pkt = &c->streams[0].packet;
+ ret = ff_opus_parse_packet(pkt, buf, buf_size, c->nb_streams > 1);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
+ return ret;
+ }
+ coded_samples += pkt->frame_count * pkt->frame_duration;
+ c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
+ }
+
+ frame->nb_samples = coded_samples + c->streams[0].delayed_samples;
+
+ /* no input or buffered data => nothing to do */
+ if (!frame->nb_samples) {
+ *got_frame_ptr = 0;
+ return 0;
+ }
+
+ /* setup the data buffers */
+ ret = ff_get_buffer(avctx, frame, 0);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+ frame->nb_samples = 0;
+
+ for (i = 0; i < avctx->channels; i++) {
+ ChannelMap *map = &c->channel_maps[i];
+ if (!map->copy)
+ c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
+ }
+
+ for (i = 0; i < c->nb_streams; i++)
+ c->streams[i].out_size = frame->linesize[0];
+
+ /* decode each sub-packet */
+ for (i = 0; i < c->nb_streams; i++) {
+ OpusStreamContext *s = &c->streams[i];
+
+ if (i && buf) {
+ ret = ff_opus_parse_packet(&s->packet, buf, buf_size, i != c->nb_streams - 1);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
+ return ret;
+ }
+ s->silk_samplerate = get_silk_samplerate(s->packet.config);
+ }
+
+ ret = opus_decode_subpacket(&c->streams[i], buf,
+ s->packet.data_size, coded_samples);
+ if (ret < 0)
+ return ret;
+ if (decoded_samples && ret != decoded_samples) {
+ av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples "
+ "in a multi-channel stream\n");
+ return AVERROR_INVALIDDATA;
+ }
+ decoded_samples = ret;
+ buf += s->packet.packet_size;
+ buf_size -= s->packet.packet_size;
+ }
+
+ for (i = 0; i < avctx->channels; i++) {
+ ChannelMap *map = &c->channel_maps[i];
+
+ /* handle copied channels */
+ if (map->copy) {
+ memcpy(frame->extended_data[i],
+ frame->extended_data[map->copy_idx],
+ frame->linesize[0]);
+ } else if (map->silence) {
+ memset(frame->extended_data[i], 0, frame->linesize[0]);
+ }
+
+ if (c->gain_i) {
+ c->fdsp.vector_fmul_scalar((float*)frame->extended_data[i],
+ (float*)frame->extended_data[i],
+ c->gain, FFALIGN(decoded_samples, 8));
+ }
+ }
+
+ frame->nb_samples = decoded_samples;
+ *got_frame_ptr = !!decoded_samples;
+
+ return avpkt->size;
+}
+
+static av_cold void opus_decode_flush(AVCodecContext *ctx)
+{
+ OpusContext *c = ctx->priv_data;
+ int i;
+
+ for (i = 0; i < c->nb_streams; i++) {
+ OpusStreamContext *s = &c->streams[i];
+
+ memset(&s->packet, 0, sizeof(s->packet));
+ s->delayed_samples = 0;
+
+ if (s->celt_delay)
+ av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay));
+ swr_close(s->swr);
+
+ ff_silk_flush(s->silk);
+ ff_celt_flush(s->celt);
+ }
+}
+
+static av_cold int opus_decode_close(AVCodecContext *avctx)
+{
+ OpusContext *c = avctx->priv_data;
+ int i;
+
+ for (i = 0; i < c->nb_streams; i++) {
+ OpusStreamContext *s = &c->streams[i];
+
+ ff_silk_free(&s->silk);
+ ff_celt_free(&s->celt);
+
+ av_freep(&s->out_dummy);
+ s->out_dummy_allocated_size = 0;
+
+ av_audio_fifo_free(s->celt_delay);
+ swr_free(&s->swr);
+ }
+
+ av_freep(&c->streams);
+ c->nb_streams = 0;
+
+ av_freep(&c->channel_maps);
+
+ return 0;
+}
+
+static av_cold int opus_decode_init(AVCodecContext *avctx)
+{
+ OpusContext *c = avctx->priv_data;
+ int ret, i, j;
+
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+ avctx->sample_rate = 48000;
+
+ avpriv_float_dsp_init(&c->fdsp, 0);
+
+ /* find out the channel configuration */
+ ret = ff_opus_parse_extradata(avctx, c);
+ if (ret < 0)
+ return ret;
+
+ /* allocate and init each independent decoder */
+ c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams));
+ if (!c->streams) {
+ c->nb_streams = 0;
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ for (i = 0; i < c->nb_streams; i++) {
+ OpusStreamContext *s = &c->streams[i];
+ uint64_t layout;
+
+ s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1;
+
+ s->avctx = avctx;
+
+ for (j = 0; j < s->output_channels; j++) {
+ s->silk_output[j] = s->silk_buf[j];
+ s->celt_output[j] = s->celt_buf[j];
+ s->redundancy_output[j] = s->redundancy_buf[j];
+ }
+
+ s->fdsp = &c->fdsp;
+
+ s->swr =swr_alloc();
+ if (!s->swr)
+ goto fail;
+
+ layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+ av_opt_set_int(s->swr, "in_sample_fmt", avctx->sample_fmt, 0);
+ av_opt_set_int(s->swr, "out_sample_fmt", avctx->sample_fmt, 0);
+ av_opt_set_int(s->swr, "in_channel_layout", layout, 0);
+ av_opt_set_int(s->swr, "out_channel_layout", layout, 0);
+ av_opt_set_int(s->swr, "out_sample_rate", avctx->sample_rate, 0);
+ av_opt_set_int(s->swr, "filter_size", 16, 0);
+
+ ret = ff_silk_init(avctx, &s->silk, s->output_channels);
+ if (ret < 0)
+ goto fail;
+
+ ret = ff_celt_init(avctx, &s->celt, s->output_channels);
+ if (ret < 0)
+ goto fail;
+
+ s->celt_delay = av_audio_fifo_alloc(avctx->sample_fmt,
+ s->output_channels, 1024);
+ if (!s->celt_delay) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ }
+
+ return 0;
+fail:
+ opus_decode_close(avctx);
+ return ret;
+}
+
+AVCodec ff_opus_decoder = {
+ .name = "opus",
+ .long_name = NULL_IF_CONFIG_SMALL("Opus"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_OPUS,
+ .priv_data_size = sizeof(OpusContext),
+ .init = opus_decode_init,
+ .close = opus_decode_close,
+ .decode = opus_decode_packet,
+ .flush = opus_decode_flush,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/paf.c b/chromium/third_party/ffmpeg/libavcodec/paf.c
index 76c90c9f49a..05164ee32cf 100644
--- a/chromium/third_party/ffmpeg/libavcodec/paf.c
+++ b/chromium/third_party/ffmpeg/libavcodec/paf.c
@@ -19,16 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+
#include "libavcodec/paf.h"
-#include "bytestream.h"
#include "avcodec.h"
+#include "bytestream.h"
#include "copy_block.h"
#include "internal.h"
+#include "mathops.h"
-
-static const uint8_t block_sequences[16][8] =
-{
+static const uint8_t block_sequences[16][8] = {
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 2, 0, 0, 0, 0, 0, 0, 0 },
{ 5, 7, 0, 0, 0, 0, 0, 0 },
@@ -44,22 +45,25 @@ static const uint8_t block_sequences[16][8] =
{ 2, 4, 5, 7, 0, 0, 0, 0 },
{ 2, 4, 5, 0, 0, 0, 0, 0 },
{ 2, 4, 6, 0, 0, 0, 0, 0 },
- { 2, 4, 5, 7, 5, 7, 0, 0 }
+ { 2, 4, 5, 7, 5, 7, 0, 0 },
};
typedef struct PAFVideoDecContext {
AVFrame *pic;
GetByteContext gb;
- int current_frame;
+ int width;
+ int height;
+
+ int current_frame;
uint8_t *frame[4];
- int frame_size;
- int video_size;
+ int frame_size;
+ int video_size;
uint8_t *opcodes;
} PAFVideoDecContext;
-static av_cold int paf_vid_close(AVCodecContext *avctx)
+static av_cold int paf_video_close(AVCodecContext *avctx)
{
PAFVideoDecContext *c = avctx->priv_data;
int i;
@@ -72,13 +76,18 @@ static av_cold int paf_vid_close(AVCodecContext *avctx)
return 0;
}
-static av_cold int paf_vid_init(AVCodecContext *avctx)
+static av_cold int paf_video_init(AVCodecContext *avctx)
{
PAFVideoDecContext *c = avctx->priv_data;
int i;
+ c->width = avctx->width;
+ c->height = avctx->height;
+
if (avctx->height & 3 || avctx->width & 3) {
- av_log(avctx, AV_LOG_ERROR, "width and height must be multiplies of 4\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "width %d and height %d must be multiplie of 4.\n",
+ avctx->width, avctx->height);
return AVERROR_INVALIDDATA;
}
@@ -88,12 +97,12 @@ static av_cold int paf_vid_init(AVCodecContext *avctx)
if (!c->pic)
return AVERROR(ENOMEM);
- c->frame_size = FFALIGN(avctx->height, 256) * avctx->width;
- c->video_size = avctx->height * avctx->width;
+ c->frame_size = avctx->width * FFALIGN(avctx->height, 256);
+ c->video_size = avctx->width * avctx->height;
for (i = 0; i < 4; i++) {
c->frame[i] = av_mallocz(c->frame_size);
if (!c->frame[i]) {
- paf_vid_close(avctx);
+ paf_video_close(avctx);
return AVERROR(ENOMEM);
}
}
@@ -101,58 +110,59 @@ static av_cold int paf_vid_init(AVCodecContext *avctx)
return 0;
}
-static int get_video_page_offset(AVCodecContext *avctx, uint8_t a, uint8_t b)
+static void read4x4block(PAFVideoDecContext *c, uint8_t *dst, int width)
{
- int x, y;
-
- x = b & 0x7F;
- y = ((a & 0x3F) << 1) | (b >> 7 & 1);
-
- return y * 2 * avctx->width + x * 2;
-}
-
-static void copy4h(AVCodecContext *avctx, uint8_t *dst)
-{
- PAFVideoDecContext *c = avctx->priv_data;
int i;
for (i = 0; i < 4; i++) {
bytestream2_get_buffer(&c->gb, dst, 4);
- dst += avctx->width;
+ dst += width;
}
}
-static void copy_color_mask(AVCodecContext *avctx, uint8_t mask, uint8_t *dst, uint8_t color)
+static void copy_color_mask(uint8_t *dst, int width, uint8_t mask, uint8_t color)
{
int i;
for (i = 0; i < 4; i++) {
- if ((mask >> 4) & (1 << (3 - i)))
+ if (mask & (1 << 7 - i))
dst[i] = color;
- if ((mask & 15) & (1 << (3 - i)))
- dst[avctx->width + i] = color;
+ if (mask & (1 << 3 - i))
+ dst[width + i] = color;
}
}
-static void copy_src_mask(AVCodecContext *avctx, uint8_t mask, uint8_t *dst, const uint8_t *src)
+static void copy_src_mask(uint8_t *dst, int width, uint8_t mask, const uint8_t *src)
{
int i;
for (i = 0; i < 4; i++) {
- if ((mask >> 4) & (1 << (3 - i)))
+ if (mask & (1 << 7 - i))
dst[i] = src[i];
- if ((mask & 15) & (1 << (3 - i)))
- dst[avctx->width + i] = src[avctx->width + i];
+ if (mask & (1 << 3 - i))
+ dst[width + i] = src[width + i];
}
}
-static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
+static void set_src_position(PAFVideoDecContext *c,
+ const uint8_t **p,
+ const uint8_t **pend)
+{
+ int val = bytestream2_get_be16(&c->gb);
+ int page = val >> 14;
+ int x = (val & 0x7F);
+ int y = ((val >> 7) & 0x7F);
+
+ *p = c->frame[page] + x * 2 + y * 2 * c->width;
+ *pend = c->frame[page] + c->frame_size;
+}
+
+static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
{
- PAFVideoDecContext *c = avctx->priv_data;
uint32_t opcode_size, offset;
- uint8_t *dst, *dend, mask = 0, color = 0, a, b, p;
+ uint8_t *dst, *dend, mask = 0, color = 0;
const uint8_t *src, *send, *opcodes;
- int i, j, x = 0;
+ int i, j, op = 0;
i = bytestream2_get_byte(&c->gb);
if (i) {
@@ -164,21 +174,22 @@ static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
bytestream2_skip(&c->gb, 4 - align);
}
do {
- a = bytestream2_get_byte(&c->gb);
- b = bytestream2_get_byte(&c->gb);
- p = (a & 0xC0) >> 6;
- dst = c->frame[p] + get_video_page_offset(avctx, a, b);
- dend = c->frame[p] + c->frame_size;
- offset = (b & 0x7F) * 2;
+ int page, val, x, y;
+ val = bytestream2_get_be16(&c->gb);
+ page = val >> 14;
+ x = (val & 0x7F) * 2;
+ y = ((val >> 7) & 0x7F) * 2;
+ dst = c->frame[page] + x + y * c->width;
+ dend = c->frame[page] + c->frame_size;
+ offset = (x & 0x7F) * 2;
j = bytestream2_get_le16(&c->gb) + offset;
-
do {
offset++;
- if (dst + 3 * avctx->width + 4 > dend)
+ if (dst + 3 * c->width + 4 > dend)
return AVERROR_INVALIDDATA;
- copy4h(avctx, dst);
+ read4x4block(c, dst, c->width);
if ((offset & 0x3F) == 0)
- dst += avctx->width * 3;
+ dst += c->width * 3;
dst += 4;
} while (offset < j);
} while (--i);
@@ -187,18 +198,14 @@ static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
dst = c->frame[c->current_frame];
dend = c->frame[c->current_frame] + c->frame_size;
do {
- a = bytestream2_get_byte(&c->gb);
- b = bytestream2_get_byte(&c->gb);
- p = (a & 0xC0) >> 6;
- src = c->frame[p] + get_video_page_offset(avctx, a, b);
- send = c->frame[p] + c->frame_size;
- if ((src + 3 * avctx->width + 4 > send) ||
- (dst + 3 * avctx->width + 4 > dend))
+ set_src_position(c, &src, &send);
+ if ((src + 3 * c->width + 4 > send) ||
+ (dst + 3 * c->width + 4 > dend))
return AVERROR_INVALIDDATA;
- copy_block4(dst, src, avctx->width, avctx->width, 4);
+ copy_block4(dst, src, c->width, c->width, 4);
i++;
if ((i & 0x3F) == 0)
- dst += avctx->width * 3;
+ dst += c->width * 3;
dst += 4;
} while (i < c->video_size / 16);
@@ -213,60 +220,53 @@ static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
dst = c->frame[c->current_frame];
- for (i = 0; i < avctx->height; i += 4, dst += avctx->width * 3) {
- for (j = 0; j < avctx->width; j += 4, dst += 4) {
+ for (i = 0; i < c->height; i += 4, dst += c->width * 3)
+ for (j = 0; j < c->width; j += 4, dst += 4) {
int opcode, k = 0;
-
- if (x > opcode_size)
+ if (op > opcode_size)
return AVERROR_INVALIDDATA;
if (j & 4) {
- opcode = opcodes[x] & 15;
- x++;
+ opcode = opcodes[op] & 15;
+ op++;
} else {
- opcode = opcodes[x] >> 4;
+ opcode = opcodes[op] >> 4;
}
while (block_sequences[opcode][k]) {
-
- offset = avctx->width * 2;
+ offset = c->width * 2;
code = block_sequences[opcode][k++];
switch (code) {
case 2:
offset = 0;
case 3:
- color = bytestream2_get_byte(&c->gb);
+ color = bytestream2_get_byte(&c->gb);
case 4:
- mask = bytestream2_get_byte(&c->gb);
- copy_color_mask(avctx, mask, dst + offset, color);
+ mask = bytestream2_get_byte(&c->gb);
+ copy_color_mask(dst + offset, c->width, mask, color);
break;
case 5:
offset = 0;
case 6:
- a = bytestream2_get_byte(&c->gb);
- b = bytestream2_get_byte(&c->gb);
- p = (a & 0xC0) >> 6;
- src = c->frame[p] + get_video_page_offset(avctx, a, b);
- send = c->frame[p] + c->frame_size;
+ set_src_position(c, &src, &send);
case 7:
- if (src + offset + avctx->width + 4 > send)
+ if (src + offset + c->width + 4 > send)
return AVERROR_INVALIDDATA;
mask = bytestream2_get_byte(&c->gb);
- copy_src_mask(avctx, mask, dst + offset, src + offset);
+ copy_src_mask(dst + offset, c->width, mask, src + offset);
break;
}
}
}
- }
return 0;
}
-static int paf_vid_decode(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *pkt)
+static int paf_video_decode(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *pkt)
{
PAFVideoDecContext *c = avctx->priv_data;
- uint8_t code, *dst, *src, *end;
+ uint8_t code, *dst, *end;
int i, frame, ret;
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
@@ -275,12 +275,12 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb);
- if (code & 0x20) {
+ if (code & 0x20) { // frame is keyframe
for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size);
memset(c->pic->data[1], 0, AVPALETTE_SIZE);
- c->current_frame = 0;
+ c->current_frame = 0;
c->pic->key_frame = 1;
c->pic->pict_type = AV_PICTURE_TYPE_I;
} else {
@@ -288,7 +288,7 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
c->pic->pict_type = AV_PICTURE_TYPE_P;
}
- if (code & 0x40) {
+ if (code & 0x40) { // palette update
uint32_t *out = (uint32_t *)c->pic->data[1];
int index, count;
@@ -297,7 +297,7 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
if (index + count > 256)
return AVERROR_INVALIDDATA;
- if (bytestream2_get_bytes_left(&c->gb) < 3*count)
+ if (bytestream2_get_bytes_left(&c->gb) < 3 * count)
return AVERROR_INVALIDDATA;
out += index;
@@ -310,24 +310,32 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
g = g << 2 | g >> 4;
b = bytestream2_get_byteu(&c->gb);
b = b << 2 | b >> 4;
- *out++ = 0xFFU << 24 | r << 16 | g << 8 | b;
+ *out++ = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
c->pic->palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
- if ((ret = decode_0(avctx, code, pkt->data)) < 0)
+ /* Block-based motion compensation using 4x4 blocks with either
+ * horizontal or vertical vectors; might incorporate VQ as well. */
+ if ((ret = decode_0(c, pkt->data, code)) < 0)
return ret;
break;
case 1:
+ /* Uncompressed data. This mode specifies that (width * height) bytes
+ * should be copied directly from the encoded buffer into the output. */
dst = c->frame[c->current_frame];
+ // possibly chunk length data
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
+ /* Copy reference frame: Consume the next byte in the stream as the
+ * reference frame (which should be 0, 1, 2, or 3, and should not be
+ * the same as the current frame number). */
frame = bytestream2_get_byte(&c->gb);
if (frame > 3)
return AVERROR_INVALIDDATA;
@@ -335,6 +343,7 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size);
break;
case 4:
+ /* Run length encoding.*/
dst = c->frame[c->current_frame];
end = dst + c->video_size;
@@ -364,24 +373,20 @@ static int paf_vid_decode(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
- dst = c->pic->data[0];
- src = c->frame[c->current_frame];
- for (i = 0; i < avctx->height; i++) {
- memcpy(dst, src, avctx->width);
- dst += c->pic->linesize[0];
- src += avctx->width;
- }
+ av_image_copy_plane(c->pic->data[0], c->pic->linesize[0],
+ c->frame[c->current_frame], c->width,
+ c->width, c->height);
c->current_frame = (c->current_frame + 1) & 3;
if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
- *got_frame = 1;
+ *got_frame = 1;
return pkt->size;
}
-static av_cold int paf_aud_init(AVCodecContext *avctx)
+static av_cold int paf_audio_init(AVCodecContext *avctx)
{
if (avctx->channels != 2) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
@@ -394,14 +399,14 @@ static av_cold int paf_aud_init(AVCodecContext *avctx)
return 0;
}
-static int paf_aud_decode(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *pkt)
+static int paf_audio_decode(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *pkt)
{
AVFrame *frame = data;
- uint8_t *buf = pkt->data;
int16_t *output_samples;
- const uint8_t *t;
- int frames, ret, i, j, k;
+ const uint8_t *src = pkt->data;
+ int frames, ret, i, j;
+ int16_t cb[256];
frames = pkt->size / PAF_SOUND_FRAME_SIZE;
if (frames < 1)
@@ -412,40 +417,42 @@ static int paf_aud_decode(AVCodecContext *avctx, void *data,
return ret;
output_samples = (int16_t *)frame->data[0];
- for (i = 0; i < frames; i++) {
- t = buf + 256 * sizeof(uint16_t);
- for (j = 0; j < PAF_SOUND_SAMPLES; j++) {
- for (k = 0; k < 2; k++) {
- *output_samples++ = AV_RL16(buf + *t * 2);
- t++;
- }
- }
- buf += PAF_SOUND_FRAME_SIZE;
+ // codebook of 256 16-bit samples and 8-bit indices to it
+ for (j = 0; j < frames; j++) {
+ for (i = 0; i < 256; i++)
+ cb[i] = sign_extend(AV_RL16(src + i * 2), 16);
+ src += 256 * 2;
+ // always 2 channels
+ for (i = 0; i < PAF_SOUND_SAMPLES * 2; i++)
+ *output_samples++ = cb[*src++];
}
-
- *got_frame_ptr = 1;
+ *got_frame = 1;
return pkt->size;
}
+#if CONFIG_PAF_VIDEO_DECODER
AVCodec ff_paf_video_decoder = {
.name = "paf_video",
.long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PAF_VIDEO,
.priv_data_size = sizeof(PAFVideoDecContext),
- .init = paf_vid_init,
- .close = paf_vid_close,
- .decode = paf_vid_decode,
+ .init = paf_video_init,
+ .close = paf_video_close,
+ .decode = paf_video_decode,
.capabilities = CODEC_CAP_DR1,
};
+#endif
+#if CONFIG_PAF_AUDIO_DECODER
AVCodec ff_paf_audio_decoder = {
- .name = "paf_audio",
- .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio"),
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_PAF_AUDIO,
- .init = paf_aud_init,
- .decode = paf_aud_decode,
- .capabilities = CODEC_CAP_DR1,
+ .name = "paf_audio",
+ .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_PAF_AUDIO,
+ .init = paf_audio_init,
+ .decode = paf_audio_decode,
+ .capabilities = CODEC_CAP_DR1,
};
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/parser.c b/chromium/third_party/ffmpeg/libavcodec/parser.c
index 083ce022b5d..3169e2501f9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/parser.c
@@ -23,15 +23,19 @@
#include <stdint.h>
#include <string.h>
-#include "parser.h"
#include "libavutil/atomic.h"
#include "libavutil/mem.h"
+#include "parser.h"
+
static AVCodecParser *av_first_parser = NULL;
-AVCodecParser* av_parser_next(AVCodecParser *p){
- if(p) return p->next;
- else return av_first_parser;
+AVCodecParser *av_parser_next(AVCodecParser *p)
+{
+ if (p)
+ return p->next;
+ else
+ return av_first_parser;
}
void av_register_codec_parser(AVCodecParser *parser)
@@ -47,10 +51,10 @@ AVCodecParserContext *av_parser_init(int codec_id)
AVCodecParser *parser;
int ret;
- if(codec_id == AV_CODEC_ID_NONE)
+ if (codec_id == AV_CODEC_ID_NONE)
return NULL;
- for(parser = av_first_parser; parser != NULL; parser = parser->next) {
+ for (parser = av_first_parser; parser != NULL; parser = parser->next) {
if (parser->codec_ids[0] == codec_id ||
parser->codec_ids[1] == codec_id ||
parser->codec_ids[2] == codec_id ||
@@ -59,7 +63,8 @@ AVCodecParserContext *av_parser_init(int codec_id)
goto found;
}
return NULL;
- found:
+
+found:
s = av_mallocz(sizeof(AVCodecParserContext));
if (!s)
goto err_out;
@@ -74,7 +79,7 @@ AVCodecParserContext *av_parser_init(int codec_id)
if (ret != 0)
goto err_out;
}
- s->key_frame = -1;
+ s->key_frame = -1;
s->convergence_duration = 0;
s->dts_sync_point = INT_MIN;
s->dts_ref_dts_delta = INT_MIN;
@@ -88,72 +93,72 @@ err_out:
return NULL;
}
-void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){
+void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove)
+{
int i;
- s->dts= s->pts= AV_NOPTS_VALUE;
- s->pos= -1;
- s->offset= 0;
- for(i = 0; i < AV_PARSER_PTS_NB; i++) {
- if ( s->cur_offset + off >= s->cur_frame_offset[i]
- && (s->frame_offset < s->cur_frame_offset[i] ||
- (!s->frame_offset && !s->next_frame_offset)) // first field/frame
+ s->dts =
+ s->pts = AV_NOPTS_VALUE;
+ s->pos = -1;
+ s->offset = 0;
+ for (i = 0; i < AV_PARSER_PTS_NB; i++) {
+ if (s->cur_offset + off >= s->cur_frame_offset[i] &&
+ (s->frame_offset < s->cur_frame_offset[i] ||
+ (!s->frame_offset && !s->next_frame_offset)) && // first field/frame
// check disabled since MPEG-TS does not send complete PES packets
- && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){
- s->dts= s->cur_frame_dts[i];
- s->pts= s->cur_frame_pts[i];
- s->pos= s->cur_frame_pos[i];
+ /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){
+
+ s->dts = s->cur_frame_dts[i];
+ s->pts = s->cur_frame_pts[i];
+ s->pos = s->cur_frame_pos[i];
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
- if(remove)
- s->cur_frame_offset[i]= INT64_MAX;
- if(s->cur_offset + off < s->cur_frame_end[i])
+ if (remove)
+ s->cur_frame_offset[i] = INT64_MAX;
+ if (s->cur_offset + off < s->cur_frame_end[i])
break;
}
}
}
-int av_parser_parse2(AVCodecParserContext *s,
- AVCodecContext *avctx,
+int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
- int64_t pts, int64_t dts,
- int64_t pos)
+ int64_t pts, int64_t dts, int64_t pos)
{
int index, i;
uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
- if(!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
+ if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
s->next_frame_offset =
s->cur_offset = pos;
- s->flags |= PARSER_FLAG_FETCHED_OFFSET;
+ s->flags |= PARSER_FLAG_FETCHED_OFFSET;
}
if (buf_size == 0) {
/* padding is always necessary even if EOF, so we add it here */
memset(dummy_buf, 0, sizeof(dummy_buf));
buf = dummy_buf;
- } else if (s->cur_offset + buf_size !=
- s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
+ } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
/* add a new packet descriptor */
- i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
- s->cur_frame_start_index = i;
- s->cur_frame_offset[i] = s->cur_offset;
- s->cur_frame_end[i] = s->cur_offset + buf_size;
- s->cur_frame_pts[i] = pts;
- s->cur_frame_dts[i] = dts;
- s->cur_frame_pos[i] = pos;
+ i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
+ s->cur_frame_start_index = i;
+ s->cur_frame_offset[i] = s->cur_offset;
+ s->cur_frame_end[i] = s->cur_offset + buf_size;
+ s->cur_frame_pts[i] = pts;
+ s->cur_frame_dts[i] = dts;
+ s->cur_frame_pos[i] = pos;
}
- if (s->fetch_timestamp){
- s->fetch_timestamp=0;
- s->last_pts = s->pts;
- s->last_dts = s->dts;
- s->last_pos = s->pos;
+ if (s->fetch_timestamp) {
+ s->fetch_timestamp = 0;
+ s->last_pts = s->pts;
+ s->last_dts = s->dts;
+ s->last_pos = s->pos;
ff_fetch_timestamp(s, 0, 0);
}
-
/* WARNING: the returned index can be negative */
- index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size);
+ index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
+ poutbuf_size, buf, buf_size);
/* update the file pointer */
if (*poutbuf_size) {
/* fill the data for the current frame */
@@ -161,7 +166,7 @@ int av_parser_parse2(AVCodecParserContext *s,
/* offset of the next frame */
s->next_frame_offset = s->cur_offset + index;
- s->fetch_timestamp=1;
+ s->fetch_timestamp = 1;
}
if (index < 0)
index = 0;
@@ -169,32 +174,32 @@ int av_parser_parse2(AVCodecParserContext *s,
return index;
}
-int av_parser_change(AVCodecParserContext *s,
- AVCodecContext *avctx,
+int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size, int keyframe){
-
- if(s && s->parser->split){
- if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){
- int i= s->parser->split(avctx, buf, buf_size);
- buf += i;
+ const uint8_t *buf, int buf_size, int keyframe)
+{
+ if (s && s->parser->split) {
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER ||
+ avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) {
+ int i = s->parser->split(avctx, buf, buf_size);
+ buf += i;
buf_size -= i;
}
}
/* cast to avoid warning about discarding qualifiers */
- *poutbuf= (uint8_t *) buf;
- *poutbuf_size= buf_size;
- if(avctx->extradata){
- if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
- /*||(s->pict_type != AV_PICTURE_TYPE_I && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/
- /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){
- int size= buf_size + avctx->extradata_size;
- *poutbuf_size= size;
- *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+ *poutbuf = (uint8_t *) buf;
+ *poutbuf_size = buf_size;
+ if (avctx->extradata) {
+ if (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) {
+ int size = buf_size + avctx->extradata_size;
+
+ *poutbuf_size = size;
+ *poutbuf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
- memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ memcpy(*poutbuf + avctx->extradata_size, buf,
+ buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
return 1;
}
}
@@ -204,7 +209,7 @@ int av_parser_change(AVCodecParserContext *s,
void av_parser_close(AVCodecParserContext *s)
{
- if(s){
+ if (s) {
if (s->parser->parser_close)
s->parser->parser_close(s);
av_free(s->priv_data);
@@ -212,33 +217,33 @@ void av_parser_close(AVCodecParserContext *s)
}
}
-/*****************************************************/
-
-int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
+int ff_combine_frame(ParseContext *pc, int next,
+ const uint8_t **buf, int *buf_size)
{
- if(pc->overread){
+ if (pc->overread) {
av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
pc->overread, pc->state, next, pc->index, pc->overread_index);
- av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
+ av_dlog(NULL, "%X %X %X %X\n",
+ (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
}
/* Copy overread bytes from last frame into buffer. */
- for(; pc->overread>0; pc->overread--){
- pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
- }
+ for (; pc->overread > 0; pc->overread--)
+ pc->buffer[pc->index++] = pc->buffer[pc->overread_index++];
/* flush remaining if EOF */
- if(!*buf_size && next == END_NOT_FOUND){
- next= 0;
- }
+ if (!*buf_size && next == END_NOT_FOUND)
+ next = 0;
- pc->last_index= pc->index;
+ pc->last_index = pc->index;
/* copy into buffer end return */
- if(next == END_NOT_FOUND){
- void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (next == END_NOT_FOUND) {
+ void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+ *buf_size + pc->index +
+ FF_INPUT_BUFFER_PADDING_SIZE);
- if(!new_buffer) {
+ if (!new_buffer) {
pc->index = 0;
return AVERROR(ENOMEM);
}
@@ -248,13 +253,15 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
return -1;
}
- *buf_size=
- pc->overread_index= pc->index + next;
+ *buf_size =
+ pc->overread_index = pc->index + next;
/* append to buffer */
- if(pc->index){
- void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
- if(!new_buffer) {
+ if (pc->index) {
+ void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+ next + pc->index +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!new_buffer) {
pc->overread_index =
pc->index = 0;
return AVERROR(ENOMEM);
@@ -264,20 +271,21 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
memcpy(&pc->buffer[pc->index], *buf,
next + FF_INPUT_BUFFER_PADDING_SIZE);
pc->index = 0;
- *buf= pc->buffer;
+ *buf = pc->buffer;
}
/* store overread bytes */
- for(;next < 0; next++){
- pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
- pc->state64 = (pc->state64<<8) | pc->buffer[pc->last_index + next];
+ for (; next < 0; next++) {
+ pc->state = pc->state << 8 | pc->buffer[pc->last_index + next];
+ pc->state64 = pc->state64 << 8 | pc->buffer[pc->last_index + next];
pc->overread++;
}
- if(pc->overread){
+ if (pc->overread) {
av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
pc->overread, pc->state, next, pc->index, pc->overread_index);
- av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
+ av_dlog(NULL, "%X %X %X %X\n",
+ (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
}
return 0;
@@ -290,18 +298,15 @@ void ff_parse_close(AVCodecParserContext *s)
av_freep(&pc->buffer);
}
-/*************************/
-
-int ff_mpeg4video_split(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
+int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
{
int i;
- uint32_t state= -1;
+ uint32_t state = -1;
- for(i=0; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state == 0x1B3 || state == 0x1B6)
- return i-3;
+ for (i = 0; i < buf_size; i++) {
+ state = state << 8 | buf[i];
+ if (state == 0x1B3 || state == 0x1B6)
+ return i - 3;
}
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/pcm-dvd.c b/chromium/third_party/ffmpeg/libavcodec/pcm-dvd.c
index 77da8bf7e7c..9b4c40ee224 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pcm-dvd.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pcm-dvd.c
@@ -70,6 +70,7 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header)
/* early exit if the header didn't change apart from the frame number */
if (s->last_header == header_int)
return 0;
+ s->last_header = -1;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_dlog(avctx, "pcm_dvd_parse_header: header = %02x%02x%02x\n",
diff --git a/chromium/third_party/ffmpeg/libavcodec/pgssubdec.c b/chromium/third_party/ffmpeg/libavcodec/pgssubdec.c
index f45f0bfc874..b2c779a3caa 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pgssubdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pgssubdec.c
@@ -25,9 +25,9 @@
*/
#include "avcodec.h"
-#include "dsputil.h"
#include "bytestream.h"
#include "internal.h"
+#include "mathops.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
@@ -232,7 +232,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
ctx->pictures[picture_id].w = width;
ctx->pictures[picture_id].h = height;
- av_fast_malloc(&ctx->pictures[picture_id].rle, &ctx->pictures[picture_id].rle_buffer_size, rle_bitmap_len);
+ av_fast_padded_malloc(&ctx->pictures[picture_id].rle, &ctx->pictures[picture_id].rle_buffer_size, rle_bitmap_len);
if (!ctx->pictures[picture_id].rle)
return -1;
@@ -260,7 +260,7 @@ static void parse_palette_segment(AVCodecContext *avctx,
PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int color_id;
int y, cb, cr, alpha;
int r, g, b, r_add, g_add, b_add;
diff --git a/chromium/third_party/ffmpeg/libavcodec/pixels.h b/chromium/third_party/ffmpeg/libavcodec/pixels.h
new file mode 100644
index 00000000000..98eacd4df61
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/pixels.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_PIXELS_H
+#define AVCODEC_PIXELS_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* pixel operations */
+#define CALL_2X_PIXELS_MACRO(STATIC, a, b, n) \
+STATIC void a(uint8_t *block, const uint8_t *pixels, \
+ ptrdiff_t line_size, int h) \
+{ \
+ b(block, pixels, line_size, h); \
+ b(block + n, pixels + n, line_size, h); \
+}
+
+#define CALL_2X_PIXELS(a, b, n) CALL_2X_PIXELS_MACRO(static, a, b, n)
+#define CALL_2X_PIXELS_EXPORT(a, b, n) CALL_2X_PIXELS_MACRO(, a, b, n)
+
+#endif /* AVCODEC_PIXELS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/png.c b/chromium/third_party/ffmpeg/libavcodec/png.c
index b398d910003..ef52b51bd43 100644
--- a/chromium/third_party/ffmpeg/libavcodec/png.c
+++ b/chromium/third_party/ffmpeg/libavcodec/png.c
@@ -66,7 +66,7 @@ int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
xmin = ff_png_pass_xmin[pass];
if (width <= xmin)
return 0;
- shift = ff_png_pass_xshift[pass];
+ shift = ff_png_pass_xshift[pass];
pass_width = (width - xmin + (1 << shift) - 1) >> shift;
return (pass_width * bits_per_pixel + 7) >> 3;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/png_parser.c b/chromium/third_party/ffmpeg/libavcodec/png_parser.c
index 6f153d91d6f..530d5a0bad9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/png_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/png_parser.c
@@ -27,12 +27,11 @@
#include "parser.h"
#include "png.h"
-typedef struct PNGParseContext
-{
+typedef struct PNGParseContext {
ParseContext pc;
- uint32_t index;
- uint32_t chunk_length;
- uint32_t remaining_size;
+ uint32_t chunk_pos; ///< position inside current chunk
+ uint32_t chunk_length; ///< length of the current chunk
+ uint32_t remaining_size; ///< remaining size of the current chunk
} PNGParseContext;
static int png_parse(AVCodecParserContext *s, AVCodecContext *avctx,
@@ -60,38 +59,37 @@ static int png_parse(AVCodecParserContext *s, AVCodecContext *avctx,
}
}
ppc->pc.state64 = state64;
- } else
- if (ppc->remaining_size) {
- i = FFMIN(ppc->remaining_size, buf_size);
- ppc->remaining_size -= i;
- if (ppc->remaining_size)
- goto flush;
- if (ppc->index == -1) {
- next = i;
- goto flush;
- }
+ } else if (ppc->remaining_size) {
+ i = FFMIN(ppc->remaining_size, buf_size);
+ ppc->remaining_size -= i;
+ if (ppc->remaining_size)
+ goto flush;
+ if (ppc->chunk_pos == -1) {
+ next = i;
+ goto flush;
}
+ }
- for (;ppc->pc.frame_start_found && i < buf_size; i++) {
- ppc->pc.state = (ppc->pc.state<<8) | buf[i];
- if (ppc->index == 3) {
+ for (; ppc->pc.frame_start_found && i < buf_size; i++) {
+ ppc->pc.state = (ppc->pc.state << 8) | buf[i];
+ if (ppc->chunk_pos == 3) {
ppc->chunk_length = ppc->pc.state;
if (ppc->chunk_length > 0x7fffffff) {
- ppc->index = ppc->pc.frame_start_found = 0;
+ ppc->chunk_pos = ppc->pc.frame_start_found = 0;
goto flush;
}
ppc->chunk_length += 4;
- } else if (ppc->index == 7) {
+ } else if (ppc->chunk_pos == 7) {
if (ppc->chunk_length >= buf_size - i)
- ppc->remaining_size = ppc->chunk_length - buf_size + i + 1;
+ ppc->remaining_size = ppc->chunk_length - buf_size + i + 1;
if (ppc->pc.state == MKBETAG('I', 'E', 'N', 'D')) {
if (ppc->remaining_size)
- ppc->index = -1;
+ ppc->chunk_pos = -1;
else
next = ppc->chunk_length + i + 1;
break;
} else {
- ppc->index = 0;
+ ppc->chunk_pos = 0;
if (ppc->remaining_size)
break;
else
@@ -99,13 +97,14 @@ static int png_parse(AVCodecParserContext *s, AVCodecContext *avctx,
continue;
}
}
- ppc->index++;
+ ppc->chunk_pos++;
}
+
flush:
if (ff_combine_frame(&ppc->pc, next, &buf, &buf_size) < 0)
return buf_size;
- ppc->index = ppc->pc.frame_start_found = 0;
+ ppc->chunk_pos = ppc->pc.frame_start_found = 0;
*poutbuf = buf;
*poutbuf_size = buf_size;
diff --git a/chromium/third_party/ffmpeg/libavcodec/pngdec.c b/chromium/third_party/ffmpeg/libavcodec/pngdec.c
index 3d21e502881..fd771fc9466 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pngdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pngdec.c
@@ -85,8 +85,8 @@ static const uint8_t png_pass_dsp_mask[NB_PASSES] = {
};
/* NOTE: we try to construct a good looking image at each pass. width
- is the original image width. We also do pixel format conversion at
- this stage */
+ * is the original image width. We also do pixel format conversion at
+ * this stage */
static void png_put_interlaced_row(uint8_t *dst, int width,
int bits_per_pixel, int pass,
int color_type, const uint8_t *src)
@@ -157,7 +157,8 @@ static void png_put_interlaced_row(uint8_t *dst, int width,
}
}
-void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
+void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top,
+ int w, int bpp)
{
int i;
for (i = 0; i < w; i++) {
@@ -184,29 +185,35 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
}
}
-#define UNROLL1(bpp, op) {\
- r = dst[0];\
- if(bpp >= 2) g = dst[1];\
- if(bpp >= 3) b = dst[2];\
- if(bpp >= 4) a = dst[3];\
- for(; i <= size - bpp; i+=bpp) {\
- dst[i+0] = r = op(r, src[i+0], last[i+0]);\
- if(bpp == 1) continue;\
- dst[i+1] = g = op(g, src[i+1], last[i+1]);\
- if(bpp == 2) continue;\
- dst[i+2] = b = op(b, src[i+2], last[i+2]);\
- if(bpp == 3) continue;\
- dst[i+3] = a = op(a, src[i+3], last[i+3]);\
- }\
+#define UNROLL1(bpp, op) { \
+ r = dst[0]; \
+ if (bpp >= 2) \
+ g = dst[1]; \
+ if (bpp >= 3) \
+ b = dst[2]; \
+ if (bpp >= 4) \
+ a = dst[3]; \
+ for (; i <= size - bpp; i += bpp) { \
+ dst[i + 0] = r = op(r, src[i + 0], last[i + 0]); \
+ if (bpp == 1) \
+ continue; \
+ dst[i + 1] = g = op(g, src[i + 1], last[i + 1]); \
+ if (bpp == 2) \
+ continue; \
+ dst[i + 2] = b = op(b, src[i + 2], last[i + 2]); \
+ if (bpp == 3) \
+ continue; \
+ dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \
+ } \
}
#define UNROLL_FILTER(op)\
- if(bpp == 1) UNROLL1(1, op)\
- else if(bpp == 2) UNROLL1(2, op)\
- else if(bpp == 3) UNROLL1(3, op)\
- else if(bpp == 4) UNROLL1(4, op)\
+ if (bpp == 1) UNROLL1(1, op)\
+ else if (bpp == 2) UNROLL1(2, op)\
+ else if (bpp == 3) UNROLL1(3, op)\
+ else if (bpp == 4) UNROLL1(4, op)\
for (; i < size; i++) {\
- dst[i] = op(dst[i-bpp], src[i], last[i]);\
+ dst[i] = op(dst[i - bpp], src[i], last[i]);\
}\
/* NOTE: 'dst' can be equal to 'last' */
@@ -220,18 +227,17 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
memcpy(dst, src, size);
break;
case PNG_FILTER_VALUE_SUB:
- for (i = 0; i < bpp; i++) {
+ for (i = 0; i < bpp; i++)
dst[i] = src[i];
- }
if (bpp == 4) {
- p = *(int*)dst;
+ p = *(int *)dst;
for (; i < size; i += bpp) {
- int s = *(int*)(src + i);
+ unsigned s = *(int *)(src + i);
p = ((s & 0x7f7f7f7f) + (p & 0x7f7f7f7f)) ^ ((s ^ p) & 0x80808080);
- *(int*)(dst + i) = p;
+ *(int *)(dst + i) = p;
}
} else {
-#define OP_SUB(x,s,l) x+s
+#define OP_SUB(x, s, l) x + s
UNROLL_FILTER(OP_SUB);
}
break;
@@ -240,19 +246,20 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
break;
case PNG_FILTER_VALUE_AVG:
for (i = 0; i < bpp; i++) {
- p = (last[i] >> 1);
+ p = (last[i] >> 1);
dst[i] = p + src[i];
}
-#define OP_AVG(x,s,l) (((x + l) >> 1) + s) & 0xff
+#define OP_AVG(x, s, l) (((x + l) >> 1) + s) & 0xff
UNROLL_FILTER(OP_AVG);
break;
case PNG_FILTER_VALUE_PAETH:
for (i = 0; i < bpp; i++) {
- p = last[i];
+ p = last[i];
dst[i] = p + src[i];
}
if (bpp > 2 && size > 4) {
- // would write off the end of the array if we let it process the last pixel with bpp=3
+ /* would write off the end of the array if we let it process
+ * the last pixel with bpp=3 */
int w = bpp == 4 ? size : size - 3;
dsp->add_paeth_prediction(dst + i, src + i, last + i, w - i, bpp);
i = w;
@@ -269,9 +276,9 @@ static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \
int i; \
for (i = 0; i < size; i += 3 + alpha) { \
- int g = dst [i+1]; \
- dst[i+0] += g; \
- dst[i+2] += g; \
+ int g = dst [i + 1]; \
+ dst[i + 0] += g; \
+ dst[i + 2] += g; \
} \
}
@@ -322,12 +329,12 @@ static void png_handle_row(PNGDecContext *s)
ptr = s->image_buf + s->image_linesize * s->y;
if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
/* if we already read one row, it is time to stop to
- wait for the next one */
+ * wait for the next one */
if (got_line)
break;
png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
s->last_row, s->pass_row_size, s->bpp);
- FFSWAP(uint8_t*, s->last_row, s->tmp_row);
+ FFSWAP(uint8_t *, s->last_row, s->tmp_row);
FFSWAP(unsigned int, s->last_row_size, s->tmp_row_size);
got_line = 1;
}
@@ -346,8 +353,8 @@ static void png_handle_row(PNGDecContext *s)
s->pass++;
s->y = 0;
s->pass_row_size = ff_png_pass_row_size(s->pass,
- s->bits_per_pixel,
- s->width);
+ s->bits_per_pixel,
+ s->width);
s->crow_size = s->pass_row_size + 1;
if (s->pass_row_size != 0)
break;
@@ -356,7 +363,7 @@ static void png_handle_row(PNGDecContext *s)
}
}
}
- the_end: ;
+the_end:;
}
}
@@ -382,7 +389,8 @@ static int png_decode_idat(PNGDecContext *s, int length)
s->zstream.next_out = s->crow_buf;
}
if (ret == Z_STREAM_END && s->zstream.avail_in > 0) {
- av_log(NULL, AV_LOG_WARNING, "%d undecompressed bytes left in buffer\n", s->zstream.avail_in);
+ av_log(NULL, AV_LOG_WARNING,
+ "%d undecompressed bytes left in buffer\n", s->zstream.avail_in);
return 0;
}
}
@@ -509,9 +517,9 @@ static int decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
- PNGDecContext * const s = avctx->priv_data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ PNGDecContext *const s = avctx->priv_data;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
AVFrame *p;
AVDictionary *metadata = NULL;
uint32_t tag, length;
@@ -546,6 +554,9 @@ static int decode_frame(AVCodecContext *avctx,
for (;;) {
if (bytestream2_get_bytes_left(&s->gb) <= 0) {
av_log(avctx, AV_LOG_ERROR, "No bytes left\n");
+ if ( s->state & PNG_ALLIMAGE
+ && avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL)
+ goto exit_loop;
goto fail;
}
@@ -581,7 +592,7 @@ static int decode_frame(AVCodecContext *avctx,
s->state |= PNG_IHDR;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "
- "compression_type=%d filter_type=%d interlace_type=%d\n",
+ "compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
break;
@@ -657,10 +668,10 @@ static int decode_frame(AVCodecContext *avctx,
if (!s->interlace_type) {
s->crow_size = s->row_size + 1;
} else {
- s->pass = 0;
+ s->pass = 0;
s->pass_row_size = ff_png_pass_row_size(s->pass,
- s->bits_per_pixel,
- s->width);
+ s->bits_per_pixel,
+ s->width);
s->crow_size = s->pass_row_size + 1;
}
av_dlog(avctx, "row_size=%d crow_size =%d\n",
@@ -696,42 +707,41 @@ static int decode_frame(AVCodecContext *avctx,
bytestream2_skip(&s->gb, 4); /* crc */
break;
case MKTAG('P', 'L', 'T', 'E'):
- {
- int n, i, r, g, b;
-
- if ((length % 3) != 0 || length > 256 * 3)
- goto skip_tag;
- /* read the palette */
- n = length / 3;
- for (i = 0; i < n; i++) {
- r = bytestream2_get_byte(&s->gb);
- g = bytestream2_get_byte(&s->gb);
- b = bytestream2_get_byte(&s->gb);
- s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | b;
- }
- for (; i < 256; i++) {
- s->palette[i] = (0xFFU << 24);
- }
- s->state |= PNG_PLTE;
- bytestream2_skip(&s->gb, 4); /* crc */
+ {
+ int n, i, r, g, b;
+
+ if ((length % 3) != 0 || length > 256 * 3)
+ goto skip_tag;
+ /* read the palette */
+ n = length / 3;
+ for (i = 0; i < n; i++) {
+ r = bytestream2_get_byte(&s->gb);
+ g = bytestream2_get_byte(&s->gb);
+ b = bytestream2_get_byte(&s->gb);
+ s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
- break;
+ for (; i < 256; i++)
+ s->palette[i] = (0xFFU << 24);
+ s->state |= PNG_PLTE;
+ bytestream2_skip(&s->gb, 4); /* crc */
+ }
+ break;
case MKTAG('t', 'R', 'N', 'S'):
- {
- int v, i;
-
- /* read the transparency. XXX: Only palette mode supported */
- if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
- length > 256 ||
- !(s->state & PNG_PLTE))
- goto skip_tag;
- for (i = 0; i < length; i++) {
- v = bytestream2_get_byte(&s->gb);
- s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
- }
- bytestream2_skip(&s->gb, 4); /* crc */
+ {
+ int v, i;
+
+ /* read the transparency. XXX: Only palette mode supported */
+ if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
+ length > 256 ||
+ !(s->state & PNG_PLTE))
+ goto skip_tag;
+ for (i = 0; i < length; i++) {
+ v = bytestream2_get_byte(&s->gb);
+ s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
}
- break;
+ bytestream2_skip(&s->gb, 4); /* crc */
+ }
+ break;
case MKTAG('t', 'E', 'X', 't'):
if (decode_text_chunk(s, length, 0, &metadata) < 0)
av_log(avctx, AV_LOG_WARNING, "Broken tEXt chunk\n");
@@ -752,12 +762,12 @@ static int decode_frame(AVCodecContext *avctx,
goto exit_loop;
default:
/* skip tag */
- skip_tag:
+skip_tag:
bytestream2_skip(&s->gb, length + 4);
break;
}
}
- exit_loop:
+exit_loop:
if (s->bits_per_pixel == 1 && s->color_type == PNG_COLOR_TYPE_PALETTE){
int i, j, k;
@@ -831,9 +841,9 @@ static int decode_frame(AVCodecContext *avctx,
}
}
- /* handle p-frames only if a predecessor frame is available */
- if (s->last_picture.f->data[0]) {
- if ( !(avpkt->flags & AV_PKT_FLAG_KEY) && avctx->codec_tag != AV_RL32("MPNG")
+ /* handle p-frames only if a predecessor frame is available */
+ if (s->last_picture.f->data[0]) {
+ if ( !(avpkt->flags & AV_PKT_FLAG_KEY) && avctx->codec_tag != AV_RL32("MPNG")
&& s->last_picture.f->width == p->width
&& s->last_picture.f->height== p->height
&& s->last_picture.f->format== p->format
@@ -844,9 +854,8 @@ static int decode_frame(AVCodecContext *avctx,
ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
for (j = 0; j < s->height; j++) {
- for (i = 0; i < s->width * s->bpp; i++) {
+ for (i = 0; i < s->width * s->bpp; i++)
pd[i] += pd_last[i];
- }
pd += s->image_linesize;
pd_last += s->image_linesize;
}
@@ -863,11 +872,11 @@ static int decode_frame(AVCodecContext *avctx,
*got_frame = 1;
ret = bytestream2_tell(&s->gb);
- the_end:
+the_end:
inflateEnd(&s->zstream);
s->crow_buf = NULL;
return ret;
- fail:
+fail:
av_dict_free(&metadata);
ff_thread_report_progress(&s->picture, INT_MAX, 0);
ret = AVERROR_INVALIDDATA;
diff --git a/chromium/third_party/ffmpeg/libavcodec/pngdsp.c b/chromium/third_party/ffmpeg/libavcodec/pngdsp.c
index 5ab1c351b25..d2753163dad 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pngdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pngdsp.c
@@ -25,13 +25,13 @@
#include "pngdsp.h"
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
-#define pb_7f (~0UL/255 * 0x7f)
-#define pb_80 (~0UL/255 * 0x80)
+#define pb_7f (~0UL / 255 * 0x7f)
+#define pb_80 (~0UL / 255 * 0x80)
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
{
long i;
- for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
+ for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
long a = *(long *)(src1 + i);
long b = *(long *)(src2 + i);
*(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
@@ -45,5 +45,6 @@ av_cold void ff_pngdsp_init(PNGDSPContext *dsp)
dsp->add_bytes_l2 = add_bytes_l2_c;
dsp->add_paeth_prediction = ff_add_png_paeth_prediction;
- if (ARCH_X86) ff_pngdsp_init_x86(dsp);
+ if (ARCH_X86)
+ ff_pngdsp_init_x86(dsp);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/pngenc.c b/chromium/third_party/ffmpeg/libavcodec/pngenc.c
index bf61be1609e..8d9eaa37dc2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pngenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pngenc.c
@@ -18,6 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include "avcodec.h"
#include "internal.h"
#include "bytestream.h"
@@ -57,11 +58,11 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
static const int masks[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
mask = masks[pass];
- switch(bits_per_pixel) {
+ switch (bits_per_pixel) {
case 1:
memset(dst, 0, row_size);
dst_x = 0;
- for(x = 0; x < width; x++) {
+ for (x = 0; x < width; x++) {
j = (x & 7);
if ((mask << j) & 0x80) {
b = (src[x >> 3] >> (7 - j)) & 1;
@@ -74,7 +75,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
bpp = bits_per_pixel >> 3;
d = dst;
s = src;
- for(x = 0; x < width; x++) {
+ for (x = 0; x < width; x++) {
j = x & 7;
if ((mask << j) & 0x80) {
memcpy(d, s, bpp);
@@ -86,17 +87,18 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
}
}
-static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
+static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top,
+ int w, int bpp)
{
int i;
- for(i = 0; i < w; i++) {
+ for (i = 0; i < w; i++) {
int a, b, c, p, pa, pb, pc;
a = src[i - bpp];
b = top[i];
c = top[i - bpp];
- p = b - c;
+ p = b - c;
pc = a - c;
pa = abs(p);
@@ -113,32 +115,47 @@ static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, i
}
}
+static void sub_left_prediction(DSPContext *dsp, uint8_t *dst, const uint8_t *src, int bpp, int size)
+{
+ const uint8_t *src1 = src + bpp;
+ const uint8_t *src2 = src;
+ int x, unaligned_w;
+
+ memcpy(dst, src, bpp);
+ dst += bpp;
+ size -= bpp;
+ unaligned_w = FFMIN(32 - bpp, size);
+ for (x = 0; x < unaligned_w; x++)
+ *dst++ = *src1++ - *src2++;
+ size -= unaligned_w;
+ dsp->diff_bytes(dst, src1, src2, size);
+}
+
static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type,
uint8_t *src, uint8_t *top, int size, int bpp)
{
int i;
- switch(filter_type) {
+ switch (filter_type) {
case PNG_FILTER_VALUE_NONE:
memcpy(dst, src, size);
break;
case PNG_FILTER_VALUE_SUB:
- dsp->diff_bytes(dst, src, src-bpp, size);
- memcpy(dst, src, bpp);
+ sub_left_prediction(dsp, dst, src, bpp, size);
break;
case PNG_FILTER_VALUE_UP:
dsp->diff_bytes(dst, src, top, size);
break;
case PNG_FILTER_VALUE_AVG:
- for(i = 0; i < bpp; i++)
+ for (i = 0; i < bpp; i++)
dst[i] = src[i] - (top[i] >> 1);
- for(; i < size; i++)
- dst[i] = src[i] - ((src[i-bpp] + top[i]) >> 1);
+ for (; i < size; i++)
+ dst[i] = src[i] - ((src[i - bpp] + top[i]) >> 1);
break;
case PNG_FILTER_VALUE_PAETH:
- for(i = 0; i < bpp; i++)
+ for (i = 0; i < bpp; i++)
dst[i] = src[i] - top[i];
- sub_png_paeth_prediction(dst+i, src+i, top+i, size-i, bpp);
+ sub_png_paeth_prediction(dst + i, src + i, top + i, size - i, bpp);
break;
}
}
@@ -148,26 +165,26 @@ static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t *dst,
{
int pred = s->filter_type;
av_assert0(bpp || !pred);
- if(!top && pred)
+ if (!top && pred)
pred = PNG_FILTER_VALUE_SUB;
- if(pred == PNG_FILTER_VALUE_MIXED) {
+ if (pred == PNG_FILTER_VALUE_MIXED) {
int i;
int cost, bcost = INT_MAX;
uint8_t *buf1 = dst, *buf2 = dst + size + 16;
- for(pred=0; pred<5; pred++) {
- png_filter_row(&s->dsp, buf1+1, pred, src, top, size, bpp);
+ for (pred = 0; pred < 5; pred++) {
+ png_filter_row(&s->dsp, buf1 + 1, pred, src, top, size, bpp);
buf1[0] = pred;
cost = 0;
- for(i=0; i<=size; i++)
- cost += abs((int8_t)buf1[i]);
- if(cost < bcost) {
+ for (i = 0; i <= size; i++)
+ cost += abs((int8_t) buf1[i]);
+ if (cost < bcost) {
bcost = cost;
- FFSWAP(uint8_t*, buf1, buf2);
+ FFSWAP(uint8_t *, buf1, buf2);
}
}
return buf2;
} else {
- png_filter_row(&s->dsp, dst+1, pred, src, top, size, bpp);
+ png_filter_row(&s->dsp, dst + 1, pred, src, top, size, bpp);
dst[0] = pred;
return dst;
}
@@ -198,16 +215,17 @@ static int png_write_row(PNGEncContext *s, const uint8_t *data, int size)
int ret;
s->zstream.avail_in = size;
- s->zstream.next_in = (uint8_t *)data;
+ s->zstream.next_in = (uint8_t *)data;
while (s->zstream.avail_in > 0) {
ret = deflate(&s->zstream, Z_NO_FLUSH);
if (ret != Z_OK)
return -1;
if (s->zstream.avail_out == 0) {
- if(s->bytestream_end - s->bytestream > IOBUF_SIZE + 100)
- png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);
+ if (s->bytestream_end - s->bytestream > IOBUF_SIZE + 100)
+ png_write_chunk(&s->bytestream,
+ MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);
s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
+ s->zstream.next_out = s->buf;
}
}
return 0;
@@ -216,19 +234,19 @@ static int png_write_row(PNGEncContext *s, const uint8_t *data, int size)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
- PNGEncContext *s = avctx->priv_data;
- const AVFrame * const p = pict;
+ PNGEncContext *s = avctx->priv_data;
+ const AVFrame *const p = pict;
int bit_depth, color_type, y, len, row_size, ret, is_progressive;
int bits_per_pixel, pass_row_size, enc_row_size;
int64_t max_packet_size;
int compression_level;
- uint8_t *ptr, *top;
- uint8_t *crow_base = NULL, *crow_buf, *crow;
+ uint8_t *ptr, *top, *crow_buf, *crow;
+ uint8_t *crow_base = NULL;
uint8_t *progressive_buf = NULL;
- uint8_t *top_buf = NULL;
+ uint8_t *top_buf = NULL;
is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
- switch(avctx->pix_fmt) {
+ switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGBA64BE:
bit_depth = 16;
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
@@ -238,19 +256,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
color_type = PNG_COLOR_TYPE_RGB;
break;
case AV_PIX_FMT_RGBA:
- bit_depth = 8;
+ bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break;
case AV_PIX_FMT_RGB24:
- bit_depth = 8;
+ bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB;
break;
case AV_PIX_FMT_GRAY16BE:
- bit_depth = 16;
+ bit_depth = 16;
color_type = PNG_COLOR_TYPE_GRAY;
break;
case AV_PIX_FMT_GRAY8:
- bit_depth = 8;
+ bit_depth = 8;
color_type = PNG_COLOR_TYPE_GRAY;
break;
case AV_PIX_FMT_GRAY8A:
@@ -258,25 +276,25 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
break;
case AV_PIX_FMT_MONOBLACK:
- bit_depth = 1;
+ bit_depth = 1;
color_type = PNG_COLOR_TYPE_GRAY;
break;
case AV_PIX_FMT_PAL8:
- bit_depth = 8;
+ bit_depth = 8;
color_type = PNG_COLOR_TYPE_PALETTE;
break;
default:
return -1;
}
bits_per_pixel = ff_png_get_nb_channels(color_type) * bit_depth;
- row_size = (avctx->width * bits_per_pixel + 7) >> 3;
+ row_size = (avctx->width * bits_per_pixel + 7) >> 3;
s->zstream.zalloc = ff_png_zalloc;
- s->zstream.zfree = ff_png_zfree;
+ s->zstream.zfree = ff_png_zfree;
s->zstream.opaque = NULL;
- compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT ?
- Z_DEFAULT_COMPRESSION :
- av_clip(avctx->compression_level, 0, 9);
+ compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT
+ ? Z_DEFAULT_COMPRESSION
+ : av_clip(avctx->compression_level, 0, 9);
ret = deflateInit2(&s->zstream, compression_level,
Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
if (ret != Z_OK)
@@ -298,7 +316,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED));
if (!crow_base)
goto fail;
- crow_buf = crow_base + 15; // pixel data should be aligned, but there's a control byte before it
+ // pixel data should be aligned, but there's a control byte before it
+ crow_buf = crow_base + 15;
if (is_progressive) {
progressive_buf = av_malloc(row_size + 1);
if (!progressive_buf)
@@ -316,8 +335,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
AV_WB32(s->buf, avctx->width);
AV_WB32(s->buf + 4, avctx->height);
- s->buf[8] = bit_depth;
- s->buf[9] = color_type;
+ s->buf[8] = bit_depth;
+ s->buf[9] = color_type;
s->buf[10] = 0; /* compression type */
s->buf[11] = 0; /* filter type */
s->buf[12] = is_progressive; /* interlace type */
@@ -342,61 +361,64 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint32_t *palette;
uint8_t *alpha_ptr;
- palette = (uint32_t *)p->data[1];
- ptr = s->buf;
+ palette = (uint32_t *)p->data[1];
+ ptr = s->buf;
alpha_ptr = s->buf + 256 * 3;
has_alpha = 0;
- for(i = 0; i < 256; i++) {
- v = palette[i];
+ for (i = 0; i < 256; i++) {
+ v = palette[i];
alpha = v >> 24;
if (alpha != 0xff)
has_alpha = 1;
*alpha_ptr++ = alpha;
bytestream_put_be24(&ptr, v);
}
- png_write_chunk(&s->bytestream, MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
+ png_write_chunk(&s->bytestream,
+ MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
if (has_alpha) {
- png_write_chunk(&s->bytestream, MKTAG('t', 'R', 'N', 'S'), s->buf + 256 * 3, 256);
+ png_write_chunk(&s->bytestream,
+ MKTAG('t', 'R', 'N', 'S'), s->buf + 256 * 3, 256);
}
}
/* now put each row */
s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
+ s->zstream.next_out = s->buf;
if (is_progressive) {
int pass;
- for(pass = 0; pass < NB_PASSES; pass++) {
+ for (pass = 0; pass < NB_PASSES; pass++) {
/* NOTE: a pass is completely omitted if no pixels would be
- output */
+ * output */
pass_row_size = ff_png_pass_row_size(pass, bits_per_pixel, avctx->width);
if (pass_row_size > 0) {
top = NULL;
- for(y = 0; y < avctx->height; y++) {
+ for (y = 0; y < avctx->height; y++)
if ((ff_png_pass_ymask[pass] << (y & 7)) & 0x80) {
ptr = p->data[0] + y * p->linesize[0];
- FFSWAP(uint8_t*, progressive_buf, top_buf);
+ FFSWAP(uint8_t *, progressive_buf, top_buf);
png_get_interlaced_row(progressive_buf, pass_row_size,
bits_per_pixel, pass,
ptr, avctx->width);
- crow = png_choose_filter(s, crow_buf, progressive_buf, top, pass_row_size, bits_per_pixel>>3);
+ crow = png_choose_filter(s, crow_buf, progressive_buf,
+ top, pass_row_size, bits_per_pixel >> 3);
png_write_row(s, crow, pass_row_size + 1);
top = progressive_buf;
}
- }
}
}
} else {
top = NULL;
- for(y = 0; y < avctx->height; y++) {
+ for (y = 0; y < avctx->height; y++) {
ptr = p->data[0] + y * p->linesize[0];
- crow = png_choose_filter(s, crow_buf, ptr, top, row_size, bits_per_pixel>>3);
+ crow = png_choose_filter(s, crow_buf, ptr, top,
+ row_size, bits_per_pixel >> 3);
png_write_row(s, crow, row_size + 1);
top = ptr;
}
}
/* compress last bytes */
- for(;;) {
+ for (;;) {
ret = deflate(&s->zstream, Z_FINISH);
if (ret == Z_OK || ret == Z_STREAM_END) {
len = IOBUF_SIZE - s->zstream.avail_out;
@@ -404,7 +426,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, len);
}
s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
+ s->zstream.next_out = s->buf;
if (ret == Z_STREAM_END)
break;
} else {
@@ -418,21 +440,22 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
*got_packet = 1;
ret = 0;
- the_end:
+the_end:
av_free(crow_base);
av_free(progressive_buf);
av_free(top_buf);
deflateEnd(&s->zstream);
return ret;
- fail:
+fail:
ret = -1;
goto the_end;
}
-static av_cold int png_enc_init(AVCodecContext *avctx){
+static av_cold int png_enc_init(AVCodecContext *avctx)
+{
PNGEncContext *s = avctx->priv_data;
- switch(avctx->pix_fmt) {
+ switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGBA:
avctx->bits_per_coded_sample = 32;
break;
@@ -458,8 +481,10 @@ static av_cold int png_enc_init(AVCodecContext *avctx){
ff_dsputil_init(&s->dsp, avctx);
- s->filter_type = av_clip(avctx->prediction_method, PNG_FILTER_VALUE_NONE, PNG_FILTER_VALUE_MIXED);
- if(avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
+ s->filter_type = av_clip(avctx->prediction_method,
+ PNG_FILTER_VALUE_NONE,
+ PNG_FILTER_VALUE_MIXED);
+ if (avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
s->filter_type = PNG_FILTER_VALUE_NONE;
if (s->dpi && s->dpm) {
@@ -503,7 +528,7 @@ AVCodec ff_png_encoder = {
.close = png_enc_close,
.encode2 = encode_frame,
.capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
- .pix_fmts = (const enum AVPixelFormat[]){
+ .pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
AV_PIX_FMT_RGB48BE, AV_PIX_FMT_RGBA64BE,
AV_PIX_FMT_PAL8,
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/Makefile b/chromium/third_party/ffmpeg/libavcodec/ppc/Makefile
index 71b23da10ea..80ed14bb190 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/Makefile
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/Makefile
@@ -1,7 +1,6 @@
-OBJS += ppc/dsputil_ppc.o \
- ppc/fmtconvert_altivec.o \
- ppc/videodsp_ppc.o \
+OBJS += ppc/fmtconvert_altivec.o \
+OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_ppc.o
OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o
OBJS-$(CONFIG_H264CHROMA) += ppc/h264chroma_init.o
OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o
@@ -9,12 +8,15 @@ OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o
OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o
OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o
OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o
+OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o
+OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o
+
OBJS-$(CONFIG_VC1_DECODER) += ppc/vc1dsp_altivec.o
OBJS-$(CONFIG_VORBIS_DECODER) += ppc/vorbisdsp_altivec.o
-OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o
+OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o
OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o
-ALTIVEC-OBJS += ppc/dsputil_altivec.o \
+ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \
ppc/gmc_altivec.o \
ppc/idct_altivec.o \
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.c
index f36e394fb22..cb6f1e13294 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -24,49 +24,50 @@
#if HAVE_ALTIVEC_H
#include <altivec.h>
#endif
+
#include "libavutil/attributes.h"
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
+#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
+#include "libavcodec/mpegvideo.h"
#include "dsputil_altivec.h"
-static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
+ int i, s = 0;
+ const vector unsigned char zero =
+ (const vector unsigned char) vec_splat_u8(0);
vector unsigned char perm1 = vec_lvsl(0, pix2);
vector unsigned char perm2 = vec_add(perm1, vec_splat_u8(1));
- vector unsigned char pix2l, pix2r;
- vector unsigned char pix1v, pix2v, pix2iv, avgv, t5;
- vector unsigned int sad;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
- s = 0;
- sad = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < h; i++) {
/* Read unaligned pixels into our vectors. The vectors are as follows:
- pix1v: pix1[0]-pix1[15]
- pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16] */
- pix1v = vec_ld( 0, pix1);
- pix2l = vec_ld( 0, pix2);
- pix2r = vec_ld(16, pix2);
- pix2v = vec_perm(pix2l, pix2r, perm1);
- pix2iv = vec_perm(pix2l, pix2r, perm2);
-
- /* Calculate the average vector */
- avgv = vec_avg(pix2v, pix2iv);
-
- /* Calculate a sum of abs differences vector */
- t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
-
- /* Add each 4 pixel group together and put 4 results into sad */
+ * pix1v: pix1[0] - pix1[15]
+ * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16] */
+ vector unsigned char pix1v = vec_ld(0, pix1);
+ vector unsigned char pix2l = vec_ld(0, pix2);
+ vector unsigned char pix2r = vec_ld(16, pix2);
+ vector unsigned char pix2v = vec_perm(pix2l, pix2r, perm1);
+ vector unsigned char pix2iv = vec_perm(pix2l, pix2r, perm2);
+
+ /* Calculate the average vector. */
+ vector unsigned char avgv = vec_avg(pix2v, pix2iv);
+
+ /* Calculate a sum of abs differences vector. */
+ vector unsigned char t5 = vec_sub(vec_max(pix1v, avgv),
+ vec_min(pix1v, avgv));
+
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix2 += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
@@ -74,152 +75,148 @@ static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size
return s;
}
-static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
+ int i, s = 0;
+ const vector unsigned char zero =
+ (const vector unsigned char) vec_splat_u8(0);
vector unsigned char perm = vec_lvsl(0, pix2);
- vector unsigned char pix2l, pix2r;
- vector unsigned char pix1v, pix2v, pix3v, avgv, t5;
- vector unsigned int sad;
+ vector unsigned char pix1v, pix3v, avgv, t5;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
uint8_t *pix3 = pix2 + line_size;
- s = 0;
- sad = (vector unsigned int)vec_splat_u32(0);
-
/* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
- iteration becomes pix2 in the next iteration. We can use this
- fact to avoid a potentially expensive unaligned read, each
- time around the loop.
- Read unaligned pixels into our vectors. The vectors are as follows:
- pix2v: pix2[0]-pix2[15]
- Split the pixel vectors into shorts */
- pix2l = vec_ld( 0, pix2);
- pix2r = vec_ld(15, pix2);
- pix2v = vec_perm(pix2l, pix2r, perm);
+ * iteration becomes pix2 in the next iteration. We can use this
+ * fact to avoid a potentially expensive unaligned read, each
+ * time around the loop.
+ * Read unaligned pixels into our vectors. The vectors are as follows:
+ * pix2v: pix2[0] - pix2[15]
+ * Split the pixel vectors into shorts. */
+ vector unsigned char pix2l = vec_ld(0, pix2);
+ vector unsigned char pix2r = vec_ld(15, pix2);
+ vector unsigned char pix2v = vec_perm(pix2l, pix2r, perm);
for (i = 0; i < h; i++) {
/* Read unaligned pixels into our vectors. The vectors are as follows:
- pix1v: pix1[0]-pix1[15]
- pix3v: pix3[0]-pix3[15] */
- pix1v = vec_ld(0, pix1);
+ * pix1v: pix1[0] - pix1[15]
+ * pix3v: pix3[0] - pix3[15] */
+ pix1v = vec_ld(0, pix1);
- pix2l = vec_ld( 0, pix3);
+ pix2l = vec_ld(0, pix3);
pix2r = vec_ld(15, pix3);
pix3v = vec_perm(pix2l, pix2r, perm);
- /* Calculate the average vector */
+ /* Calculate the average vector. */
avgv = vec_avg(pix2v, pix3v);
- /* Calculate a sum of abs differences vector */
+ /* Calculate a sum of abs differences vector. */
t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
- /* Add each 4 pixel group together and put 4 results into sad */
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix2v = pix3v;
pix3 += line_size;
-
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
return s;
}
-static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sad16_xy2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
+ int i, s = 0;
uint8_t *pix3 = pix2 + line_size;
- const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
- const vector unsigned short two = (const vector unsigned short)vec_splat_u16(2);
+ const vector unsigned char zero =
+ (const vector unsigned char) vec_splat_u8(0);
+ const vector unsigned short two =
+ (const vector unsigned short) vec_splat_u16(2);
vector unsigned char avgv, t5;
vector unsigned char perm1 = vec_lvsl(0, pix2);
vector unsigned char perm2 = vec_add(perm1, vec_splat_u8(1));
- vector unsigned char pix2l, pix2r;
- vector unsigned char pix1v, pix2v, pix3v, pix2iv, pix3iv;
- vector unsigned short pix2lv, pix2hv, pix2ilv, pix2ihv;
+ vector unsigned char pix1v, pix3v, pix3iv;
vector unsigned short pix3lv, pix3hv, pix3ilv, pix3ihv;
vector unsigned short avghv, avglv;
- vector unsigned short t1, t2, t3, t4;
- vector unsigned int sad;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
- sad = (vector unsigned int)vec_splat_u32(0);
-
- s = 0;
-
/* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
- iteration becomes pix2 in the next iteration. We can use this
- fact to avoid a potentially expensive unaligned read, as well
- as some splitting, and vector addition each time around the loop.
- Read unaligned pixels into our vectors. The vectors are as follows:
- pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16]
- Split the pixel vectors into shorts */
- pix2l = vec_ld( 0, pix2);
- pix2r = vec_ld(16, pix2);
- pix2v = vec_perm(pix2l, pix2r, perm1);
- pix2iv = vec_perm(pix2l, pix2r, perm2);
-
- pix2hv = (vector unsigned short) vec_mergeh(zero, pix2v);
- pix2lv = (vector unsigned short) vec_mergel(zero, pix2v);
- pix2ihv = (vector unsigned short) vec_mergeh(zero, pix2iv);
- pix2ilv = (vector unsigned short) vec_mergel(zero, pix2iv);
- t1 = vec_add(pix2hv, pix2ihv);
- t2 = vec_add(pix2lv, pix2ilv);
+ * iteration becomes pix2 in the next iteration. We can use this
+ * fact to avoid a potentially expensive unaligned read, as well
+ * as some splitting, and vector addition each time around the loop.
+ * Read unaligned pixels into our vectors. The vectors are as follows:
+ * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16]
+ * Split the pixel vectors into shorts. */
+ vector unsigned char pix2l = vec_ld(0, pix2);
+ vector unsigned char pix2r = vec_ld(16, pix2);
+ vector unsigned char pix2v = vec_perm(pix2l, pix2r, perm1);
+ vector unsigned char pix2iv = vec_perm(pix2l, pix2r, perm2);
+
+ vector unsigned short pix2hv =
+ (vector unsigned short) vec_mergeh(zero, pix2v);
+ vector unsigned short pix2lv =
+ (vector unsigned short) vec_mergel(zero, pix2v);
+ vector unsigned short pix2ihv =
+ (vector unsigned short) vec_mergeh(zero, pix2iv);
+ vector unsigned short pix2ilv =
+ (vector unsigned short) vec_mergel(zero, pix2iv);
+ vector unsigned short t1 = vec_add(pix2hv, pix2ihv);
+ vector unsigned short t2 = vec_add(pix2lv, pix2ilv);
+ vector unsigned short t3, t4;
for (i = 0; i < h; i++) {
/* Read unaligned pixels into our vectors. The vectors are as follows:
- pix1v: pix1[0]-pix1[15]
- pix3v: pix3[0]-pix3[15] pix3iv: pix3[1]-pix3[16] */
- pix1v = vec_ld(0, pix1);
+ * pix1v: pix1[0] - pix1[15]
+ * pix3v: pix3[0] - pix3[15] pix3iv: pix3[1] - pix3[16] */
+ pix1v = vec_ld(0, pix1);
- pix2l = vec_ld( 0, pix3);
+ pix2l = vec_ld(0, pix3);
pix2r = vec_ld(16, pix3);
pix3v = vec_perm(pix2l, pix2r, perm1);
pix3iv = vec_perm(pix2l, pix2r, perm2);
/* Note that AltiVec does have vec_avg, but this works on vector pairs
- and rounds up. We could do avg(avg(a,b),avg(c,d)), but the rounding
- would mean that, for example, avg(3,0,0,1) = 2, when it should be 1.
- Instead, we have to split the pixel vectors into vectors of shorts,
- and do the averaging by hand. */
+ * and rounds up. We could do avg(avg(a, b), avg(c, d)), but the
+ * rounding would mean that, for example, avg(3, 0, 0, 1) = 2, when
+ * it should be 1. Instead, we have to split the pixel vectors into
+ * vectors of shorts and do the averaging by hand. */
- /* Split the pixel vectors into shorts */
+ /* Split the pixel vectors into shorts. */
pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v);
pix3lv = (vector unsigned short) vec_mergel(zero, pix3v);
pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv);
pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv);
- /* Do the averaging on them */
+ /* Do the averaging on them. */
t3 = vec_add(pix3hv, pix3ihv);
t4 = vec_add(pix3lv, pix3ilv);
avghv = vec_sr(vec_add(vec_add(t1, t3), two), two);
avglv = vec_sr(vec_add(vec_add(t2, t4), two), two);
- /* Pack the shorts back into a result */
+ /* Pack the shorts back into a result. */
avgv = vec_pack(avghv, avglv);
- /* Calculate a sum of abs differences vector */
+ /* Calculate a sum of abs differences vector. */
t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
- /* Add each 4 pixel group together and put 4 results into sad */
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix3 += line_size;
- /* Transfer the calculated values for pix3 into pix2 */
+ /* Transfer the calculated values for pix3 into pix2. */
t1 = t3;
t2 = t4;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
@@ -227,39 +224,36 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz
return s;
}
-static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sad16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
+ int i, s;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
vector unsigned char perm = vec_lvsl(0, pix2);
- vector unsigned char t1, t2, t3,t4, t5;
- vector unsigned int sad;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
- sad = (vector unsigned int)vec_splat_u32(0);
-
-
for (i = 0; i < h; i++) {
- /* Read potentially unaligned pixels into t1 and t2 */
- vector unsigned char pix2l = vec_ld( 0, pix2);
+ /* Read potentially unaligned pixels into t1 and t2. */
+ vector unsigned char pix2l = vec_ld(0, pix2);
vector unsigned char pix2r = vec_ld(15, pix2);
- t1 = vec_ld(0, pix1);
- t2 = vec_perm(pix2l, pix2r, perm);
+ vector unsigned char t1 = vec_ld(0, pix1);
+ vector unsigned char t2 = vec_perm(pix2l, pix2r, perm);
- /* Calculate a sum of abs differences vector */
- t3 = vec_max(t1, t2);
- t4 = vec_min(t1, t2);
- t5 = vec_sub(t3, t4);
+ /* Calculate a sum of abs differences vector. */
+ vector unsigned char t3 = vec_max(t1, t2);
+ vector unsigned char t4 = vec_min(t1, t2);
+ vector unsigned char t5 = vec_sub(t3, t4);
- /* Add each 4 pixel group together and put 4 results into sad */
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix2 += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
@@ -267,44 +261,46 @@ static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
return s;
}
-static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
- const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
+ int i, s;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
+ const vector unsigned char permclear =
+ (vector unsigned char)
+ { 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0 };
vector unsigned char perm1 = vec_lvsl(0, pix1);
vector unsigned char perm2 = vec_lvsl(0, pix2);
- vector unsigned char t1, t2, t3,t4, t5;
- vector unsigned int sad;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
- sad = (vector unsigned int)vec_splat_u32(0);
-
for (i = 0; i < h; i++) {
- /* Read potentially unaligned pixels into t1 and t2
- Since we're reading 16 pixels, and actually only want 8,
- mask out the last 8 pixels. The 0s don't change the sum. */
- vector unsigned char pix1l = vec_ld( 0, pix1);
- vector unsigned char pix1r = vec_ld(15, pix1);
- vector unsigned char pix2l = vec_ld( 0, pix2);
- vector unsigned char pix2r = vec_ld(15, pix2);
- t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
- t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
-
- /* Calculate a sum of abs differences vector */
- t3 = vec_max(t1, t2);
- t4 = vec_min(t1, t2);
- t5 = vec_sub(t3, t4);
-
- /* Add each 4 pixel group together and put 4 results into sad */
+ /* Read potentially unaligned pixels into t1 and t2.
+ * Since we're reading 16 pixels, and actually only want 8,
+ * mask out the last 8 pixels. The 0s don't change the sum. */
+ vector unsigned char pix1l = vec_ld(0, pix1);
+ vector unsigned char pix1r = vec_ld(7, pix1);
+ vector unsigned char pix2l = vec_ld(0, pix2);
+ vector unsigned char pix2r = vec_ld(7, pix2);
+ vector unsigned char t1 = vec_and(vec_perm(pix1l, pix1r, perm1),
+ permclear);
+ vector unsigned char t2 = vec_and(vec_perm(pix2l, pix2r, perm2),
+ permclear);
+
+ /* Calculate a sum of abs differences vector. */
+ vector unsigned char t3 = vec_max(t1, t2);
+ vector unsigned char t4 = vec_min(t1, t2);
+ vector unsigned char t5 = vec_sub(t3, t4);
+
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix2 += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
@@ -314,29 +310,25 @@ static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in
static int pix_norm1_altivec(uint8_t *pix, int line_size)
{
- int i;
- int s;
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
+ int i, s = 0;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
vector unsigned char perm = vec_lvsl(0, pix);
- vector unsigned char pixv;
- vector unsigned int sv;
+ vector unsigned int sv = (vector unsigned int) vec_splat_u32(0);
vector signed int sum;
- sv = (vector unsigned int)vec_splat_u32(0);
-
- s = 0;
for (i = 0; i < 16; i++) {
- /* Read in the potentially unaligned pixels */
- vector unsigned char pixl = vec_ld( 0, pix);
+ /* Read the potentially unaligned pixels. */
+ vector unsigned char pixl = vec_ld(0, pix);
vector unsigned char pixr = vec_ld(15, pix);
- pixv = vec_perm(pixl, pixr, perm);
+ vector unsigned char pixv = vec_perm(pixl, pixr, perm);
- /* Square the values, and add them to our sum */
+ /* Square the values, and add them to our sum. */
sv = vec_msum(pixv, pixv, sv);
pix += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sum = vec_sums((vector signed int) sv, (vector signed int) zero);
sum = vec_splat(sum, 3);
vec_ste(sum, 0, &s);
@@ -344,52 +336,51 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size)
return s;
}
-/**
- * Sum of Squared Errors for a 8x8 block.
- * AltiVec-enhanced.
- * It's the sad8_altivec code above w/ squaring added.
- */
-static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+/* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced.
+ * It's the sad8_altivec code above w/ squaring added. */
+static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
- const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
+ int i, s;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
+ const vector unsigned char permclear =
+ (vector unsigned char)
+ { 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0 };
vector unsigned char perm1 = vec_lvsl(0, pix1);
vector unsigned char perm2 = vec_lvsl(0, pix2);
- vector unsigned char t1, t2, t3,t4, t5;
- vector unsigned int sum;
+ vector unsigned int sum = (vector unsigned int) vec_splat_u32(0);
vector signed int sumsqr;
- sum = (vector unsigned int)vec_splat_u32(0);
-
for (i = 0; i < h; i++) {
- /* Read potentially unaligned pixels into t1 and t2
- Since we're reading 16 pixels, and actually only want 8,
- mask out the last 8 pixels. The 0s don't change the sum. */
- vector unsigned char pix1l = vec_ld( 0, pix1);
- vector unsigned char pix1r = vec_ld(15, pix1);
- vector unsigned char pix2l = vec_ld( 0, pix2);
- vector unsigned char pix2r = vec_ld(15, pix2);
- t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
- t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
+ /* Read potentially unaligned pixels into t1 and t2.
+ * Since we're reading 16 pixels, and actually only want 8,
+ * mask out the last 8 pixels. The 0s don't change the sum. */
+ vector unsigned char pix1l = vec_ld(0, pix1);
+ vector unsigned char pix1r = vec_ld(7, pix1);
+ vector unsigned char pix2l = vec_ld(0, pix2);
+ vector unsigned char pix2r = vec_ld(7, pix2);
+ vector unsigned char t1 = vec_and(vec_perm(pix1l, pix1r, perm1),
+ permclear);
+ vector unsigned char t2 = vec_and(vec_perm(pix2l, pix2r, perm2),
+ permclear);
/* Since we want to use unsigned chars, we can take advantage
- of the fact that abs(a-b)^2 = (a-b)^2. */
+ * of the fact that abs(a - b) ^ 2 = (a - b) ^ 2. */
- /* Calculate abs differences vector */
- t3 = vec_max(t1, t2);
- t4 = vec_min(t1, t2);
- t5 = vec_sub(t3, t4);
+ /* Calculate abs differences vector. */
+ vector unsigned char t3 = vec_max(t1, t2);
+ vector unsigned char t4 = vec_min(t1, t2);
+ vector unsigned char t5 = vec_sub(t3, t4);
- /* Square the values and add them to our sum */
+ /* Square the values and add them to our sum. */
sum = vec_msum(t5, t5, sum);
pix1 += line_size;
pix2 += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &s);
@@ -397,46 +388,41 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in
return s;
}
-/**
- * Sum of Squared Errors for a 16x16 block.
- * AltiVec-enhanced.
- * It's the sad16_altivec code above w/ squaring added.
- */
-static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+/* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced.
+ * It's the sad16_altivec code above w/ squaring added. */
+static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
{
- int i;
- int s;
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
+ int i, s;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
vector unsigned char perm = vec_lvsl(0, pix2);
- vector unsigned char t1, t2, t3,t4, t5;
- vector unsigned int sum;
+ vector unsigned int sum = (vector unsigned int) vec_splat_u32(0);
vector signed int sumsqr;
- sum = (vector unsigned int)vec_splat_u32(0);
-
for (i = 0; i < h; i++) {
- /* Read potentially unaligned pixels into t1 and t2 */
- vector unsigned char pix2l = vec_ld( 0, pix2);
+ /* Read potentially unaligned pixels into t1 and t2. */
+ vector unsigned char pix2l = vec_ld(0, pix2);
vector unsigned char pix2r = vec_ld(15, pix2);
- t1 = vec_ld(0, pix1);
- t2 = vec_perm(pix2l, pix2r, perm);
+ vector unsigned char t1 = vec_ld(0, pix1);
+ vector unsigned char t2 = vec_perm(pix2l, pix2r, perm);
/* Since we want to use unsigned chars, we can take advantage
- of the fact that abs(a-b)^2 = (a-b)^2. */
+ * of the fact that abs(a - b) ^ 2 = (a - b) ^ 2. */
- /* Calculate abs differences vector */
- t3 = vec_max(t1, t2);
- t4 = vec_min(t1, t2);
- t5 = vec_sub(t3, t4);
+ /* Calculate abs differences vector. */
+ vector unsigned char t3 = vec_max(t1, t2);
+ vector unsigned char t4 = vec_min(t1, t2);
+ vector unsigned char t5 = vec_sub(t3, t4);
- /* Square the values and add them to our sum */
+ /* Square the values and add them to our sum. */
sum = vec_msum(t5, t5, sum);
pix1 += line_size;
pix2 += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &s);
@@ -444,32 +430,28 @@ static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
return s;
}
-static int pix_sum_altivec(uint8_t * pix, int line_size)
+static int pix_sum_altivec(uint8_t *pix, int line_size)
{
- const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
+ int i, s;
+ const vector unsigned int zero =
+ (const vector unsigned int) vec_splat_u32(0);
vector unsigned char perm = vec_lvsl(0, pix);
- vector unsigned char t1;
- vector unsigned int sad;
+ vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
vector signed int sumdiffs;
- int i;
- int s;
-
- sad = (vector unsigned int)vec_splat_u32(0);
-
for (i = 0; i < 16; i++) {
- /* Read the potentially unaligned 16 pixels into t1 */
- vector unsigned char pixl = vec_ld( 0, pix);
+ /* Read the potentially unaligned 16 pixels into t1. */
+ vector unsigned char pixl = vec_ld(0, pix);
vector unsigned char pixr = vec_ld(15, pix);
- t1 = vec_perm(pixl, pixr, perm);
+ vector unsigned char t1 = vec_perm(pixl, pixr, perm);
- /* Add each 4 pixel group together and put 4 results into sad */
+ /* Add each 4 pixel group together and put 4 results into sad. */
sad = vec_sum4s(t1, sad);
pix += line_size;
}
- /* Sum up the four partial sums, and put the result into s */
+ /* Sum up the four partial sums, and put the result into s. */
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
@@ -477,107 +459,107 @@ static int pix_sum_altivec(uint8_t * pix, int line_size)
return s;
}
-static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, int line_size)
+static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels,
+ int line_size)
{
int i;
vector unsigned char perm = vec_lvsl(0, pixels);
- vector unsigned char bytes;
- const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
- vector signed short shorts;
+ const vector unsigned char zero =
+ (const vector unsigned char) vec_splat_u8(0);
for (i = 0; i < 8; i++) {
- // Read potentially unaligned pixels.
- // We're reading 16 pixels, and actually only want 8,
- // but we simply ignore the extras.
- vector unsigned char pixl = vec_ld( 0, pixels);
- vector unsigned char pixr = vec_ld(15, pixels);
- bytes = vec_perm(pixl, pixr, perm);
+ /* Read potentially unaligned pixels.
+ * We're reading 16 pixels, and actually only want 8,
+ * but we simply ignore the extras. */
+ vector unsigned char pixl = vec_ld(0, pixels);
+ vector unsigned char pixr = vec_ld(7, pixels);
+ vector unsigned char bytes = vec_perm(pixl, pixr, perm);
- // convert the bytes into shorts
- shorts = (vector signed short)vec_mergeh(zero, bytes);
+ // Convert the bytes into shorts.
+ vector signed short shorts = (vector signed short) vec_mergeh(zero,
+ bytes);
- // save the data to the block, we assume the block is 16-byte aligned
- vec_st(shorts, i*16, (vector signed short*)block);
+ // Save the data to the block, we assume the block is 16-byte aligned.
+ vec_st(shorts, i * 16, (vector signed short *) block);
pixels += line_size;
}
}
static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
- const uint8_t *s2, int stride)
+ const uint8_t *s2, int stride)
{
int i;
vector unsigned char perm1 = vec_lvsl(0, s1);
vector unsigned char perm2 = vec_lvsl(0, s2);
- vector unsigned char bytes, pixl, pixr;
- const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
+ const vector unsigned char zero =
+ (const vector unsigned char) vec_splat_u8(0);
vector signed short shorts1, shorts2;
for (i = 0; i < 4; i++) {
- // Read potentially unaligned pixels
- // We're reading 16 pixels, and actually only want 8,
- // but we simply ignore the extras.
- pixl = vec_ld( 0, s1);
- pixr = vec_ld(15, s1);
- bytes = vec_perm(pixl, pixr, perm1);
-
- // convert the bytes into shorts
- shorts1 = (vector signed short)vec_mergeh(zero, bytes);
-
- // Do the same for the second block of pixels
- pixl = vec_ld( 0, s2);
- pixr = vec_ld(15, s2);
+ /* Read potentially unaligned pixels.
+ * We're reading 16 pixels, and actually only want 8,
+ * but we simply ignore the extras. */
+ vector unsigned char pixl = vec_ld(0, s1);
+ vector unsigned char pixr = vec_ld(15, s1);
+ vector unsigned char bytes = vec_perm(pixl, pixr, perm1);
+
+ // Convert the bytes into shorts.
+ shorts1 = (vector signed short) vec_mergeh(zero, bytes);
+
+ // Do the same for the second block of pixels.
+ pixl = vec_ld(0, s2);
+ pixr = vec_ld(15, s2);
bytes = vec_perm(pixl, pixr, perm2);
- // convert the bytes into shorts
- shorts2 = (vector signed short)vec_mergeh(zero, bytes);
+ // Convert the bytes into shorts.
+ shorts2 = (vector signed short) vec_mergeh(zero, bytes);
- // Do the subtraction
+ // Do the subtraction.
shorts1 = vec_sub(shorts1, shorts2);
- // save the data to the block, we assume the block is 16-byte aligned
- vec_st(shorts1, 0, (vector signed short*)block);
+ // Save the data to the block, we assume the block is 16-byte aligned.
+ vec_st(shorts1, 0, (vector signed short *) block);
- s1 += stride;
- s2 += stride;
+ s1 += stride;
+ s2 += stride;
block += 8;
+ /* The code below is a copy of the code above...
+ * This is a manual unroll. */
- // The code below is a copy of the code above... This is a manual
- // unroll.
-
- // Read potentially unaligned pixels
- // We're reading 16 pixels, and actually only want 8,
- // but we simply ignore the extras.
- pixl = vec_ld( 0, s1);
- pixr = vec_ld(15, s1);
+ /* Read potentially unaligned pixels.
+ * We're reading 16 pixels, and actually only want 8,
+ * but we simply ignore the extras. */
+ pixl = vec_ld(0, s1);
+ pixr = vec_ld(15, s1);
bytes = vec_perm(pixl, pixr, perm1);
- // convert the bytes into shorts
- shorts1 = (vector signed short)vec_mergeh(zero, bytes);
+ // Convert the bytes into shorts.
+ shorts1 = (vector signed short) vec_mergeh(zero, bytes);
- // Do the same for the second block of pixels
- pixl = vec_ld( 0, s2);
- pixr = vec_ld(15, s2);
+ // Do the same for the second block of pixels.
+ pixl = vec_ld(0, s2);
+ pixr = vec_ld(15, s2);
bytes = vec_perm(pixl, pixr, perm2);
- // convert the bytes into shorts
- shorts2 = (vector signed short)vec_mergeh(zero, bytes);
+ // Convert the bytes into shorts.
+ shorts2 = (vector signed short) vec_mergeh(zero, bytes);
- // Do the subtraction
+ // Do the subtraction.
shorts1 = vec_sub(shorts1, shorts2);
- // save the data to the block, we assume the block is 16-byte aligned
- vec_st(shorts1, 0, (vector signed short*)block);
+ // Save the data to the block, we assume the block is 16-byte aligned.
+ vec_st(shorts1, 0, (vector signed short *) block);
- s1 += stride;
- s2 += stride;
+ s1 += stride;
+ s2 += stride;
block += 8;
}
}
-
-static void clear_block_altivec(int16_t *block) {
+static void clear_block_altivec(int16_t *block)
+{
LOAD_ZERO;
vec_st(zero_s16v, 0, block);
vec_st(zero_s16v, 16, block);
@@ -589,148 +571,155 @@ static void clear_block_altivec(int16_t *block) {
vec_st(zero_s16v, 112, block);
}
-
-static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) {
+static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w)
+{
register int i;
register vector unsigned char vdst, vsrc;
- /* dst and src are 16 bytes-aligned (guaranteed) */
- for (i = 0 ; (i + 15) < w ; i+=16) {
- vdst = vec_ld(i, (unsigned char*)dst);
- vsrc = vec_ld(i, (unsigned char*)src);
+ /* dst and src are 16 bytes-aligned (guaranteed). */
+ for (i = 0; i + 15 < w; i += 16) {
+ vdst = vec_ld(i, (unsigned char *) dst);
+ vsrc = vec_ld(i, (unsigned char *) src);
vdst = vec_add(vsrc, vdst);
- vec_st(vdst, i, (unsigned char*)dst);
+ vec_st(vdst, i, (unsigned char *) dst);
}
- /* if w is not a multiple of 16 */
- for (; (i < w) ; i++) {
+ /* If w is not a multiple of 16. */
+ for (; i < w; i++)
dst[i] = src[i];
- }
}
-static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
+static int hadamard8_diff8x8_altivec(MpegEncContext *s, uint8_t *dst,
+ uint8_t *src, int stride, int h)
+{
int sum;
register const vector unsigned char vzero =
- (const vector unsigned char)vec_splat_u8(0);
+ (const vector unsigned char) vec_splat_u8(0);
register vector signed short temp0, temp1, temp2, temp3, temp4,
temp5, temp6, temp7;
{
- register const vector signed short vprod1 =(const vector signed short)
- { 1,-1, 1,-1, 1,-1, 1,-1 };
- register const vector signed short vprod2 =(const vector signed short)
- { 1, 1,-1,-1, 1, 1,-1,-1 };
- register const vector signed short vprod3 =(const vector signed short)
- { 1, 1, 1, 1,-1,-1,-1,-1 };
- register const vector unsigned char perm1 = (const vector unsigned char)
- {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
- 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D};
- register const vector unsigned char perm2 = (const vector unsigned char)
- {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
- 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B};
- register const vector unsigned char perm3 = (const vector unsigned char)
- {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-
-#define ONEITERBUTTERFLY(i, res) \
- { \
- register vector unsigned char src1, src2, srcO; \
- register vector unsigned char dst1, dst2, dstO; \
- register vector signed short srcV, dstV; \
- register vector signed short but0, but1, but2, op1, op2, op3; \
- src1 = vec_ld(stride * i, src); \
- src2 = vec_ld((stride * i) + 15, src); \
- srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
- dst1 = vec_ld(stride * i, dst); \
- dst2 = vec_ld((stride * i) + 15, dst); \
- dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
- /* promote the unsigned chars to signed shorts */ \
- /* we're in the 8x8 function, we only care for the first 8 */ \
- srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
- (vector signed char)srcO); \
- dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
- (vector signed char)dstO); \
- /* subtractions inside the first butterfly */ \
- but0 = vec_sub(srcV, dstV); \
- op1 = vec_perm(but0, but0, perm1); \
- but1 = vec_mladd(but0, vprod1, op1); \
- op2 = vec_perm(but1, but1, perm2); \
- but2 = vec_mladd(but1, vprod2, op2); \
- op3 = vec_perm(but2, but2, perm3); \
- res = vec_mladd(but2, vprod3, op3); \
+ register const vector signed short vprod1 =
+ (const vector signed short) { 1, -1, 1, -1, 1, -1, 1, -1 };
+ register const vector signed short vprod2 =
+ (const vector signed short) { 1, 1, -1, -1, 1, 1, -1, -1 };
+ register const vector signed short vprod3 =
+ (const vector signed short) { 1, 1, 1, 1, -1, -1, -1, -1 };
+ register const vector unsigned char perm1 =
+ (const vector unsigned char)
+ { 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
+ 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D };
+ register const vector unsigned char perm2 =
+ (const vector unsigned char)
+ { 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
+ 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B };
+ register const vector unsigned char perm3 =
+ (const vector unsigned char)
+ { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
+
+#define ONEITERBUTTERFLY(i, res) \
+ { \
+ register vector unsigned char src1 = vec_ld(stride * i, src); \
+ register vector unsigned char src2 = vec_ld(stride * i + 15, src); \
+ register vector unsigned char srcO = \
+ vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
+ register vector unsigned char dst1 = vec_ld(stride * i, dst); \
+ register vector unsigned char dst2 = vec_ld(stride * i + 15, dst); \
+ register vector unsigned char dstO = \
+ vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
+ \
+ /* Promote the unsigned chars to signed shorts. */ \
+ /* We're in the 8x8 function, we only care for the first 8. */ \
+ register vector signed short srcV = \
+ (vector signed short) vec_mergeh((vector signed char) vzero, \
+ (vector signed char) srcO); \
+ register vector signed short dstV = \
+ (vector signed short) vec_mergeh((vector signed char) vzero, \
+ (vector signed char) dstO); \
+ \
+ /* subtractions inside the first butterfly */ \
+ register vector signed short but0 = vec_sub(srcV, dstV); \
+ register vector signed short op1 = vec_perm(but0, but0, perm1); \
+ register vector signed short but1 = vec_mladd(but0, vprod1, op1); \
+ register vector signed short op2 = vec_perm(but1, but1, perm2); \
+ register vector signed short but2 = vec_mladd(but1, vprod2, op2); \
+ register vector signed short op3 = vec_perm(but2, but2, perm3); \
+ res = vec_mladd(but2, vprod3, op3); \
}
- ONEITERBUTTERFLY(0, temp0);
- ONEITERBUTTERFLY(1, temp1);
- ONEITERBUTTERFLY(2, temp2);
- ONEITERBUTTERFLY(3, temp3);
- ONEITERBUTTERFLY(4, temp4);
- ONEITERBUTTERFLY(5, temp5);
- ONEITERBUTTERFLY(6, temp6);
- ONEITERBUTTERFLY(7, temp7);
+ ONEITERBUTTERFLY(0, temp0);
+ ONEITERBUTTERFLY(1, temp1);
+ ONEITERBUTTERFLY(2, temp2);
+ ONEITERBUTTERFLY(3, temp3);
+ ONEITERBUTTERFLY(4, temp4);
+ ONEITERBUTTERFLY(5, temp5);
+ ONEITERBUTTERFLY(6, temp6);
+ ONEITERBUTTERFLY(7, temp7);
}
#undef ONEITERBUTTERFLY
{
- register vector signed int vsum;
- register vector signed short line0 = vec_add(temp0, temp1);
- register vector signed short line1 = vec_sub(temp0, temp1);
- register vector signed short line2 = vec_add(temp2, temp3);
- register vector signed short line3 = vec_sub(temp2, temp3);
- register vector signed short line4 = vec_add(temp4, temp5);
- register vector signed short line5 = vec_sub(temp4, temp5);
- register vector signed short line6 = vec_add(temp6, temp7);
- register vector signed short line7 = vec_sub(temp6, temp7);
-
- register vector signed short line0B = vec_add(line0, line2);
- register vector signed short line2B = vec_sub(line0, line2);
- register vector signed short line1B = vec_add(line1, line3);
- register vector signed short line3B = vec_sub(line1, line3);
- register vector signed short line4B = vec_add(line4, line6);
- register vector signed short line6B = vec_sub(line4, line6);
- register vector signed short line5B = vec_add(line5, line7);
- register vector signed short line7B = vec_sub(line5, line7);
-
- register vector signed short line0C = vec_add(line0B, line4B);
- register vector signed short line4C = vec_sub(line0B, line4B);
- register vector signed short line1C = vec_add(line1B, line5B);
- register vector signed short line5C = vec_sub(line1B, line5B);
- register vector signed short line2C = vec_add(line2B, line6B);
- register vector signed short line6C = vec_sub(line2B, line6B);
- register vector signed short line3C = vec_add(line3B, line7B);
- register vector signed short line7C = vec_sub(line3B, line7B);
-
- vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
- vsum = vec_sum4s(vec_abs(line1C), vsum);
- vsum = vec_sum4s(vec_abs(line2C), vsum);
- vsum = vec_sum4s(vec_abs(line3C), vsum);
- vsum = vec_sum4s(vec_abs(line4C), vsum);
- vsum = vec_sum4s(vec_abs(line5C), vsum);
- vsum = vec_sum4s(vec_abs(line6C), vsum);
- vsum = vec_sum4s(vec_abs(line7C), vsum);
- vsum = vec_sums(vsum, (vector signed int)vzero);
- vsum = vec_splat(vsum, 3);
- vec_ste(vsum, 0, &sum);
+ register vector signed int vsum;
+ register vector signed short line0 = vec_add(temp0, temp1);
+ register vector signed short line1 = vec_sub(temp0, temp1);
+ register vector signed short line2 = vec_add(temp2, temp3);
+ register vector signed short line3 = vec_sub(temp2, temp3);
+ register vector signed short line4 = vec_add(temp4, temp5);
+ register vector signed short line5 = vec_sub(temp4, temp5);
+ register vector signed short line6 = vec_add(temp6, temp7);
+ register vector signed short line7 = vec_sub(temp6, temp7);
+
+ register vector signed short line0B = vec_add(line0, line2);
+ register vector signed short line2B = vec_sub(line0, line2);
+ register vector signed short line1B = vec_add(line1, line3);
+ register vector signed short line3B = vec_sub(line1, line3);
+ register vector signed short line4B = vec_add(line4, line6);
+ register vector signed short line6B = vec_sub(line4, line6);
+ register vector signed short line5B = vec_add(line5, line7);
+ register vector signed short line7B = vec_sub(line5, line7);
+
+ register vector signed short line0C = vec_add(line0B, line4B);
+ register vector signed short line4C = vec_sub(line0B, line4B);
+ register vector signed short line1C = vec_add(line1B, line5B);
+ register vector signed short line5C = vec_sub(line1B, line5B);
+ register vector signed short line2C = vec_add(line2B, line6B);
+ register vector signed short line6C = vec_sub(line2B, line6B);
+ register vector signed short line3C = vec_add(line3B, line7B);
+ register vector signed short line7C = vec_sub(line3B, line7B);
+
+ vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
+ vsum = vec_sum4s(vec_abs(line1C), vsum);
+ vsum = vec_sum4s(vec_abs(line2C), vsum);
+ vsum = vec_sum4s(vec_abs(line3C), vsum);
+ vsum = vec_sum4s(vec_abs(line4C), vsum);
+ vsum = vec_sum4s(vec_abs(line5C), vsum);
+ vsum = vec_sum4s(vec_abs(line6C), vsum);
+ vsum = vec_sum4s(vec_abs(line7C), vsum);
+ vsum = vec_sums(vsum, (vector signed int) vzero);
+ vsum = vec_splat(vsum, 3);
+ vec_ste(vsum, 0, &sum);
}
return sum;
}
/*
-16x8 works with 16 elements; it allows to avoid replicating loads, and
-give the compiler more rooms for scheduling. It's only used from
-inside hadamard8_diff16_altivec.
-
-Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has a LOT
-of spill code, it seems gcc (unlike xlc) cannot keep everything in registers
-by itself. The following code include hand-made registers allocation. It's not
-clean, but on a 7450 the resulting code is much faster (best case fall from
-700+ cycles to 550).
-
-xlc doesn't add spill code, but it doesn't know how to schedule for the 7450,
-and its code isn't much faster than gcc-3.3 on the 7450 (but uses 25% less
-instructions...)
-
-On the 970, the hand-made RA is still a win (around 690 vs. around 780), but
-xlc goes to around 660 on the regular C code...
-*/
-
-static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
+ * 16x8 works with 16 elements; it allows to avoid replicating loads, and
+ * gives the compiler more room for scheduling. It's only used from
+ * inside hadamard8_diff16_altivec.
+ *
+ * Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has
+ * a LOT of spill code, it seems gcc (unlike xlc) cannot keep everything in
+ * registers by itself. The following code includes hand-made register
+ * allocation. It's not clean, but on a 7450 the resulting code is much faster
+ * (best case falls from 700+ cycles to 550).
+ *
+ * xlc doesn't add spill code, but it doesn't know how to schedule for the
+ * 7450, and its code isn't much faster than gcc-3.3 on the 7450 (but uses
+ * 25% fewer instructions...)
+ *
+ * On the 970, the hand-made RA is still a win (around 690 vs. around 780),
+ * but xlc goes to around 660 on the regular C code...
+ */
+static int hadamard8_diff16x8_altivec(MpegEncContext *s, uint8_t *dst,
+ uint8_t *src, int stride, int h)
+{
int sum;
register vector signed short
temp0 __asm__ ("v0"),
@@ -751,211 +740,216 @@ static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst,
temp6S __asm__ ("v14"),
temp7S __asm__ ("v15");
register const vector unsigned char vzero __asm__ ("v31") =
- (const vector unsigned char)vec_splat_u8(0);
+ (const vector unsigned char) vec_splat_u8(0);
{
- register const vector signed short vprod1 __asm__ ("v16") =
- (const vector signed short){ 1,-1, 1,-1, 1,-1, 1,-1 };
- register const vector signed short vprod2 __asm__ ("v17") =
- (const vector signed short){ 1, 1,-1,-1, 1, 1,-1,-1 };
- register const vector signed short vprod3 __asm__ ("v18") =
- (const vector signed short){ 1, 1, 1, 1,-1,-1,-1,-1 };
- register const vector unsigned char perm1 __asm__ ("v19") =
- (const vector unsigned char)
- {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
- 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D};
- register const vector unsigned char perm2 __asm__ ("v20") =
- (const vector unsigned char)
- {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
- 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B};
- register const vector unsigned char perm3 __asm__ ("v21") =
- (const vector unsigned char)
- {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-
-#define ONEITERBUTTERFLY(i, res1, res2) \
- { \
- register vector unsigned char src1 __asm__ ("v22"), \
- src2 __asm__ ("v23"), \
- dst1 __asm__ ("v24"), \
- dst2 __asm__ ("v25"), \
- srcO __asm__ ("v22"), \
- dstO __asm__ ("v23"); \
- \
- register vector signed short srcV __asm__ ("v24"), \
- dstV __asm__ ("v25"), \
- srcW __asm__ ("v26"), \
- dstW __asm__ ("v27"), \
- but0 __asm__ ("v28"), \
- but0S __asm__ ("v29"), \
- op1 __asm__ ("v30"), \
- but1 __asm__ ("v22"), \
- op1S __asm__ ("v23"), \
- but1S __asm__ ("v24"), \
- op2 __asm__ ("v25"), \
- but2 __asm__ ("v26"), \
- op2S __asm__ ("v27"), \
- but2S __asm__ ("v28"), \
- op3 __asm__ ("v29"), \
- op3S __asm__ ("v30"); \
- \
- src1 = vec_ld(stride * i, src); \
- src2 = vec_ld((stride * i) + 16, src); \
- srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
- dst1 = vec_ld(stride * i, dst); \
- dst2 = vec_ld((stride * i) + 16, dst); \
- dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
- /* promote the unsigned chars to signed shorts */ \
- srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
- (vector signed char)srcO); \
- dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
- (vector signed char)dstO); \
- srcW = (vector signed short)vec_mergel((vector signed char)vzero, \
- (vector signed char)srcO); \
- dstW = (vector signed short)vec_mergel((vector signed char)vzero, \
- (vector signed char)dstO); \
- /* subtractions inside the first butterfly */ \
- but0 = vec_sub(srcV, dstV); \
- but0S = vec_sub(srcW, dstW); \
- op1 = vec_perm(but0, but0, perm1); \
- but1 = vec_mladd(but0, vprod1, op1); \
- op1S = vec_perm(but0S, but0S, perm1); \
- but1S = vec_mladd(but0S, vprod1, op1S); \
- op2 = vec_perm(but1, but1, perm2); \
- but2 = vec_mladd(but1, vprod2, op2); \
- op2S = vec_perm(but1S, but1S, perm2); \
- but2S = vec_mladd(but1S, vprod2, op2S); \
- op3 = vec_perm(but2, but2, perm3); \
- res1 = vec_mladd(but2, vprod3, op3); \
- op3S = vec_perm(but2S, but2S, perm3); \
- res2 = vec_mladd(but2S, vprod3, op3S); \
+ register const vector signed short vprod1 __asm__ ("v16") =
+ (const vector signed short) { 1, -1, 1, -1, 1, -1, 1, -1 };
+
+ register const vector signed short vprod2 __asm__ ("v17") =
+ (const vector signed short) { 1, 1, -1, -1, 1, 1, -1, -1 };
+
+ register const vector signed short vprod3 __asm__ ("v18") =
+ (const vector signed short) { 1, 1, 1, 1, -1, -1, -1, -1 };
+
+ register const vector unsigned char perm1 __asm__ ("v19") =
+ (const vector unsigned char)
+ { 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
+ 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D };
+
+ register const vector unsigned char perm2 __asm__ ("v20") =
+ (const vector unsigned char)
+ { 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
+ 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B };
+
+ register const vector unsigned char perm3 __asm__ ("v21") =
+ (const vector unsigned char)
+ { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
+
+#define ONEITERBUTTERFLY(i, res1, res2) \
+ { \
+ register vector unsigned char src1 __asm__ ("v22") = \
+ vec_ld(stride * i, src); \
+ register vector unsigned char src2 __asm__ ("v23") = \
+ vec_ld(stride * i + 16, src); \
+ register vector unsigned char srcO __asm__ ("v22") = \
+ vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
+ register vector unsigned char dst1 __asm__ ("v24") = \
+ vec_ld(stride * i, dst); \
+ register vector unsigned char dst2 __asm__ ("v25") = \
+ vec_ld(stride * i + 16, dst); \
+ register vector unsigned char dstO __asm__ ("v23") = \
+ vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
+ \
+ /* Promote the unsigned chars to signed shorts. */ \
+ register vector signed short srcV __asm__ ("v24") = \
+ (vector signed short) vec_mergeh((vector signed char) vzero, \
+ (vector signed char) srcO); \
+ register vector signed short dstV __asm__ ("v25") = \
+ (vector signed short) vec_mergeh((vector signed char) vzero, \
+ (vector signed char) dstO); \
+ register vector signed short srcW __asm__ ("v26") = \
+ (vector signed short) vec_mergel((vector signed char) vzero, \
+ (vector signed char) srcO); \
+ register vector signed short dstW __asm__ ("v27") = \
+ (vector signed short) vec_mergel((vector signed char) vzero, \
+ (vector signed char) dstO); \
+ \
+ /* subtractions inside the first butterfly */ \
+ register vector signed short but0 __asm__ ("v28") = \
+ vec_sub(srcV, dstV); \
+ register vector signed short but0S __asm__ ("v29") = \
+ vec_sub(srcW, dstW); \
+ register vector signed short op1 __asm__ ("v30") = \
+ vec_perm(but0, but0, perm1); \
+ register vector signed short but1 __asm__ ("v22") = \
+ vec_mladd(but0, vprod1, op1); \
+ register vector signed short op1S __asm__ ("v23") = \
+ vec_perm(but0S, but0S, perm1); \
+ register vector signed short but1S __asm__ ("v24") = \
+ vec_mladd(but0S, vprod1, op1S); \
+ register vector signed short op2 __asm__ ("v25") = \
+ vec_perm(but1, but1, perm2); \
+ register vector signed short but2 __asm__ ("v26") = \
+ vec_mladd(but1, vprod2, op2); \
+ register vector signed short op2S __asm__ ("v27") = \
+ vec_perm(but1S, but1S, perm2); \
+ register vector signed short but2S __asm__ ("v28") = \
+ vec_mladd(but1S, vprod2, op2S); \
+ register vector signed short op3 __asm__ ("v29") = \
+ vec_perm(but2, but2, perm3); \
+ register vector signed short op3S __asm__ ("v30") = \
+ vec_perm(but2S, but2S, perm3); \
+ res1 = vec_mladd(but2, vprod3, op3); \
+ res2 = vec_mladd(but2S, vprod3, op3S); \
}
- ONEITERBUTTERFLY(0, temp0, temp0S);
- ONEITERBUTTERFLY(1, temp1, temp1S);
- ONEITERBUTTERFLY(2, temp2, temp2S);
- ONEITERBUTTERFLY(3, temp3, temp3S);
- ONEITERBUTTERFLY(4, temp4, temp4S);
- ONEITERBUTTERFLY(5, temp5, temp5S);
- ONEITERBUTTERFLY(6, temp6, temp6S);
- ONEITERBUTTERFLY(7, temp7, temp7S);
+ ONEITERBUTTERFLY(0, temp0, temp0S);
+ ONEITERBUTTERFLY(1, temp1, temp1S);
+ ONEITERBUTTERFLY(2, temp2, temp2S);
+ ONEITERBUTTERFLY(3, temp3, temp3S);
+ ONEITERBUTTERFLY(4, temp4, temp4S);
+ ONEITERBUTTERFLY(5, temp5, temp5S);
+ ONEITERBUTTERFLY(6, temp6, temp6S);
+ ONEITERBUTTERFLY(7, temp7, temp7S);
}
#undef ONEITERBUTTERFLY
{
- register vector signed int vsum;
- register vector signed short line0S, line1S, line2S, line3S, line4S,
- line5S, line6S, line7S, line0BS,line2BS,
- line1BS,line3BS,line4BS,line6BS,line5BS,
- line7BS,line0CS,line4CS,line1CS,line5CS,
- line2CS,line6CS,line3CS,line7CS;
-
- register vector signed short line0 = vec_add(temp0, temp1);
- register vector signed short line1 = vec_sub(temp0, temp1);
- register vector signed short line2 = vec_add(temp2, temp3);
- register vector signed short line3 = vec_sub(temp2, temp3);
- register vector signed short line4 = vec_add(temp4, temp5);
- register vector signed short line5 = vec_sub(temp4, temp5);
- register vector signed short line6 = vec_add(temp6, temp7);
- register vector signed short line7 = vec_sub(temp6, temp7);
-
- register vector signed short line0B = vec_add(line0, line2);
- register vector signed short line2B = vec_sub(line0, line2);
- register vector signed short line1B = vec_add(line1, line3);
- register vector signed short line3B = vec_sub(line1, line3);
- register vector signed short line4B = vec_add(line4, line6);
- register vector signed short line6B = vec_sub(line4, line6);
- register vector signed short line5B = vec_add(line5, line7);
- register vector signed short line7B = vec_sub(line5, line7);
-
- register vector signed short line0C = vec_add(line0B, line4B);
- register vector signed short line4C = vec_sub(line0B, line4B);
- register vector signed short line1C = vec_add(line1B, line5B);
- register vector signed short line5C = vec_sub(line1B, line5B);
- register vector signed short line2C = vec_add(line2B, line6B);
- register vector signed short line6C = vec_sub(line2B, line6B);
- register vector signed short line3C = vec_add(line3B, line7B);
- register vector signed short line7C = vec_sub(line3B, line7B);
-
- vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
- vsum = vec_sum4s(vec_abs(line1C), vsum);
- vsum = vec_sum4s(vec_abs(line2C), vsum);
- vsum = vec_sum4s(vec_abs(line3C), vsum);
- vsum = vec_sum4s(vec_abs(line4C), vsum);
- vsum = vec_sum4s(vec_abs(line5C), vsum);
- vsum = vec_sum4s(vec_abs(line6C), vsum);
- vsum = vec_sum4s(vec_abs(line7C), vsum);
-
- line0S = vec_add(temp0S, temp1S);
- line1S = vec_sub(temp0S, temp1S);
- line2S = vec_add(temp2S, temp3S);
- line3S = vec_sub(temp2S, temp3S);
- line4S = vec_add(temp4S, temp5S);
- line5S = vec_sub(temp4S, temp5S);
- line6S = vec_add(temp6S, temp7S);
- line7S = vec_sub(temp6S, temp7S);
-
- line0BS = vec_add(line0S, line2S);
- line2BS = vec_sub(line0S, line2S);
- line1BS = vec_add(line1S, line3S);
- line3BS = vec_sub(line1S, line3S);
- line4BS = vec_add(line4S, line6S);
- line6BS = vec_sub(line4S, line6S);
- line5BS = vec_add(line5S, line7S);
- line7BS = vec_sub(line5S, line7S);
-
- line0CS = vec_add(line0BS, line4BS);
- line4CS = vec_sub(line0BS, line4BS);
- line1CS = vec_add(line1BS, line5BS);
- line5CS = vec_sub(line1BS, line5BS);
- line2CS = vec_add(line2BS, line6BS);
- line6CS = vec_sub(line2BS, line6BS);
- line3CS = vec_add(line3BS, line7BS);
- line7CS = vec_sub(line3BS, line7BS);
-
- vsum = vec_sum4s(vec_abs(line0CS), vsum);
- vsum = vec_sum4s(vec_abs(line1CS), vsum);
- vsum = vec_sum4s(vec_abs(line2CS), vsum);
- vsum = vec_sum4s(vec_abs(line3CS), vsum);
- vsum = vec_sum4s(vec_abs(line4CS), vsum);
- vsum = vec_sum4s(vec_abs(line5CS), vsum);
- vsum = vec_sum4s(vec_abs(line6CS), vsum);
- vsum = vec_sum4s(vec_abs(line7CS), vsum);
- vsum = vec_sums(vsum, (vector signed int)vzero);
- vsum = vec_splat(vsum, 3);
- vec_ste(vsum, 0, &sum);
+ register vector signed int vsum;
+
+ register vector signed short line0 = vec_add(temp0, temp1);
+ register vector signed short line1 = vec_sub(temp0, temp1);
+ register vector signed short line2 = vec_add(temp2, temp3);
+ register vector signed short line3 = vec_sub(temp2, temp3);
+ register vector signed short line4 = vec_add(temp4, temp5);
+ register vector signed short line5 = vec_sub(temp4, temp5);
+ register vector signed short line6 = vec_add(temp6, temp7);
+ register vector signed short line7 = vec_sub(temp6, temp7);
+
+ register vector signed short line0B = vec_add(line0, line2);
+ register vector signed short line2B = vec_sub(line0, line2);
+ register vector signed short line1B = vec_add(line1, line3);
+ register vector signed short line3B = vec_sub(line1, line3);
+ register vector signed short line4B = vec_add(line4, line6);
+ register vector signed short line6B = vec_sub(line4, line6);
+ register vector signed short line5B = vec_add(line5, line7);
+ register vector signed short line7B = vec_sub(line5, line7);
+
+ register vector signed short line0C = vec_add(line0B, line4B);
+ register vector signed short line4C = vec_sub(line0B, line4B);
+ register vector signed short line1C = vec_add(line1B, line5B);
+ register vector signed short line5C = vec_sub(line1B, line5B);
+ register vector signed short line2C = vec_add(line2B, line6B);
+ register vector signed short line6C = vec_sub(line2B, line6B);
+ register vector signed short line3C = vec_add(line3B, line7B);
+ register vector signed short line7C = vec_sub(line3B, line7B);
+
+ register vector signed short line0S = vec_add(temp0S, temp1S);
+ register vector signed short line1S = vec_sub(temp0S, temp1S);
+ register vector signed short line2S = vec_add(temp2S, temp3S);
+ register vector signed short line3S = vec_sub(temp2S, temp3S);
+ register vector signed short line4S = vec_add(temp4S, temp5S);
+ register vector signed short line5S = vec_sub(temp4S, temp5S);
+ register vector signed short line6S = vec_add(temp6S, temp7S);
+ register vector signed short line7S = vec_sub(temp6S, temp7S);
+
+ register vector signed short line0BS = vec_add(line0S, line2S);
+ register vector signed short line2BS = vec_sub(line0S, line2S);
+ register vector signed short line1BS = vec_add(line1S, line3S);
+ register vector signed short line3BS = vec_sub(line1S, line3S);
+ register vector signed short line4BS = vec_add(line4S, line6S);
+ register vector signed short line6BS = vec_sub(line4S, line6S);
+ register vector signed short line5BS = vec_add(line5S, line7S);
+ register vector signed short line7BS = vec_sub(line5S, line7S);
+
+ register vector signed short line0CS = vec_add(line0BS, line4BS);
+ register vector signed short line4CS = vec_sub(line0BS, line4BS);
+ register vector signed short line1CS = vec_add(line1BS, line5BS);
+ register vector signed short line5CS = vec_sub(line1BS, line5BS);
+ register vector signed short line2CS = vec_add(line2BS, line6BS);
+ register vector signed short line6CS = vec_sub(line2BS, line6BS);
+ register vector signed short line3CS = vec_add(line3BS, line7BS);
+ register vector signed short line7CS = vec_sub(line3BS, line7BS);
+
+ vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
+ vsum = vec_sum4s(vec_abs(line1C), vsum);
+ vsum = vec_sum4s(vec_abs(line2C), vsum);
+ vsum = vec_sum4s(vec_abs(line3C), vsum);
+ vsum = vec_sum4s(vec_abs(line4C), vsum);
+ vsum = vec_sum4s(vec_abs(line5C), vsum);
+ vsum = vec_sum4s(vec_abs(line6C), vsum);
+ vsum = vec_sum4s(vec_abs(line7C), vsum);
+
+ vsum = vec_sum4s(vec_abs(line0CS), vsum);
+ vsum = vec_sum4s(vec_abs(line1CS), vsum);
+ vsum = vec_sum4s(vec_abs(line2CS), vsum);
+ vsum = vec_sum4s(vec_abs(line3CS), vsum);
+ vsum = vec_sum4s(vec_abs(line4CS), vsum);
+ vsum = vec_sum4s(vec_abs(line5CS), vsum);
+ vsum = vec_sum4s(vec_abs(line6CS), vsum);
+ vsum = vec_sum4s(vec_abs(line7CS), vsum);
+ vsum = vec_sums(vsum, (vector signed int) vzero);
+ vsum = vec_splat(vsum, 3);
+ vec_ste(vsum, 0, &sum);
}
return sum;
}
-static int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
- int score;
- score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
- if (h==16) {
- dst += 8*stride;
- src += 8*stride;
+static int hadamard8_diff16_altivec(MpegEncContext *s, uint8_t *dst,
+ uint8_t *src, int stride, int h)
+{
+ int score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
+
+ if (h == 16) {
+ dst += 8 * stride;
+ src += 8 * stride;
score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
}
return score;
}
-av_cold void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
c->pix_abs[0][1] = sad16_x2_altivec;
c->pix_abs[0][2] = sad16_y2_altivec;
c->pix_abs[0][3] = sad16_xy2_altivec;
c->pix_abs[0][0] = sad16_altivec;
c->pix_abs[1][0] = sad8_altivec;
- c->sad[0]= sad16_altivec;
- c->sad[1]= sad8_altivec;
+
+ c->sad[0] = sad16_altivec;
+ c->sad[1] = sad8_altivec;
+ c->sse[0] = sse16_altivec;
+ c->sse[1] = sse8_altivec;
+
c->pix_norm1 = pix_norm1_altivec;
- c->sse[1]= sse8_altivec;
- c->sse[0]= sse16_altivec;
- c->pix_sum = pix_sum_altivec;
+ c->pix_sum = pix_sum_altivec;
+
c->diff_pixels = diff_pixels_altivec;
- c->add_bytes= add_bytes_altivec;
+ c->add_bytes = add_bytes_altivec;
+
if (!high_bit_depth) {
- c->get_pixels = get_pixels_altivec;
- c->clear_block = clear_block_altivec;
+ c->get_pixels = get_pixels_altivec;
+ c->clear_block = clear_block_altivec;
}
c->hadamard8_diff[0] = hadamard8_diff16_altivec;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.h b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.h
index 0e769ab0606..cdbfc35ac3f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_altivec.h
@@ -24,11 +24,8 @@
#define AVCODEC_PPC_DSPUTIL_ALTIVEC_H
#include <stdint.h>
-#include "libavcodec/dsputil.h"
-
-void ff_put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h);
-void ff_avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h);
+#include "libavcodec/dsputil.h"
void ff_fdct_altivec(int16_t *block);
void ff_gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
@@ -36,8 +33,8 @@ void ff_gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
void ff_idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
void ff_idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
-void ff_dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx);
-void ff_float_init_altivec(DSPContext* c, AVCodecContext *avctx);
-void ff_int_init_altivec(DSPContext* c, AVCodecContext *avctx);
+void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_int_init_altivec(DSPContext *c, AVCodecContext *avctx);
#endif /* AVCODEC_PPC_DSPUTIL_ALTIVEC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_ppc.c b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_ppc.c
index 7454ea0f1e8..cbb1cfbcc8c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_ppc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/dsputil_ppc.c
@@ -26,126 +26,112 @@
#include "libavutil/cpu.h"
#include "libavutil/mem.h"
#include "libavutil/ppc/cpu.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
#include "dsputil_altivec.h"
/* ***** WARNING ***** WARNING ***** WARNING ***** */
/*
-clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a
-cache line size not equal to 32 bytes.
-Fortunately all processor used by Apple up to at least the 7450 (aka second
-generation G4) use 32 bytes cache line.
-This is due to the use of the 'dcbz' instruction. It simply clear to zero a
-single cache line, so you need to know the cache line size to use it !
-It's absurd, but it's fast...
-
-update 24/06/2003 : Apple released yesterday the G5, with a PPC970. cache line
-size: 128 bytes. Oups.
-The semantic of dcbz was changed, it always clear 32 bytes. so the function
-below will work, but will be slow. So I fixed check_dcbz_effect to use dcbzl,
-which is defined to clear a cache line (as dcbz before). So we still can
-distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.
-
-see <http://developer.apple.com/technotes/tn/tn2087.html>
-and <http://developer.apple.com/technotes/tn/tn2086.html>
-*/
+ * clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with
+ * a cache line size not equal to 32 bytes. Fortunately all processors used
+ * by Apple up to at least the 7450 (AKA second generation G4) use 32-byte
+ * cache lines. This is due to the use of the 'dcbz' instruction. It simply
+ * clears a single cache line to zero, so you need to know the cache line
+ * size to use it! It's absurd, but it's fast...
+ *
+ * update 24/06/2003: Apple released the G5 yesterday, with a PPC970.
+ * cache line size: 128 bytes. Oups.
+ * The semantics of dcbz was changed, it always clears 32 bytes. So the function
+ * below will work, but will be slow. So I fixed check_dcbz_effect to use dcbzl,
+ * which is defined to clear a cache line (as dcbz before). So we can still
+ * distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.
+ *
+ * see <http://developer.apple.com/technotes/tn/tn2087.html>
+ * and <http://developer.apple.com/technotes/tn/tn2086.html>
+ */
static void clear_blocks_dcbz32_ppc(int16_t *blocks)
{
- register int misal = ((unsigned long)blocks & 0x00000010);
- register int i = 0;
+ register int misal = (unsigned long) blocks & 0x00000010, i = 0;
+
if (misal) {
- ((unsigned long*)blocks)[0] = 0L;
- ((unsigned long*)blocks)[1] = 0L;
- ((unsigned long*)blocks)[2] = 0L;
- ((unsigned long*)blocks)[3] = 0L;
+ ((unsigned long *) blocks)[0] = 0L;
+ ((unsigned long *) blocks)[1] = 0L;
+ ((unsigned long *) blocks)[2] = 0L;
+ ((unsigned long *) blocks)[3] = 0L;
i += 16;
}
- for ( ; i < sizeof(int16_t)*6*64-31 ; i += 32) {
- __asm__ volatile("dcbz %0,%1" : : "b" (blocks), "r" (i) : "memory");
- }
+ for (; i < sizeof(int16_t) * 6 * 64 - 31; i += 32)
+ __asm__ volatile ("dcbz %0,%1" :: "b" (blocks), "r" (i) : "memory");
if (misal) {
- ((unsigned long*)blocks)[188] = 0L;
- ((unsigned long*)blocks)[189] = 0L;
- ((unsigned long*)blocks)[190] = 0L;
- ((unsigned long*)blocks)[191] = 0L;
+ ((unsigned long *) blocks)[188] = 0L;
+ ((unsigned long *) blocks)[189] = 0L;
+ ((unsigned long *) blocks)[190] = 0L;
+ ((unsigned long *) blocks)[191] = 0L;
i += 16;
}
}
-/* same as above, when dcbzl clear a whole 128B cache line
- i.e. the PPC970 aka G5 */
-#if HAVE_DCBZL
+/* Same as above, when dcbzl clears a whole 128 bytes cache line
+ * i.e. the PPC970 AKA G5. */
static void clear_blocks_dcbz128_ppc(int16_t *blocks)
{
- register int misal = ((unsigned long)blocks & 0x0000007f);
- register int i = 0;
+#if HAVE_DCBZL
+ register int misal = (unsigned long) blocks & 0x0000007f, i = 0;
+
if (misal) {
- // we could probably also optimize this case,
- // but there's not much point as the machines
- // aren't available yet (2003-06-26)
- memset(blocks, 0, sizeof(int16_t)*6*64);
+ /* We could probably also optimize this case,
+ * but there's not much point as the machines
+ * aren't available yet (2003-06-26). */
+ memset(blocks, 0, sizeof(int16_t) * 6 * 64);
+ } else {
+ for (; i < sizeof(int16_t) * 6 * 64; i += 128)
+ __asm__ volatile ("dcbzl %0,%1" :: "b" (blocks), "r" (i) : "memory");
}
- else
- for ( ; i < sizeof(int16_t)*6*64 ; i += 128) {
- __asm__ volatile("dcbzl %0,%1" : : "b" (blocks), "r" (i) : "memory");
- }
-}
#else
-static void clear_blocks_dcbz128_ppc(int16_t *blocks)
-{
- memset(blocks, 0, sizeof(int16_t)*6*64);
-}
+ memset(blocks, 0, sizeof(int16_t) * 6 * 64);
#endif
+}
-#if HAVE_DCBZL
-/* check dcbz report how many bytes are set to 0 by dcbz */
-/* update 24/06/2003 : replace dcbz by dcbzl to get
- the intended effect (Apple "fixed" dcbz)
- unfortunately this cannot be used unless the assembler
- knows about dcbzl ... */
+/* Check dcbz report how many bytes are set to 0 by dcbz. */
+/* update 24/06/2003: Replace dcbz by dcbzl to get the intended effect
+ * (Apple "fixed" dcbz). Unfortunately this cannot be used unless the
+ * assembler knows about dcbzl ... */
static long check_dcbzl_effect(void)
{
+ long count = 0;
+#if HAVE_DCBZL
register char *fakedata = av_malloc(1024);
register char *fakedata_middle;
- register long zero = 0;
- register long i = 0;
- long count = 0;
+ register long zero = 0, i = 0;
- if (!fakedata) {
+ if (!fakedata)
return 0L;
- }
- fakedata_middle = (fakedata + 512);
+ fakedata_middle = fakedata + 512;
memset(fakedata, 0xFF, 1024);
- /* below the constraint "b" seems to mean "Address base register"
- in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */
- __asm__ volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
+ /* Below the constraint "b" seems to mean "address base register"
+ * in gcc-3.3 / RS/6000 speaks. Seems to avoid using r0, so.... */
+ __asm__ volatile ("dcbzl %0, %1" :: "b" (fakedata_middle), "r" (zero));
- for (i = 0; i < 1024 ; i ++) {
- if (fakedata[i] == (char)0)
+ for (i = 0; i < 1024; i++)
+ if (fakedata[i] == (char) 0)
count++;
- }
av_free(fakedata);
+#endif
return count;
}
-#else
-static long check_dcbzl_effect(void)
-{
- return 0;
-}
-#endif
-av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
int mm_flags = av_get_cpu_flags();
-
- // Common optimizations whether AltiVec is available or not
+ // common optimizations whether AltiVec is available or not
if (!high_bit_depth) {
- switch (check_dcbzl_effect()) {
+ switch (check_dcbzl_effect()) {
case 32:
c->clear_blocks = clear_blocks_dcbz32_ppc;
break;
@@ -154,30 +140,29 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx)
break;
default:
break;
- }
+ }
}
if (PPC_ALTIVEC(mm_flags)) {
- ff_dsputil_init_altivec(c, avctx);
+ ff_dsputil_init_altivec(c, avctx, high_bit_depth);
ff_int_init_altivec(c, avctx);
c->gmc1 = ff_gmc1_altivec;
+ if (!high_bit_depth) {
#if CONFIG_ENCODERS
- if (avctx->bits_per_raw_sample <= 8 &&
- (avctx->dct_algo == FF_DCT_AUTO ||
- avctx->dct_algo == FF_DCT_ALTIVEC)) {
- c->fdct = ff_fdct_altivec;
- }
+ if (avctx->dct_algo == FF_DCT_AUTO ||
+ avctx->dct_algo == FF_DCT_ALTIVEC) {
+ c->fdct = ff_fdct_altivec;
+ }
#endif //CONFIG_ENCODERS
-
- if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
+ if (avctx->lowres == 0) {
if ((avctx->idct_algo == FF_IDCT_AUTO) ||
(avctx->idct_algo == FF_IDCT_ALTIVEC)) {
- c->idct_put = ff_idct_put_altivec;
- c->idct_add = ff_idct_add_altivec;
+ c->idct_put = ff_idct_put_altivec;
+ c->idct_add = ff_idct_add_altivec;
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
}
+ }
}
-
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/fdct_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/fdct_altivec.c
index ff816e2a5f3..e6f36497ac7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/fdct_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/fdct_altivec.c
@@ -22,39 +22,37 @@
#if HAVE_ALTIVEC_H
#include <altivec.h>
#endif
+
#include "libavutil/common.h"
#include "dsputil_altivec.h"
-#define vs16(v) ((vector signed short)(v))
-#define vs32(v) ((vector signed int)(v))
-#define vu8(v) ((vector unsigned char)(v))
-#define vu16(v) ((vector unsigned short)(v))
-#define vu32(v) ((vector unsigned int)(v))
-
-
-#define C1 0.98078525066375732421875000 /* cos(1*PI/16) */
-#define C2 0.92387950420379638671875000 /* cos(2*PI/16) */
-#define C3 0.83146959543228149414062500 /* cos(3*PI/16) */
-#define C4 0.70710676908493041992187500 /* cos(4*PI/16) */
-#define C5 0.55557024478912353515625000 /* cos(5*PI/16) */
-#define C6 0.38268342614173889160156250 /* cos(6*PI/16) */
-#define C7 0.19509032368659973144531250 /* cos(7*PI/16) */
-#define SQRT_2 1.41421353816986083984375000 /* sqrt(2) */
-
+#define vs16(v) ((vector signed short) (v))
+#define vs32(v) ((vector signed int) (v))
+#define vu8(v) ((vector unsigned char) (v))
+#define vu16(v) ((vector unsigned short) (v))
+#define vu32(v) ((vector unsigned int) (v))
+
+#define C1 0.98078525066375732421875000 /* cos(1 * PI / 16) */
+#define C2 0.92387950420379638671875000 /* cos(2 * PI / 16) */
+#define C3 0.83146959543228149414062500 /* cos(3 * PI / 16) */
+#define C4 0.70710676908493041992187500 /* cos(4 * PI / 16) */
+#define C5 0.55557024478912353515625000 /* cos(5 * PI / 16) */
+#define C6 0.38268342614173889160156250 /* cos(6 * PI / 16) */
+#define C7 0.19509032368659973144531250 /* cos(7 * PI / 16) */
+#define SQRT_2 1.41421353816986083984375000 /* sqrt(2) */
#define W0 -(2 * C2)
-#define W1 (2 * C6)
+#define W1 (2 * C6)
#define W2 (SQRT_2 * C6)
#define W3 (SQRT_2 * C3)
#define W4 (SQRT_2 * (-C1 + C3 + C5 - C7))
-#define W5 (SQRT_2 * ( C1 + C3 - C5 + C7))
-#define W6 (SQRT_2 * ( C1 + C3 + C5 - C7))
-#define W7 (SQRT_2 * ( C1 + C3 - C5 - C7))
-#define W8 (SQRT_2 * ( C7 - C3))
+#define W5 (SQRT_2 * (C1 + C3 - C5 + C7))
+#define W6 (SQRT_2 * (C1 + C3 + C5 - C7))
+#define W7 (SQRT_2 * (C1 + C3 - C5 - C7))
+#define W8 (SQRT_2 * (C7 - C3))
#define W9 (SQRT_2 * (-C1 - C3))
#define WA (SQRT_2 * (-C3 - C5))
-#define WB (SQRT_2 * ( C5 - C3))
-
+#define WB (SQRT_2 * (C5 - C3))
static vector float fdctconsts[3] = {
{ W0, W1, W2, W3 },
@@ -75,8 +73,7 @@ static vector float fdctconsts[3] = {
#define LD_WA vec_splat(cnsts2, 2)
#define LD_WB vec_splat(cnsts2, 3)
-
-#define FDCTROW(b0,b1,b2,b3,b4,b5,b6,b7) /* {{{ */ \
+#define FDCTROW(b0, b1, b2, b3, b4, b5, b6, b7) /* {{{ */ \
x0 = vec_add(b0, b7); /* x0 = b0 + b7; */ \
x7 = vec_sub(b0, b7); /* x7 = b0 - b7; */ \
x1 = vec_add(b1, b6); /* x1 = b1 + b6; */ \
@@ -91,49 +88,49 @@ static vector float fdctconsts[3] = {
b0 = vec_add(b7, b1); /* b0 = b7 + b1; */ \
b4 = vec_sub(b7, b1); /* b4 = b7 - b1; */ \
\
- b2 = vec_sub(x0, x3); /* b2 = x0 - x3; */ \
- b6 = vec_sub(x1, x2); /* b6 = x1 - x2; */ \
- b5 = vec_add(b6, b2); /* b5 = b6 + b2; */ \
+ b2 = vec_sub(x0, x3); /* b2 = x0 - x3; */ \
+ b6 = vec_sub(x1, x2); /* b6 = x1 - x2; */ \
+ b5 = vec_add(b6, b2); /* b5 = b6 + b2; */ \
cnst = LD_W2; \
- b5 = vec_madd(cnst, b5, mzero); /* b5 = b5 * W2; */ \
+ b5 = vec_madd(cnst, b5, mzero); /* b5 = b5 * W2; */ \
cnst = LD_W1; \
- b2 = vec_madd(cnst, b2, b5); /* b2 = b5 + b2 * W1; */ \
+ b2 = vec_madd(cnst, b2, b5); /* b2 = b5 + b2 * W1; */ \
cnst = LD_W0; \
- b6 = vec_madd(cnst, b6, b5); /* b6 = b5 + b6 * W0; */ \
+ b6 = vec_madd(cnst, b6, b5); /* b6 = b5 + b6 * W0; */ \
\
- x0 = vec_add(x4, x7); /* x0 = x4 + x7; */ \
- x1 = vec_add(x5, x6); /* x1 = x5 + x6; */ \
- x2 = vec_add(x4, x6); /* x2 = x4 + x6; */ \
- x3 = vec_add(x5, x7); /* x3 = x5 + x7; */ \
- x8 = vec_add(x2, x3); /* x8 = x2 + x3; */ \
+ x0 = vec_add(x4, x7); /* x0 = x4 + x7; */ \
+ x1 = vec_add(x5, x6); /* x1 = x5 + x6; */ \
+ x2 = vec_add(x4, x6); /* x2 = x4 + x6; */ \
+ x3 = vec_add(x5, x7); /* x3 = x5 + x7; */ \
+ x8 = vec_add(x2, x3); /* x8 = x2 + x3; */ \
cnst = LD_W3; \
- x8 = vec_madd(cnst, x8, mzero); /* x8 = x8 * W3; */ \
+ x8 = vec_madd(cnst, x8, mzero); /* x8 = x8 * W3; */ \
\
cnst = LD_W8; \
- x0 = vec_madd(cnst, x0, mzero); /* x0 *= W8; */ \
+ x0 = vec_madd(cnst, x0, mzero); /* x0 *= W8; */ \
cnst = LD_W9; \
- x1 = vec_madd(cnst, x1, mzero); /* x1 *= W9; */ \
+ x1 = vec_madd(cnst, x1, mzero); /* x1 *= W9; */ \
cnst = LD_WA; \
- x2 = vec_madd(cnst, x2, x8); /* x2 = x2 * WA + x8; */ \
+ x2 = vec_madd(cnst, x2, x8); /* x2 = x2 * WA + x8; */ \
cnst = LD_WB; \
- x3 = vec_madd(cnst, x3, x8); /* x3 = x3 * WB + x8; */ \
+ x3 = vec_madd(cnst, x3, x8); /* x3 = x3 * WB + x8; */ \
\
cnst = LD_W4; \
- b7 = vec_madd(cnst, x4, x0); /* b7 = x4 * W4 + x0; */ \
+ b7 = vec_madd(cnst, x4, x0); /* b7 = x4 * W4 + x0; */ \
cnst = LD_W5; \
- b5 = vec_madd(cnst, x5, x1); /* b5 = x5 * W5 + x1; */ \
+ b5 = vec_madd(cnst, x5, x1); /* b5 = x5 * W5 + x1; */ \
cnst = LD_W6; \
- b3 = vec_madd(cnst, x6, x1); /* b3 = x6 * W6 + x1; */ \
+ b3 = vec_madd(cnst, x6, x1); /* b3 = x6 * W6 + x1; */ \
cnst = LD_W7; \
- b1 = vec_madd(cnst, x7, x0); /* b1 = x7 * W7 + x0; */ \
+ b1 = vec_madd(cnst, x7, x0); /* b1 = x7 * W7 + x0; */ \
\
b7 = vec_add(b7, x2); /* b7 = b7 + x2; */ \
b5 = vec_add(b5, x3); /* b5 = b5 + x3; */ \
b3 = vec_add(b3, x2); /* b3 = b3 + x2; */ \
- b1 = vec_add(b1, x3); /* b1 = b1 + x3; */ \
+ b1 = vec_add(b1, x3) /* b1 = b1 + x3; */ \
/* }}} */
-#define FDCTCOL(b0,b1,b2,b3,b4,b5,b6,b7) /* {{{ */ \
+#define FDCTCOL(b0, b1, b2, b3, b4, b5, b6, b7) /* {{{ */ \
x0 = vec_add(b0, b7); /* x0 = b0 + b7; */ \
x7 = vec_sub(b0, b7); /* x7 = b0 - b7; */ \
x1 = vec_add(b1, b6); /* x1 = b1 + b6; */ \
@@ -148,56 +145,53 @@ static vector float fdctconsts[3] = {
b0 = vec_add(b7, b1); /* b0 = b7 + b1; */ \
b4 = vec_sub(b7, b1); /* b4 = b7 - b1; */ \
\
- b2 = vec_sub(x0, x3); /* b2 = x0 - x3; */ \
- b6 = vec_sub(x1, x2); /* b6 = x1 - x2; */ \
- b5 = vec_add(b6, b2); /* b5 = b6 + b2; */ \
+ b2 = vec_sub(x0, x3); /* b2 = x0 - x3; */ \
+ b6 = vec_sub(x1, x2); /* b6 = x1 - x2; */ \
+ b5 = vec_add(b6, b2); /* b5 = b6 + b2; */ \
cnst = LD_W2; \
- b5 = vec_madd(cnst, b5, mzero); /* b5 = b5 * W2; */ \
+ b5 = vec_madd(cnst, b5, mzero); /* b5 = b5 * W2; */ \
cnst = LD_W1; \
- b2 = vec_madd(cnst, b2, b5); /* b2 = b5 + b2 * W1; */ \
+ b2 = vec_madd(cnst, b2, b5); /* b2 = b5 + b2 * W1; */ \
cnst = LD_W0; \
- b6 = vec_madd(cnst, b6, b5); /* b6 = b5 + b6 * W0; */ \
+ b6 = vec_madd(cnst, b6, b5); /* b6 = b5 + b6 * W0; */ \
\
- x0 = vec_add(x4, x7); /* x0 = x4 + x7; */ \
- x1 = vec_add(x5, x6); /* x1 = x5 + x6; */ \
- x2 = vec_add(x4, x6); /* x2 = x4 + x6; */ \
- x3 = vec_add(x5, x7); /* x3 = x5 + x7; */ \
- x8 = vec_add(x2, x3); /* x8 = x2 + x3; */ \
+ x0 = vec_add(x4, x7); /* x0 = x4 + x7; */ \
+ x1 = vec_add(x5, x6); /* x1 = x5 + x6; */ \
+ x2 = vec_add(x4, x6); /* x2 = x4 + x6; */ \
+ x3 = vec_add(x5, x7); /* x3 = x5 + x7; */ \
+ x8 = vec_add(x2, x3); /* x8 = x2 + x3; */ \
cnst = LD_W3; \
- x8 = vec_madd(cnst, x8, mzero); /* x8 = x8 * W3; */ \
+ x8 = vec_madd(cnst, x8, mzero); /* x8 = x8 * W3; */ \
\
cnst = LD_W8; \
- x0 = vec_madd(cnst, x0, mzero); /* x0 *= W8; */ \
+ x0 = vec_madd(cnst, x0, mzero); /* x0 *= W8; */ \
cnst = LD_W9; \
- x1 = vec_madd(cnst, x1, mzero); /* x1 *= W9; */ \
+ x1 = vec_madd(cnst, x1, mzero); /* x1 *= W9; */ \
cnst = LD_WA; \
- x2 = vec_madd(cnst, x2, x8); /* x2 = x2 * WA + x8; */ \
+ x2 = vec_madd(cnst, x2, x8); /* x2 = x2 * WA + x8; */ \
cnst = LD_WB; \
- x3 = vec_madd(cnst, x3, x8); /* x3 = x3 * WB + x8; */ \
+ x3 = vec_madd(cnst, x3, x8); /* x3 = x3 * WB + x8; */ \
\
cnst = LD_W4; \
- b7 = vec_madd(cnst, x4, x0); /* b7 = x4 * W4 + x0; */ \
+ b7 = vec_madd(cnst, x4, x0); /* b7 = x4 * W4 + x0; */ \
cnst = LD_W5; \
- b5 = vec_madd(cnst, x5, x1); /* b5 = x5 * W5 + x1; */ \
+ b5 = vec_madd(cnst, x5, x1); /* b5 = x5 * W5 + x1; */ \
cnst = LD_W6; \
- b3 = vec_madd(cnst, x6, x1); /* b3 = x6 * W6 + x1; */ \
+ b3 = vec_madd(cnst, x6, x1); /* b3 = x6 * W6 + x1; */ \
cnst = LD_W7; \
- b1 = vec_madd(cnst, x7, x0); /* b1 = x7 * W7 + x0; */ \
+ b1 = vec_madd(cnst, x7, x0); /* b1 = x7 * W7 + x0; */ \
\
b7 = vec_add(b7, x2); /* b7 += x2; */ \
b5 = vec_add(b5, x3); /* b5 += x3; */ \
b3 = vec_add(b3, x2); /* b3 += x2; */ \
- b1 = vec_add(b1, x3); /* b1 += x3; */ \
+ b1 = vec_add(b1, x3) /* b1 += x3; */ \
/* }}} */
-
-
/* two dimensional discrete cosine transform */
-
void ff_fdct_altivec(int16_t *block)
{
vector signed short *bp;
- vector float *cp;
+ vector float *cp = fdctconsts;
vector float b00, b10, b20, b30, b40, b50, b60, b70;
vector float b01, b11, b21, b31, b41, b51, b61, b71;
vector float mzero, cnst, cnsts0, cnsts1, cnsts2;
@@ -205,92 +199,91 @@ void ff_fdct_altivec(int16_t *block)
/* setup constants {{{ */
/* mzero = -0.0 */
- mzero = ((vector float)vec_splat_u32(-1));
- mzero = ((vector float)vec_sl(vu32(mzero), vu32(mzero)));
- cp = fdctconsts;
- cnsts0 = vec_ld(0, cp); cp++;
- cnsts1 = vec_ld(0, cp); cp++;
+ mzero = ((vector float) vec_splat_u32(-1));
+ mzero = ((vector float) vec_sl(vu32(mzero), vu32(mzero)));
+ cnsts0 = vec_ld(0, cp);
+ cp++;
+ cnsts1 = vec_ld(0, cp);
+ cp++;
cnsts2 = vec_ld(0, cp);
/* }}} */
-
/* 8x8 matrix transpose (vector short[8]) {{{ */
-#define MERGE_S16(hl,a,b) vec_merge##hl(vs16(a), vs16(b))
+#define MERGE_S16(hl, a, b) vec_merge ## hl(vs16(a), vs16(b))
- bp = (vector signed short*)block;
- b00 = ((vector float)vec_ld(0, bp));
- b40 = ((vector float)vec_ld(16*4, bp));
- b01 = ((vector float)MERGE_S16(h, b00, b40));
- b11 = ((vector float)MERGE_S16(l, b00, b40));
+ bp = (vector signed short *) block;
+ b00 = ((vector float) vec_ld(0, bp));
+ b40 = ((vector float) vec_ld(16 * 4, bp));
+ b01 = ((vector float) MERGE_S16(h, b00, b40));
+ b11 = ((vector float) MERGE_S16(l, b00, b40));
bp++;
- b10 = ((vector float)vec_ld(0, bp));
- b50 = ((vector float)vec_ld(16*4, bp));
- b21 = ((vector float)MERGE_S16(h, b10, b50));
- b31 = ((vector float)MERGE_S16(l, b10, b50));
+ b10 = ((vector float) vec_ld(0, bp));
+ b50 = ((vector float) vec_ld(16 * 4, bp));
+ b21 = ((vector float) MERGE_S16(h, b10, b50));
+ b31 = ((vector float) MERGE_S16(l, b10, b50));
bp++;
- b20 = ((vector float)vec_ld(0, bp));
- b60 = ((vector float)vec_ld(16*4, bp));
- b41 = ((vector float)MERGE_S16(h, b20, b60));
- b51 = ((vector float)MERGE_S16(l, b20, b60));
+ b20 = ((vector float) vec_ld(0, bp));
+ b60 = ((vector float) vec_ld(16 * 4, bp));
+ b41 = ((vector float) MERGE_S16(h, b20, b60));
+ b51 = ((vector float) MERGE_S16(l, b20, b60));
bp++;
- b30 = ((vector float)vec_ld(0, bp));
- b70 = ((vector float)vec_ld(16*4, bp));
- b61 = ((vector float)MERGE_S16(h, b30, b70));
- b71 = ((vector float)MERGE_S16(l, b30, b70));
-
- x0 = ((vector float)MERGE_S16(h, b01, b41));
- x1 = ((vector float)MERGE_S16(l, b01, b41));
- x2 = ((vector float)MERGE_S16(h, b11, b51));
- x3 = ((vector float)MERGE_S16(l, b11, b51));
- x4 = ((vector float)MERGE_S16(h, b21, b61));
- x5 = ((vector float)MERGE_S16(l, b21, b61));
- x6 = ((vector float)MERGE_S16(h, b31, b71));
- x7 = ((vector float)MERGE_S16(l, b31, b71));
-
- b00 = ((vector float)MERGE_S16(h, x0, x4));
- b10 = ((vector float)MERGE_S16(l, x0, x4));
- b20 = ((vector float)MERGE_S16(h, x1, x5));
- b30 = ((vector float)MERGE_S16(l, x1, x5));
- b40 = ((vector float)MERGE_S16(h, x2, x6));
- b50 = ((vector float)MERGE_S16(l, x2, x6));
- b60 = ((vector float)MERGE_S16(h, x3, x7));
- b70 = ((vector float)MERGE_S16(l, x3, x7));
+ b30 = ((vector float) vec_ld(0, bp));
+ b70 = ((vector float) vec_ld(16 * 4, bp));
+ b61 = ((vector float) MERGE_S16(h, b30, b70));
+ b71 = ((vector float) MERGE_S16(l, b30, b70));
+
+ x0 = ((vector float) MERGE_S16(h, b01, b41));
+ x1 = ((vector float) MERGE_S16(l, b01, b41));
+ x2 = ((vector float) MERGE_S16(h, b11, b51));
+ x3 = ((vector float) MERGE_S16(l, b11, b51));
+ x4 = ((vector float) MERGE_S16(h, b21, b61));
+ x5 = ((vector float) MERGE_S16(l, b21, b61));
+ x6 = ((vector float) MERGE_S16(h, b31, b71));
+ x7 = ((vector float) MERGE_S16(l, b31, b71));
+
+ b00 = ((vector float) MERGE_S16(h, x0, x4));
+ b10 = ((vector float) MERGE_S16(l, x0, x4));
+ b20 = ((vector float) MERGE_S16(h, x1, x5));
+ b30 = ((vector float) MERGE_S16(l, x1, x5));
+ b40 = ((vector float) MERGE_S16(h, x2, x6));
+ b50 = ((vector float) MERGE_S16(l, x2, x6));
+ b60 = ((vector float) MERGE_S16(h, x3, x7));
+ b70 = ((vector float) MERGE_S16(l, x3, x7));
#undef MERGE_S16
/* }}} */
+ /* Some of the initial calculations can be done as vector short
+ * before conversion to vector float. The following code section
+ * takes advantage of this. */
-/* Some of the initial calculations can be done as vector short before
- * conversion to vector float. The following code section takes advantage
- * of this.
- */
/* fdct rows {{{ */
- x0 = ((vector float)vec_add(vs16(b00), vs16(b70)));
- x7 = ((vector float)vec_sub(vs16(b00), vs16(b70)));
- x1 = ((vector float)vec_add(vs16(b10), vs16(b60)));
- x6 = ((vector float)vec_sub(vs16(b10), vs16(b60)));
- x2 = ((vector float)vec_add(vs16(b20), vs16(b50)));
- x5 = ((vector float)vec_sub(vs16(b20), vs16(b50)));
- x3 = ((vector float)vec_add(vs16(b30), vs16(b40)));
- x4 = ((vector float)vec_sub(vs16(b30), vs16(b40)));
-
- b70 = ((vector float)vec_add(vs16(x0), vs16(x3)));
- b10 = ((vector float)vec_add(vs16(x1), vs16(x2)));
-
- b00 = ((vector float)vec_add(vs16(b70), vs16(b10)));
- b40 = ((vector float)vec_sub(vs16(b70), vs16(b10)));
-
-#define CTF0(n) \
- b##n##1 = ((vector float)vec_unpackl(vs16(b##n##0))); \
- b##n##0 = ((vector float)vec_unpackh(vs16(b##n##0))); \
- b##n##1 = vec_ctf(vs32(b##n##1), 0); \
- b##n##0 = vec_ctf(vs32(b##n##0), 0);
+ x0 = ((vector float) vec_add(vs16(b00), vs16(b70)));
+ x7 = ((vector float) vec_sub(vs16(b00), vs16(b70)));
+ x1 = ((vector float) vec_add(vs16(b10), vs16(b60)));
+ x6 = ((vector float) vec_sub(vs16(b10), vs16(b60)));
+ x2 = ((vector float) vec_add(vs16(b20), vs16(b50)));
+ x5 = ((vector float) vec_sub(vs16(b20), vs16(b50)));
+ x3 = ((vector float) vec_add(vs16(b30), vs16(b40)));
+ x4 = ((vector float) vec_sub(vs16(b30), vs16(b40)));
+
+ b70 = ((vector float) vec_add(vs16(x0), vs16(x3)));
+ b10 = ((vector float) vec_add(vs16(x1), vs16(x2)));
+
+ b00 = ((vector float) vec_add(vs16(b70), vs16(b10)));
+ b40 = ((vector float) vec_sub(vs16(b70), vs16(b10)));
+
+#define CTF0(n) \
+ b ## n ## 1 = ((vector float) vec_unpackl(vs16(b ## n ## 0))); \
+ b ## n ## 0 = ((vector float) vec_unpackh(vs16(b ## n ## 0))); \
+ b ## n ## 1 = vec_ctf(vs32(b ## n ## 1), 0); \
+ b ## n ## 0 = vec_ctf(vs32(b ## n ## 0), 0)
CTF0(0);
CTF0(4);
- b20 = ((vector float)vec_sub(vs16(x0), vs16(x3)));
- b60 = ((vector float)vec_sub(vs16(x1), vs16(x2)));
+ b20 = ((vector float) vec_sub(vs16(x0), vs16(x3)));
+ b60 = ((vector float) vec_sub(vs16(x1), vs16(x2)));
CTF0(2);
CTF0(6);
@@ -301,20 +294,20 @@ void ff_fdct_altivec(int16_t *block)
x1 = vec_add(b61, b21);
cnst = LD_W2;
- x0 = vec_madd(cnst, x0, mzero);
- x1 = vec_madd(cnst, x1, mzero);
+ x0 = vec_madd(cnst, x0, mzero);
+ x1 = vec_madd(cnst, x1, mzero);
cnst = LD_W1;
- b20 = vec_madd(cnst, b20, x0);
- b21 = vec_madd(cnst, b21, x1);
+ b20 = vec_madd(cnst, b20, x0);
+ b21 = vec_madd(cnst, b21, x1);
cnst = LD_W0;
- b60 = vec_madd(cnst, b60, x0);
- b61 = vec_madd(cnst, b61, x1);
+ b60 = vec_madd(cnst, b60, x0);
+ b61 = vec_madd(cnst, b61, x1);
-#define CTFX(x,b) \
- b##0 = ((vector float)vec_unpackh(vs16(x))); \
- b##1 = ((vector float)vec_unpackl(vs16(x))); \
- b##0 = vec_ctf(vs32(b##0), 0); \
- b##1 = vec_ctf(vs32(b##1), 0); \
+#define CTFX(x, b) \
+ b ## 0 = ((vector float) vec_unpackh(vs16(x))); \
+ b ## 1 = ((vector float) vec_unpackl(vs16(x))); \
+ b ## 0 = vec_ctf(vs32(b ## 0), 0); \
+ b ## 1 = vec_ctf(vs32(b ## 1), 0)
CTFX(x4, b7);
CTFX(x5, b5);
@@ -323,64 +316,62 @@ void ff_fdct_altivec(int16_t *block)
#undef CTFX
-
- x0 = vec_add(b70, b10);
- x1 = vec_add(b50, b30);
- x2 = vec_add(b70, b30);
- x3 = vec_add(b50, b10);
- x8 = vec_add(x2, x3);
+ x0 = vec_add(b70, b10);
+ x1 = vec_add(b50, b30);
+ x2 = vec_add(b70, b30);
+ x3 = vec_add(b50, b10);
+ x8 = vec_add(x2, x3);
cnst = LD_W3;
- x8 = vec_madd(cnst, x8, mzero);
+ x8 = vec_madd(cnst, x8, mzero);
cnst = LD_W8;
- x0 = vec_madd(cnst, x0, mzero);
+ x0 = vec_madd(cnst, x0, mzero);
cnst = LD_W9;
- x1 = vec_madd(cnst, x1, mzero);
+ x1 = vec_madd(cnst, x1, mzero);
cnst = LD_WA;
- x2 = vec_madd(cnst, x2, x8);
+ x2 = vec_madd(cnst, x2, x8);
cnst = LD_WB;
- x3 = vec_madd(cnst, x3, x8);
+ x3 = vec_madd(cnst, x3, x8);
cnst = LD_W4;
- b70 = vec_madd(cnst, b70, x0);
+ b70 = vec_madd(cnst, b70, x0);
cnst = LD_W5;
- b50 = vec_madd(cnst, b50, x1);
+ b50 = vec_madd(cnst, b50, x1);
cnst = LD_W6;
- b30 = vec_madd(cnst, b30, x1);
+ b30 = vec_madd(cnst, b30, x1);
cnst = LD_W7;
- b10 = vec_madd(cnst, b10, x0);
+ b10 = vec_madd(cnst, b10, x0);
b70 = vec_add(b70, x2);
b50 = vec_add(b50, x3);
b30 = vec_add(b30, x2);
b10 = vec_add(b10, x3);
-
- x0 = vec_add(b71, b11);
- x1 = vec_add(b51, b31);
- x2 = vec_add(b71, b31);
- x3 = vec_add(b51, b11);
- x8 = vec_add(x2, x3);
+ x0 = vec_add(b71, b11);
+ x1 = vec_add(b51, b31);
+ x2 = vec_add(b71, b31);
+ x3 = vec_add(b51, b11);
+ x8 = vec_add(x2, x3);
cnst = LD_W3;
- x8 = vec_madd(cnst, x8, mzero);
+ x8 = vec_madd(cnst, x8, mzero);
cnst = LD_W8;
- x0 = vec_madd(cnst, x0, mzero);
+ x0 = vec_madd(cnst, x0, mzero);
cnst = LD_W9;
- x1 = vec_madd(cnst, x1, mzero);
+ x1 = vec_madd(cnst, x1, mzero);
cnst = LD_WA;
- x2 = vec_madd(cnst, x2, x8);
+ x2 = vec_madd(cnst, x2, x8);
cnst = LD_WB;
- x3 = vec_madd(cnst, x3, x8);
+ x3 = vec_madd(cnst, x3, x8);
cnst = LD_W4;
- b71 = vec_madd(cnst, b71, x0);
+ b71 = vec_madd(cnst, b71, x0);
cnst = LD_W5;
- b51 = vec_madd(cnst, b51, x1);
+ b51 = vec_madd(cnst, b51, x1);
cnst = LD_W6;
- b31 = vec_madd(cnst, b31, x1);
+ b31 = vec_madd(cnst, b31, x1);
cnst = LD_W7;
- b11 = vec_madd(cnst, b11, x0);
+ b11 = vec_madd(cnst, b11, x0);
b71 = vec_add(b71, x2);
b51 = vec_add(b51, x3);
@@ -388,7 +379,6 @@ void ff_fdct_altivec(int16_t *block)
b11 = vec_add(b11, x3);
/* }}} */
-
/* 8x8 matrix transpose (vector float[8][2]) {{{ */
x0 = vec_mergel(b00, b20);
x1 = vec_mergeh(b00, b20);
@@ -431,28 +421,34 @@ void ff_fdct_altivec(int16_t *block)
b31 = vec_mergel(x4, x6);
/* }}} */
-
FDCTCOL(b00, b10, b20, b30, b40, b50, b60, b70);
FDCTCOL(b01, b11, b21, b31, b41, b51, b61, b71);
-
/* round, convert back to short {{{ */
-#define CTS(n) \
- b##n##0 = vec_round(b##n##0); \
- b##n##1 = vec_round(b##n##1); \
- b##n##0 = ((vector float)vec_cts(b##n##0, 0)); \
- b##n##1 = ((vector float)vec_cts(b##n##1, 0)); \
- b##n##0 = ((vector float)vec_pack(vs32(b##n##0), vs32(b##n##1))); \
- vec_st(vs16(b##n##0), 0, bp);
-
- bp = (vector signed short*)block;
- CTS(0); bp++;
- CTS(1); bp++;
- CTS(2); bp++;
- CTS(3); bp++;
- CTS(4); bp++;
- CTS(5); bp++;
- CTS(6); bp++;
+#define CTS(n) \
+ b ## n ## 0 = vec_round(b ## n ## 0); \
+ b ## n ## 1 = vec_round(b ## n ## 1); \
+ b ## n ## 0 = ((vector float) vec_cts(b ## n ## 0, 0)); \
+ b ## n ## 1 = ((vector float) vec_cts(b ## n ## 1, 0)); \
+ b ## n ## 0 = ((vector float) vec_pack(vs32(b ## n ## 0), \
+ vs32(b ## n ## 1))); \
+ vec_st(vs16(b ## n ## 0), 0, bp)
+
+ bp = (vector signed short *) block;
+ CTS(0);
+ bp++;
+ CTS(1);
+ bp++;
+ CTS(2);
+ bp++;
+ CTS(3);
+ bp++;
+ CTS(4);
+ bp++;
+ CTS(5);
+ bp++;
+ CTS(6);
+ bp++;
CTS(7);
#undef CTS
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/fft_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/fft_altivec.c
index 2357198f1ee..8f14d27e17f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/fft_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/fft_altivec.c
@@ -27,12 +27,12 @@
#include "libavcodec/fft.h"
/**
- * Do a complex FFT with the parameters defined in ff_fft_init(). The
- * input data must be permuted before with s->revtab table. No
- * 1.0/sqrt(n) normalization is done.
- * AltiVec-enabled
- * This code assumes that the 'z' pointer is 16 bytes-aligned
- * It also assumes all FFTComplex are 8 bytes-aligned pair of float
+ * Do a complex FFT with the parameters defined in ff_fft_init().
+ * The input data must be permuted before with s->revtab table.
+ * No 1.0 / sqrt(n) normalization is done.
+ * AltiVec-enabled:
+ * This code assumes that the 'z' pointer is 16 bytes-aligned.
+ * It also assumes all FFTComplex are 8 bytes-aligned pairs of floats.
*/
void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
index cd32e39384a..011633e4fe0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
@@ -24,7 +24,6 @@
#include "libavutil/mem.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/fmtconvert.h"
-#include "dsputil_altivec.h"
#if HAVE_ALTIVEC
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/gmc_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/gmc_altivec.c
index 45d850a2965..683a056b63f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/gmc_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/gmc_altivec.c
@@ -1,6 +1,6 @@
/*
- * GMC (Global Motion Compensation)
- * AltiVec-enabled
+ * GMC (Global Motion Compensation), AltiVec-enabled
+ *
* Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
*
* This file is part of FFmpeg.
@@ -25,102 +25,96 @@
#include "libavutil/ppc/util_altivec.h"
#include "dsputil_altivec.h"
-/*
- altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,
- to preserve proper dst alignment.
-*/
-void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
+/* AltiVec-enhanced gmc1. ATM this code assumes stride is a multiple of 8
+ * to preserve proper dst alignment. */
+void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */,
+ int stride, int h, int x16, int y16, int rounder)
{
- const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder;
- const DECLARE_ALIGNED(16, unsigned short, ABCD)[8] =
- {
- (16-x16)*(16-y16), /* A */
- ( x16)*(16-y16), /* B */
- (16-x16)*( y16), /* C */
- ( x16)*( y16), /* D */
- 0, 0, 0, 0 /* padding */
- };
- register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
- register const vector unsigned short vcsr8 = (const vector unsigned short)vec_splat_u16(8);
- register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD;
- register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD;
int i;
- unsigned long dst_odd = (unsigned long)dst & 0x0000000F;
- unsigned long src_really_odd = (unsigned long)src & 0x0000000F;
-
- tempA = vec_ld(0, (const unsigned short*)ABCD);
- Av = vec_splat(tempA, 0);
- Bv = vec_splat(tempA, 1);
- Cv = vec_splat(tempA, 2);
- Dv = vec_splat(tempA, 3);
-
- rounderV = vec_splat((vec_u16)vec_lde(0, &rounder_a), 0);
-
- // we'll be able to pick-up our 9 char elements
- // at src from those 32 bytes
- // we load the first batch here, as inside the loop
- // we can re-use 'src+stride' from one iteration
- // as the 'src' of the next.
- src_0 = vec_ld(0, src);
- src_1 = vec_ld(16, src);
- srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
-
- if (src_really_odd != 0x0000000F) {
- // if (src & 0xF) == 0xF, then (src+1) is properly aligned
- // on the second vector.
+ const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder;
+ const DECLARE_ALIGNED(16, unsigned short, ABCD)[8] = {
+ (16 - x16) * (16 - y16), /* A */
+ (x16) * (16 - y16), /* B */
+ (16 - x16) * (y16), /* C */
+ (x16) * (y16), /* D */
+ 0, 0, 0, 0 /* padding */
+ };
+ register const vector unsigned char vczero =
+ (const vector unsigned char) vec_splat_u8(0);
+ register const vector unsigned short vcsr8 =
+ (const vector unsigned short) vec_splat_u16(8);
+ register vector unsigned char dstv, dstv2, srcvB, srcvC, srcvD;
+ register vector unsigned short tempB, tempC, tempD;
+ unsigned long dst_odd = (unsigned long) dst & 0x0000000F;
+ unsigned long src_really_odd = (unsigned long) src & 0x0000000F;
+ register vector unsigned short tempA =
+ vec_ld(0, (const unsigned short *) ABCD);
+ register vector unsigned short Av = vec_splat(tempA, 0);
+ register vector unsigned short Bv = vec_splat(tempA, 1);
+ register vector unsigned short Cv = vec_splat(tempA, 2);
+ register vector unsigned short Dv = vec_splat(tempA, 3);
+ register vector unsigned short rounderV =
+ vec_splat((vec_u16) vec_lde(0, &rounder_a), 0);
+
+ /* we'll be able to pick-up our 9 char elements at src from those
+ * 32 bytes we load the first batch here, as inside the loop we can
+ * reuse 'src + stride' from one iteration as the 'src' of the next. */
+ register vector unsigned char src_0 = vec_ld(0, src);
+ register vector unsigned char src_1 = vec_ld(16, src);
+ register vector unsigned char srcvA = vec_perm(src_0, src_1,
+ vec_lvsl(0, src));
+
+ if (src_really_odd != 0x0000000F)
+ /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
+ * on the second vector. */
srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
- } else {
+ else
srcvB = src_1;
- }
srcvA = vec_mergeh(vczero, srcvA);
srcvB = vec_mergeh(vczero, srcvB);
- for(i=0; i<h; i++) {
- dst_odd = (unsigned long)dst & 0x0000000F;
- src_really_odd = (((unsigned long)src) + stride) & 0x0000000F;
+ for (i = 0; i < h; i++) {
+ dst_odd = (unsigned long) dst & 0x0000000F;
+ src_really_odd = (((unsigned long) src) + stride) & 0x0000000F;
dstv = vec_ld(0, dst);
- // we we'll be able to pick-up our 9 char elements
- // at src + stride from those 32 bytes
- // then reuse the resulting 2 vectors srvcC and srcvD
- // as the next srcvA and srcvB
- src_0 = vec_ld(stride + 0, src);
+ /* We'll be able to pick-up our 9 char elements at src + stride from
+ * those 32 bytes then reuse the resulting 2 vectors srvcC and srcvD
+ * as the next srcvA and srcvB. */
+ src_0 = vec_ld(stride + 0, src);
src_1 = vec_ld(stride + 16, src);
srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
- if (src_really_odd != 0x0000000F) {
- // if (src & 0xF) == 0xF, then (src+1) is properly aligned
- // on the second vector.
+ if (src_really_odd != 0x0000000F)
+ /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
+ * on the second vector. */
srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
- } else {
+ else
srcvD = src_1;
- }
srcvC = vec_mergeh(vczero, srcvC);
srcvD = vec_mergeh(vczero, srcvD);
-
- // OK, now we (finally) do the math :-)
- // those four instructions replaces 32 int muls & 32 int adds.
- // isn't AltiVec nice ?
- tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
- tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
- tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
- tempD = vec_mladd((vector unsigned short)srcvD, Dv, tempC);
+ /* OK, now we (finally) do the math :-)
+ * Those four instructions replace 32 int muls & 32 int adds.
+ * Isn't AltiVec nice? */
+ tempA = vec_mladd((vector unsigned short) srcvA, Av, rounderV);
+ tempB = vec_mladd((vector unsigned short) srcvB, Bv, tempA);
+ tempC = vec_mladd((vector unsigned short) srcvC, Cv, tempB);
+ tempD = vec_mladd((vector unsigned short) srcvD, Dv, tempC);
srcvA = srcvC;
srcvB = srcvD;
tempD = vec_sr(tempD, vcsr8);
- dstv2 = vec_pack(tempD, (vector unsigned short)vczero);
+ dstv2 = vec_pack(tempD, (vector unsigned short) vczero);
- if (dst_odd) {
- dstv2 = vec_perm(dstv, dstv2, vcprm(0,1,s0,s1));
- } else {
- dstv2 = vec_perm(dstv, dstv2, vcprm(s0,s1,2,3));
- }
+ if (dst_odd)
+ dstv2 = vec_perm(dstv, dstv2, vcprm(0, 1, s0, s1));
+ else
+ dstv2 = vec_perm(dstv, dstv2, vcprm(s0, s1, 2, 3));
vec_st(dstv2, 0, dst);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/h264chroma_init.c b/chromium/third_party/ffmpeg/libavcodec/ppc/h264chroma_init.c
index 921f2deecb6..edf05ec9ba0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/h264chroma_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/h264chroma_init.c
@@ -25,7 +25,6 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/h264chroma.h"
-#include "dsputil_altivec.h"
#if HAVE_ALTIVEC
#define PUT_OP_U8_ALTIVEC(d, s, dst) d = s
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/h264dsp.c b/chromium/third_party/ffmpeg/libavcodec/ppc/h264dsp.c
index 9e749b5bc66..f532197a524 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/h264dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/h264dsp.c
@@ -750,7 +750,7 @@ av_cold void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
if (bit_depth == 8) {
c->h264_idct_add = h264_idct_add_altivec;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = h264_idct_add8_altivec;
c->h264_idct_add16 = h264_idct_add16_altivec;
c->h264_idct_add16intra = h264_idct_add16intra_altivec;
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/h264qpel.c b/chromium/third_party/ffmpeg/libavcodec/ppc/h264qpel.c
index 1f50ec99297..41477677281 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/h264qpel.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/h264qpel.c
@@ -25,7 +25,7 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/h264qpel.h"
-#include "dsputil_altivec.h"
+#include "hpeldsp_altivec.h"
#if HAVE_ALTIVEC
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.c
index 345ec39b95d..d82a7032654 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.c
@@ -31,7 +31,7 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/hpeldsp.h"
-#include "dsputil_altivec.h"
+#include "hpeldsp_altivec.h"
#if HAVE_ALTIVEC
/* next one assumes that ((line_size % 16) == 0) */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.h b/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.h
new file mode 100644
index 00000000000..590809f5394
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/hpeldsp_altivec.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2002 Brian Foley
+ * Copyright (c) 2002 Dieter Shirley
+ * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_PPC_HPELDSP_ALTIVEC_H
+#define AVCODEC_PPC_HPELDSP_ALTIVEC_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+void ff_avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_altivec(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+#endif /* AVCODEC_PPC_HPELDSP_ALTIVEC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/idct_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/idct_altivec.c
index c6f2cd8b8aa..cb6bd67a6fb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/idct_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/idct_altivec.c
@@ -18,199 +18,204 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/*
- * NOTE: This code is based on GPL code from the libmpeg2 project. The
+/* NOTE: This code is based on GPL code from the libmpeg2 project. The
* author, Michel Lespinasses, has given explicit permission to release
* under LGPL as part of FFmpeg.
- */
-
-/*
+ *
* FFmpeg integration by Dieter Shirley
*
* This file is a direct copy of the AltiVec IDCT module from the libmpeg2
* project. I've deleted all of the libmpeg2-specific code, renamed the
* functions and reordered the function parameters. The only change to the
* IDCT function itself was to factor out the partial transposition, and to
- * perform a full transpose at the end of the function.
- */
+ * perform a full transpose at the end of the function. */
-
-#include <stdlib.h> /* malloc(), free() */
+#include <stdlib.h>
#include <string.h>
#include "config.h"
#if HAVE_ALTIVEC_H
#include <altivec.h>
#endif
+
#include "libavutil/ppc/types_altivec.h"
#include "dsputil_altivec.h"
#define IDCT_HALF \
/* 1st stage */ \
- t1 = vec_mradds (a1, vx7, vx1 ); \
- t8 = vec_mradds (a1, vx1, vec_subs (zero, vx7)); \
- t7 = vec_mradds (a2, vx5, vx3); \
- t3 = vec_mradds (ma2, vx3, vx5); \
+ t1 = vec_mradds(a1, vx7, vx1); \
+ t8 = vec_mradds(a1, vx1, vec_subs(zero, vx7)); \
+ t7 = vec_mradds(a2, vx5, vx3); \
+ t3 = vec_mradds(ma2, vx3, vx5); \
\
/* 2nd stage */ \
- t5 = vec_adds (vx0, vx4); \
- t0 = vec_subs (vx0, vx4); \
- t2 = vec_mradds (a0, vx6, vx2); \
- t4 = vec_mradds (a0, vx2, vec_subs (zero, vx6)); \
- t6 = vec_adds (t8, t3); \
- t3 = vec_subs (t8, t3); \
- t8 = vec_subs (t1, t7); \
- t1 = vec_adds (t1, t7); \
+ t5 = vec_adds(vx0, vx4); \
+ t0 = vec_subs(vx0, vx4); \
+ t2 = vec_mradds(a0, vx6, vx2); \
+ t4 = vec_mradds(a0, vx2, vec_subs(zero, vx6)); \
+ t6 = vec_adds(t8, t3); \
+ t3 = vec_subs(t8, t3); \
+ t8 = vec_subs(t1, t7); \
+ t1 = vec_adds(t1, t7); \
\
/* 3rd stage */ \
- t7 = vec_adds (t5, t2); \
- t2 = vec_subs (t5, t2); \
- t5 = vec_adds (t0, t4); \
- t0 = vec_subs (t0, t4); \
- t4 = vec_subs (t8, t3); \
- t3 = vec_adds (t8, t3); \
+ t7 = vec_adds(t5, t2); \
+ t2 = vec_subs(t5, t2); \
+ t5 = vec_adds(t0, t4); \
+ t0 = vec_subs(t0, t4); \
+ t4 = vec_subs(t8, t3); \
+ t3 = vec_adds(t8, t3); \
\
/* 4th stage */ \
- vy0 = vec_adds (t7, t1); \
- vy7 = vec_subs (t7, t1); \
- vy1 = vec_mradds (c4, t3, t5); \
- vy6 = vec_mradds (mc4, t3, t5); \
- vy2 = vec_mradds (c4, t4, t0); \
- vy5 = vec_mradds (mc4, t4, t0); \
- vy3 = vec_adds (t2, t6); \
- vy4 = vec_subs (t2, t6);
-
-
-#define IDCT \
- vec_s16 vx0, vx1, vx2, vx3, vx4, vx5, vx6, vx7; \
- vec_s16 vy0, vy1, vy2, vy3, vy4, vy5, vy6, vy7; \
- vec_s16 a0, a1, a2, ma2, c4, mc4, zero, bias; \
- vec_s16 t0, t1, t2, t3, t4, t5, t6, t7, t8; \
- vec_u16 shift; \
- \
- c4 = vec_splat (constants[0], 0); \
- a0 = vec_splat (constants[0], 1); \
- a1 = vec_splat (constants[0], 2); \
- a2 = vec_splat (constants[0], 3); \
- mc4 = vec_splat (constants[0], 4); \
- ma2 = vec_splat (constants[0], 5); \
- bias = (vec_s16)vec_splat ((vec_s32)constants[0], 3); \
- \
- zero = vec_splat_s16 (0); \
- shift = vec_splat_u16 (4); \
- \
- vx0 = vec_mradds (vec_sl (block[0], shift), constants[1], zero); \
- vx1 = vec_mradds (vec_sl (block[1], shift), constants[2], zero); \
- vx2 = vec_mradds (vec_sl (block[2], shift), constants[3], zero); \
- vx3 = vec_mradds (vec_sl (block[3], shift), constants[4], zero); \
- vx4 = vec_mradds (vec_sl (block[4], shift), constants[1], zero); \
- vx5 = vec_mradds (vec_sl (block[5], shift), constants[4], zero); \
- vx6 = vec_mradds (vec_sl (block[6], shift), constants[3], zero); \
- vx7 = vec_mradds (vec_sl (block[7], shift), constants[2], zero); \
- \
- IDCT_HALF \
- \
- vx0 = vec_mergeh (vy0, vy4); \
- vx1 = vec_mergel (vy0, vy4); \
- vx2 = vec_mergeh (vy1, vy5); \
- vx3 = vec_mergel (vy1, vy5); \
- vx4 = vec_mergeh (vy2, vy6); \
- vx5 = vec_mergel (vy2, vy6); \
- vx6 = vec_mergeh (vy3, vy7); \
- vx7 = vec_mergel (vy3, vy7); \
- \
- vy0 = vec_mergeh (vx0, vx4); \
- vy1 = vec_mergel (vx0, vx4); \
- vy2 = vec_mergeh (vx1, vx5); \
- vy3 = vec_mergel (vx1, vx5); \
- vy4 = vec_mergeh (vx2, vx6); \
- vy5 = vec_mergel (vx2, vx6); \
- vy6 = vec_mergeh (vx3, vx7); \
- vy7 = vec_mergel (vx3, vx7); \
- \
- vx0 = vec_adds (vec_mergeh (vy0, vy4), bias); \
- vx1 = vec_mergel (vy0, vy4); \
- vx2 = vec_mergeh (vy1, vy5); \
- vx3 = vec_mergel (vy1, vy5); \
- vx4 = vec_mergeh (vy2, vy6); \
- vx5 = vec_mergel (vy2, vy6); \
- vx6 = vec_mergeh (vy3, vy7); \
- vx7 = vec_mergel (vy3, vy7); \
- \
- IDCT_HALF \
- \
- shift = vec_splat_u16 (6); \
- vx0 = vec_sra (vy0, shift); \
- vx1 = vec_sra (vy1, shift); \
- vx2 = vec_sra (vy2, shift); \
- vx3 = vec_sra (vy3, shift); \
- vx4 = vec_sra (vy4, shift); \
- vx5 = vec_sra (vy5, shift); \
- vx6 = vec_sra (vy6, shift); \
- vx7 = vec_sra (vy7, shift);
-
+ vy0 = vec_adds(t7, t1); \
+ vy7 = vec_subs(t7, t1); \
+ vy1 = vec_mradds(c4, t3, t5); \
+ vy6 = vec_mradds(mc4, t3, t5); \
+ vy2 = vec_mradds(c4, t4, t0); \
+ vy5 = vec_mradds(mc4, t4, t0); \
+ vy3 = vec_adds(t2, t6); \
+ vy4 = vec_subs(t2, t6)
+
+#define IDCT \
+ vec_s16 vy0, vy1, vy2, vy3, vy4, vy5, vy6, vy7; \
+ vec_s16 t0, t1, t2, t3, t4, t5, t6, t7, t8; \
+ \
+ vec_s16 c4 = vec_splat(constants[0], 0); \
+ vec_s16 a0 = vec_splat(constants[0], 1); \
+ vec_s16 a1 = vec_splat(constants[0], 2); \
+ vec_s16 a2 = vec_splat(constants[0], 3); \
+ vec_s16 mc4 = vec_splat(constants[0], 4); \
+ vec_s16 ma2 = vec_splat(constants[0], 5); \
+ vec_s16 bias = (vec_s16) vec_splat((vec_s32) constants[0], 3); \
+ \
+ vec_s16 zero = vec_splat_s16(0); \
+ vec_u16 shift = vec_splat_u16(4); \
+ \
+ vec_s16 vx0 = vec_mradds(vec_sl(block[0], shift), constants[1], zero); \
+ vec_s16 vx1 = vec_mradds(vec_sl(block[1], shift), constants[2], zero); \
+ vec_s16 vx2 = vec_mradds(vec_sl(block[2], shift), constants[3], zero); \
+ vec_s16 vx3 = vec_mradds(vec_sl(block[3], shift), constants[4], zero); \
+ vec_s16 vx4 = vec_mradds(vec_sl(block[4], shift), constants[1], zero); \
+ vec_s16 vx5 = vec_mradds(vec_sl(block[5], shift), constants[4], zero); \
+ vec_s16 vx6 = vec_mradds(vec_sl(block[6], shift), constants[3], zero); \
+ vec_s16 vx7 = vec_mradds(vec_sl(block[7], shift), constants[2], zero); \
+ \
+ IDCT_HALF; \
+ \
+ vx0 = vec_mergeh(vy0, vy4); \
+ vx1 = vec_mergel(vy0, vy4); \
+ vx2 = vec_mergeh(vy1, vy5); \
+ vx3 = vec_mergel(vy1, vy5); \
+ vx4 = vec_mergeh(vy2, vy6); \
+ vx5 = vec_mergel(vy2, vy6); \
+ vx6 = vec_mergeh(vy3, vy7); \
+ vx7 = vec_mergel(vy3, vy7); \
+ \
+ vy0 = vec_mergeh(vx0, vx4); \
+ vy1 = vec_mergel(vx0, vx4); \
+ vy2 = vec_mergeh(vx1, vx5); \
+ vy3 = vec_mergel(vx1, vx5); \
+ vy4 = vec_mergeh(vx2, vx6); \
+ vy5 = vec_mergel(vx2, vx6); \
+ vy6 = vec_mergeh(vx3, vx7); \
+ vy7 = vec_mergel(vx3, vx7); \
+ \
+ vx0 = vec_adds(vec_mergeh(vy0, vy4), bias); \
+ vx1 = vec_mergel(vy0, vy4); \
+ vx2 = vec_mergeh(vy1, vy5); \
+ vx3 = vec_mergel(vy1, vy5); \
+ vx4 = vec_mergeh(vy2, vy6); \
+ vx5 = vec_mergel(vy2, vy6); \
+ vx6 = vec_mergeh(vy3, vy7); \
+ vx7 = vec_mergel(vy3, vy7); \
+ \
+ IDCT_HALF; \
+ \
+ shift = vec_splat_u16(6); \
+ vx0 = vec_sra(vy0, shift); \
+ vx1 = vec_sra(vy1, shift); \
+ vx2 = vec_sra(vy2, shift); \
+ vx3 = vec_sra(vy3, shift); \
+ vx4 = vec_sra(vy4, shift); \
+ vx5 = vec_sra(vy5, shift); \
+ vx6 = vec_sra(vy6, shift); \
+ vx7 = vec_sra(vy7, shift)
static const vec_s16 constants[5] = {
- {23170, 13573, 6518, 21895, -23170, -21895, 32, 31},
- {16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725},
- {22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521},
- {21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692},
- {19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722}
+ { 23170, 13573, 6518, 21895, -23170, -21895, 32, 31 },
+ { 16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725 },
+ { 22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521 },
+ { 21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692 },
+ { 19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722 }
};
-void ff_idct_put_altivec(uint8_t* dest, int stride, int16_t *blk)
+void ff_idct_put_altivec(uint8_t *dest, int stride, int16_t *blk)
{
- vec_s16 *block = (vec_s16*)blk;
+ vec_s16 *block = (vec_s16 *) blk;
vec_u8 tmp;
- IDCT
-
-#define COPY(dest,src) \
- tmp = vec_packsu (src, src); \
- vec_ste ((vec_u32)tmp, 0, (unsigned int *)dest); \
- vec_ste ((vec_u32)tmp, 4, (unsigned int *)dest);
-
- COPY (dest, vx0) dest += stride;
- COPY (dest, vx1) dest += stride;
- COPY (dest, vx2) dest += stride;
- COPY (dest, vx3) dest += stride;
- COPY (dest, vx4) dest += stride;
- COPY (dest, vx5) dest += stride;
- COPY (dest, vx6) dest += stride;
- COPY (dest, vx7)
+ IDCT;
+
+#define COPY(dest, src) \
+ tmp = vec_packsu(src, src); \
+ vec_ste((vec_u32) tmp, 0, (unsigned int *) dest); \
+ vec_ste((vec_u32) tmp, 4, (unsigned int *) dest)
+
+ COPY(dest, vx0);
+ dest += stride;
+ COPY(dest, vx1);
+ dest += stride;
+ COPY(dest, vx2);
+ dest += stride;
+ COPY(dest, vx3);
+ dest += stride;
+ COPY(dest, vx4);
+ dest += stride;
+ COPY(dest, vx5);
+ dest += stride;
+ COPY(dest, vx6);
+ dest += stride;
+ COPY(dest, vx7);
}
-void ff_idct_add_altivec(uint8_t* dest, int stride, int16_t *blk)
+void ff_idct_add_altivec(uint8_t *dest, int stride, int16_t *blk)
{
- vec_s16 *block = (vec_s16*)blk;
+ vec_s16 *block = (vec_s16 *) blk;
vec_u8 tmp;
vec_s16 tmp2, tmp3;
vec_u8 perm0;
vec_u8 perm1;
vec_u8 p0, p1, p;
- IDCT
-
- p0 = vec_lvsl (0, dest);
- p1 = vec_lvsl (stride, dest);
- p = vec_splat_u8 (-1);
- perm0 = vec_mergeh (p, p0);
- perm1 = vec_mergeh (p, p1);
-
-#define ADD(dest,src,perm) \
- /* *(uint64_t *)&tmp = *(uint64_t *)dest; */ \
- tmp = vec_ld (0, dest); \
- tmp2 = (vec_s16)vec_perm (tmp, (vec_u8)zero, perm); \
- tmp3 = vec_adds (tmp2, src); \
- tmp = vec_packsu (tmp3, tmp3); \
- vec_ste ((vec_u32)tmp, 0, (unsigned int *)dest); \
- vec_ste ((vec_u32)tmp, 4, (unsigned int *)dest);
-
- ADD (dest, vx0, perm0) dest += stride;
- ADD (dest, vx1, perm1) dest += stride;
- ADD (dest, vx2, perm0) dest += stride;
- ADD (dest, vx3, perm1) dest += stride;
- ADD (dest, vx4, perm0) dest += stride;
- ADD (dest, vx5, perm1) dest += stride;
- ADD (dest, vx6, perm0) dest += stride;
- ADD (dest, vx7, perm1)
+ IDCT;
+
+ p0 = vec_lvsl(0, dest);
+ p1 = vec_lvsl(stride, dest);
+ p = vec_splat_u8(-1);
+ perm0 = vec_mergeh(p, p0);
+ perm1 = vec_mergeh(p, p1);
+
+#define ADD(dest, src, perm) \
+ /* *(uint64_t *) &tmp = *(uint64_t *) dest; */ \
+ tmp = vec_ld(0, dest); \
+ tmp2 = (vec_s16) vec_perm(tmp, (vec_u8) zero, perm); \
+ tmp3 = vec_adds(tmp2, src); \
+ tmp = vec_packsu(tmp3, tmp3); \
+ vec_ste((vec_u32) tmp, 0, (unsigned int *) dest); \
+ vec_ste((vec_u32) tmp, 4, (unsigned int *) dest)
+
+ ADD(dest, vx0, perm0);
+ dest += stride;
+ ADD(dest, vx1, perm1);
+ dest += stride;
+ ADD(dest, vx2, perm0);
+ dest += stride;
+ ADD(dest, vx3, perm1);
+ dest += stride;
+ ADD(dest, vx4, perm0);
+ dest += stride;
+ ADD(dest, vx5, perm1);
+ dest += stride;
+ ADD(dest, vx6, perm0);
+ dest += stride;
+ ADD(dest, vx7, perm1);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/int_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/int_altivec.c
index d4e0c852ea0..fe0e5f68e0a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/int_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/int_altivec.c
@@ -19,9 +19,9 @@
*/
/**
- ** @file
- ** integer misc ops.
- **/
+ * @file
+ * miscellaneous integer operations
+ */
#include "config.h"
#if HAVE_ALTIVEC_H
@@ -31,51 +31,50 @@
#include "libavutil/attributes.h"
#include "libavutil/ppc/types_altivec.h"
#include "libavcodec/dsputil.h"
-
#include "dsputil_altivec.h"
static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2,
- int size) {
- int i, size16;
+ int size)
+{
+ int i, size16 = size >> 4;
vector signed char vpix1;
- vector signed short vpix2, vdiff, vpix1l,vpix1h;
- union { vector signed int vscore;
- int32_t score[4];
- } u;
- u.vscore = vec_splat_s32(0);
-//
-//XXX lazy way, fix it later
-
-#define vec_unaligned_load(b) \
- vec_perm(vec_ld(0,b),vec_ld(15,b),vec_lvsl(0, b));
-
- size16 = size >> 4;
- while(size16) {
-// score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
- //load pix1 and the first batch of pix2
+ vector signed short vpix2, vdiff, vpix1l, vpix1h;
+ union {
+ vector signed int vscore;
+ int32_t score[4];
+ } u = { .vscore = vec_splat_s32(0) };
+
+// XXX lazy way, fix it later
+
+#define vec_unaligned_load(b) \
+ vec_perm(vec_ld(0, b), vec_ld(15, b), vec_lvsl(0, b));
+
+ while (size16) {
+ // score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+ // load pix1 and the first batch of pix2
vpix1 = vec_unaligned_load(pix1);
vpix2 = vec_unaligned_load(pix2);
pix2 += 8;
- //unpack
+ // unpack
vpix1h = vec_unpackh(vpix1);
vdiff = vec_sub(vpix1h, vpix2);
vpix1l = vec_unpackl(vpix1);
// load another batch from pix2
- vpix2 = vec_unaligned_load(pix2);
+ vpix2 = vec_unaligned_load(pix2);
u.vscore = vec_msum(vdiff, vdiff, u.vscore);
- vdiff = vec_sub(vpix1l, vpix2);
+ vdiff = vec_sub(vpix1l, vpix2);
u.vscore = vec_msum(vdiff, vdiff, u.vscore);
- pix1 += 16;
- pix2 += 8;
+ pix1 += 16;
+ pix2 += 8;
size16--;
}
u.vscore = vec_sums(u.vscore, vec_splat_s32(0));
size %= 16;
- for (i = 0; i < size; i++) {
- u.score[3] += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
- }
+ for (i = 0; i < size; i++)
+ u.score[3] += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+
return u.score[3];
}
@@ -88,56 +87,64 @@ static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
register vec_s32 res = vec_splat_s32(0), t;
int32_t ires;
- for(i = 0; i < order; i += 8){
+ for (i = 0; i < order; i += 8) {
vec1 = vec_unaligned_load(v1);
- t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
- res = vec_sums(t, res);
- v1 += 8;
- v2 += 8;
+ t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
+ res = vec_sums(t, res);
+ v1 += 8;
+ v2 += 8;
}
res = vec_splat(res, 3);
vec_ste(res, 0, &ires);
+
return ires;
}
-static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
+static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1,
+ const int16_t *v2,
+ const int16_t *v3,
+ int order, int mul)
{
LOAD_ZERO;
- vec_s16 *pv1 = (vec_s16*)v1;
- register vec_s16 muls = {mul,mul,mul,mul,mul,mul,mul,mul};
+ vec_s16 *pv1 = (vec_s16 *) v1;
+ register vec_s16 muls = { mul, mul, mul, mul, mul, mul, mul, mul };
register vec_s16 t0, t1, i0, i1, i4;
register vec_s16 i2 = vec_ld(0, v2), i3 = vec_ld(0, v3);
register vec_s32 res = zero_s32v;
register vec_u8 align = vec_lvsl(0, v2);
int32_t ires;
+
order >>= 4;
do {
- i1 = vec_ld(16, v2);
- t0 = vec_perm(i2, i1, align);
- i2 = vec_ld(32, v2);
- t1 = vec_perm(i1, i2, align);
- i0 = pv1[0];
- i1 = pv1[1];
- res = vec_msum(t0, i0, res);
- res = vec_msum(t1, i1, res);
- i4 = vec_ld(16, v3);
- t0 = vec_perm(i3, i4, align);
- i3 = vec_ld(32, v3);
- t1 = vec_perm(i4, i3, align);
+ i1 = vec_ld(16, v2);
+ t0 = vec_perm(i2, i1, align);
+ i2 = vec_ld(32, v2);
+ t1 = vec_perm(i1, i2, align);
+ i0 = pv1[0];
+ i1 = pv1[1];
+ res = vec_msum(t0, i0, res);
+ res = vec_msum(t1, i1, res);
+ i4 = vec_ld(16, v3);
+ t0 = vec_perm(i3, i4, align);
+ i3 = vec_ld(32, v3);
+ t1 = vec_perm(i4, i3, align);
pv1[0] = vec_mladd(t0, muls, i0);
pv1[1] = vec_mladd(t1, muls, i1);
- pv1 += 2;
- v2 += 16;
- v3 += 16;
- } while(--order);
+ pv1 += 2;
+ v2 += 16;
+ v3 += 16;
+ } while (--order);
res = vec_splat(vec_sums(res, zero_s32v), 3);
vec_ste(res, 0, &ires);
+
return ires;
}
av_cold void ff_int_init_altivec(DSPContext *c, AVCodecContext *avctx)
{
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_altivec;
+
c->scalarproduct_int16 = scalarproduct_int16_altivec;
+
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_altivec;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/mpegaudiodsp_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/mpegaudiodsp_altivec.c
index 091f9a39114..09f6f29e7a7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/mpegaudiodsp_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/mpegaudiodsp_altivec.c
@@ -25,7 +25,6 @@
#include "libavutil/internal.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/mpegaudiodsp.h"
-#include "dsputil_altivec.h"
#if HAVE_ALTIVEC
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
index cedc1c8bf63..d39c8f32542 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
@@ -30,7 +30,6 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/mpegvideo.h"
-#include "dsputil_altivec.h"
#if HAVE_ALTIVEC
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
index 1b73dd03fa6..adaae0ca5e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/vc1dsp_altivec.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/vc1dsp.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/vp3dsp_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/vp3dsp_altivec.c
index 56c2d0b8224..5915a43d292 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/vp3dsp_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/vp3dsp_altivec.c
@@ -26,7 +26,6 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/vp3dsp.h"
-#include "dsputil_altivec.h"
#if HAVE_ALTIVEC
diff --git a/chromium/third_party/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c b/chromium/third_party/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
index c858d8a45f8..2d558a5171d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
@@ -26,7 +26,7 @@
#include "libavutil/ppc/types_altivec.h"
#include "libavutil/ppc/util_altivec.h"
#include "libavcodec/vp8dsp.h"
-#include "dsputil_altivec.h"
+#include "hpeldsp_altivec.h"
#if HAVE_ALTIVEC
#define REPT4(...) { __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ }
@@ -311,7 +311,8 @@ static void put_vp8_pixels16_altivec(uint8_t *dst, ptrdiff_t dstride, uint8_t *s
#endif /* HAVE_ALTIVEC */
-av_cold void ff_vp8dsp_init_ppc(VP8DSPContext *c)
+
+av_cold void ff_vp78dsp_init_ppc(VP8DSPContext *c)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
diff --git a/chromium/third_party/ffmpeg/libavcodec/proresdsp.c b/chromium/third_party/ffmpeg/libavcodec/proresdsp.c
index 4ff219e58b5..b5230649508 100644
--- a/chromium/third_party/ffmpeg/libavcodec/proresdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/proresdsp.c
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/common.h"
-#include "dct.h"
#include "dsputil.h"
#include "proresdsp.h"
#include "simple_idct.h"
@@ -31,9 +31,8 @@
#define CLIP_MIN (1 << (PRORES_BITS_PER_SAMPLE - 8)) ///< minimum value for clipping resulting pixels
#define CLIP_MAX (1 << PRORES_BITS_PER_SAMPLE) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels
-#define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
+#define CLIP(x) (av_clip((x), CLIP_MIN, CLIP_MAX))
-#if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
/**
* Add bias value, clamp and output pixels of a slice
*/
@@ -45,7 +44,7 @@ static void put_pixels(uint16_t *dst, int stride, const int16_t *in)
for (x = 0; x < 8; x++) {
src_offset = (y << 3) + x;
- dst[dst_offset + x] = CLIP_AND_BIAS(in[src_offset]);
+ dst[dst_offset + x] = CLIP(in[src_offset]);
}
}
}
@@ -55,38 +54,15 @@ static void prores_idct_put_c(uint16_t *out, int linesize, int16_t *block, const
ff_prores_idct(block, qmat);
put_pixels(out, linesize >> 1, block);
}
-#endif
-
-#if CONFIG_PRORES_KS_ENCODER
-static void prores_fdct_c(const uint16_t *src, int linesize, int16_t *block)
-{
- int x, y;
- const uint16_t *tsrc = src;
-
- for (y = 0; y < 8; y++) {
- for (x = 0; x < 8; x++)
- block[y * 8 + x] = tsrc[x];
- tsrc += linesize >> 1;
- }
- ff_jpeg_fdct_islow_10(block);
-}
-#endif
av_cold void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
{
-#if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
dsp->idct_put = prores_idct_put_c;
dsp->idct_permutation_type = FF_NO_IDCT_PERM;
- if (ARCH_X86) ff_proresdsp_x86_init(dsp, avctx);
+ if (ARCH_X86)
+ ff_proresdsp_init_x86(dsp, avctx);
ff_init_scantable_permutation(dsp->idct_permutation,
dsp->idct_permutation_type);
-#endif
-#if CONFIG_PRORES_KS_ENCODER
- dsp->fdct = prores_fdct_c;
- dsp->dct_permutation_type = FF_NO_IDCT_PERM;
- ff_init_scantable_permutation(dsp->dct_permutation,
- dsp->dct_permutation_type);
-#endif
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/proresdsp.h b/chromium/third_party/ffmpeg/libavcodec/proresdsp.h
index 706162af529..07871cfbd82 100644
--- a/chromium/third_party/ffmpeg/libavcodec/proresdsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/proresdsp.h
@@ -31,14 +31,11 @@
typedef struct ProresDSPContext {
int idct_permutation_type;
uint8_t idct_permutation[64];
- int dct_permutation_type;
- uint8_t dct_permutation[64];
void (* idct_put) (uint16_t *out, int linesize, int16_t *block, const int16_t *qmat);
- void (* fdct) (const uint16_t *src, int linesize, int16_t *block);
} ProresDSPContext;
void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx);
-void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx);
+void ff_proresdsp_init_x86(ProresDSPContext *dsp, AVCodecContext *avctx);
#endif /* AVCODEC_PRORESDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/proresenc_kostya.c b/chromium/third_party/ffmpeg/libavcodec/proresenc_kostya.c
index 71c2cb49f2a..ea1fd8ae7fc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/proresenc_kostya.c
+++ b/chromium/third_party/ffmpeg/libavcodec/proresenc_kostya.c
@@ -26,11 +26,11 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
+#include "dct.h"
#include "dsputil.h"
#include "put_bits.h"
#include "bytestream.h"
#include "internal.h"
-#include "proresdsp.h"
#include "proresdata.h"
#define CFACTOR_Y422 2
@@ -193,9 +193,11 @@ typedef struct ProresContext {
int16_t quants[MAX_STORED_Q][64];
int16_t custom_q[64];
const uint8_t *quant_mat;
+ const uint8_t *scantable;
- ProresDSPContext dsp;
- ScanTable scantable;
+ void (* fdct)(DSPContext *dsp, const uint16_t *src,
+ int linesize, int16_t *block);
+ DSPContext dsp;
int mb_width, mb_height;
int mbs_per_slice;
@@ -264,27 +266,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
mb_width * sizeof(*emu_buf));
}
if (!is_chroma) {
- ctx->dsp.fdct(esrc, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
- ctx->dsp.fdct(esrc + 8, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
blocks += 64;
}
- ctx->dsp.fdct(esrc + elinesize * 4, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
- ctx->dsp.fdct(esrc + elinesize * 4 + 8, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64;
}
} else {
- ctx->dsp.fdct(esrc, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
blocks += 64;
- ctx->dsp.fdct(esrc + elinesize * 4, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
- ctx->dsp.fdct(esrc + 8, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
blocks += 64;
- ctx->dsp.fdct(esrc + elinesize * 4 + 8, elinesize, blocks);
+ ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
blocks += 64;
}
}
@@ -429,7 +431,7 @@ static int encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
- ctx->scantable.permutated, qmat);
+ ctx->scantable, qmat);
flush_put_bits(pb);
return (put_bits_count(pb) - saved_pos) >> 3;
@@ -676,7 +678,7 @@ static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
bits = estimate_dcs(error, td->blocks[plane], blocks_per_slice, qmat[0]);
bits += estimate_acs(error, td->blocks[plane], blocks_per_slice,
- plane_size_factor, ctx->scantable.permutated, qmat);
+ plane_size_factor, ctx->scantable, qmat);
return FFALIGN(bits, 8);
}
@@ -1064,6 +1066,20 @@ static av_cold int encode_close(AVCodecContext *avctx)
return 0;
}
+static void prores_fdct(DSPContext *dsp, const uint16_t *src,
+ int linesize, int16_t *block)
+{
+ int x, y;
+ const uint16_t *tsrc = src;
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++)
+ block[y * 8 + x] = tsrc[x];
+ tsrc += linesize >> 1;
+ }
+ dsp->fdct(block);
+}
+
static av_cold int encode_init(AVCodecContext *avctx)
{
ProresContext *ctx = avctx->priv_data;
@@ -1077,10 +1093,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
- ff_proresdsp_init(&ctx->dsp, avctx);
- ff_init_scantable(ctx->dsp.dct_permutation, &ctx->scantable,
- interlaced ? ff_prores_interlaced_scan
- : ff_prores_progressive_scan);
+ ctx->fdct = prores_fdct;
+ ctx->scantable = interlaced ? ff_prores_interlaced_scan
+ : ff_prores_progressive_scan;
+ ff_dsputil_init(&ctx->dsp, avctx);
mps = ctx->mbs_per_slice;
if (mps & (mps - 1)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/psymodel.c b/chromium/third_party/ffmpeg/libavcodec/psymodel.c
index bfc85b3bc56..22d2497f785 100644
--- a/chromium/third_party/ffmpeg/libavcodec/psymodel.c
+++ b/chromium/third_party/ffmpeg/libavcodec/psymodel.c
@@ -35,10 +35,10 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
int i, j, k = 0;
ctx->avctx = avctx;
- ctx->ch = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
- ctx->group = av_mallocz(sizeof(ctx->group[0]) * num_groups);
- ctx->bands = av_malloc (sizeof(ctx->bands[0]) * num_lens);
- ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
+ ctx->ch = av_mallocz_array(sizeof(ctx->ch[0]), avctx->channels * 2);
+ ctx->group = av_mallocz_array(sizeof(ctx->group[0]), num_groups);
+ ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens);
+ ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens);
memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens);
memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens);
@@ -112,7 +112,7 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
FF_FILTER_MODE_LOWPASS, FILT_ORDER,
cutoff_coeff, 0.0, 0.0);
if (ctx->fcoeffs) {
- ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
+ ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels);
for (i = 0; i < avctx->channels; i++)
ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/pthread_frame.c b/chromium/third_party/ffmpeg/libavcodec/pthread_frame.c
index 51a163384b7..f01ac559024 100644
--- a/chromium/third_party/ffmpeg/libavcodec/pthread_frame.c
+++ b/chromium/third_party/ffmpeg/libavcodec/pthread_frame.c
@@ -121,8 +121,13 @@ typedef struct FrameThreadContext {
int die; ///< Set when threads should exit.
} FrameThreadContext;
+#if FF_API_GET_BUFFER
#define THREAD_SAFE_CALLBACKS(avctx) \
((avctx)->thread_safe_callbacks || (!(avctx)->get_buffer && (avctx)->get_buffer2 == avcodec_default_get_buffer2))
+#else
+#define THREAD_SAFE_CALLBACKS(avctx) \
+((avctx)->thread_safe_callbacks || (avctx)->get_buffer2 == avcodec_default_get_buffer2)
+#endif
/**
* Codec worker thread.
@@ -152,6 +157,13 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
p->got_frame = 0;
p->result = codec->decode(avctx, p->frame, &p->got_frame, &p->avpkt);
+ if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) {
+ if (avctx->internal->allocate_progress)
+ av_log(avctx, AV_LOG_ERROR, "A frame threaded decoder did not "
+ "free the frame on failure. This is a bug, please report it.\n");
+ av_frame_unref(p->frame);
+ }
+
if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);
pthread_mutex_lock(&p->progress_mutex);
@@ -219,6 +231,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->sample_rate = src->sample_rate;
dst->sample_fmt = src->sample_fmt;
dst->channel_layout = src->channel_layout;
+ dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
}
if (for_user) {
@@ -310,6 +323,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
FrameThreadContext *fctx = p->parent;
PerThreadContext *prev_thread = fctx->prev_thread;
const AVCodec *codec = p->avctx->codec;
+ int ret;
if (!avpkt->size && !(codec->capabilities & CODEC_CAP_DELAY)) return 0;
@@ -333,6 +347,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
}
}
+ av_packet_free_side_data(&p->avpkt);
av_buffer_unref(&p->avpkt.buf);
p->avpkt = *avpkt;
if (avpkt->buf)
@@ -347,6 +362,10 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
memcpy(p->buf, avpkt->data, avpkt->size);
memset(p->buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
+ if ((ret = av_copy_packet_side_data(&p->avpkt, avpkt)) < 0) {
+ pthread_mutex_unlock(&p->mutex);
+ return ret;
+ }
p->state = STATE_SETTING_UP;
pthread_cond_signal(&p->input_cond);
@@ -585,6 +604,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
pthread_cond_destroy(&p->input_cond);
pthread_cond_destroy(&p->progress_cond);
pthread_cond_destroy(&p->output_cond);
+ av_packet_free_side_data(&p->avpkt);
av_buffer_unref(&p->avpkt.buf);
av_freep(&p->buf);
av_freep(&p->released_buffers);
@@ -650,6 +670,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
p->frame = av_frame_alloc();
if (!p->frame) {
err = AVERROR(ENOMEM);
+ av_freep(&copy);
goto error;
}
@@ -719,8 +740,6 @@ void ff_thread_flush(AVCodecContext *avctx)
if (fctx->prev_thread) {
if (fctx->prev_thread != &fctx->threads[0])
update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
- if (avctx->codec->flush)
- avctx->codec->flush(fctx->threads[0].avctx);
}
fctx->next_decoding = fctx->next_finished = 0;
@@ -733,6 +752,9 @@ void ff_thread_flush(AVCodecContext *avctx)
av_frame_unref(p->frame);
release_delayed_buffers(p);
+
+ if (avctx->codec->flush)
+ avctx->codec->flush(p->avctx);
}
}
@@ -816,7 +838,7 @@ enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixe
PerThreadContext *p = avctx->internal->thread_ctx;
if (!(avctx->active_thread_type & FF_THREAD_FRAME) || avctx->thread_safe_callbacks ||
avctx->get_format == avcodec_default_get_format)
- return avctx->get_format(avctx, fmt);
+ return ff_get_format(avctx, fmt);
if (p->state != STATE_SETTING_UP) {
av_log(avctx, AV_LOG_ERROR, "get_format() cannot be called after ff_thread_finish_setup()\n");
return -1;
@@ -859,7 +881,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->get_buffer2 == avcodec_default_get_buffer2);
FF_ENABLE_DEPRECATION_WARNINGS
- if (!f->f->buf[0])
+ if (!f->f || !f->f->buf[0])
return;
if (avctx->debug & FF_DEBUG_BUFFERS)
diff --git a/chromium/third_party/ffmpeg/libavcodec/put_bits.h b/chromium/third_party/ffmpeg/libavcodec/put_bits.h
index e2c4a617912..8081fb9ea5a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/put_bits.h
+++ b/chromium/third_party/ffmpeg/libavcodec/put_bits.h
@@ -27,16 +27,11 @@
#define AVCODEC_PUT_BITS_H
#include <stdint.h>
-#include <stdlib.h>
+#include <stddef.h>
#include <assert.h>
-#include "libavutil/bswap.h"
-#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
-#include "libavutil/log.h"
#include "libavutil/avassert.h"
-#include "mathops.h"
-#include "config.h"
typedef struct PutBitContext {
uint32_t bit_buf;
diff --git a/chromium/third_party/ffmpeg/libavcodec/qcelpdata.h b/chromium/third_party/ffmpeg/libavcodec/qcelpdata.h
index 7ddeed40cc7..931c990b09d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/qcelpdata.h
+++ b/chromium/third_party/ffmpeg/libavcodec/qcelpdata.h
@@ -66,7 +66,7 @@ typedef struct QCELPFrame {
} QCELPFrame;
/**
- * pre-calculated table for hammsinc function
+ * Pre-calculated table for hammsinc function.
* Only half of the table is needed because of symmetry.
*
* TIA/EIA/IS-733 2.4.5.2-2/3
@@ -82,7 +82,7 @@ typedef struct QCELPBitmap {
#define QCELP_OF(variable, bit, len) {offsetof(QCELPFrame, variable), bit, len}
/**
- * bitmap unpacking tables for RATE_FULL
+ * Bitmap unpacking tables for RATE_FULL
*
* TIA/EIA/IS-733 Table 2.4.7.1-1
*/
@@ -169,7 +169,7 @@ static const QCELPBitmap qcelp_rate_full_bitmap[] = {
};
/**
- * bitmap unpacking tables for RATE_HALF
+ * Bitmap unpacking tables for RATE_HALF
*
* TIA/EIA/IS-733 Table 2.4.7.2-1
*/
@@ -211,7 +211,7 @@ static const QCELPBitmap qcelp_rate_half_bitmap[] = {
};
/**
- * bitmap unpacking tables for RATE_QUARTER
+ * Bitmap unpacking tables for RATE_QUARTER
*
* TIA/EIA/IS-733 Table 2.4.7.3-1
*/
@@ -232,7 +232,7 @@ static const QCELPBitmap qcelp_rate_quarter_bitmap[] = {
};
/**
- * bitmap unpacking tables for RATE_OCTAVE
+ * Bitmap unpacking tables for RATE_OCTAVE
*
* trick: CBSEED is written into QCELPContext.cbsign[15],
* which is not used for RATE_OCTAVE.
@@ -262,7 +262,7 @@ static const QCELPBitmap qcelp_rate_octave_bitmap[] = {
};
/**
- * position of the bitmapping data for each packet type in
+ * Bitmapping data position for each packet type in
* the QCELPContext
*/
static const QCELPBitmap * const qcelp_unpacking_bitmaps_per_rate[5] = {
@@ -420,12 +420,12 @@ static const qcelp_vector * const qcelp_lspvq[5] = {
};
/**
- * the final gain scalefactor before clipping into a usable output float
+ * The final gain scalefactor before clipping into a usable output float
*/
#define QCELP_SCALE 8192.
/**
- * table for computing Ga (decoded linear codebook gain magnitude)
+ * Table for computing Ga (decoded linear codebook gain magnitude)
*
* @note The table could fit in int16_t in x*8 form, but it seems
* to be slower on x86
@@ -452,7 +452,7 @@ static const float qcelp_g12ga[61] = {
1000.000/QCELP_SCALE};
/**
- * circular codebook for rate 1 frames in x*100 form
+ * Circular codebook for rate 1 frames in x*100 form
*
* TIA/EIA/IS-733 2.4.6.1-2
*/
@@ -477,7 +477,7 @@ static const int16_t qcelp_rate_full_codebook[128] = {
#define QCELP_RATE_FULL_CODEBOOK_RATIO .01
/**
- * circular codebook for rate 1/2 frames in x*2 form
+ * Circular codebook for rate 1/2 frames in x*2 form
*
* TIA/EIA/IS-733 2.4.6.1-1
*/
@@ -511,7 +511,7 @@ static const int8_t qcelp_rate_half_codebook[128] = {
#define QCELP_SQRT1887 1.373681186
/**
- * table for impulse response of BPF used to filter
+ * Table for impulse response of BPF used to filter
* the white excitation for bitrate 1/4 synthesis
*
* Only half the tables are needed because of symmetry.
@@ -526,14 +526,14 @@ static const double qcelp_rnd_fir_coefs[11] = {
/**
* This spread factor is used, for bitrate 1/8 and I_F_Q,
- * to force the LSP frequencies to be at least 80 Hz apart.
+ * to force LSP frequencies to be at least 80 Hz apart.
*
* TIA/EIA/IS-733 2.4.3.3.2
*/
#define QCELP_LSP_SPREAD_FACTOR 0.02
/**
- * predictor coefficient for the conversion of LSP codes
+ * Predictor coefficient for the conversion of LSP codes
* to LSP frequencies for 1/8 and I_F_Q
*
* TIA/EIA/IS-733 2.4.3.2.7-2
@@ -541,7 +541,7 @@ static const double qcelp_rnd_fir_coefs[11] = {
#define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
/**
- * initial coefficient to perform bandwidth expansion on LPC
+ * Initial coefficient to perform bandwidth expansion on LPC
*
* @note: 0.9883 looks like an approximation of 253/256.
*
diff --git a/chromium/third_party/ffmpeg/libavcodec/qcelpdec.c b/chromium/third_party/ffmpeg/libavcodec/qcelpdec.c
index 9650711e008..6f08607a583 100644
--- a/chromium/third_party/ffmpeg/libavcodec/qcelpdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/qcelpdec.c
@@ -319,7 +319,8 @@ static void compute_svector(QCELPContext *q, const float *gain,
tmp_gain = gain[i] * QCELP_RATE_FULL_CODEBOOK_RATIO;
cindex = -q->frame.cindex[i];
for (j = 0; j < 10; j++)
- *cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cindex++ & 127];
+ *cdn_vector++ = tmp_gain *
+ qcelp_rate_full_codebook[cindex++ & 127];
}
break;
case RATE_HALF:
@@ -327,7 +328,8 @@ static void compute_svector(QCELPContext *q, const float *gain,
tmp_gain = gain[i] * QCELP_RATE_HALF_CODEBOOK_RATIO;
cindex = -q->frame.cindex[i];
for (j = 0; j < 40; j++)
- *cdn_vector++ = tmp_gain * qcelp_rate_half_codebook[cindex++ & 127];
+ *cdn_vector++ = tmp_gain *
+ qcelp_rate_half_codebook[cindex++ & 127];
}
break;
case RATE_QUARTER:
@@ -372,7 +374,8 @@ static void compute_svector(QCELPContext *q, const float *gain,
for (i = 0; i < 4; i++) {
tmp_gain = gain[i] * QCELP_RATE_FULL_CODEBOOK_RATIO;
for (j = 0; j < 40; j++)
- *cdn_vector++ = tmp_gain * qcelp_rate_full_codebook[cbseed++ & 127];
+ *cdn_vector++ = tmp_gain *
+ qcelp_rate_full_codebook[cbseed++ & 127];
}
break;
case SILENCE:
@@ -433,7 +436,8 @@ static const float *do_pitchfilter(float memory[303], const float v_in[160],
for (v_len = v_in + 40; v_in < v_len; v_in++) {
if (pfrac[i]) { // If it is a fractional lag...
for (j = 0, *v_out = 0.0; j < 4; j++)
- *v_out += qcelp_hammsinc_table[j] * (v_lag[j - 4] + v_lag[3 - j]);
+ *v_out += qcelp_hammsinc_table[j] *
+ (v_lag[j - 4] + v_lag[3 - j]);
} else
*v_out = *v_lag;
@@ -509,7 +513,8 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
apply_gain_ctrl(cdn_vector, v_synthesis_filtered, v_pre_filtered);
} else {
- memcpy(q->pitch_synthesis_filter_mem, cdn_vector + 17, 143 * sizeof(float));
+ memcpy(q->pitch_synthesis_filter_mem,
+ cdn_vector + 17, 143 * sizeof(float));
memcpy(q->pitch_pre_filter_mem, cdn_vector + 17, 143 * sizeof(float));
memset(q->pitch_gain, 0, sizeof(q->pitch_gain));
memset(q->pitch_lag, 0, sizeof(q->pitch_lag));
@@ -628,7 +633,7 @@ static qcelp_packet_rate determine_bitrate(AVCodecContext *avctx,
(*buf)++;
} else if ((bitrate = buf_size2bitrate(buf_size + 1)) >= 0) {
av_log(avctx, AV_LOG_WARNING,
- "Bitrate byte is missing, guessing the bitrate from packet size.\n");
+ "Bitrate byte missing, guessing bitrate from packet size.\n");
} else
return I_F_Q;
@@ -698,7 +703,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
outbuffer = (float *)frame->data[0];
if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {
- warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
+ warn_insufficient_frame_quality(avctx, "Bitrate cannot be determined.");
goto erasure;
}
@@ -766,7 +771,8 @@ erasure:
formant_mem = q->formant_mem + 10;
for (i = 0; i < 4; i++) {
interpolate_lpc(q, quantized_lspf, lpc, i);
- ff_celp_lp_synthesis_filterf(formant_mem, lpc, outbuffer + i * 40, 40, 10);
+ ff_celp_lp_synthesis_filterf(formant_mem, lpc,
+ outbuffer + i * 40, 40, 10);
formant_mem += 40;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/qtrleenc.c b/chromium/third_party/ffmpeg/libavcodec/qtrleenc.c
index 7f9525abe07..8750e3097a7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/qtrleenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/qtrleenc.c
@@ -106,7 +106,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
s->rlecode_table = av_mallocz(s->logical_width);
s->skip_table = av_mallocz(s->logical_width);
- s->length_table = av_mallocz((s->logical_width + 1)*sizeof(int));
+ s->length_table = av_mallocz_array(s->logical_width + 1, sizeof(int));
if (!s->skip_table || !s->length_table || !s->rlecode_table) {
av_log(avctx, AV_LOG_ERROR, "Error allocating memory.\n");
return AVERROR(ENOMEM);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ra144.c b/chromium/third_party/ffmpeg/libavcodec/ra144.c
index fe9a5bcb3c7..992972182f5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ra144.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ra144.c
@@ -1681,12 +1681,9 @@ unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
}
/** inverse root mean square */
-int ff_irms(const int16_t *data)
+int ff_irms(DSPContext *dsp, const int16_t *data)
{
- unsigned int i, sum = 0;
-
- for (i=0; i < BLOCKSIZE; i++)
- sum += data[i] * data[i];
+ unsigned int sum = dsp->scalarproduct_int16(data, data, BLOCKSIZE);
if (sum == 0)
return 0; /* OOPS - division by zero */
@@ -1698,14 +1695,13 @@ void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
int cba_idx, int cb1_idx, int cb2_idx,
int gval, int gain)
{
- int16_t buffer_a[BLOCKSIZE];
int16_t *block;
int m[3];
if (cba_idx) {
cba_idx += BLOCKSIZE/2 - 1;
- ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
- m[0] = (ff_irms(buffer_a) * gval) >> 12;
+ ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx);
+ m[0] = (ff_irms(&ractx->dsp, ractx->buffer_a) * gval) >> 12;
} else {
m[0] = 0;
}
@@ -1716,7 +1712,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
- add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
+ add_wav(block, gain, cba_idx, m, cba_idx? ractx->buffer_a: NULL,
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE,
diff --git a/chromium/third_party/ffmpeg/libavcodec/ra144.h b/chromium/third_party/ffmpeg/libavcodec/ra144.h
index 763495dce78..c2ee59b2dc6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ra144.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ra144.h
@@ -25,6 +25,7 @@
#include <stdint.h>
#include "lpc.h"
#include "audio_frame_queue.h"
+#include "dsputil.h"
#define NBLOCKS 4 ///< number of subblocks within a block
#define BLOCKSIZE 40 ///< subblock size in 16-bit words
@@ -35,6 +36,7 @@
typedef struct RA144Context {
AVCodecContext *avctx;
+ DSPContext dsp;
LPCContext lpc_ctx;
AudioFrameQueue afq;
int last_frame;
@@ -57,6 +59,8 @@ typedef struct RA144Context {
/** Adaptive codebook, its size is two units bigger to avoid a
* buffer overflow. */
int16_t adapt_cb[146+2];
+
+ DECLARE_ALIGNED(16, int16_t, buffer_a)[FFALIGN(BLOCKSIZE,16)];
} RA144Context;
void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
@@ -68,7 +72,7 @@ unsigned int ff_rms(const int *data);
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
int energy);
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
-int ff_irms(const int16_t *data);
+int ff_irms(DSPContext *dsp, const int16_t *data/*align 16*/);
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
int cba_idx, int cb1_idx, int cb2_idx,
int gval, int gain);
diff --git a/chromium/third_party/ffmpeg/libavcodec/ra144dec.c b/chromium/third_party/ffmpeg/libavcodec/ra144dec.c
index b7add7f3656..ab7cc68306c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ra144dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ra144dec.c
@@ -34,6 +34,7 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx)
RA144Context *ractx = avctx->priv_data;
ractx->avctx = avctx;
+ ff_dsputil_init(&ractx->dsp, avctx);
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
diff --git a/chromium/third_party/ffmpeg/libavcodec/ra144enc.c b/chromium/third_party/ffmpeg/libavcodec/ra144enc.c
index 3558254e568..1f4e5bae45b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ra144enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ra144enc.c
@@ -29,12 +29,12 @@
#include "avcodec.h"
#include "audio_frame_queue.h"
+#include "celp_filters.h"
#include "internal.h"
+#include "mathops.h"
#include "put_bits.h"
-#include "celp_filters.h"
#include "ra144.h"
-
static av_cold int ra144_encode_close(AVCodecContext *avctx)
{
RA144Context *ractx = avctx->priv_data;
@@ -61,6 +61,7 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx)
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
ractx->avctx = avctx;
+ ff_dsputil_init(&ractx->dsp, avctx);
ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
FF_LPC_TYPE_LEVINSON);
if (ret < 0)
@@ -334,7 +335,6 @@ static void ra144_encode_subblock(RA144Context *ractx,
float data[BLOCKSIZE] = { 0 }, work[LPC_ORDER + BLOCKSIZE];
float coefs[LPC_ORDER];
float zero[BLOCKSIZE], cba[BLOCKSIZE], cb1[BLOCKSIZE], cb2[BLOCKSIZE];
- int16_t cba_vect[BLOCKSIZE];
int cba_idx, cb1_idx, cb2_idx, gain;
int i, n;
unsigned m[3];
@@ -373,8 +373,8 @@ static void ra144_encode_subblock(RA144Context *ractx,
*/
memcpy(cba, work + LPC_ORDER, sizeof(cba));
- ff_copy_and_dup(cba_vect, ractx->adapt_cb, cba_idx + BLOCKSIZE / 2 - 1);
- m[0] = (ff_irms(cba_vect) * rms) >> 12;
+ ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx + BLOCKSIZE / 2 - 1);
+ m[0] = (ff_irms(&ractx->dsp, ractx->buffer_a) * rms) >> 12;
}
fixed_cb_search(work + LPC_ORDER, coefs, data, cba_idx, &cb1_idx, &cb2_idx);
for (i = 0; i < BLOCKSIZE; i++) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/ratecontrol.c b/chromium/third_party/ffmpeg/libavcodec/ratecontrol.c
index 7db248ecf5f..a621f8f79a1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ratecontrol.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ratecontrol.c
@@ -28,6 +28,7 @@
#include "libavutil/attributes.h"
#include "avcodec.h"
#include "ratecontrol.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "libavutil/eval.h"
@@ -46,11 +47,11 @@ void ff_write_pass1_stats(MpegEncContext *s)
{
snprintf(s->avctx->stats_out, 256,
"in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d "
- "fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
- s->current_picture_ptr->f.display_picture_number,
- s->current_picture_ptr->f.coded_picture_number,
+ "fcode:%d bcode:%d mc-var:%"PRId64" var:%"PRId64" icount:%d skipcount:%d hbits:%d;\n",
+ s->current_picture_ptr->f->display_picture_number,
+ s->current_picture_ptr->f->coded_picture_number,
s->pict_type,
- s->current_picture.f.quality,
+ s->current_picture.f->quality,
s->i_tex_bits,
s->p_tex_bits,
s->mv_bits,
@@ -206,7 +207,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
assert(picture_number < rcc->num_entries);
rce = &rcc->entry[picture_number];
- e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d",
+ e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%"SCNd64" var:%"SCNd64" icount:%d skipcount:%d hbits:%d",
&rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits,
&rce->mv_bits, &rce->misc_bits,
&rce->f_code, &rce->b_code,
@@ -688,7 +689,7 @@ static void adaptive_quantization(MpegEncContext *s, double q)
}
/* handle qmin/qmax clipping */
- if (s->flags & CODEC_FLAG_NORMALIZE_AQP) {
+ if (s->mpv_flags & FF_MPV_FLAG_NAQ) {
float factor = bits_sum / cplx_sum;
for (i = 0; i < s->mb_num; i++) {
float newq = q * cplx_tab[i] / bits_tab[i];
@@ -713,7 +714,7 @@ static void adaptive_quantization(MpegEncContext *s, double q)
float newq = q * cplx_tab[i] / bits_tab[i];
int intq;
- if (s->flags & CODEC_FLAG_NORMALIZE_AQP) {
+ if (s->mpv_flags & FF_MPV_FLAG_NAQ) {
newq *= bits_sum / cplx_sum;
}
@@ -753,7 +754,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
RateControlEntry local_rce, *rce;
double bits;
double rate_factor;
- int var;
+ int64_t var;
const int pict_type = s->pict_type;
Picture * const pic = &s->current_picture;
emms_c();
@@ -769,8 +770,9 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
fps = get_fps(s->avctx);
/* update predictors */
if (picture_number > 2 && !dry_run) {
- const int last_var = s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum
- : rcc->last_mc_mb_var_sum;
+ const int64_t last_var =
+ s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum
+ : rcc->last_mc_mb_var_sum;
av_assert1(s->frame_bits >= s->stuffing_bits);
update_predictor(&rcc->pred[s->last_pict_type],
rcc->last_qscale,
@@ -798,10 +800,10 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
else
dts_pic = s->last_picture_ptr;
- if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE)
+ if (!dts_pic || dts_pic->f->pts == AV_NOPTS_VALUE)
wanted_bits = (uint64_t)(s->bit_rate * (double)picture_number / fps);
else
- wanted_bits = (uint64_t)(s->bit_rate * (double)dts_pic->f.pts / fps);
+ wanted_bits = (uint64_t)(s->bit_rate * (double)dts_pic->f->pts / fps);
}
diff = s->total_bits - wanted_bits;
@@ -817,7 +819,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
assert(pict_type == rce->new_pict_type);
q = rce->new_qscale / br_compensation;
- av_dlog(s, "%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale,
+ av_dlog(s, "%f %f %f last:%d var:%"PRId64" type:%d//\n", q, rce->new_qscale,
br_compensation, s->frame_bits, var, pict_type);
} else {
rce->pict_type =
@@ -879,7 +881,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
if (s->avctx->debug & FF_DEBUG_RC) {
av_log(s->avctx, AV_LOG_DEBUG,
"%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f "
- "size:%d var:%d/%d br:%d fps:%d\n",
+ "size:%d var:%"PRId64"/%"PRId64" br:%d fps:%d\n",
av_get_picture_type_char(pict_type),
qmin, q, qmax, picture_number,
(int)wanted_bits / 1000, (int)s->total_bits / 1000,
@@ -950,8 +952,8 @@ static int init_pass2(MpegEncContext *s)
return -1;
}
- qscale = av_malloc(sizeof(double) * rcc->num_entries);
- blurred_qscale = av_malloc(sizeof(double) * rcc->num_entries);
+ qscale = av_malloc_array(rcc->num_entries, sizeof(double));
+ blurred_qscale = av_malloc_array(rcc->num_entries, sizeof(double));
toobig = 0;
for (step = 256 * 256; step > 0.0000001; step *= 0.5) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/ratecontrol.h b/chromium/third_party/ffmpeg/libavcodec/ratecontrol.h
index 959b6a23534..eeb4bb96c0c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ratecontrol.h
+++ b/chromium/third_party/ffmpeg/libavcodec/ratecontrol.h
@@ -49,8 +49,8 @@ typedef struct RateControlEntry{
uint64_t expected_bits;
int new_pict_type;
float new_qscale;
- int mc_mb_var_sum;
- int mb_var_sum;
+ int64_t mc_mb_var_sum;
+ int64_t mb_var_sum;
int i_count;
int skip_count;
int f_code;
@@ -71,8 +71,8 @@ typedef struct RateControlContext{
double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
double last_qscale;
double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
- int last_mc_mb_var_sum;
- int last_mb_var_sum;
+ int64_t last_mc_mb_var_sum;
+ int64_t last_mb_var_sum;
uint64_t i_cplx_sum[5];
uint64_t p_cplx_sum[5];
uint64_t mv_bits_sum[5];
diff --git a/chromium/third_party/ffmpeg/libavcodec/raw.c b/chromium/third_party/ffmpeg/libavcodec/raw.c
index c3f3de16947..551a1722fc6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/raw.c
+++ b/chromium/third_party/ffmpeg/libavcodec/raw.c
@@ -53,6 +53,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
{ AV_PIX_FMT_YUYV422, MKTAG('V', '4', '2', '2') },
{ AV_PIX_FMT_YUYV422, MKTAG('V', 'Y', 'U', 'Y') },
{ AV_PIX_FMT_YUYV422, MKTAG('Y', 'U', 'N', 'V') },
+ { AV_PIX_FMT_YVYU422, MKTAG('Y', 'V', 'Y', 'U') }, /* Philips */
{ AV_PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') },
{ AV_PIX_FMT_UYVY422, MKTAG('H', 'D', 'Y', 'C') },
{ AV_PIX_FMT_UYVY422, MKTAG('U', 'Y', 'N', 'V') },
@@ -178,6 +179,22 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
{ AV_PIX_FMT_GBRP16LE, MKTAG('G', '3', 00 , 16 ) },
{ AV_PIX_FMT_GBRP16BE, MKTAG(16 , 00 , '3', 'G') },
+ { AV_PIX_FMT_XYZ12LE, MKTAG('X', 'Y', 'Z' , 36 ) },
+ { AV_PIX_FMT_XYZ12BE, MKTAG(36 , 'Z' , 'Y', 'X') },
+
+ { AV_PIX_FMT_BAYER_BGGR8, MKTAG(0xBA, 'B', 'G', 8 ) },
+ { AV_PIX_FMT_BAYER_BGGR16LE, MKTAG(0xBA, 'B', 'G', 16 ) },
+ { AV_PIX_FMT_BAYER_BGGR16BE, MKTAG(16 , 'G', 'B', 0xBA) },
+ { AV_PIX_FMT_BAYER_RGGB8, MKTAG(0xBA, 'R', 'G', 8 ) },
+ { AV_PIX_FMT_BAYER_RGGB16LE, MKTAG(0xBA, 'R', 'G', 16 ) },
+ { AV_PIX_FMT_BAYER_RGGB16BE, MKTAG(16 , 'G', 'R', 0xBA) },
+ { AV_PIX_FMT_BAYER_GBRG8, MKTAG(0xBA, 'G', 'B', 8 ) },
+ { AV_PIX_FMT_BAYER_GBRG16LE, MKTAG(0xBA, 'G', 'B', 16 ) },
+ { AV_PIX_FMT_BAYER_GBRG16BE, MKTAG(16, 'B', 'G', 0xBA) },
+ { AV_PIX_FMT_BAYER_GRBG8, MKTAG(0xBA, 'G', 'R', 8 ) },
+ { AV_PIX_FMT_BAYER_GRBG16LE, MKTAG(0xBA, 'G', 'R', 16 ) },
+ { AV_PIX_FMT_BAYER_GRBG16BE, MKTAG(16, 'R', 'G', 0xBA) },
+
/* quicktime */
{ AV_PIX_FMT_YUV420P, MKTAG('R', '4', '2', '0') }, /* Radius DV YUV PAL */
{ AV_PIX_FMT_YUV411P, MKTAG('R', '4', '1', '1') }, /* Radius DV YUV NTSC */
@@ -203,7 +220,6 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
/* special */
{ AV_PIX_FMT_RGB565LE,MKTAG( 3 , 0 , 0 , 0 ) }, /* flipped RGB565LE */
{ AV_PIX_FMT_YUV444P, MKTAG('Y', 'V', '2', '4') }, /* YUV444P, swapped UV */
- { AV_PIX_FMT_YUYV422, MKTAG('Y', 'V', 'Y', 'U') }, /* YUYV, swapped UV */
{ AV_PIX_FMT_NONE, 0 },
};
@@ -218,3 +234,28 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
}
return 0;
}
+
+const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
+ { AV_PIX_FMT_MONOWHITE, 1 },
+ { AV_PIX_FMT_PAL8, 2 },
+ { AV_PIX_FMT_PAL8, 4 },
+ { AV_PIX_FMT_PAL8, 8 },
+ { AV_PIX_FMT_RGB444LE, 12 },
+ { AV_PIX_FMT_RGB555LE, 15 },
+ { AV_PIX_FMT_RGB555LE, 16 },
+ { AV_PIX_FMT_BGR24, 24 },
+ { AV_PIX_FMT_BGRA, 32 },
+ { AV_PIX_FMT_NONE, 0 },
+};
+
+const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
+ { AV_PIX_FMT_MONOWHITE, 1 },
+ { AV_PIX_FMT_PAL8, 2 },
+ { AV_PIX_FMT_PAL8, 4 },
+ { AV_PIX_FMT_PAL8, 8 },
+ { AV_PIX_FMT_RGB555BE, 16 },
+ { AV_PIX_FMT_RGB24, 24 },
+ { AV_PIX_FMT_ARGB, 32 },
+ { AV_PIX_FMT_MONOWHITE,33 },
+ { AV_PIX_FMT_NONE, 0 },
+};
diff --git a/chromium/third_party/ffmpeg/libavcodec/raw.h b/chromium/third_party/ffmpeg/libavcodec/raw.h
index 3e59f28e33d..a4179930a3b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/raw.h
+++ b/chromium/third_party/ffmpeg/libavcodec/raw.h
@@ -41,4 +41,7 @@ enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int four
#endif
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc);
+extern av_export const PixelFormatTag avpriv_pix_fmt_bps_avi[];
+extern av_export const PixelFormatTag avpriv_pix_fmt_bps_mov[];
+
#endif /* AVCODEC_RAW_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/rawdec.c b/chromium/third_party/ffmpeg/libavcodec/rawdec.c
index 3f4a8fc86d7..a03b1be9fe6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rawdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rawdec.c
@@ -25,6 +25,8 @@
*/
#include "avcodec.h"
+#include "dsputil.h"
+#include "get_bits.h"
#include "internal.h"
#include "raw.h"
#include "libavutil/avassert.h"
@@ -41,7 +43,12 @@ typedef struct RawVideoContext {
int flip;
int is_2_4_bpp; // 2 or 4 bpp raw in avi/mov
int is_yuv2;
+ int is_lt_16bpp; // 16bpp pixfmt and bits_per_coded_sample < 16
int tff;
+
+ DSPContext dsp;
+ void *bitstream_buf;
+ unsigned int bitstream_buf_size;
} RawVideoContext;
static const AVOption options[]={
@@ -55,44 +62,6 @@ static const AVClass rawdec_class = {
.version = LIBAVUTIL_VERSION_INT,
};
-static const PixelFormatTag pix_fmt_bps_avi[] = {
- { AV_PIX_FMT_MONOWHITE, 1 },
- { AV_PIX_FMT_PAL8, 2 },
- { AV_PIX_FMT_PAL8, 4 },
- { AV_PIX_FMT_PAL8, 8 },
- { AV_PIX_FMT_RGB444LE, 12 },
- { AV_PIX_FMT_RGB555LE, 15 },
- { AV_PIX_FMT_RGB555LE, 16 },
- { AV_PIX_FMT_BGR24, 24 },
- { AV_PIX_FMT_BGRA, 32 },
- { AV_PIX_FMT_NONE, 0 },
-};
-
-static const PixelFormatTag pix_fmt_bps_mov[] = {
- { AV_PIX_FMT_MONOWHITE, 1 },
- { AV_PIX_FMT_PAL8, 2 },
- { AV_PIX_FMT_PAL8, 4 },
- { AV_PIX_FMT_PAL8, 8 },
- // FIXME swscale does not support 16 bit in .mov, sample 16bit.mov
- // http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
- { AV_PIX_FMT_RGB555BE, 16 },
- { AV_PIX_FMT_RGB24, 24 },
- { AV_PIX_FMT_ARGB, 32 },
- { AV_PIX_FMT_MONOWHITE,33 },
- { AV_PIX_FMT_NONE, 0 },
-};
-
-enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
- unsigned int fourcc)
-{
- while (tags->pix_fmt >= 0) {
- if (tags->fourcc == fourcc)
- return tags->pix_fmt;
- tags++;
- }
- return AV_PIX_FMT_NONE;
-}
-
#if LIBAVCODEC_VERSION_MAJOR < 55
enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
{
@@ -105,17 +74,19 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
RawVideoContext *context = avctx->priv_data;
const AVPixFmtDescriptor *desc;
+ ff_dsputil_init(&context->dsp, avctx);
+
if ( avctx->codec_tag == MKTAG('r','a','w',' ')
|| avctx->codec_tag == MKTAG('N','O','1','6'))
- avctx->pix_fmt = avpriv_find_pix_fmt(pix_fmt_bps_mov,
+ avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
avctx->bits_per_coded_sample);
else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
- avctx->pix_fmt = avpriv_find_pix_fmt(pix_fmt_bps_avi,
+ avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
avctx->bits_per_coded_sample);
- else if (avctx->codec_tag)
+ else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0))
avctx->pix_fmt = avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag);
else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
- avctx->pix_fmt = avpriv_find_pix_fmt(pix_fmt_bps_avi,
+ avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
avctx->bits_per_coded_sample);
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
@@ -142,6 +113,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
FFALIGN(avctx->width, 16),
avctx->height);
} else {
+ context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16;
context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
avctx->height);
}
@@ -166,6 +138,34 @@ static void flip(AVCodecContext *avctx, AVPicture *picture)
picture->linesize[0] *= -1;
}
+/*
+ * Scale sample to 16-bit resolution
+ */
+#define SCALE16(x, bits) (((x) << (16 - (bits))) | ((x) >> (2 * (bits) - 16)))
+
+/**
+ * Scale buffer to 16 bits per coded sample resolution
+ */
+#define MKSCALE16(name, r16, w16) \
+static void name(AVCodecContext *avctx, uint8_t * dst, const uint8_t *buf, int buf_size, int packed) \
+{ \
+ int i; \
+ if (!packed) { \
+ for (i = 0; i + 1 < buf_size; i += 2) \
+ w16(dst + i, SCALE16(r16(buf + i), avctx->bits_per_coded_sample)); \
+ } else { \
+ GetBitContext gb; \
+ init_get_bits(&gb, buf, buf_size * 8); \
+ for (i = 0; i < avctx->width * avctx->height; i++) { \
+ int sample = get_bits(&gb, avctx->bits_per_coded_sample); \
+ w16(dst + i*2, SCALE16(sample, avctx->bits_per_coded_sample)); \
+ } \
+ } \
+}
+
+MKSCALE16(scale16be, AV_RB16, AV_WB16)
+MKSCALE16(scale16le, AV_RL16, AV_WL16)
+
static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
@@ -175,15 +175,18 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
int buf_size = avpkt->size;
int linesize_align = 4;
int res, len;
- int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2;
+ int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2 || context->is_lt_16bpp;
AVFrame *frame = data;
AVPicture *picture = data;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
- frame->reordered_opaque = avctx->reordered_opaque;
- frame->pkt_pts = avctx->internal->pkt->pts;
+
+ res = ff_decode_frame_props(avctx, frame);
+ if (res < 0)
+ return res;
+
av_frame_set_pkt_pos (frame, avctx->internal->pkt->pos);
av_frame_set_pkt_duration(frame, avctx->internal->pkt->duration);
@@ -224,6 +227,30 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
linesize_align = 16;
}
buf = dst;
+ } else if (context->is_lt_16bpp) {
+ uint8_t *dst = frame->buf[0]->data;
+ int packed = (avctx->codec_tag & 0xFFFFFF) == MKTAG('B','I','T', 0);
+ int swap = avctx->codec_tag >> 24;
+
+ if (packed && swap) {
+ av_fast_padded_malloc(&context->bitstream_buf, &context->bitstream_buf_size, buf_size);
+ if (!context->bitstream_buf)
+ return AVERROR(ENOMEM);
+ if (swap == 16)
+ context->dsp.bswap16_buf(context->bitstream_buf, (const uint16_t*)buf, buf_size / 2);
+ else if (swap == 32)
+ context->dsp.bswap_buf(context->bitstream_buf, (const uint32_t*)buf, buf_size / 4);
+ else
+ return AVERROR_INVALIDDATA;
+ buf = context->bitstream_buf;
+ }
+
+ if (desc->flags & AV_PIX_FMT_FLAG_BE)
+ scale16be(avctx, dst, buf, buf_size, packed);
+ else
+ scale16le(avctx, dst, buf, buf_size, packed);
+
+ buf = dst;
} else if (need_copy) {
memcpy(frame->buf[0]->data, buf, buf_size);
buf = frame->buf[0]->data;
@@ -234,7 +261,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
buf += buf_size - context->frame_size;
len = context->frame_size - (avctx->pix_fmt==AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0);
- if (buf_size < len) {
+ if (buf_size < len && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0)) {
av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected frame_size %d\n", buf_size, len);
av_buffer_unref(&frame->buf[0]);
return AVERROR(EINVAL);
@@ -319,16 +346,6 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
line += picture->linesize[0];
}
}
- if (avctx->codec_tag == AV_RL32("YVYU") &&
- avctx->pix_fmt == AV_PIX_FMT_YUYV422) {
- int x, y;
- uint8_t *line = picture->data[0];
- for(y = 0; y < avctx->height; y++) {
- for(x = 0; x < avctx->width - 1; x += 2)
- FFSWAP(uint8_t, line[2*x + 1], line[2*x + 3]);
- line += picture->linesize[0];
- }
- }
if (avctx->field_order > AV_FIELD_PROGRESSIVE) { /* we have interlaced material flagged in container */
frame->interlaced_frame = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/rawenc.c b/chromium/third_party/ffmpeg/libavcodec/rawenc.c
index 036261d1ec6..c5d3d2e9559 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rawenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rawenc.c
@@ -31,7 +31,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/internal.h"
-static av_cold int raw_init_encoder(AVCodecContext *avctx)
+static av_cold int raw_encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
@@ -75,6 +75,6 @@ AVCodec ff_rawvideo_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_RAWVIDEO,
.priv_data_size = sizeof(AVFrame),
- .init = raw_init_encoder,
+ .init = raw_encode_init,
.encode2 = raw_encode,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/rnd_avg.h b/chromium/third_party/ffmpeg/libavcodec/rnd_avg.h
index 50ab59a0fc9..344775e31fd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rnd_avg.h
+++ b/chromium/third_party/ffmpeg/libavcodec/rnd_avg.h
@@ -25,14 +25,8 @@
#include <stddef.h>
#include <stdint.h>
-#define CALL_2X_PIXELS(a, b, n)\
-static void a(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
- b(block , pixels , line_size, h);\
- b(block+n, pixels+n, line_size, h);\
-}
-
-#define BYTE_VEC32(c) ((c)*0x01010101UL)
-#define BYTE_VEC64(c) ((c)*0x0001000100010001UL)
+#define BYTE_VEC32(c) ((c) * 0x01010101UL)
+#define BYTE_VEC64(c) ((c) * 0x0001000100010001UL)
static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/roqvideo.h b/chromium/third_party/ffmpeg/libavcodec/roqvideo.h
index 39dda0c88b2..3da6eaa9910 100644
--- a/chromium/third_party/ffmpeg/libavcodec/roqvideo.h
+++ b/chromium/third_party/ffmpeg/libavcodec/roqvideo.h
@@ -43,6 +43,7 @@ struct RoqTempData;
typedef struct RoqContext {
+ const AVClass *class;
AVCodecContext *avctx;
AVFrame *last_frame;
AVFrame *current_frame;
@@ -69,6 +70,9 @@ typedef struct RoqContext {
const AVFrame *frame_to_enc;
uint8_t *out_buf;
struct RoqTempData *tmpData;
+
+ int quake3_compat; // Quake 3 compatibility option
+
} RoqContext;
#define RoQ_INFO 0x1001
diff --git a/chromium/third_party/ffmpeg/libavcodec/roqvideodec.c b/chromium/third_party/ffmpeg/libavcodec/roqvideodec.c
index 8e7dffe5ccd..322345ef1c0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/roqvideodec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/roqvideodec.c
@@ -79,7 +79,7 @@ static void roqvideo_decode_frame(RoqContext *ri)
for (yp = ypos; yp < ypos + 16; yp += 8)
for (xp = xpos; xp < xpos + 16; xp += 8) {
if (bytestream2_tell(&ri->gb) >= chunk_start + chunk_size) {
- av_log(ri->avctx, AV_LOG_ERROR, "Input buffer too small\n");
+ av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");
return;
}
if (vqflg_pos < 0) {
@@ -114,7 +114,7 @@ static void roqvideo_decode_frame(RoqContext *ri)
if(k & 0x02) y += 4;
if (bytestream2_tell(&ri->gb) >= chunk_start + chunk_size) {
- av_log(ri->avctx, AV_LOG_ERROR, "Input buffer too small\n");
+ av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");
return;
}
if (vqflg_pos < 0) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/roqvideoenc.c b/chromium/third_party/ffmpeg/libavcodec/roqvideoenc.c
index 37bd8d5cb69..cae157b7687 100644
--- a/chromium/third_party/ffmpeg/libavcodec/roqvideoenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/roqvideoenc.c
@@ -57,6 +57,7 @@
#include <string.h>
#include "libavutil/attributes.h"
+#include "libavutil/opt.h"
#include "roqvideo.h"
#include "bytestream.h"
#include "elbg.h"
@@ -69,7 +70,7 @@
* Maximum number of generated 4x4 codebooks. Can't be 256 to workaround a
* Quake 3 bug.
*/
-#define MAX_CBS_4x4 255
+#define MAX_CBS_4x4 256
#define MAX_CBS_2x2 256 ///< Maximum number of 2x2 codebooks.
@@ -248,7 +249,7 @@ static void create_cel_evals(RoqContext *enc, RoqTempdata *tempData)
{
int n=0, x, y, i;
- tempData->cel_evals = av_malloc(enc->width*enc->height/64 * sizeof(CelEvaluation));
+ tempData->cel_evals = av_malloc_array(enc->width*enc->height/64, sizeof(CelEvaluation));
/* Map to the ROQ quadtree order */
for (y=0; y<enc->height; y+=16)
@@ -540,7 +541,7 @@ static void remap_codebooks(RoqContext *enc, RoqTempdata *tempData)
int i, j, idx=0;
/* Make remaps for the final codebook usage */
- for (i=0; i<MAX_CBS_4x4; i++) {
+ for (i=0; i<(enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4); i++) {
if (tempData->codebooks.usedCB4[i]) {
tempData->i2f4[i] = idx;
tempData->f2i4[idx] = i;
@@ -798,11 +799,11 @@ static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
int i, j, k;
int c_size = size*size/4;
int *buf;
- int *codebook = av_malloc(6*c_size*cbsize*sizeof(int));
+ int *codebook = av_malloc_array(6*c_size, cbsize*sizeof(int));
int *closest_cb;
if (size == 4)
- closest_cb = av_malloc(6*c_size*inputCount*sizeof(int));
+ closest_cb = av_malloc_array(6*c_size, inputCount*sizeof(int));
else
closest_cb = tempdata->closest_cb2;
@@ -833,8 +834,8 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
int max = enc->width*enc->height/16;
uint8_t mb2[3*4];
roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
- uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
- int *points = av_malloc(max*6*4*sizeof(int));
+ uint8_t *yuvClusters=av_malloc_array(max, sizeof(int)*6*4);
+ int *points = av_malloc_array(max, 6*4*sizeof(int));
int bias;
/* Subsample YUV data */
@@ -847,11 +848,11 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
}
/* Create 4x4 codebooks */
- generate_codebook(enc, tempData, points, max, results4, 4, MAX_CBS_4x4);
+ generate_codebook(enc, tempData, points, max, results4, 4, (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4));
- codebooks->numCB4 = MAX_CBS_4x4;
+ codebooks->numCB4 = (enc->quake3_compat ? MAX_CBS_4x4-1 : MAX_CBS_4x4);
- tempData->closest_cb2 = av_malloc(max*4*sizeof(int));
+ tempData->closest_cb2 = av_malloc_array(max, 4*sizeof(int));
/* Create 2x2 codebooks */
generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2);
@@ -901,10 +902,10 @@ static void roq_encode_video(RoqContext *enc)
gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
/* Quake 3 can't handle chunks bigger than 65535 bytes */
- if (tempData->mainChunkSize/8 > 65535) {
+ if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
av_log(enc->avctx, AV_LOG_ERROR,
- "Warning, generated a frame too big (%d > 65535), "
- "try using a smaller qscale value.\n",
+ "Warning, generated a frame too big for Quake (%d > 65535), "
+ "now switching to a bigger qscale value.\n",
tempData->mainChunkSize/8);
enc->lambda *= 1.5;
tempData->mainChunkSize = 0;
@@ -962,7 +963,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
enc->framesSinceKeyframe = 0;
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
av_log(avctx, AV_LOG_ERROR, "Dimensions must be divisible by 16\n");
- return -1;
+ return AVERROR(EINVAL);
}
if (((avctx->width)&(avctx->width-1))||((avctx->height)&(avctx->height-1)))
@@ -984,16 +985,16 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
enc->tmpData = av_malloc(sizeof(RoqTempdata));
enc->this_motion4 =
- av_mallocz((enc->width*enc->height/16)*sizeof(motion_vect));
+ av_mallocz_array((enc->width*enc->height/16), sizeof(motion_vect));
enc->last_motion4 =
- av_malloc ((enc->width*enc->height/16)*sizeof(motion_vect));
+ av_malloc_array ((enc->width*enc->height/16), sizeof(motion_vect));
enc->this_motion8 =
- av_mallocz((enc->width*enc->height/64)*sizeof(motion_vect));
+ av_mallocz_array((enc->width*enc->height/64), sizeof(motion_vect));
enc->last_motion8 =
- av_malloc ((enc->width*enc->height/64)*sizeof(motion_vect));
+ av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
return 0;
}
@@ -1073,6 +1074,20 @@ static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
+#define OFFSET(x) offsetof(RoqContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "quake3_compat", "Whether to respect known limitations in Quake 3 decoder", OFFSET(quake3_compat), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
+ { NULL },
+};
+
+static const AVClass roq_class = {
+ .class_name = "RoQ",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_roq_encoder = {
.name = "roqvideo",
.long_name = NULL_IF_CONFIG_SMALL("id RoQ video"),
@@ -1082,7 +1097,7 @@ AVCodec ff_roq_encoder = {
.init = roq_encode_init,
.encode2 = roq_encode_frame,
.close = roq_encode_end,
- .supported_framerates = (const AVRational[]){ {30,1}, {0,0} },
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE },
+ .priv_class = &roq_class,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/rpza.c b/chromium/third_party/ffmpeg/libavcodec/rpza.c
index d4e2b17addf..aac437e41c9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rpza.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rpza.c
@@ -34,13 +34,14 @@
* pixels shall be stored in native CPU endianness.
*/
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libavutil/internal.h"
-#include "libavutil/intreadwrite.h"
#include "avcodec.h"
+#include "bytestream.h"
#include "internal.h"
typedef struct RpzaContext {
@@ -48,9 +49,7 @@ typedef struct RpzaContext {
AVCodecContext *avctx;
AVFrame *frame;
- const unsigned char *buf;
- int size;
-
+ GetByteContext gb;
} RpzaContext;
#define ADVANCE_BLOCK() \
@@ -74,15 +73,11 @@ static void rpza_decode_stream(RpzaContext *s)
int width = s->avctx->width;
int stride = s->frame->linesize[0] / 2;
int row_inc = stride - 4;
- int stream_ptr = 0;
int chunk_size;
- unsigned char opcode;
- int n_blocks;
- unsigned short colorA = 0, colorB;
- unsigned short color4[4];
- unsigned char index, idx;
- unsigned short ta, tb;
- unsigned short *pixels = (unsigned short *)s->frame->data[0];
+ uint16_t colorA = 0, colorB;
+ uint16_t color4[4];
+ uint16_t ta, tb;
+ uint16_t *pixels = (uint16_t *)s->frame->data[0];
int row_ptr = 0;
int pixel_ptr = -4;
@@ -91,34 +86,31 @@ static void rpza_decode_stream(RpzaContext *s)
int total_blocks;
/* First byte is always 0xe1. Warn if it's different */
- if (s->buf[stream_ptr] != 0xe1)
+ if (bytestream2_peek_byte(&s->gb) != 0xe1)
av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n",
- s->buf[stream_ptr]);
+ bytestream2_peek_byte(&s->gb));
/* Get chunk size, ingnoring first byte */
- chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
- stream_ptr += 4;
+ chunk_size = bytestream2_get_be32(&s->gb) & 0x00FFFFFF;
/* If length mismatch use size from MOV file and try to decode anyway */
- if (chunk_size != s->size)
- av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n");
-
- chunk_size = s->size;
+ if (chunk_size != bytestream2_get_bytes_left(&s->gb) - 4)
+ av_log(s->avctx, AV_LOG_WARNING, "MOV chunk size != encoded chunk size\n");
/* Number of 4x4 blocks in frame. */
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
/* Process chunk data */
- while (stream_ptr < chunk_size) {
- opcode = s->buf[stream_ptr++]; /* Get opcode */
+ while (bytestream2_get_bytes_left(&s->gb)) {
+ uint8_t opcode = bytestream2_get_byte(&s->gb); /* Get opcode */
- n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode */
+ int n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode */
/* If opcode MSbit is 0, we need more data to decide what to do */
if ((opcode & 0x80) == 0) {
- colorA = (opcode << 8) | (s->buf[stream_ptr++]);
+ colorA = (opcode << 8) | bytestream2_get_byte(&s->gb);
opcode = 0;
- if ((s->buf[stream_ptr] & 0x80) != 0) {
+ if ((bytestream2_peek_byte(&s->gb) & 0x80) != 0) {
/* Must behave as opcode 110xxxxx, using colorA computed
* above. Use fake opcode 0x20 to enter switch block at
* the right place */
@@ -127,6 +119,8 @@ static void rpza_decode_stream(RpzaContext *s)
}
}
+ n_blocks = FFMIN(n_blocks, total_blocks);
+
switch (opcode & 0xe0) {
/* Skip blocks */
@@ -138,8 +132,7 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with one color */
case 0xa0:
- colorA = AV_RB16 (&s->buf[stream_ptr]);
- stream_ptr += 2;
+ colorA = bytestream2_get_be16(&s->gb);
while (n_blocks--) {
ADVANCE_BLOCK()
block_ptr = row_ptr + pixel_ptr;
@@ -155,11 +148,9 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with 4 colors */
case 0xc0:
- colorA = AV_RB16 (&s->buf[stream_ptr]);
- stream_ptr += 2;
+ colorA = bytestream2_get_be16(&s->gb);
case 0x20:
- colorB = AV_RB16 (&s->buf[stream_ptr]);
- stream_ptr += 2;
+ colorB = bytestream2_get_be16(&s->gb);
/* sort out the colors */
color4[0] = colorB;
@@ -185,15 +176,15 @@ static void rpza_decode_stream(RpzaContext *s)
color4[1] |= ((11 * ta + 21 * tb) >> 5);
color4[2] |= ((21 * ta + 11 * tb) >> 5);
- if (s->size - stream_ptr < n_blocks * 4)
+ if (bytestream2_get_bytes_left(&s->gb) < n_blocks * 4)
return;
while (n_blocks--) {
ADVANCE_BLOCK();
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- index = s->buf[stream_ptr++];
+ uint8_t index = bytestream2_get_byteu(&s->gb);
for (pixel_x = 0; pixel_x < 4; pixel_x++){
- idx = (index >> (2 * (3 - pixel_x))) & 0x03;
+ uint8_t idx = (index >> (2 * (3 - pixel_x))) & 0x03;
pixels[block_ptr] = color4[idx];
block_ptr++;
}
@@ -204,17 +195,15 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill block with 16 colors */
case 0x00:
- if (s->size - stream_ptr < 30)
+ if (bytestream2_get_bytes_left(&s->gb) < 30)
return;
ADVANCE_BLOCK();
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++){
/* We already have color of upper left pixel */
- if ((pixel_y != 0) || (pixel_x !=0)) {
- colorA = AV_RB16 (&s->buf[stream_ptr]);
- stream_ptr += 2;
- }
+ if ((pixel_y != 0) || (pixel_x != 0))
+ colorA = bytestream2_get_be16u(&s->gb);
pixels[block_ptr] = colorA;
block_ptr++;
}
@@ -226,7 +215,7 @@ static void rpza_decode_stream(RpzaContext *s)
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown opcode %d in rpza chunk."
" Skip remaining %d bytes of chunk data.\n", opcode,
- chunk_size - stream_ptr);
+ bytestream2_get_bytes_left(&s->gb));
return;
} /* Opcode switch */
}
@@ -250,13 +239,10 @@ static int rpza_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
RpzaContext *s = avctx->priv_data;
int ret;
- s->buf = buf;
- s->size = buf_size;
+ bytestream2_init(&s->gb, avpkt->data, avpkt->size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
@@ -269,7 +255,7 @@ static int rpza_decode_frame(AVCodecContext *avctx,
*got_frame = 1;
/* always report that the buffer was completely consumed */
- return buf_size;
+ return avpkt->size;
}
static av_cold int rpza_decode_end(AVCodecContext *avctx)
diff --git a/chromium/third_party/ffmpeg/libavcodec/rtjpeg.c b/chromium/third_party/ffmpeg/libavcodec/rtjpeg.c
index 860d95821d1..e67ba7565d1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rtjpeg.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rtjpeg.c
@@ -121,7 +121,7 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
if (res < 0) \
return res; \
if (res > 0) \
- c->dsp->idct_put(dst, stride, block); \
+ c->dsp.idct_put(dst, stride, block); \
} while (0)
int16_t *block = c->block;
BLOCK(c->lquant, y1, f->linesize[0]);
@@ -148,7 +148,6 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
/**
* @brief initialize an RTJpegContext, may be called multiple times
* @param c context to initialize
- * @param dsp specifies the idct to use for decoding
* @param width width of image, will be rounded down to the nearest multiple
* of 16 for decoding
* @param height height of image, will be rounded down to the nearest multiple
@@ -156,21 +155,29 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
* @param lquant luma quantization table to use
* @param cquant chroma quantization table to use
*/
-void ff_rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp,
- int width, int height,
+void ff_rtjpeg_decode_init(RTJpegContext *c, int width, int height,
const uint32_t *lquant, const uint32_t *cquant) {
int i;
- c->dsp = dsp;
for (i = 0; i < 64; i++) {
- int z = ff_zigzag_direct[i];
- int p = c->dsp->idct_permutation[i];
- z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant
-
- // permute the scan and quantization tables for the chosen idct
- c->scan[i] = c->dsp->idct_permutation[z];
+ int p = c->dsp.idct_permutation[i];
c->lquant[p] = lquant[i];
c->cquant[p] = cquant[i];
}
c->w = width;
c->h = height;
}
+
+void ff_rtjpeg_init(RTJpegContext *c, AVCodecContext *avctx)
+{
+ int i;
+
+ ff_dsputil_init(&c->dsp, avctx);
+
+ for (i = 0; i < 64; i++) {
+ int z = ff_zigzag_direct[i];
+ z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant
+
+ // permute the scan and quantization tables for the chosen idct
+ c->scan[i] = c->dsp.idct_permutation[z];
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/rtjpeg.h b/chromium/third_party/ffmpeg/libavcodec/rtjpeg.h
index 294b06c6978..3be4cfcad24 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rtjpeg.h
+++ b/chromium/third_party/ffmpeg/libavcodec/rtjpeg.h
@@ -31,16 +31,17 @@
typedef struct RTJpegContext {
int w, h;
- DSPContext *dsp;
+ DSPContext dsp;
uint8_t scan[64];
uint32_t lquant[64];
uint32_t cquant[64];
DECLARE_ALIGNED(16, int16_t, block)[64];
} RTJpegContext;
-void ff_rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp,
- int width, int height,
- const uint32_t *lquant, const uint32_t *cquant);
+void ff_rtjpeg_init(RTJpegContext *c, AVCodecContext *avctx);
+
+void ff_rtjpeg_decode_init(RTJpegContext *c, int width, int height,
+ const uint32_t *lquant, const uint32_t *cquant);
int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
const uint8_t *buf, int buf_size);
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv10.c b/chromium/third_party/ffmpeg/libavcodec/rv10.c
index 4d48a49f3c5..3fb94c8ad79 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv10.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv10.c
@@ -25,19 +25,22 @@
* RV10/RV20 decoder
*/
+#include <inttypes.h>
+
#include "libavutil/imgutils.h"
+
#include "avcodec.h"
#include "error_resilience.h"
+#include "h263.h"
#include "internal.h"
#include "mpegvideo.h"
#include "mpeg4video.h"
-#include "h263.h"
#define RV_GET_MAJOR_VER(x) ((x) >> 28)
#define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF)
#define RV_GET_MICRO_VER(x) (((x) >> 12) & 0xFF)
-#define DC_VLC_BITS 14 //FIXME find a better solution
+#define DC_VLC_BITS 14 // FIXME find a better solution
typedef struct RVDecContext {
MpegEncContext m;
@@ -194,18 +197,18 @@ int ff_rv_decode_dc(MpegEncContext *s, int n)
code = get_vlc2(&s->gb, rv_dc_lum.table, DC_VLC_BITS, 2);
if (code < 0) {
/* XXX: I don't understand why they use LONGER codes than
- necessary. The following code would be completely useless
- if they had thought about it !!! */
+ * necessary. The following code would be completely useless
+ * if they had thought about it !!! */
code = get_bits(&s->gb, 7);
if (code == 0x7c) {
- code = (int8_t)(get_bits(&s->gb, 7) + 1);
+ code = (int8_t) (get_bits(&s->gb, 7) + 1);
} else if (code == 0x7d) {
code = -128 + get_bits(&s->gb, 7);
} else if (code == 0x7e) {
if (get_bits1(&s->gb) == 0)
- code = (int8_t)(get_bits(&s->gb, 8) + 1);
+ code = (int8_t) (get_bits(&s->gb, 8) + 1);
else
- code = (int8_t)(get_bits(&s->gb, 8));
+ code = (int8_t) (get_bits(&s->gb, 8));
} else if (code == 0x7f) {
skip_bits(&s->gb, 11);
code = 1;
@@ -219,7 +222,7 @@ int ff_rv_decode_dc(MpegEncContext *s, int n)
if (code < 0) {
code = get_bits(&s->gb, 9);
if (code == 0x1fc) {
- code = (int8_t)(get_bits(&s->gb, 7) + 1);
+ code = (int8_t) (get_bits(&s->gb, 7) + 1);
} else if (code == 0x1fd) {
code = -128 + get_bits(&s->gb, 7);
} else if (code == 0x1fe) {
@@ -277,7 +280,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
}
}
/* if multiple packets per frame are sent, the position at which
- to display the macroblocks is coded here */
+ * to display the macroblocks is coded here */
mb_xy = s->mb_x + s->mb_y * s->mb_width;
if (show_bits(&s->gb, 12) == 0 || (mb_xy && mb_xy < s->mb_num)) {
@@ -290,7 +293,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
mb_count = s->mb_width * s->mb_height;
}
skip_bits(&s->gb, 3); /* ignored */
- s->f_code = 1;
+ s->f_code = 1;
s->unrestricted_mv = 1;
return mb_count;
@@ -300,14 +303,22 @@ static int rv20_decode_picture_header(RVDecContext *rv)
{
MpegEncContext *s = &rv->m;
int seq, mb_pos, i, ret;
- int rpr_bits;
+ int rpr_max;
i = get_bits(&s->gb, 2);
- switch(i) {
- case 0: s->pict_type = AV_PICTURE_TYPE_I; break;
- case 1: s->pict_type = AV_PICTURE_TYPE_I; break; //hmm ...
- case 2: s->pict_type = AV_PICTURE_TYPE_P; break;
- case 3: s->pict_type = AV_PICTURE_TYPE_B; break;
+ switch (i) {
+ case 0:
+ s->pict_type = AV_PICTURE_TYPE_I;
+ break;
+ case 1:
+ s->pict_type = AV_PICTURE_TYPE_I;
+ break; // hmm ...
+ case 2:
+ s->pict_type = AV_PICTURE_TYPE_P;
+ break;
+ case 3:
+ s->pict_type = AV_PICTURE_TYPE_B;
+ break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
return AVERROR_INVALIDDATA;
@@ -341,10 +352,10 @@ static int rv20_decode_picture_header(RVDecContext *rv)
else
seq = get_bits(&s->gb, 13) << 2;
- rpr_bits = s->avctx->extradata[1] & 7;
- if (rpr_bits) {
+ rpr_max = s->avctx->extradata[1] & 7;
+ if (rpr_max) {
int f, new_w, new_h;
- rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3);
+ int rpr_bits = av_log2(rpr_max) + 1;
f = get_bits(&s->gb, rpr_bits);
@@ -354,10 +365,10 @@ static int rv20_decode_picture_header(RVDecContext *rv)
return AVERROR_INVALIDDATA;
}
- new_w = 4 * ((uint8_t*)s->avctx->extradata)[6 + 2 * f];
- new_h = 4 * ((uint8_t*)s->avctx->extradata)[7 + 2 * f];
+ new_w = 4 * ((uint8_t *) s->avctx->extradata)[6 + 2 * f];
+ new_h = 4 * ((uint8_t *) s->avctx->extradata)[7 + 2 * f];
} else {
- new_w = s->orig_width ;
+ new_w = s->orig_width;
new_h = s->orig_height;
}
if (new_w != s->width || new_h != s->height) {
@@ -387,7 +398,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
}
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
+ av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d/%d\n", f, rpr_bits, rpr_max);
}
}
if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
@@ -424,7 +435,8 @@ static int rv20_decode_picture_header(RVDecContext *rv)
s->no_rounding = get_bits1(&s->gb);
if (RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
- skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they don't seem to be used
+ // binary decoder reads 3+2 bits here but they don't seem to be used
+ skip_bits(&s->gb, 5);
s->f_code = 1;
s->unrestricted_mv = 1;
@@ -434,18 +446,20 @@ static int rv20_decode_picture_header(RVDecContext *rv)
s->loop_filter = 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
- seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
+ av_log(s->avctx, AV_LOG_INFO,
+ "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
+ seq, s->mb_x, s->mb_y, s->pict_type, s->qscale,
+ s->no_rounding);
}
av_assert0(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
- return s->mb_width*s->mb_height - mb_pos;
+ return s->mb_width * s->mb_height - mb_pos;
}
static av_cold int rv10_decode_init(AVCodecContext *avctx)
{
- RVDecContext *rv = avctx->priv_data;
+ RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m;
static int done = 0;
int major_ver, minor_ver, micro_ver, ret;
@@ -460,15 +474,17 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
ff_MPV_decode_defaults(s);
- s->avctx = avctx;
- s->out_format = FMT_H263;
- s->codec_id = avctx->codec_id;
+ s->avctx = avctx;
+ s->out_format = FMT_H263;
+ s->codec_id = avctx->codec_id;
- s->orig_width = s->width = avctx->coded_width;
- s->orig_height = s->height = avctx->coded_height;
+ s->orig_width =
+ s->width = avctx->coded_width;
+ s->orig_height =
+ s->height = avctx->coded_height;
- s->h263_long_vectors = ((uint8_t*)avctx->extradata)[3] & 1;
- rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);
+ s->h263_long_vectors = ((uint8_t *) avctx->extradata)[3] & 1;
+ rv->sub_id = AV_RB32((uint8_t *) avctx->extradata + 4);
major_ver = RV_GET_MAJOR_VER(rv->sub_id);
minor_ver = RV_GET_MINOR_VER(rv->sub_id);
@@ -493,8 +509,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
}
if (avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id,
- ((uint32_t*)avctx->extradata)[0]);
+ av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%"PRIX32"\n", rv->sub_id,
+ ((uint32_t *) avctx->extradata)[0]);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@ -527,10 +543,10 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx)
return 0;
}
-static int rv10_decode_packet(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size, int buf_size2)
+static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
+ int buf_size, int buf_size2)
{
- RVDecContext *rv = avctx->priv_data;
+ RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m;
int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
@@ -552,14 +568,15 @@ static int rv10_decode_packet(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
- left = s->mb_width * s->mb_height - mb_pos;
+ left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return AVERROR_INVALIDDATA;
}
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr == NULL) {
- if (s->current_picture_ptr) { // FIXME write parser so we always have complete frames?
+ // FIXME write parser so we always have complete frames?
+ if (s->current_picture_ptr) {
ff_er_frame_end(&s->er);
ff_MPV_frame_end(s);
s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
@@ -568,7 +585,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
return ret;
ff_mpeg_er_frame_start(s);
} else {
- if (s->current_picture_ptr->f.pict_type != s->pict_type) {
+ if (s->current_picture_ptr->f->pict_type != s->pict_type) {
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
return AVERROR_INVALIDDATA;
}
@@ -588,9 +605,11 @@ static int rv10_decode_packet(AVCodecContext *avctx,
start_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
if (s->h263_aic) {
- s->y_dc_scale_table = s->c_dc_scale_table = ff_aic_dc_scale_table;
+ s->y_dc_scale_table =
+ s->c_dc_scale_table = ff_aic_dc_scale_table;
} else {
- s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
+ s->y_dc_scale_table =
+ s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
}
if (s->modified_quant)
@@ -639,7 +658,8 @@ static int rv10_decode_packet(AVCodecContext *avctx,
}
if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&s->gb)) {
- av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
+ av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x,
+ s->mb_y);
return AVERROR_INVALIDDATA;
}
if (s->pict_type != AV_PICTURE_TYPE_B)
@@ -659,7 +679,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
break;
}
- ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y,
+ ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x - 1, s->mb_y,
ER_MB_END);
return active_bits_size;
@@ -673,14 +693,13 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
return AV_RL32(buf + n * 8);
}
-static int rv10_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
+static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- MpegEncContext *s = avctx->priv_data;
- AVFrame *pict = data;
+ MpegEncContext *s = avctx->priv_data;
+ AVFrame *pict = data;
int i, ret;
int slice_count;
const uint8_t *slices_hdr = NULL;
@@ -699,7 +718,8 @@ static int rv10_decode_frame(AVCodecContext *avctx,
buf_size--;
if (!slice_count || buf_size <= 8 * slice_count) {
- av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", slice_count);
+ av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n",
+ slice_count);
return AVERROR_INVALIDDATA;
}
@@ -730,7 +750,10 @@ static int rv10_decode_frame(AVCodecContext *avctx,
offset + FFMAX(size, size2) > buf_size)
return AVERROR_INVALIDDATA;
- if (rv10_decode_packet(avctx, buf + offset, size, size2) > 8 * size)
+ if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2)) < 0)
+ return ret;
+
+ if (ret > 8 * size)
i++;
}
@@ -739,12 +762,12 @@ static int rv10_decode_frame(AVCodecContext *avctx,
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
- if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict,s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
@@ -772,7 +795,10 @@ AVCodec ff_rv10_decoder = {
.decode = rv10_decode_frame,
.capabilities = CODEC_CAP_DR1,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
AVCodec ff_rv20_decoder = {
@@ -787,5 +813,8 @@ AVCodec ff_rv20_decoder = {
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush = ff_mpeg_flush,
.max_lowres = 3,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv30.c b/chromium/third_party/ffmpeg/libavcodec/rv30.c
index 7690da70cde..fd8fd4f9874 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv30.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv30.c
@@ -25,6 +25,7 @@
*/
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "golomb.h"
@@ -34,6 +35,7 @@
static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si)
{
+ AVCodecContext *avctx = r->s.avctx;
int mb_bits;
int w = r->s.width, h = r->s.height;
int mb_size;
@@ -49,13 +51,20 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
si->quant = get_bits(gb, 5);
skip_bits1(gb);
si->pts = get_bits(gb, 13);
- rpr = get_bits(gb, r->rpr);
- if (r->s.avctx->extradata_size < 8 + rpr*2) {
- av_log(r->s.avctx, AV_LOG_WARNING,
- "Extradata does not contain selected resolution\n");
- rpr = 0;
- }
+ rpr = get_bits(gb, av_log2(r->max_rpr) + 1);
if(rpr){
+ if (rpr > r->max_rpr) {
+ av_log(avctx, AV_LOG_ERROR, "rpr too large\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (avctx->extradata_size < rpr * 2 + 8) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Insufficient extradata - need at least %d bytes, got %d\n",
+ 8 + rpr * 2, avctx->extradata_size);
+ return AVERROR(EINVAL);
+ }
+
w = r->s.avctx->extradata[6 + rpr*2] << 2;
h = r->s.avctx->extradata[7 + rpr*2] << 2;
}
@@ -124,7 +133,7 @@ static int rv30_decode_mb_info(RV34DecContext *r)
static inline void rv30_weak_loop_filter(uint8_t *src, const int step,
const int stride, const int lim)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int i, diff;
for(i = 0; i < 4; i++){
@@ -162,7 +171,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
if(mb_x)
left_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - 1]];
for(j = 0; j < 16; j += 4){
- Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;
+ Y = s->current_picture_ptr->f->data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;
for(i = !mb_x; i < 4; i++, Y += 4){
int ij = i + j;
loc_lim = 0;
@@ -182,7 +191,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
if(mb_x)
left_cbp = (r->cbp_chroma[mb_pos - 1] >> (k*4)) & 0xF;
for(j = 0; j < 8; j += 4){
- C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;
+ C = s->current_picture_ptr->f->data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;
for(i = !mb_x; i < 2; i++, C += 4){
int ij = i + (j >> 1);
loc_lim = 0;
@@ -204,7 +213,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
if(row)
top_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - s->mb_stride]];
for(j = 4*!row; j < 16; j += 4){
- Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;
+ Y = s->current_picture_ptr->f->data[0] + mb_x*16 + (row*16 + j) * s->linesize;
for(i = 0; i < 4; i++, Y += 4){
int ij = i + j;
loc_lim = 0;
@@ -224,7 +233,7 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
if(row)
top_cbp = (r->cbp_chroma[mb_pos - s->mb_stride] >> (k*4)) & 0xF;
for(j = 4*!row; j < 8; j += 4){
- C = s->current_picture_ptr->f.data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;
+ C = s->current_picture_ptr->f->data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;
for(i = 0; i < 2; i++, C += 4){
int ij = i + (j >> 1);
loc_lim = 0;
@@ -257,12 +266,13 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
}
- r->rpr = (avctx->extradata[1] & 7) >> 1;
- r->rpr = FFMIN(r->rpr + 1, 3);
- if(avctx->extradata_size - 8 < (r->rpr - 1) * 2){
- av_log(avctx, AV_LOG_ERROR, "Insufficient extradata - need at least %d bytes, got %d\n",
- 6 + r->rpr * 2, avctx->extradata_size);
+
+ r->max_rpr = avctx->extradata[1] & 7;
+ if(avctx->extradata_size < 2*r->max_rpr + 8){
+ av_log(avctx, AV_LOG_WARNING, "Insufficient extradata - need at least %d bytes, got %d\n",
+ 2*r->max_rpr + 8, avctx->extradata_size);
}
+
r->parse_slice_header = rv30_parse_slice_header;
r->decode_intra_types = rv30_decode_intra_types;
r->decode_mb_info = rv30_decode_mb_info;
@@ -284,7 +294,10 @@ AVCodec ff_rv30_decoder = {
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
CODEC_CAP_FRAME_THREADS,
.flush = ff_mpeg_flush,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
.init_thread_copy = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv30data.h b/chromium/third_party/ffmpeg/libavcodec/rv30data.h
index 9cc48a6a31f..5c4cb9710b9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv30data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/rv30data.h
@@ -58,7 +58,7 @@ static const uint8_t rv30_itype_code[9*9*2] = {
*
* This is really a three-dimensional matrix with dimensions
* [-1..9][-1..9][0..9]. The first and second coordinates are
- * detemined by the top and left neighbors (-1 if unavailable).
+ * determined by the top and left neighbors (-1 if unavailable).
*/
static const uint8_t rv30_itype_from_context[900] = {
0, 9, 9, 9, 9, 9, 9, 9, 9,
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv30dsp.c b/chromium/third_party/ffmpeg/libavcodec/rv30dsp.c
index 5e47b647cb6..bd084bff7a5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv30dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv30dsp.c
@@ -27,12 +27,13 @@
#include "avcodec.h"
#include "h264chroma.h"
#include "h264qpel.h"
+#include "mathops.h"
#include "rv34dsp.h"
#define RV30_LOWPASS(OPNAME, OP) \
static av_unused void OPNAME ## rv30_tpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
const int h = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i = 0; i < h; i++)\
{\
@@ -51,7 +52,7 @@ static av_unused void OPNAME ## rv30_tpel8_h_lowpass(uint8_t *dst, uint8_t *src,
\
static void OPNAME ## rv30_tpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
const int w = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i = 0; i < w; i++)\
{\
@@ -82,7 +83,7 @@ static void OPNAME ## rv30_tpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstSt
static void OPNAME ## rv30_tpel8_hv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w = 8;\
const int h = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i, j;\
for(j = 0; j < h; j++){\
for(i = 0; i < w; i++){\
@@ -101,7 +102,7 @@ static void OPNAME ## rv30_tpel8_hv_lowpass(uint8_t *dst, uint8_t *src, int dstS
static void OPNAME ## rv30_tpel8_hhv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w = 8;\
const int h = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i, j;\
for(j = 0; j < h; j++){\
for(i = 0; i < w; i++){\
@@ -120,7 +121,7 @@ static void OPNAME ## rv30_tpel8_hhv_lowpass(uint8_t *dst, uint8_t *src, int dst
static void OPNAME ## rv30_tpel8_hvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w = 8;\
const int h = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i, j;\
for(j = 0; j < h; j++){\
for(i = 0; i < w; i++){\
@@ -139,7 +140,7 @@ static void OPNAME ## rv30_tpel8_hvv_lowpass(uint8_t *dst, uint8_t *src, int dst
static void OPNAME ## rv30_tpel8_hhvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w = 8;\
const int h = 8;\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i, j;\
for(j = 0; j < h; j++){\
for(i = 0; i < w; i++){\
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv34.c b/chromium/third_party/ffmpeg/libavcodec/rv34.c
index 1aee59ce73a..4bae2c4112e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv34.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv34.c
@@ -29,6 +29,7 @@
#include "avcodec.h"
#include "error_resilience.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "golomb.h"
#include "internal.h"
@@ -708,9 +709,9 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
}
dxy = ly*4 + lx;
- srcY = dir ? s->next_picture_ptr->f.data[0] : s->last_picture_ptr->f.data[0];
- srcU = dir ? s->next_picture_ptr->f.data[1] : s->last_picture_ptr->f.data[1];
- srcV = dir ? s->next_picture_ptr->f.data[2] : s->last_picture_ptr->f.data[2];
+ srcY = dir ? s->next_picture_ptr->f->data[0] : s->last_picture_ptr->f->data[0];
+ srcU = dir ? s->next_picture_ptr->f->data[1] : s->last_picture_ptr->f->data[1];
+ srcV = dir ? s->next_picture_ptr->f->data[2] : s->last_picture_ptr->f->data[2];
src_x = s->mb_x * 16 + xoff + mx;
src_y = s->mb_y * 16 + yoff + my;
uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx;
@@ -1362,11 +1363,11 @@ static int rv34_decoder_alloc(RV34DecContext *r)
{
r->intra_types_stride = r->s.mb_width * 4 + 4;
- r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height *
+ r->cbp_chroma = av_mallocz(r->s.mb_stride * r->s.mb_height *
sizeof(*r->cbp_chroma));
- r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height *
+ r->cbp_luma = av_mallocz(r->s.mb_stride * r->s.mb_height *
sizeof(*r->cbp_luma));
- r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height *
+ r->deblock_coefs = av_mallocz(r->s.mb_stride * r->s.mb_height *
sizeof(*r->deblock_coefs));
r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
sizeof(*r->intra_types_hist));
@@ -1489,8 +1490,6 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
s->height = avctx->height;
r->s.avctx = avctx;
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
- r->s.flags |= CODEC_FLAG_EMU_EDGE;
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
avctx->has_b_frames = 1;
s->low_delay = 0;
@@ -1592,13 +1591,13 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
got_picture = 1;
} else if (s->last_picture_ptr != NULL) {
- if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
@@ -1637,7 +1636,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
- if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr = NULL;
@@ -1665,7 +1664,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
return AVERROR_INVALIDDATA;
}
- if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) &&
+ if ((!s->last_picture_ptr || !s->last_picture_ptr->f->data[0]) &&
si.type == AV_PICTURE_TYPE_B) {
av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without "
"reference data.\n");
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv34.h b/chromium/third_party/ffmpeg/libavcodec/rv34.h
index 475f17a496e..870164c6e5d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv34.h
+++ b/chromium/third_party/ffmpeg/libavcodec/rv34.h
@@ -102,7 +102,7 @@ typedef struct RV34DecContext{
int dmv[4][2]; ///< differential motion vectors for the current macroblock
int rv30; ///< indicates which RV variasnt is currently decoded
- int rpr; ///< one field size in RV30 slice header
+ int max_rpr;
int cur_pts, last_pts, next_pts;
int scaled_weight;
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv34dsp.h b/chromium/third_party/ffmpeg/libavcodec/rv34dsp.h
index 7e28b26147e..75f9ff8e669 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv34dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/rv34dsp.h
@@ -81,6 +81,7 @@ void ff_rv40dsp_init(RV34DSPContext *c);
void ff_rv34dsp_init_arm(RV34DSPContext *c);
void ff_rv34dsp_init_x86(RV34DSPContext *c);
+void ff_rv40dsp_init_aarch64(RV34DSPContext *c);
void ff_rv40dsp_init_x86(RV34DSPContext *c);
void ff_rv40dsp_init_arm(RV34DSPContext *c);
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv40.c b/chromium/third_party/ffmpeg/libavcodec/rv40.c
index 17a2f917286..043fd724a9e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv40.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv40.c
@@ -27,6 +27,7 @@
#include "libavutil/imgutils.h"
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "golomb.h"
@@ -455,7 +456,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
}
for(j = 0; j < 16; j += 4){
- Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;
+ Y = s->current_picture_ptr->f->data[0] + mb_x*16 + (row*16 + j) * s->linesize;
for(i = 0; i < 4; i++, Y += 4){
int ij = i + j;
int clip_cur = y_to_deblock & (MASK_CUR << ij) ? clip[POS_CUR] : 0;
@@ -500,7 +501,7 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
}
for(k = 0; k < 2; k++){
for(j = 0; j < 2; j++){
- C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize;
+ C = s->current_picture_ptr->f->data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize;
for(i = 0; i < 2; i++, C += 4){
int ij = i + j*2;
int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0;
@@ -575,7 +576,10 @@ AVCodec ff_rv40_decoder = {
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
CODEC_CAP_FRAME_THREADS,
.flush = ff_mpeg_flush,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
.init_thread_copy = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/rv40dsp.c b/chromium/third_party/ffmpeg/libavcodec/rv40dsp.c
index bdd9a3e3e69..7df554962f6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/rv40dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/rv40dsp.c
@@ -24,16 +24,20 @@
* RV40 decoder motion compensation functions
*/
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "h264qpel.h"
+#include "mathops.h"
+#include "pixels.h"
+#include "rnd_avg.h"
#include "rv34dsp.h"
#include "libavutil/avassert.h"
-#include "libavutil/common.h"
#define RV40_LOWPASS(OPNAME, OP) \
static av_unused void OPNAME ## rv40_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
const int h, const int C1, const int C2, const int SHIFT){\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i = 0; i < h; i++)\
{\
@@ -52,7 +56,7 @@ static av_unused void OPNAME ## rv40_qpel8_h_lowpass(uint8_t *dst, uint8_t *src,
\
static void OPNAME ## rv40_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
const int w, const int C1, const int C2, const int SHIFT){\
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
int i;\
for(i = 0; i < w; i++)\
{\
@@ -203,6 +207,83 @@ RV40_MC(put_, 16)
RV40_MC(avg_, 8)
RV40_MC(avg_, 16)
+#define PIXOP2(OPNAME, OP) \
+static inline void OPNAME ## _pixels8_xy2_8_c(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ /* FIXME HIGH BIT DEPTH */ \
+ int j; \
+ \
+ for (j = 0; j < 2; j++) { \
+ int i; \
+ const uint32_t a = AV_RN32(pixels); \
+ const uint32_t b = AV_RN32(pixels + 1); \
+ uint32_t l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ uint32_t l1, h1; \
+ \
+ pixels += line_size; \
+ for (i = 0; i < h; i += 2) { \
+ uint32_t a = AV_RN32(pixels); \
+ uint32_t b = AV_RN32(pixels + 1); \
+ l1 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL); \
+ h1 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ a = AV_RN32(pixels); \
+ b = AV_RN32(pixels + 1); \
+ l0 = (a & 0x03030303UL) + \
+ (b & 0x03030303UL) + \
+ 0x02020202UL; \
+ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
+ ((b & 0xFCFCFCFCUL) >> 2); \
+ OP(*((uint32_t *) block), \
+ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+ pixels += 4 - line_size * (h + 1); \
+ block += 4 - line_size * h; \
+ } \
+} \
+ \
+CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_8_c, \
+ OPNAME ## _pixels8_xy2_8_c, \
+ 8) \
+
+#define op_avg(a, b) a = rnd_avg32(a, b)
+#define op_put(a, b) a = b
+PIXOP2(avg, op_avg)
+PIXOP2(put, op_put)
+#undef op_avg
+#undef op_put
+
+static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ put_pixels16_xy2_8_c(dst, src, stride, 16);
+}
+static void avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ avg_pixels16_xy2_8_c(dst, src, stride, 16);
+}
+static void put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ put_pixels8_xy2_8_c(dst, src, stride, 8);
+}
+static void avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ avg_pixels8_xy2_8_c(dst, src, stride, 8);
+}
+
static const int rv40_bias[4][4] = {
{ 0, 16, 32, 16 },
{ 32, 28, 32, 28 },
@@ -351,7 +432,7 @@ static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
const int lim_q1,
const int lim_p1)
{
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int i, t, u, diff;
for (i = 0; i < 4; i++, src += stride) {
@@ -552,7 +633,7 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c)
c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c;
c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c;
c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c;
- c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c;
+ c->put_pixels_tab[0][15] = put_rv40_qpel16_mc33_c;
c->avg_pixels_tab[0][ 0] = qpel.avg_h264_qpel_pixels_tab[0][0];
c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c;
c->avg_pixels_tab[0][ 2] = qpel.avg_h264_qpel_pixels_tab[0][2];
@@ -568,7 +649,7 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c)
c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c;
c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c;
c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c;
- c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c;
+ c->avg_pixels_tab[0][15] = avg_rv40_qpel16_mc33_c;
c->put_pixels_tab[1][ 0] = qpel.put_h264_qpel_pixels_tab[1][0];
c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c;
c->put_pixels_tab[1][ 2] = qpel.put_h264_qpel_pixels_tab[1][2];
@@ -584,7 +665,7 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c)
c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c;
c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c;
c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c;
- c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c;
+ c->put_pixels_tab[1][15] = put_rv40_qpel8_mc33_c;
c->avg_pixels_tab[1][ 0] = qpel.avg_h264_qpel_pixels_tab[1][0];
c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c;
c->avg_pixels_tab[1][ 2] = qpel.avg_h264_qpel_pixels_tab[1][2];
@@ -600,7 +681,7 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c)
c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c;
c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c;
c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c;
- c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c;
+ c->avg_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c;
c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;
c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;
@@ -619,6 +700,8 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c)
c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;
c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;
+ if (ARCH_AARCH64)
+ ff_rv40dsp_init_aarch64(c);
if (ARCH_ARM)
ff_rv40dsp_init_arm(c);
if (ARCH_X86)
diff --git a/chromium/third_party/ffmpeg/libavcodec/s302menc.c b/chromium/third_party/ffmpeg/libavcodec/s302menc.c
index a7e5b1d26b8..540ac29dab0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/s302menc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/s302menc.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "internal.h"
+#include "mathops.h"
#include "put_bits.h"
#define AES3_HEADER_LEN 4
diff --git a/chromium/third_party/ffmpeg/libavcodec/sanm.c b/chromium/third_party/ffmpeg/libavcodec/sanm.c
index a6c1c01e5c8..880ef8fa223 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sanm.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sanm.c
@@ -20,26 +20,253 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-// #define DEBUG 1
+#include "libavutil/avassert.h"
+#include "libavutil/bswap.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
-#include "copy_block.h"
#include "bytestream.h"
+#include "copy_block.h"
#include "internal.h"
-#include "libavutil/bswap.h"
-#include "libavutil/imgutils.h"
-#include "sanm_data.h"
-#include "libavutil/avassert.h"
#define NGLYPHS 256
+#define GLYPH_COORD_VECT_SIZE 16
+#define PALETTE_SIZE 256
+#define PALETTE_DELTA 768
+
+static const int8_t glyph4_x[GLYPH_COORD_VECT_SIZE] = {
+ 0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1
+};
+
+static const int8_t glyph4_y[GLYPH_COORD_VECT_SIZE] = {
+ 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2
+};
+
+static const int8_t glyph8_x[GLYPH_COORD_VECT_SIZE] = {
+ 0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0
+};
-typedef struct {
+static const int8_t glyph8_y[GLYPH_COORD_VECT_SIZE] = {
+ 0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1
+};
+
+static const int8_t motion_vectors[256][2] = {
+ { 0, 0 }, { -1, -43 }, { 6, -43 }, { -9, -42 }, { 13, -41 },
+ { -16, -40 }, { 19, -39 }, { -23, -36 }, { 26, -34 }, { -2, -33 },
+ { 4, -33 }, { -29, -32 }, { -9, -32 }, { 11, -31 }, { -16, -29 },
+ { 32, -29 }, { 18, -28 }, { -34, -26 }, { -22, -25 }, { -1, -25 },
+ { 3, -25 }, { -7, -24 }, { 8, -24 }, { 24, -23 }, { 36, -23 },
+ { -12, -22 }, { 13, -21 }, { -38, -20 }, { 0, -20 }, { -27, -19 },
+ { -4, -19 }, { 4, -19 }, { -17, -18 }, { -8, -17 }, { 8, -17 },
+ { 18, -17 }, { 28, -17 }, { 39, -17 }, { -12, -15 }, { 12, -15 },
+ { -21, -14 }, { -1, -14 }, { 1, -14 }, { -41, -13 }, { -5, -13 },
+ { 5, -13 }, { 21, -13 }, { -31, -12 }, { -15, -11 }, { -8, -11 },
+ { 8, -11 }, { 15, -11 }, { -2, -10 }, { 1, -10 }, { 31, -10 },
+ { -23, -9 }, { -11, -9 }, { -5, -9 }, { 4, -9 }, { 11, -9 },
+ { 42, -9 }, { 6, -8 }, { 24, -8 }, { -18, -7 }, { -7, -7 },
+ { -3, -7 }, { -1, -7 }, { 2, -7 }, { 18, -7 }, { -43, -6 },
+ { -13, -6 }, { -4, -6 }, { 4, -6 }, { 8, -6 }, { -33, -5 },
+ { -9, -5 }, { -2, -5 }, { 0, -5 }, { 2, -5 }, { 5, -5 },
+ { 13, -5 }, { -25, -4 }, { -6, -4 }, { -3, -4 }, { 3, -4 },
+ { 9, -4 }, { -19, -3 }, { -7, -3 }, { -4, -3 }, { -2, -3 },
+ { -1, -3 }, { 0, -3 }, { 1, -3 }, { 2, -3 }, { 4, -3 },
+ { 6, -3 }, { 33, -3 }, { -14, -2 }, { -10, -2 }, { -5, -2 },
+ { -3, -2 }, { -2, -2 }, { -1, -2 }, { 0, -2 }, { 1, -2 },
+ { 2, -2 }, { 3, -2 }, { 5, -2 }, { 7, -2 }, { 14, -2 },
+ { 19, -2 }, { 25, -2 }, { 43, -2 }, { -7, -1 }, { -3, -1 },
+ { -2, -1 }, { -1, -1 }, { 0, -1 }, { 1, -1 }, { 2, -1 },
+ { 3, -1 }, { 10, -1 }, { -5, 0 }, { -3, 0 }, { -2, 0 },
+ { -1, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, { 5, 0 },
+ { 7, 0 }, { -10, 1 }, { -7, 1 }, { -3, 1 }, { -2, 1 },
+ { -1, 1 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 },
+ { -43, 2 }, { -25, 2 }, { -19, 2 }, { -14, 2 }, { -5, 2 },
+ { -3, 2 }, { -2, 2 }, { -1, 2 }, { 0, 2 }, { 1, 2 },
+ { 2, 2 }, { 3, 2 }, { 5, 2 }, { 7, 2 }, { 10, 2 },
+ { 14, 2 }, { -33, 3 }, { -6, 3 }, { -4, 3 }, { -2, 3 },
+ { -1, 3 }, { 0, 3 }, { 1, 3 }, { 2, 3 }, { 4, 3 },
+ { 19, 3 }, { -9, 4 }, { -3, 4 }, { 3, 4 }, { 7, 4 },
+ { 25, 4 }, { -13, 5 }, { -5, 5 }, { -2, 5 }, { 0, 5 },
+ { 2, 5 }, { 5, 5 }, { 9, 5 }, { 33, 5 }, { -8, 6 },
+ { -4, 6 }, { 4, 6 }, { 13, 6 }, { 43, 6 }, { -18, 7 },
+ { -2, 7 }, { 0, 7 }, { 2, 7 }, { 7, 7 }, { 18, 7 },
+ { -24, 8 }, { -6, 8 }, { -42, 9 }, { -11, 9 }, { -4, 9 },
+ { 5, 9 }, { 11, 9 }, { 23, 9 }, { -31, 10 }, { -1, 10 },
+ { 2, 10 }, { -15, 11 }, { -8, 11 }, { 8, 11 }, { 15, 11 },
+ { 31, 12 }, { -21, 13 }, { -5, 13 }, { 5, 13 }, { 41, 13 },
+ { -1, 14 }, { 1, 14 }, { 21, 14 }, { -12, 15 }, { 12, 15 },
+ { -39, 17 }, { -28, 17 }, { -18, 17 }, { -8, 17 }, { 8, 17 },
+ { 17, 18 }, { -4, 19 }, { 0, 19 }, { 4, 19 }, { 27, 19 },
+ { 38, 20 }, { -13, 21 }, { 12, 22 }, { -36, 23 }, { -24, 23 },
+ { -8, 24 }, { 7, 24 }, { -3, 25 }, { 1, 25 }, { 22, 25 },
+ { 34, 26 }, { -18, 28 }, { -32, 29 }, { 16, 29 }, { -11, 31 },
+ { 9, 32 }, { 29, 32 }, { -4, 33 }, { 2, 33 }, { -26, 34 },
+ { 23, 36 }, { -19, 39 }, { 16, 40 }, { -13, 41 }, { 9, 42 },
+ { -6, 43 }, { 1, 43 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
+};
+
+static const int8_t c37_mv[] = {
+ 0, 0, 1, 0, 2, 0, 3, 0, 5, 0,
+ 8, 0, 13, 0, 21, 0, -1, 0, -2, 0,
+ -3, 0, -5, 0, -8, 0, -13, 0, -17, 0,
+ -21, 0, 0, 1, 1, 1, 2, 1, 3, 1,
+ 5, 1, 8, 1, 13, 1, 21, 1, -1, 1,
+ -2, 1, -3, 1, -5, 1, -8, 1, -13, 1,
+ -17, 1, -21, 1, 0, 2, 1, 2, 2, 2,
+ 3, 2, 5, 2, 8, 2, 13, 2, 21, 2,
+ -1, 2, -2, 2, -3, 2, -5, 2, -8, 2,
+ -13, 2, -17, 2, -21, 2, 0, 3, 1, 3,
+ 2, 3, 3, 3, 5, 3, 8, 3, 13, 3,
+ 21, 3, -1, 3, -2, 3, -3, 3, -5, 3,
+ -8, 3, -13, 3, -17, 3, -21, 3, 0, 5,
+ 1, 5, 2, 5, 3, 5, 5, 5, 8, 5,
+ 13, 5, 21, 5, -1, 5, -2, 5, -3, 5,
+ -5, 5, -8, 5, -13, 5, -17, 5, -21, 5,
+ 0, 8, 1, 8, 2, 8, 3, 8, 5, 8,
+ 8, 8, 13, 8, 21, 8, -1, 8, -2, 8,
+ -3, 8, -5, 8, -8, 8, -13, 8, -17, 8,
+ -21, 8, 0, 13, 1, 13, 2, 13, 3, 13,
+ 5, 13, 8, 13, 13, 13, 21, 13, -1, 13,
+ -2, 13, -3, 13, -5, 13, -8, 13, -13, 13,
+ -17, 13, -21, 13, 0, 21, 1, 21, 2, 21,
+ 3, 21, 5, 21, 8, 21, 13, 21, 21, 21,
+ -1, 21, -2, 21, -3, 21, -5, 21, -8, 21,
+ -13, 21, -17, 21, -21, 21, 0, -1, 1, -1,
+ 2, -1, 3, -1, 5, -1, 8, -1, 13, -1,
+ 21, -1, -1, -1, -2, -1, -3, -1, -5, -1,
+ -8, -1, -13, -1, -17, -1, -21, -1, 0, -2,
+ 1, -2, 2, -2, 3, -2, 5, -2, 8, -2,
+ 13, -2, 21, -2, -1, -2, -2, -2, -3, -2,
+ -5, -2, -8, -2, -13, -2, -17, -2, -21, -2,
+ 0, -3, 1, -3, 2, -3, 3, -3, 5, -3,
+ 8, -3, 13, -3, 21, -3, -1, -3, -2, -3,
+ -3, -3, -5, -3, -8, -3, -13, -3, -17, -3,
+ -21, -3, 0, -5, 1, -5, 2, -5, 3, -5,
+ 5, -5, 8, -5, 13, -5, 21, -5, -1, -5,
+ -2, -5, -3, -5, -5, -5, -8, -5, -13, -5,
+ -17, -5, -21, -5, 0, -8, 1, -8, 2, -8,
+ 3, -8, 5, -8, 8, -8, 13, -8, 21, -8,
+ -1, -8, -2, -8, -3, -8, -5, -8, -8, -8,
+ -13, -8, -17, -8, -21, -8, 0, -13, 1, -13,
+ 2, -13, 3, -13, 5, -13, 8, -13, 13, -13,
+ 21, -13, -1, -13, -2, -13, -3, -13, -5, -13,
+ -8, -13, -13, -13, -17, -13, -21, -13, 0, -17,
+ 1, -17, 2, -17, 3, -17, 5, -17, 8, -17,
+ 13, -17, 21, -17, -1, -17, -2, -17, -3, -17,
+ -5, -17, -8, -17, -13, -17, -17, -17, -21, -17,
+ 0, -21, 1, -21, 2, -21, 3, -21, 5, -21,
+ 8, -21, 13, -21, 21, -21, -1, -21, -2, -21,
+ -3, -21, -5, -21, -8, -21, -13, -21, -17, -21,
+ 0, 0, -8, -29, 8, -29, -18, -25, 17, -25,
+ 0, -23, -6, -22, 6, -22, -13, -19, 12, -19,
+ 0, -18, 25, -18, -25, -17, -5, -17, 5, -17,
+ -10, -15, 10, -15, 0, -14, -4, -13, 4, -13,
+ 19, -13, -19, -12, -8, -11, -2, -11, 0, -11,
+ 2, -11, 8, -11, -15, -10, -4, -10, 4, -10,
+ 15, -10, -6, -9, -1, -9, 1, -9, 6, -9,
+ -29, -8, -11, -8, -8, -8, -3, -8, 3, -8,
+ 8, -8, 11, -8, 29, -8, -5, -7, -2, -7,
+ 0, -7, 2, -7, 5, -7, -22, -6, -9, -6,
+ -6, -6, -3, -6, -1, -6, 1, -6, 3, -6,
+ 6, -6, 9, -6, 22, -6, -17, -5, -7, -5,
+ -4, -5, -2, -5, 0, -5, 2, -5, 4, -5,
+ 7, -5, 17, -5, -13, -4, -10, -4, -5, -4,
+ -3, -4, -1, -4, 0, -4, 1, -4, 3, -4,
+ 5, -4, 10, -4, 13, -4, -8, -3, -6, -3,
+ -4, -3, -3, -3, -2, -3, -1, -3, 0, -3,
+ 1, -3, 2, -3, 4, -3, 6, -3, 8, -3,
+ -11, -2, -7, -2, -5, -2, -3, -2, -2, -2,
+ -1, -2, 0, -2, 1, -2, 2, -2, 3, -2,
+ 5, -2, 7, -2, 11, -2, -9, -1, -6, -1,
+ -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
+ 1, -1, 2, -1, 3, -1, 4, -1, 6, -1,
+ 9, -1, -31, 0, -23, 0, -18, 0, -14, 0,
+ -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
+ -2, 0, -1, 0, 0, -31, 1, 0, 2, 0,
+ 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
+ 14, 0, 18, 0, 23, 0, 31, 0, -9, 1,
+ -6, 1, -4, 1, -3, 1, -2, 1, -1, 1,
+ 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
+ 6, 1, 9, 1, -11, 2, -7, 2, -5, 2,
+ -3, 2, -2, 2, -1, 2, 0, 2, 1, 2,
+ 2, 2, 3, 2, 5, 2, 7, 2, 11, 2,
+ -8, 3, -6, 3, -4, 3, -2, 3, -1, 3,
+ 0, 3, 1, 3, 2, 3, 3, 3, 4, 3,
+ 6, 3, 8, 3, -13, 4, -10, 4, -5, 4,
+ -3, 4, -1, 4, 0, 4, 1, 4, 3, 4,
+ 5, 4, 10, 4, 13, 4, -17, 5, -7, 5,
+ -4, 5, -2, 5, 0, 5, 2, 5, 4, 5,
+ 7, 5, 17, 5, -22, 6, -9, 6, -6, 6,
+ -3, 6, -1, 6, 1, 6, 3, 6, 6, 6,
+ 9, 6, 22, 6, -5, 7, -2, 7, 0, 7,
+ 2, 7, 5, 7, -29, 8, -11, 8, -8, 8,
+ -3, 8, 3, 8, 8, 8, 11, 8, 29, 8,
+ -6, 9, -1, 9, 1, 9, 6, 9, -15, 10,
+ -4, 10, 4, 10, 15, 10, -8, 11, -2, 11,
+ 0, 11, 2, 11, 8, 11, 19, 12, -19, 13,
+ -4, 13, 4, 13, 0, 14, -10, 15, 10, 15,
+ -5, 17, 5, 17, 25, 17, -25, 18, 0, 18,
+ -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
+ -17, 25, 18, 25, -8, 29, 8, 29, 0, 31,
+ 0, 0, -6, -22, 6, -22, -13, -19, 12, -19,
+ 0, -18, -5, -17, 5, -17, -10, -15, 10, -15,
+ 0, -14, -4, -13, 4, -13, 19, -13, -19, -12,
+ -8, -11, -2, -11, 0, -11, 2, -11, 8, -11,
+ -15, -10, -4, -10, 4, -10, 15, -10, -6, -9,
+ -1, -9, 1, -9, 6, -9, -11, -8, -8, -8,
+ -3, -8, 0, -8, 3, -8, 8, -8, 11, -8,
+ -5, -7, -2, -7, 0, -7, 2, -7, 5, -7,
+ -22, -6, -9, -6, -6, -6, -3, -6, -1, -6,
+ 1, -6, 3, -6, 6, -6, 9, -6, 22, -6,
+ -17, -5, -7, -5, -4, -5, -2, -5, -1, -5,
+ 0, -5, 1, -5, 2, -5, 4, -5, 7, -5,
+ 17, -5, -13, -4, -10, -4, -5, -4, -3, -4,
+ -2, -4, -1, -4, 0, -4, 1, -4, 2, -4,
+ 3, -4, 5, -4, 10, -4, 13, -4, -8, -3,
+ -6, -3, -4, -3, -3, -3, -2, -3, -1, -3,
+ 0, -3, 1, -3, 2, -3, 3, -3, 4, -3,
+ 6, -3, 8, -3, -11, -2, -7, -2, -5, -2,
+ -4, -2, -3, -2, -2, -2, -1, -2, 0, -2,
+ 1, -2, 2, -2, 3, -2, 4, -2, 5, -2,
+ 7, -2, 11, -2, -9, -1, -6, -1, -5, -1,
+ -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
+ 1, -1, 2, -1, 3, -1, 4, -1, 5, -1,
+ 6, -1, 9, -1, -23, 0, -18, 0, -14, 0,
+ -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
+ -2, 0, -1, 0, 0, -23, 1, 0, 2, 0,
+ 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
+ 14, 0, 18, 0, 23, 0, -9, 1, -6, 1,
+ -5, 1, -4, 1, -3, 1, -2, 1, -1, 1,
+ 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
+ 5, 1, 6, 1, 9, 1, -11, 2, -7, 2,
+ -5, 2, -4, 2, -3, 2, -2, 2, -1, 2,
+ 0, 2, 1, 2, 2, 2, 3, 2, 4, 2,
+ 5, 2, 7, 2, 11, 2, -8, 3, -6, 3,
+ -4, 3, -3, 3, -2, 3, -1, 3, 0, 3,
+ 1, 3, 2, 3, 3, 3, 4, 3, 6, 3,
+ 8, 3, -13, 4, -10, 4, -5, 4, -3, 4,
+ -2, 4, -1, 4, 0, 4, 1, 4, 2, 4,
+ 3, 4, 5, 4, 10, 4, 13, 4, -17, 5,
+ -7, 5, -4, 5, -2, 5, -1, 5, 0, 5,
+ 1, 5, 2, 5, 4, 5, 7, 5, 17, 5,
+ -22, 6, -9, 6, -6, 6, -3, 6, -1, 6,
+ 1, 6, 3, 6, 6, 6, 9, 6, 22, 6,
+ -5, 7, -2, 7, 0, 7, 2, 7, 5, 7,
+ -11, 8, -8, 8, -3, 8, 0, 8, 3, 8,
+ 8, 8, 11, 8, -6, 9, -1, 9, 1, 9,
+ 6, 9, -15, 10, -4, 10, 4, 10, 15, 10,
+ -8, 11, -2, 11, 0, 11, 2, 11, 8, 11,
+ 19, 12, -19, 13, -4, 13, 4, 13, 0, 14,
+ -10, 15, 10, 15, -5, 17, 5, 17, 0, 18,
+ -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
+};
+
+typedef struct SANMVideoContext {
AVCodecContext *avctx;
GetByteContext gb;
int version, subversion;
- uint32_t pal[256];
- int16_t delta_pal[768];
+ uint32_t pal[PALETTE_SIZE];
+ int16_t delta_pal[PALETTE_DELTA];
int pitch;
int width, height;
@@ -66,7 +293,7 @@ typedef struct {
int8_t p8x8glyphs[NGLYPHS][64];
} SANMVideoContext;
-typedef struct {
+typedef struct SANMFrameHeader {
int seq_num, codec, rotate_code, rle_output_size;
uint16_t bg_color;
@@ -100,17 +327,16 @@ static enum GlyphEdge which_edge(int x, int y, int edge_size)
{
const int edge_max = edge_size - 1;
- if (!y) {
+ if (!y)
return BOTTOM_EDGE;
- } else if (y == edge_max) {
+ else if (y == edge_max)
return TOP_EDGE;
- } else if (!x) {
+ else if (!x)
return LEFT_EDGE;
- } else if (x == edge_max) {
+ else if (x == edge_max)
return RIGHT_EDGE;
- } else {
+ else
return NO_EDGE;
- }
}
static enum GlyphDir which_direction(enum GlyphEdge edge0, enum GlyphEdge edge1)
@@ -118,27 +344,24 @@ static enum GlyphDir which_direction(enum GlyphEdge edge0, enum GlyphEdge edge1)
if ((edge0 == LEFT_EDGE && edge1 == RIGHT_EDGE) ||
(edge1 == LEFT_EDGE && edge0 == RIGHT_EDGE) ||
(edge0 == BOTTOM_EDGE && edge1 != TOP_EDGE) ||
- (edge1 == BOTTOM_EDGE && edge0 != TOP_EDGE)) {
+ (edge1 == BOTTOM_EDGE && edge0 != TOP_EDGE))
return DIR_UP;
- } else if ((edge0 == TOP_EDGE && edge1 != BOTTOM_EDGE) ||
- (edge1 == TOP_EDGE && edge0 != BOTTOM_EDGE)) {
+ else if ((edge0 == TOP_EDGE && edge1 != BOTTOM_EDGE) ||
+ (edge1 == TOP_EDGE && edge0 != BOTTOM_EDGE))
return DIR_DOWN;
- } else if ((edge0 == LEFT_EDGE && edge1 != RIGHT_EDGE) ||
- (edge1 == LEFT_EDGE && edge0 != RIGHT_EDGE)) {
+ else if ((edge0 == LEFT_EDGE && edge1 != RIGHT_EDGE) ||
+ (edge1 == LEFT_EDGE && edge0 != RIGHT_EDGE))
return DIR_LEFT;
- } else if ((edge0 == TOP_EDGE && edge1 == BOTTOM_EDGE) ||
- (edge1 == TOP_EDGE && edge0 == BOTTOM_EDGE) ||
- (edge0 == RIGHT_EDGE && edge1 != LEFT_EDGE) ||
- (edge1 == RIGHT_EDGE && edge0 != LEFT_EDGE)) {
+ else if ((edge0 == TOP_EDGE && edge1 == BOTTOM_EDGE) ||
+ (edge1 == TOP_EDGE && edge0 == BOTTOM_EDGE) ||
+ (edge0 == RIGHT_EDGE && edge1 != LEFT_EDGE) ||
+ (edge1 == RIGHT_EDGE && edge0 != LEFT_EDGE))
return DIR_RIGHT;
- }
return NO_DIR;
}
-/**
- * Interpolate two points.
- */
+/* Interpolate two points. */
static void interp_point(int8_t *points, int x0, int y0, int x1, int y1,
int pos, int npoints)
{
@@ -152,11 +375,11 @@ static void interp_point(int8_t *points, int x0, int y0, int x1, int y1,
}
/**
- * Construct glyphs by iterating through vectors coordinates.
+ * Construct glyphs by iterating through vector coordinates.
*
* @param pglyphs pointer to table where glyphs are stored
- * @param xvec pointer to x component of vectors coordinates
- * @param yvec pointer to y component of vectors coordinates
+ * @param xvec pointer to x component of vector coordinates
+ * @param yvec pointer to y component of vector coordinates
* @param side_length glyph width/height.
*/
static void make_glyphs(int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec,
@@ -167,15 +390,15 @@ static void make_glyphs(int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec,
int i, j;
for (i = 0; i < GLYPH_COORD_VECT_SIZE; i++) {
- int x0 = xvec[i];
- int y0 = yvec[i];
+ int x0 = xvec[i];
+ int y0 = yvec[i];
enum GlyphEdge edge0 = which_edge(x0, y0, side_length);
for (j = 0; j < GLYPH_COORD_VECT_SIZE; j++, pglyph += glyph_size) {
- int x1 = xvec[j];
- int y1 = yvec[j];
- enum GlyphEdge edge1 = which_edge(x1, y1, side_length);
- enum GlyphDir dir = which_direction(edge0, edge1);
+ int x1 = xvec[j];
+ int y1 = yvec[j];
+ enum GlyphEdge edge1 = which_edge(x1, y1, side_length);
+ enum GlyphDir dir = which_direction(edge0, edge1);
int npoints = FFMAX(FFABS(x1 - x0), FFABS(y1 - y0));
int ipoint;
@@ -217,7 +440,7 @@ static void init_sizes(SANMVideoContext *ctx, int width, int height)
ctx->height = height;
ctx->npixels = width * height;
- ctx->aligned_width = FFALIGN(width, 8);
+ ctx->aligned_width = FFALIGN(width, 8);
ctx->aligned_height = FFALIGN(height, 8);
ctx->buf_size = ctx->aligned_width * ctx->aligned_height * sizeof(ctx->frm0[0]);
@@ -242,9 +465,11 @@ static av_cold int init_buffers(SANMVideoContext *ctx)
av_fast_padded_malloc(&ctx->frm1, &ctx->frm1_size, ctx->buf_size);
av_fast_padded_malloc(&ctx->frm2, &ctx->frm2_size, ctx->buf_size);
if (!ctx->version)
- av_fast_padded_malloc(&ctx->stored_frame, &ctx->stored_frame_size, ctx->buf_size);
+ av_fast_padded_malloc(&ctx->stored_frame,
+ &ctx->stored_frame_size, ctx->buf_size);
- if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 || (!ctx->stored_frame && !ctx->version)) {
+ if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 ||
+ (!ctx->stored_frame && !ctx->version)) {
destroy_buffers(ctx);
return AVERROR(ENOMEM);
}
@@ -254,7 +479,6 @@ static av_cold int init_buffers(SANMVideoContext *ctx)
static void rotate_bufs(SANMVideoContext *ctx, int rotate_code)
{
- av_dlog(ctx->avctx, "rotate %d\n", rotate_code);
if (rotate_code == 2)
FFSWAP(uint16_t*, ctx->frm1, ctx->frm2);
FFSWAP(uint16_t*, ctx->frm2, ctx->frm0);
@@ -264,14 +488,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
{
SANMVideoContext *ctx = avctx->priv_data;
- ctx->avctx = avctx;
- ctx->version = !avctx->extradata_size;
+ ctx->avctx = avctx;
+ ctx->version = !avctx->extradata_size;
avctx->pix_fmt = ctx->version ? AV_PIX_FMT_RGB565 : AV_PIX_FMT_PAL8;
init_sizes(ctx, avctx->width, avctx->height);
if (init_buffers(ctx)) {
- av_log(avctx, AV_LOG_ERROR, "error allocating buffers\n");
+ av_log(avctx, AV_LOG_ERROR, "Error allocating buffers.\n");
return AVERROR(ENOMEM);
}
@@ -282,12 +506,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
int i;
if (avctx->extradata_size < 1026) {
- av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
+ av_log(avctx, AV_LOG_ERROR, "Not enough extradata.\n");
return AVERROR_INVALIDDATA;
}
ctx->subversion = AV_RL16(avctx->extradata);
- for (i = 0; i < 256; i++)
+ for (i = 0; i < PALETTE_SIZE; i++)
ctx->pal[i] = 0xFFU << 24 | AV_RL32(avctx->extradata + 2 + i * 4);
}
@@ -332,7 +556,7 @@ static int rle_decode(SANMVideoContext *ctx, uint8_t *dst, const int out_size)
static int old_codec1(SANMVideoContext *ctx, int top,
int left, int width, int height)
{
- uint8_t *dst = ((uint8_t*)ctx->frm0) + left + top * ctx->pitch;
+ uint8_t *dst = ((uint8_t *)ctx->frm0) + left + top * ctx->pitch;
int i, j, len, flag, code, val, pos, end;
for (i = 0; i < height; i++) {
@@ -400,22 +624,21 @@ static int old_codec37(SANMVideoContext *ctx, int top,
{
int stride = ctx->pitch;
int i, j, k, t;
- int skip_run = 0;
- int compr, mvoff, seq, flags;
- uint32_t decoded_size;
uint8_t *dst, *prev;
+ int skip_run = 0;
+ int compr = bytestream2_get_byte(&ctx->gb);
+ int mvoff = bytestream2_get_byte(&ctx->gb);
+ int seq = bytestream2_get_le16(&ctx->gb);
+ uint32_t decoded_size = bytestream2_get_le32(&ctx->gb);
+ int flags;
- compr = bytestream2_get_byte(&ctx->gb);
- mvoff = bytestream2_get_byte(&ctx->gb);
- seq = bytestream2_get_le16(&ctx->gb);
- decoded_size = bytestream2_get_le32(&ctx->gb);
bytestream2_skip(&ctx->gb, 4);
- flags = bytestream2_get_byte(&ctx->gb);
+ flags = bytestream2_get_byte(&ctx->gb);
bytestream2_skip(&ctx->gb, 3);
if (decoded_size > ctx->height * stride - left - top * stride) {
decoded_size = ctx->height * stride - left - top * stride;
- av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n");
+ av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n");
}
ctx->rotate_code = 0;
@@ -427,10 +650,10 @@ static int old_codec37(SANMVideoContext *ctx, int top,
prev = ((uint8_t*)ctx->frm2) + left + top * stride;
if (mvoff > 2) {
- av_log(ctx->avctx, AV_LOG_ERROR, "invalid motion base value %d\n", mvoff);
+ av_log(ctx->avctx, AV_LOG_ERROR, "Invalid motion base value %d.\n", mvoff);
return AVERROR_INVALIDDATA;
}
- av_dlog(ctx->avctx, "compression %d\n", compr);
+
switch (compr) {
case 0:
for (i = 0; i < height; i++) {
@@ -489,7 +712,7 @@ static int old_codec37(SANMVideoContext *ctx, int top,
} else {
int mx, my;
- mx = c37_mv[(mvoff * 255 + code) * 2 ];
+ mx = c37_mv[(mvoff * 255 + code) * 2];
my = c37_mv[(mvoff * 255 + code) * 2 + 1];
codec37_mv(dst + i, prev + i + mx + my * stride,
ctx->height, stride, i + mx, j + my);
@@ -534,8 +757,8 @@ static int old_codec37(SANMVideoContext *ctx, int top,
}
break;
default:
- av_log(ctx->avctx, AV_LOG_ERROR,
- "subcodec 37 compression %d not implemented\n", compr);
+ avpriv_report_missing_feature(ctx->avctx,
+ "Subcodec 37 compression %d", compr);
return AVERROR_PATCHWELCOME;
}
@@ -559,10 +782,10 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
if (size == 2) {
if (bytestream2_get_bytes_left(&ctx->gb) < 4)
return AVERROR_INVALIDDATA;
- dst[0] = bytestream2_get_byteu(&ctx->gb);
- dst[1] = bytestream2_get_byteu(&ctx->gb);
- dst[0+stride] = bytestream2_get_byteu(&ctx->gb);
- dst[1+stride] = bytestream2_get_byteu(&ctx->gb);
+ dst[0] = bytestream2_get_byteu(&ctx->gb);
+ dst[1] = bytestream2_get_byteu(&ctx->gb);
+ dst[0 + stride] = bytestream2_get_byteu(&ctx->gb);
+ dst[1 + stride] = bytestream2_get_byteu(&ctx->gb);
} else {
size >>= 1;
if (process_block(ctx, dst, prev1, prev2, stride, tbl, size))
@@ -615,13 +838,13 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
} else {
int mx = motion_vectors[code][0];
int my = motion_vectors[code][1];
- int index = prev2 - (const uint8_t*)ctx->frm2;
+ int index = prev2 - (const uint8_t *)ctx->frm2;
- av_assert2(index >= 0 && index < (ctx->buf_size>>1));
+ av_assert2(index >= 0 && index < (ctx->buf_size >> 1));
- if (index < - mx - my*stride ||
- (ctx->buf_size>>1) - index < mx + size + (my + size - 1)*stride) {
- av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid \n");
+ if (index < -mx - my * stride ||
+ (ctx->buf_size >> 1) - index < mx + size + (my + size - 1) * stride) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid.\n");
return AVERROR_INVALIDDATA;
}
@@ -635,25 +858,25 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
static int old_codec47(SANMVideoContext *ctx, int top,
int left, int width, int height)
{
- int i, j, seq, compr, new_rot, tbl_pos, skip;
- int stride = ctx->pitch;
- uint8_t *dst = ((uint8_t*)ctx->frm0) + left + top * stride;
- uint8_t *prev1 = (uint8_t*)ctx->frm1;
- uint8_t *prev2 = (uint8_t*)ctx->frm2;
uint32_t decoded_size;
+ int i, j;
+ int stride = ctx->pitch;
+ uint8_t *dst = (uint8_t *)ctx->frm0 + left + top * stride;
+ uint8_t *prev1 = (uint8_t *)ctx->frm1;
+ uint8_t *prev2 = (uint8_t *)ctx->frm2;
+ int tbl_pos = bytestream2_tell(&ctx->gb);
+ int seq = bytestream2_get_le16(&ctx->gb);
+ int compr = bytestream2_get_byte(&ctx->gb);
+ int new_rot = bytestream2_get_byte(&ctx->gb);
+ int skip = bytestream2_get_byte(&ctx->gb);
- tbl_pos = bytestream2_tell(&ctx->gb);
- seq = bytestream2_get_le16(&ctx->gb);
- compr = bytestream2_get_byte(&ctx->gb);
- new_rot = bytestream2_get_byte(&ctx->gb);
- skip = bytestream2_get_byte(&ctx->gb);
bytestream2_skip(&ctx->gb, 9);
decoded_size = bytestream2_get_le32(&ctx->gb);
bytestream2_skip(&ctx->gb, 8);
if (decoded_size > ctx->height * stride - left - top * stride) {
decoded_size = ctx->height * stride - left - top * stride;
- av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n");
+ av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n");
}
if (skip & 1)
@@ -663,7 +886,7 @@ static int old_codec47(SANMVideoContext *ctx, int top,
memset(prev1, 0, ctx->height * stride);
memset(prev2, 0, ctx->height * stride);
}
- av_dlog(ctx->avctx, "compression %d\n", compr);
+
switch (compr) {
case 0:
if (bytestream2_get_bytes_left(&ctx->gb) < width * height)
@@ -678,8 +901,10 @@ static int old_codec47(SANMVideoContext *ctx, int top,
return AVERROR_INVALIDDATA;
for (j = 0; j < height; j += 2) {
for (i = 0; i < width; i += 2) {
- dst[i] = dst[i + 1] =
- dst[stride + i] = dst[stride + i + 1] = bytestream2_get_byteu(&ctx->gb);
+ dst[i] =
+ dst[i + 1] =
+ dst[stride + i] =
+ dst[stride + i + 1] = bytestream2_get_byteu(&ctx->gb);
}
dst += stride * 2;
}
@@ -687,11 +912,10 @@ static int old_codec47(SANMVideoContext *ctx, int top,
case 2:
if (seq == ctx->prev_seq + 1) {
for (j = 0; j < height; j += 8) {
- for (i = 0; i < width; i += 8) {
+ for (i = 0; i < width; i += 8)
if (process_block(ctx, dst + i, prev1 + i, prev2 + i, stride,
tbl_pos + 8, 8))
return AVERROR_INVALIDDATA;
- }
dst += stride * 8;
prev1 += stride * 8;
prev2 += stride * 8;
@@ -709,8 +933,8 @@ static int old_codec47(SANMVideoContext *ctx, int top,
return AVERROR_INVALIDDATA;
break;
default:
- av_log(ctx->avctx, AV_LOG_ERROR,
- "subcodec 47 compression %d not implemented\n", compr);
+ avpriv_report_missing_feature(ctx->avctx,
+ "Subcodec 47 compression %d", compr);
return AVERROR_PATCHWELCOME;
}
if (seq == ctx->prev_seq + 1)
@@ -724,34 +948,31 @@ static int old_codec47(SANMVideoContext *ctx, int top,
static int process_frame_obj(SANMVideoContext *ctx)
{
- uint16_t codec, top, left, w, h;
-
- codec = bytestream2_get_le16u(&ctx->gb);
- left = bytestream2_get_le16u(&ctx->gb);
- top = bytestream2_get_le16u(&ctx->gb);
- w = bytestream2_get_le16u(&ctx->gb);
- h = bytestream2_get_le16u(&ctx->gb);
+ uint16_t codec = bytestream2_get_le16u(&ctx->gb);
+ uint16_t left = bytestream2_get_le16u(&ctx->gb);
+ uint16_t top = bytestream2_get_le16u(&ctx->gb);
+ uint16_t w = bytestream2_get_le16u(&ctx->gb);
+ uint16_t h = bytestream2_get_le16u(&ctx->gb);
if (!w || !h) {
- av_log(ctx->avctx, AV_LOG_ERROR, "dimensions are invalid\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Dimensions are invalid.\n");
return AVERROR_INVALIDDATA;
}
if (ctx->width < left + w || ctx->height < top + h) {
int ret = ff_set_dimensions(ctx->avctx, FFMAX(left + w, ctx->width),
- FFMAX(top + h, ctx->height));
+ FFMAX(top + h, ctx->height));
if (ret < 0)
return ret;
init_sizes(ctx, FFMAX(left + w, ctx->width),
- FFMAX(top + h, ctx->height));
+ FFMAX(top + h, ctx->height));
if (init_buffers(ctx)) {
- av_log(ctx->avctx, AV_LOG_ERROR, "error resizing buffers\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Error resizing buffers.\n");
return AVERROR(ENOMEM);
}
}
bytestream2_skip(&ctx->gb, 4);
- av_dlog(ctx->avctx, "subcodec %d\n", codec);
switch (codec) {
case 1:
case 3:
@@ -764,7 +985,7 @@ static int process_frame_obj(SANMVideoContext *ctx)
return old_codec47(ctx, top, left, w, h);
break;
default:
- avpriv_request_sample(ctx->avctx, "unknown subcodec %d", codec);
+ avpriv_request_sample(ctx->avctx, "Subcodec %d", codec);
return AVERROR_PATCHWELCOME;
}
}
@@ -775,7 +996,7 @@ static int decode_0(SANMVideoContext *ctx)
int x, y;
if (bytestream2_get_bytes_left(&ctx->gb) < ctx->width * ctx->height * 2) {
- av_log(ctx->avctx, AV_LOG_ERROR, "insufficient data for raw frame\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for raw frame.\n");
return AVERROR_INVALIDDATA;
}
for (y = 0; y < ctx->height; y++) {
@@ -788,7 +1009,7 @@ static int decode_0(SANMVideoContext *ctx)
static int decode_nop(SANMVideoContext *ctx)
{
- avpriv_request_sample(ctx->avctx, "unknown/unsupported compression type");
+ avpriv_request_sample(ctx->avctx, "Unknown/unsupported compression type");
return AVERROR_PATCHWELCOME;
}
@@ -821,15 +1042,16 @@ static void fill_block(uint16_t *pdest, uint16_t color, int block_size, int pitc
*pdest++ = color;
}
-static int draw_glyph(SANMVideoContext *ctx, uint16_t *dst, int index, uint16_t fg_color,
- uint16_t bg_color, int block_size, int pitch)
+static int draw_glyph(SANMVideoContext *ctx, uint16_t *dst, int index,
+ uint16_t fg_color, uint16_t bg_color, int block_size,
+ int pitch)
{
int8_t *pglyph;
uint16_t colors[2] = { fg_color, bg_color };
int x, y;
if (index >= NGLYPHS) {
- av_log(ctx->avctx, AV_LOG_ERROR, "ignoring nonexistent glyph #%u\n", index);
+ av_log(ctx->avctx, AV_LOG_ERROR, "Ignoring nonexistent glyph #%u.\n", index);
return AVERROR_INVALIDDATA;
}
@@ -853,9 +1075,12 @@ static int opcode_0xf7(SANMVideoContext *ctx, int cx, int cy, int block_size, in
return AVERROR_INVALIDDATA;
indices = bytestream2_get_le32u(&ctx->gb);
- dst[0] = ctx->codebook[indices & 0xFF]; indices >>= 8;
- dst[1] = ctx->codebook[indices & 0xFF]; indices >>= 8;
- dst[pitch] = ctx->codebook[indices & 0xFF]; indices >>= 8;
+ dst[0] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
+ dst[1] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
+ dst[pitch] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
dst[pitch + 1] = ctx->codebook[indices & 0xFF];
} else {
uint16_t fgcolor, bgcolor;
@@ -909,10 +1134,10 @@ static int good_mvec(SANMVideoContext *ctx, int cx, int cy, int mx, int my,
int good = start_pos >= 0 && end_pos < (ctx->buf_size >> 1);
- if (!good) {
- av_log(ctx->avctx, AV_LOG_ERROR, "ignoring invalid motion vector (%i, %i)->(%u, %u), block size = %u\n",
+ if (!good)
+ av_log(ctx->avctx, AV_LOG_ERROR,
+ "Ignoring invalid motion vector (%i, %i)->(%u, %u), block size = %u\n",
cx + mx, cy + my, cx, cy, block_size);
- }
return good;
}
@@ -927,7 +1152,6 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size)
opcode = bytestream2_get_byteu(&ctx->gb);
- av_dlog(ctx->avctx, "opcode 0x%0X cx %d cy %d blk %d\n", opcode, cx, cy, blk_size);
switch (opcode) {
default:
mx = motion_vectors[opcode][0];
@@ -989,11 +1213,11 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size)
opcode_0xf8(ctx, cx, cy, blk_size, ctx->pitch);
} else {
blk_size >>= 1;
- if (codec2subblock(ctx, cx , cy , blk_size))
+ if (codec2subblock(ctx, cx, cy, blk_size))
return AVERROR_INVALIDDATA;
- if (codec2subblock(ctx, cx + blk_size, cy , blk_size))
+ if (codec2subblock(ctx, cx + blk_size, cy, blk_size))
return AVERROR_INVALIDDATA;
- if (codec2subblock(ctx, cx , cy + blk_size, blk_size))
+ if (codec2subblock(ctx, cx, cy + blk_size, blk_size))
return AVERROR_INVALIDDATA;
if (codec2subblock(ctx, cx + blk_size, cy + blk_size, blk_size))
return AVERROR_INVALIDDATA;
@@ -1007,12 +1231,10 @@ static int decode_2(SANMVideoContext *ctx)
{
int cx, cy, ret;
- for (cy = 0; cy < ctx->aligned_height; cy += 8) {
- for (cx = 0; cx < ctx->aligned_width; cx += 8) {
+ for (cy = 0; cy < ctx->aligned_height; cy += 8)
+ for (cx = 0; cx < ctx->aligned_width; cx += 8)
if (ret = codec2subblock(ctx, cx, cy, 8))
return ret;
- }
- }
return 0;
}
@@ -1058,7 +1280,7 @@ static int decode_6(SANMVideoContext *ctx)
uint16_t *frm = ctx->frm0;
if (bytestream2_get_bytes_left(&ctx->gb) < npixels) {
- av_log(ctx->avctx, AV_LOG_ERROR, "insufficient data for frame\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for frame.\n");
return AVERROR_INVALIDDATA;
}
while (npixels--)
@@ -1075,7 +1297,7 @@ static int decode_8(SANMVideoContext *ctx)
av_fast_malloc(&ctx->rle_buf, &ctx->rle_buf_size, npixels);
if (!ctx->rle_buf) {
- av_log(ctx->avctx, AV_LOG_ERROR, "RLE buffer allocation failed\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "RLE buffer allocation failed.\n");
return AVERROR(ENOMEM);
}
rsrc = ctx->rle_buf;
@@ -1101,7 +1323,7 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
int i, ret;
if ((ret = bytestream2_get_bytes_left(&ctx->gb)) < 560) {
- av_log(ctx->avctx, AV_LOG_ERROR, "too short input frame (%d bytes)\n",
+ av_log(ctx->avctx, AV_LOG_ERROR, "Input frame too short (%d bytes).\n",
ret);
return AVERROR_INVALIDDATA;
}
@@ -1111,7 +1333,7 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
hdr->height = bytestream2_get_le32u(&ctx->gb);
if (hdr->width != ctx->width || hdr->height != ctx->height) {
- av_log(ctx->avctx, AV_LOG_ERROR, "variable size frames are not implemented\n");
+ avpriv_report_missing_feature(ctx->avctx, "Variable size frames");
return AVERROR_PATCHWELCOME;
}
@@ -1133,7 +1355,6 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
bytestream2_skip(&ctx->gb, 8); // skip pad
- av_dlog(ctx->avctx, "subcodec %d\n", hdr->codec);
return 0;
}
@@ -1186,17 +1407,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
pos = bytestream2_tell(&ctx->gb);
if (bytestream2_get_bytes_left(&ctx->gb) < size) {
- av_log(avctx, AV_LOG_ERROR, "incorrect chunk size %d\n", size);
+ av_log(avctx, AV_LOG_ERROR, "Incorrect chunk size %d.\n", size);
break;
}
switch (sig) {
case MKBETAG('N', 'P', 'A', 'L'):
- if (size != 256 * 3) {
- av_log(avctx, AV_LOG_ERROR, "incorrect palette block size %d\n",
- size);
+ if (size != PALETTE_SIZE * 3) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Incorrect palette block size %d.\n", size);
return AVERROR_INVALIDDATA;
}
- for (i = 0; i < 256; i++)
+ for (i = 0; i < PALETTE_SIZE; i++)
ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb);
break;
case MKBETAG('F', 'O', 'B', 'J'):
@@ -1210,7 +1431,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
uint8_t tmp[3];
int j;
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < PALETTE_SIZE; i++) {
for (j = 0; j < 3; j++) {
int t = (ctx->pal[i] >> (16 - j * 8)) & 0xFF;
tmp[j] = av_clip_uint8((t * 129 + ctx->delta_pal[i * 3 + j]) >> 7);
@@ -1218,16 +1439,16 @@ static int decode_frame(AVCodecContext *avctx, void *data,
ctx->pal[i] = 0xFFU << 24 | AV_RB24(tmp);
}
} else {
- if (size < 768 * 2 + 4) {
- av_log(avctx, AV_LOG_ERROR, "incorrect palette change block size %d\n",
+ if (size < PALETTE_DELTA * 2 + 4) {
+ av_log(avctx, AV_LOG_ERROR, "Incorrect palette change block size %d.\n",
size);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&ctx->gb, 4);
- for (i = 0; i < 768; i++)
+ for (i = 0; i < PALETTE_DELTA; i++)
ctx->delta_pal[i] = bytestream2_get_le16u(&ctx->gb);
- if (size >= 768 * 5 + 4) {
- for (i = 0; i < 256; i++)
+ if (size >= PALETTE_DELTA * 5 + 4) {
+ for (i = 0; i < PALETTE_SIZE; i++)
ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb);
} else {
memset(ctx->pal, 0, sizeof(ctx->pal));
@@ -1242,7 +1463,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
break;
default:
bytestream2_skip(&ctx->gb, size);
- av_log(avctx, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig);
+ av_log(avctx, AV_LOG_DEBUG, "Unknown/unsupported chunk %x.\n", sig);
break;
}
@@ -1273,12 +1494,11 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {
if ((ret = v1_decoders[header.codec](ctx))) {
av_log(avctx, AV_LOG_ERROR,
- "subcodec %d: error decoding frame\n", header.codec);
+ "Subcodec %d: error decoding frame.\n", header.codec);
return ret;
}
} else {
- avpriv_request_sample(avctx, "subcodec %d",
- header.codec);
+ avpriv_request_sample(avctx, "Subcodec %d", header.codec);
return AVERROR_PATCHWELCOME;
}
@@ -1288,14 +1508,14 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (ctx->rotate_code)
rotate_bufs(ctx, ctx->rotate_code);
- *got_frame_ptr = 1;
+ *got_frame_ptr = 1;
return pkt->size;
}
AVCodec ff_sanm_decoder = {
.name = "sanm",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts SMUSH video"),
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/Smush video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SANM,
.priv_data_size = sizeof(SANMVideoContext),
diff --git a/chromium/third_party/ffmpeg/libavcodec/sanm_data.h b/chromium/third_party/ffmpeg/libavcodec/sanm_data.h
deleted file mode 100644
index 8fccf38eea8..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sanm_data.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * LucasArts Smush video decoder
- * Copyright (c) 2006 Cyril Zorin
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SANM_DATA_H
-#define AVCODEC_SANM_DATA_H
-
-#include <stdint.h>
-
-#define GLYPH_COORD_VECT_SIZE 16
-
-static const int8_t glyph4_x[GLYPH_COORD_VECT_SIZE] =
- { 0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1 };
-static const int8_t glyph4_y[GLYPH_COORD_VECT_SIZE] =
- { 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2 };
-static const int8_t glyph8_x[GLYPH_COORD_VECT_SIZE] =
- { 0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0 };
-static const int8_t glyph8_y[GLYPH_COORD_VECT_SIZE] =
- { 0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1 };
-
-static const int8_t motion_vectors[256][2] =
-{
- { 0, 0}, { -1, -43}, { 6, -43}, { -9, -42}, { 13, -41},
- {-16, -40}, { 19, -39}, {-23, -36}, { 26, -34}, { -2, -33},
- { 4, -33}, {-29, -32}, { -9, -32}, { 11, -31}, {-16, -29},
- { 32, -29}, { 18, -28}, {-34, -26}, {-22, -25}, { -1, -25},
- { 3, -25}, { -7, -24}, { 8, -24}, { 24, -23}, { 36, -23},
- {-12, -22}, { 13, -21}, {-38, -20}, { 0, -20}, {-27, -19},
- { -4, -19}, { 4, -19}, {-17, -18}, { -8, -17}, { 8, -17},
- { 18, -17}, { 28, -17}, { 39, -17}, {-12, -15}, { 12, -15},
- {-21, -14}, { -1, -14}, { 1, -14}, {-41, -13}, { -5, -13},
- { 5, -13}, { 21, -13}, {-31, -12}, {-15, -11}, { -8, -11},
- { 8, -11}, { 15, -11}, { -2, -10}, { 1, -10}, { 31, -10},
- {-23, -9}, {-11, -9}, { -5, -9}, { 4, -9}, { 11, -9},
- { 42, -9}, { 6, -8}, { 24, -8}, {-18, -7}, { -7, -7},
- { -3, -7}, { -1, -7}, { 2, -7}, { 18, -7}, {-43, -6},
- {-13, -6}, { -4, -6}, { 4, -6}, { 8, -6}, {-33, -5},
- { -9, -5}, { -2, -5}, { 0, -5}, { 2, -5}, { 5, -5},
- { 13, -5}, {-25, -4}, { -6, -4}, { -3, -4}, { 3, -4},
- { 9, -4}, {-19, -3}, { -7, -3}, { -4, -3}, { -2, -3},
- { -1, -3}, { 0, -3}, { 1, -3}, { 2, -3}, { 4, -3},
- { 6, -3}, { 33, -3}, {-14, -2}, {-10, -2}, { -5, -2},
- { -3, -2}, { -2, -2}, { -1, -2}, { 0, -2}, { 1, -2},
- { 2, -2}, { 3, -2}, { 5, -2}, { 7, -2}, { 14, -2},
- { 19, -2}, { 25, -2}, { 43, -2}, { -7, -1}, { -3, -1},
- { -2, -1}, { -1, -1}, { 0, -1}, { 1, -1}, { 2, -1},
- { 3, -1}, { 10, -1}, { -5, 0}, { -3, 0}, { -2, 0},
- { -1, 0}, { 1, 0}, { 2, 0}, { 3, 0}, { 5, 0},
- { 7, 0}, {-10, 1}, { -7, 1}, { -3, 1}, { -2, 1},
- { -1, 1}, { 0, 1}, { 1, 1}, { 2, 1}, { 3, 1},
- {-43, 2}, {-25, 2}, {-19, 2}, {-14, 2}, { -5, 2},
- { -3, 2}, { -2, 2}, { -1, 2}, { 0, 2}, { 1, 2},
- { 2, 2}, { 3, 2}, { 5, 2}, { 7, 2}, { 10, 2},
- { 14, 2}, {-33, 3}, { -6, 3}, { -4, 3}, { -2, 3},
- { -1, 3}, { 0, 3}, { 1, 3}, { 2, 3}, { 4, 3},
- { 19, 3}, { -9, 4}, { -3, 4}, { 3, 4}, { 7, 4},
- { 25, 4}, {-13, 5}, { -5, 5}, { -2, 5}, { 0, 5},
- { 2, 5}, { 5, 5}, { 9, 5}, { 33, 5}, { -8, 6},
- { -4, 6}, { 4, 6}, { 13, 6}, { 43, 6}, {-18, 7},
- { -2, 7}, { 0, 7}, { 2, 7}, { 7, 7}, { 18, 7},
- {-24, 8}, { -6, 8}, {-42, 9}, {-11, 9}, { -4, 9},
- { 5, 9}, { 11, 9}, { 23, 9}, {-31, 10}, { -1, 10},
- { 2, 10}, {-15, 11}, { -8, 11}, { 8, 11}, { 15, 11},
- { 31, 12}, {-21, 13}, { -5, 13}, { 5, 13}, { 41, 13},
- { -1, 14}, { 1, 14}, { 21, 14}, {-12, 15}, { 12, 15},
- {-39, 17}, {-28, 17}, {-18, 17}, { -8, 17}, { 8, 17},
- { 17, 18}, { -4, 19}, { 0, 19}, { 4, 19}, { 27, 19},
- { 38, 20}, {-13, 21}, { 12, 22}, {-36, 23}, {-24, 23},
- { -8, 24}, { 7, 24}, { -3, 25}, { 1, 25}, { 22, 25},
- { 34, 26}, {-18, 28}, {-32, 29}, { 16, 29}, {-11, 31},
- { 9, 32}, { 29, 32}, { -4, 33}, { 2, 33}, {-26, 34},
- { 23, 36}, {-19, 39}, { 16, 40}, {-13, 41}, { 9, 42},
- { -6, 43}, { 1, 43}, { 0, 0}, { 0, 0}, { 0, 0},
-};
-
-static const int8_t c37_mv[] = {
- 0, 0, 1, 0, 2, 0, 3, 0, 5, 0,
- 8, 0, 13, 0, 21, 0, -1, 0, -2, 0,
- -3, 0, -5, 0, -8, 0, -13, 0, -17, 0,
- -21, 0, 0, 1, 1, 1, 2, 1, 3, 1,
- 5, 1, 8, 1, 13, 1, 21, 1, -1, 1,
- -2, 1, -3, 1, -5, 1, -8, 1, -13, 1,
- -17, 1, -21, 1, 0, 2, 1, 2, 2, 2,
- 3, 2, 5, 2, 8, 2, 13, 2, 21, 2,
- -1, 2, -2, 2, -3, 2, -5, 2, -8, 2,
- -13, 2, -17, 2, -21, 2, 0, 3, 1, 3,
- 2, 3, 3, 3, 5, 3, 8, 3, 13, 3,
- 21, 3, -1, 3, -2, 3, -3, 3, -5, 3,
- -8, 3, -13, 3, -17, 3, -21, 3, 0, 5,
- 1, 5, 2, 5, 3, 5, 5, 5, 8, 5,
- 13, 5, 21, 5, -1, 5, -2, 5, -3, 5,
- -5, 5, -8, 5, -13, 5, -17, 5, -21, 5,
- 0, 8, 1, 8, 2, 8, 3, 8, 5, 8,
- 8, 8, 13, 8, 21, 8, -1, 8, -2, 8,
- -3, 8, -5, 8, -8, 8, -13, 8, -17, 8,
- -21, 8, 0, 13, 1, 13, 2, 13, 3, 13,
- 5, 13, 8, 13, 13, 13, 21, 13, -1, 13,
- -2, 13, -3, 13, -5, 13, -8, 13, -13, 13,
- -17, 13, -21, 13, 0, 21, 1, 21, 2, 21,
- 3, 21, 5, 21, 8, 21, 13, 21, 21, 21,
- -1, 21, -2, 21, -3, 21, -5, 21, -8, 21,
- -13, 21, -17, 21, -21, 21, 0, -1, 1, -1,
- 2, -1, 3, -1, 5, -1, 8, -1, 13, -1,
- 21, -1, -1, -1, -2, -1, -3, -1, -5, -1,
- -8, -1, -13, -1, -17, -1, -21, -1, 0, -2,
- 1, -2, 2, -2, 3, -2, 5, -2, 8, -2,
- 13, -2, 21, -2, -1, -2, -2, -2, -3, -2,
- -5, -2, -8, -2, -13, -2, -17, -2, -21, -2,
- 0, -3, 1, -3, 2, -3, 3, -3, 5, -3,
- 8, -3, 13, -3, 21, -3, -1, -3, -2, -3,
- -3, -3, -5, -3, -8, -3, -13, -3, -17, -3,
- -21, -3, 0, -5, 1, -5, 2, -5, 3, -5,
- 5, -5, 8, -5, 13, -5, 21, -5, -1, -5,
- -2, -5, -3, -5, -5, -5, -8, -5, -13, -5,
- -17, -5, -21, -5, 0, -8, 1, -8, 2, -8,
- 3, -8, 5, -8, 8, -8, 13, -8, 21, -8,
- -1, -8, -2, -8, -3, -8, -5, -8, -8, -8,
- -13, -8, -17, -8, -21, -8, 0, -13, 1, -13,
- 2, -13, 3, -13, 5, -13, 8, -13, 13, -13,
- 21, -13, -1, -13, -2, -13, -3, -13, -5, -13,
- -8, -13, -13, -13, -17, -13, -21, -13, 0, -17,
- 1, -17, 2, -17, 3, -17, 5, -17, 8, -17,
- 13, -17, 21, -17, -1, -17, -2, -17, -3, -17,
- -5, -17, -8, -17, -13, -17, -17, -17, -21, -17,
- 0, -21, 1, -21, 2, -21, 3, -21, 5, -21,
- 8, -21, 13, -21, 21, -21, -1, -21, -2, -21,
- -3, -21, -5, -21, -8, -21, -13, -21, -17, -21,
- 0, 0, -8, -29, 8, -29, -18, -25, 17, -25,
- 0, -23, -6, -22, 6, -22, -13, -19, 12, -19,
- 0, -18, 25, -18, -25, -17, -5, -17, 5, -17,
- -10, -15, 10, -15, 0, -14, -4, -13, 4, -13,
- 19, -13, -19, -12, -8, -11, -2, -11, 0, -11,
- 2, -11, 8, -11, -15, -10, -4, -10, 4, -10,
- 15, -10, -6, -9, -1, -9, 1, -9, 6, -9,
- -29, -8, -11, -8, -8, -8, -3, -8, 3, -8,
- 8, -8, 11, -8, 29, -8, -5, -7, -2, -7,
- 0, -7, 2, -7, 5, -7, -22, -6, -9, -6,
- -6, -6, -3, -6, -1, -6, 1, -6, 3, -6,
- 6, -6, 9, -6, 22, -6, -17, -5, -7, -5,
- -4, -5, -2, -5, 0, -5, 2, -5, 4, -5,
- 7, -5, 17, -5, -13, -4, -10, -4, -5, -4,
- -3, -4, -1, -4, 0, -4, 1, -4, 3, -4,
- 5, -4, 10, -4, 13, -4, -8, -3, -6, -3,
- -4, -3, -3, -3, -2, -3, -1, -3, 0, -3,
- 1, -3, 2, -3, 4, -3, 6, -3, 8, -3,
- -11, -2, -7, -2, -5, -2, -3, -2, -2, -2,
- -1, -2, 0, -2, 1, -2, 2, -2, 3, -2,
- 5, -2, 7, -2, 11, -2, -9, -1, -6, -1,
- -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
- 1, -1, 2, -1, 3, -1, 4, -1, 6, -1,
- 9, -1, -31, 0, -23, 0, -18, 0, -14, 0,
- -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
- -2, 0, -1, 0, 0, -31, 1, 0, 2, 0,
- 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
- 14, 0, 18, 0, 23, 0, 31, 0, -9, 1,
- -6, 1, -4, 1, -3, 1, -2, 1, -1, 1,
- 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
- 6, 1, 9, 1, -11, 2, -7, 2, -5, 2,
- -3, 2, -2, 2, -1, 2, 0, 2, 1, 2,
- 2, 2, 3, 2, 5, 2, 7, 2, 11, 2,
- -8, 3, -6, 3, -4, 3, -2, 3, -1, 3,
- 0, 3, 1, 3, 2, 3, 3, 3, 4, 3,
- 6, 3, 8, 3, -13, 4, -10, 4, -5, 4,
- -3, 4, -1, 4, 0, 4, 1, 4, 3, 4,
- 5, 4, 10, 4, 13, 4, -17, 5, -7, 5,
- -4, 5, -2, 5, 0, 5, 2, 5, 4, 5,
- 7, 5, 17, 5, -22, 6, -9, 6, -6, 6,
- -3, 6, -1, 6, 1, 6, 3, 6, 6, 6,
- 9, 6, 22, 6, -5, 7, -2, 7, 0, 7,
- 2, 7, 5, 7, -29, 8, -11, 8, -8, 8,
- -3, 8, 3, 8, 8, 8, 11, 8, 29, 8,
- -6, 9, -1, 9, 1, 9, 6, 9, -15, 10,
- -4, 10, 4, 10, 15, 10, -8, 11, -2, 11,
- 0, 11, 2, 11, 8, 11, 19, 12, -19, 13,
- -4, 13, 4, 13, 0, 14, -10, 15, 10, 15,
- -5, 17, 5, 17, 25, 17, -25, 18, 0, 18,
- -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
- -17, 25, 18, 25, -8, 29, 8, 29, 0, 31,
- 0, 0, -6, -22, 6, -22, -13, -19, 12, -19,
- 0, -18, -5, -17, 5, -17, -10, -15, 10, -15,
- 0, -14, -4, -13, 4, -13, 19, -13, -19, -12,
- -8, -11, -2, -11, 0, -11, 2, -11, 8, -11,
- -15, -10, -4, -10, 4, -10, 15, -10, -6, -9,
- -1, -9, 1, -9, 6, -9, -11, -8, -8, -8,
- -3, -8, 0, -8, 3, -8, 8, -8, 11, -8,
- -5, -7, -2, -7, 0, -7, 2, -7, 5, -7,
- -22, -6, -9, -6, -6, -6, -3, -6, -1, -6,
- 1, -6, 3, -6, 6, -6, 9, -6, 22, -6,
- -17, -5, -7, -5, -4, -5, -2, -5, -1, -5,
- 0, -5, 1, -5, 2, -5, 4, -5, 7, -5,
- 17, -5, -13, -4, -10, -4, -5, -4, -3, -4,
- -2, -4, -1, -4, 0, -4, 1, -4, 2, -4,
- 3, -4, 5, -4, 10, -4, 13, -4, -8, -3,
- -6, -3, -4, -3, -3, -3, -2, -3, -1, -3,
- 0, -3, 1, -3, 2, -3, 3, -3, 4, -3,
- 6, -3, 8, -3, -11, -2, -7, -2, -5, -2,
- -4, -2, -3, -2, -2, -2, -1, -2, 0, -2,
- 1, -2, 2, -2, 3, -2, 4, -2, 5, -2,
- 7, -2, 11, -2, -9, -1, -6, -1, -5, -1,
- -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
- 1, -1, 2, -1, 3, -1, 4, -1, 5, -1,
- 6, -1, 9, -1, -23, 0, -18, 0, -14, 0,
- -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
- -2, 0, -1, 0, 0, -23, 1, 0, 2, 0,
- 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
- 14, 0, 18, 0, 23, 0, -9, 1, -6, 1,
- -5, 1, -4, 1, -3, 1, -2, 1, -1, 1,
- 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
- 5, 1, 6, 1, 9, 1, -11, 2, -7, 2,
- -5, 2, -4, 2, -3, 2, -2, 2, -1, 2,
- 0, 2, 1, 2, 2, 2, 3, 2, 4, 2,
- 5, 2, 7, 2, 11, 2, -8, 3, -6, 3,
- -4, 3, -3, 3, -2, 3, -1, 3, 0, 3,
- 1, 3, 2, 3, 3, 3, 4, 3, 6, 3,
- 8, 3, -13, 4, -10, 4, -5, 4, -3, 4,
- -2, 4, -1, 4, 0, 4, 1, 4, 2, 4,
- 3, 4, 5, 4, 10, 4, 13, 4, -17, 5,
- -7, 5, -4, 5, -2, 5, -1, 5, 0, 5,
- 1, 5, 2, 5, 4, 5, 7, 5, 17, 5,
- -22, 6, -9, 6, -6, 6, -3, 6, -1, 6,
- 1, 6, 3, 6, 6, 6, 9, 6, 22, 6,
- -5, 7, -2, 7, 0, 7, 2, 7, 5, 7,
- -11, 8, -8, 8, -3, 8, 0, 8, 3, 8,
- 8, 8, 11, 8, -6, 9, -1, 9, 1, 9,
- 6, 9, -15, 10, -4, 10, 4, 10, 15, 10,
- -8, 11, -2, 11, 0, 11, 2, 11, 8, 11,
- 19, 12, -19, 13, -4, 13, 4, 13, 0, 14,
- -10, 15, 10, 15, -5, 17, 5, 17, 0, 18,
- -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
-};
-#endif /* AVCODEC_SANM_DATA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/sbrdsp.c b/chromium/third_party/ffmpeg/libavcodec/sbrdsp.c
index b4d5824e923..e4f053b1076 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sbrdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sbrdsp.c
@@ -110,6 +110,11 @@ static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1)
}
}
+
+#if 0
+ /* This code is slower because it multiplies memory accesses.
+ * It is left for educational purposes and because it may offer
+ * a better reference for writing arch-specific DSP functions. */
static av_always_inline void autocorrelate(const float x[40][2],
float phi[3][2][2], int lag)
{
@@ -138,14 +143,13 @@ static av_always_inline void autocorrelate(const float x[40][2],
static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2])
{
-#if 0
- /* This code is slower because it multiplies memory accesses.
- * It is left for educational purposes and because it may offer
- * a better reference for writing arch-specific DSP functions. */
autocorrelate(x, phi, 0);
autocorrelate(x, phi, 1);
autocorrelate(x, phi, 2);
+}
#else
+static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2])
+{
float real_sum2 = x[0][0] * x[2][0] + x[0][1] * x[2][1];
float imag_sum2 = x[0][0] * x[2][1] - x[0][1] * x[2][0];
float real_sum1 = 0.0f, imag_sum1 = 0.0f, real_sum0 = 0.0f;
diff --git a/chromium/third_party/ffmpeg/libavcodec/sgi.h b/chromium/third_party/ffmpeg/libavcodec/sgi.h
index be17f2e2374..5ec891e4311 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sgi.h
+++ b/chromium/third_party/ffmpeg/libavcodec/sgi.h
@@ -1,4 +1,4 @@
- /*
+/*
* SGI image encoder
* Xiaohui Sun <tjnksxh@hotmail.com>
*
diff --git a/chromium/third_party/ffmpeg/libavcodec/sgidec.c b/chromium/third_party/ffmpeg/libavcodec/sgidec.c
index 35063ea53be..6f51ec35315 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sgidec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sgidec.c
@@ -27,6 +27,7 @@
#include "sgi.h"
typedef struct SgiState {
+ AVCodecContext *avctx;
unsigned int width;
unsigned int height;
unsigned int depth;
@@ -39,15 +40,16 @@ typedef struct SgiState {
* Expand an RLE row into a channel.
* @param s the current image state
* @param out_buf Points to one line after the output buffer.
- * @param out_end end of line in output buffer
+ * @param len length of out_buf in bytes
* @param pixelstride pixel stride of input buffer
* @return size of output in bytes, else return error code.
*/
-static int expand_rle_row(SgiState *s, uint8_t *out_buf,
- uint8_t *out_end, int pixelstride)
+static int expand_rle_row8(SgiState *s, uint8_t *out_buf,
+ int len, int pixelstride)
{
unsigned char pixel, count;
unsigned char *orig = out_buf;
+ uint8_t *out_end = out_buf + len;
while (out_buf < out_end) {
if (bytestream2_get_bytes_left(&s->g) < 1)
@@ -58,8 +60,10 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
}
/* Check for buffer overflow. */
- if (out_end - out_buf <= pixelstride * (count - 1))
+ if (out_end - out_buf <= pixelstride * (count - 1)) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n");
return AVERROR_INVALIDDATA;
+ }
if (pixel & 0x80) {
while (count--) {
@@ -78,6 +82,46 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
return (out_buf - orig) / pixelstride;
}
+static int expand_rle_row16(SgiState *s, uint16_t *out_buf,
+ int len, int pixelstride)
+{
+ unsigned short pixel;
+ unsigned char count;
+ unsigned short *orig = out_buf;
+ uint16_t *out_end = out_buf + len;
+
+ while (out_buf < out_end) {
+ if (bytestream2_get_bytes_left(&s->g) < 2)
+ return AVERROR_INVALIDDATA;
+ pixel = bytestream2_get_be16u(&s->g);
+ if (!(count = (pixel & 0x7f)))
+ break;
+
+ /* Check for buffer overflow. */
+ if (pixelstride * (count - 1) >= len) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (pixel & 0x80) {
+ while (count--) {
+ pixel = bytestream2_get_ne16(&s->g);
+ AV_WN16A(out_buf, pixel);
+ out_buf += pixelstride;
+ }
+ } else {
+ pixel = bytestream2_get_ne16(&s->g);
+
+ while (count--) {
+ AV_WN16A(out_buf, pixel);
+ out_buf += pixelstride;
+ }
+ }
+ }
+ return (out_buf - orig) / pixelstride;
+}
+
+
/**
* Read a run length encoded SGI image.
* @param out_buf output buffer
@@ -91,22 +135,26 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
GetByteContext g_table = s->g;
unsigned int y, z;
unsigned int start_offset;
+ int linesize, ret;
/* size of RLE offset and length tables */
- if (len * 2 > bytestream2_get_bytes_left(&s->g)) {
+ if (len * 2 > bytestream2_get_bytes_left(&s->g)) {
return AVERROR_INVALIDDATA;
}
for (z = 0; z < s->depth; z++) {
dest_row = out_buf;
for (y = 0; y < s->height; y++) {
+ linesize = s->width * s->depth * s->bytes_per_channel;
dest_row -= s->linesize;
start_offset = bytestream2_get_be32(&g_table);
bytestream2_seek(&s->g, start_offset, SEEK_SET);
- if (expand_rle_row(s, dest_row + z, dest_row + s->width*s->depth,
- s->depth) != s->width) {
+ if (s->bytes_per_channel == 1)
+ ret = expand_rle_row8(s, dest_row + z, linesize, s->depth);
+ else
+ ret = expand_rle_row16(s, (uint16_t *)dest_row + z, linesize, s->depth);
+ if (ret != s->width)
return AVERROR_INVALIDDATA;
- }
}
}
return 0;
@@ -118,7 +166,7 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
* @param s the current image state
* @return 0 if read success, else return error code.
*/
-static int read_uncompressed_sgi(unsigned char* out_buf, SgiState *s)
+static int read_uncompressed_sgi(unsigned char *out_buf, SgiState *s)
{
int x, y, z;
unsigned int offset = s->height * s->width * s->bytes_per_channel;
@@ -180,7 +228,7 @@ static int decode_frame(AVCodecContext *avctx,
s->height = bytestream2_get_be16u(&s->g);
s->depth = bytestream2_get_be16u(&s->g);
- if (s->bytes_per_channel != 1 && (s->bytes_per_channel != 2 || rle)) {
+ if (s->bytes_per_channel != 1 && s->bytes_per_channel != 2) {
av_log(avctx, AV_LOG_ERROR, "wrong channel number\n");
return AVERROR_INVALIDDATA;
}
@@ -231,6 +279,15 @@ static int decode_frame(AVCodecContext *avctx,
return avpkt->size;
}
+static av_cold int sgi_decode_init(AVCodecContext *avctx)
+{
+ SgiState *s = avctx->priv_data;
+
+ s->avctx = avctx;
+
+ return 0;
+}
+
AVCodec ff_sgi_decoder = {
.name = "sgi",
.long_name = NULL_IF_CONFIG_SMALL("SGI image"),
@@ -238,5 +295,6 @@ AVCodec ff_sgi_decoder = {
.id = AV_CODEC_ID_SGI,
.priv_data_size = sizeof(SgiState),
.decode = decode_frame,
+ .init = sgi_decode_init,
.capabilities = CODEC_CAP_DR1,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/sgienc.c b/chromium/third_party/ffmpeg/libavcodec/sgienc.c
index 0e4f304a23c..21026afcccb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sgienc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sgienc.c
@@ -31,9 +31,12 @@
static av_cold int encode_init(AVCodecContext *avctx)
{
if (avctx->width > 65535 || avctx->height > 65535) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported resolution %dx%d.\n", avctx->width, avctx->height);
av_log(avctx, AV_LOG_ERROR, "SGI does not support resolutions above 65535x65535\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
+
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
@@ -47,7 +50,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame * const p = frame;
uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *buf;
int x, y, z, length, tablesize, ret;
- unsigned int width, height, depth, dimension, bytes_per_channel, pixmax, put_be;
+ unsigned int width, height, depth, dimension;
+ unsigned int bytes_per_channel, pixmax, put_be;
unsigned char *end_buf;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -132,14 +136,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memset(buf, 0, SGI_HEADER_SIZE);
buf += 80;
- /* colormap */
+ /* colormap */
bytestream_put_be32(&buf, 0L);
/* The rest of the 512 byte header is unused. */
buf += 404;
offsettab = buf;
- if (avctx->coder_type != FF_CODER_TYPE_RAW) {
+ if (avctx->coder_type != FF_CODER_TYPE_RAW) {
/* Skip RLE offset table. */
buf += tablesize;
lengthtab = buf;
@@ -180,7 +184,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for (y = 0; y < height; y++) {
for (x = 0; x < width * depth; x += depth)
if (bytes_per_channel == 1) {
- bytestream_put_byte(&buf, in_buf[x]);
+ bytestream_put_byte(&buf, in_buf[x]);
} else {
if (put_be) {
bytestream_put_be16(&buf, ((uint16_t *)in_buf)[x]);
@@ -195,7 +199,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
/* total length */
- pkt->size = buf - pkt->data;
+ pkt->size = buf - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -209,18 +213,18 @@ static av_cold int encode_close(AVCodecContext *avctx)
}
AVCodec ff_sgi_encoder = {
- .name = "sgi",
- .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_SGI,
- .init = encode_init,
- .encode2 = encode_frame,
- .close = encode_close,
- .pix_fmts = (const enum AVPixelFormat[]){
+ .name = "sgi",
+ .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_SGI,
+ .init = encode_init,
+ .encode2 = encode_frame,
+ .close = encode_close,
+ .pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE,
AV_PIX_FMT_RGBA64LE, AV_PIX_FMT_RGBA64BE,
- AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE,
- AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
+ AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_GRAY8,
+ AV_PIX_FMT_NONE
},
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/sgirledec.c b/chromium/third_party/ffmpeg/libavcodec/sgirledec.c
index fd3cc5e78a6..5e2cd3a4d38 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sgirledec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sgirledec.c
@@ -1,5 +1,5 @@
/*
- * SGI RLE 8-bit decoder
+ * Silicon Graphics RLE 8-bit video decoder
* Copyright (c) 2012 Peter Ross
*
* This file is part of FFmpeg.
@@ -21,9 +21,13 @@
/**
* @file
- * SGI RLE 8-bit decoder
+ * Silicon Graphics RLE 8-bit video decoder
+ * @note Data is packed in rbg323 with rle, contained in mv or mov.
+ * The algorithm and pixfmt are subtly different from SGI images.
*/
+#include "libavutil/common.h"
+
#include "avcodec.h"
#include "internal.h"
@@ -42,39 +46,44 @@ static av_cold int sgirle_decode_init(AVCodecContext *avctx)
}
/**
- * Convert SGI RGB332 pixel into AV_PIX_FMT_BGR8
- * SGI RGB332 is packed RGB 3:3:2, 8bpp, (msb)3R 2B 3G(lsb)
+ * Convert SGI RBG323 pixel into AV_PIX_FMT_BGR8
+ * SGI RGB data is packed as 8bpp, (msb)3R 2B 3G(lsb)
*/
-#define RGB332_TO_BGR8(x) (((x << 3) & 0xC0) | ((x << 3) & 0x38) | ((x >> 5) & 7))
-
-static av_always_inline void memcpy_rgb332_to_bgr8(uint8_t *dst, const uint8_t *src, int size)
+#define RBG323_TO_BGR8(x) (((x << 3) & 0xC0) | \
+ ((x << 3) & 0x38) | \
+ ((x >> 5) & 7))
+static av_always_inline
+void rbg323_to_bgr8(uint8_t *dst, const uint8_t *src, int size)
{
int i;
for (i = 0; i < size; i++)
- dst[i] = RGB332_TO_BGR8(src[i]);
+ dst[i] = RBG323_TO_BGR8(src[i]);
}
/**
* @param[out] dst Destination buffer
- * @param[in] src Source buffer
+ * @param[in] src Source buffer
* @param src_size Source buffer size (bytes)
- * @param width Width of destination buffer (pixels)
- * @param height Height of destination buffer (pixels)
+ * @param width Width of destination buffer (pixels)
+ * @param height Height of destination buffer (pixels)
* @param linesize Line size of destination buffer (bytes)
+ *
* @return <0 on error
*/
-static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize)
+static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst,
+ const uint8_t *src, int src_size,
+ int width, int height, ptrdiff_t linesize)
{
const uint8_t *src_end = src + src_size;
int x = 0, y = 0;
-#define INC_XY(n) \
- x += n; \
- if (x >= width) { \
- y++; \
- if (y >= height) \
- return 0; \
- x = 0; \
+#define INC_XY(n) \
+ x += n; \
+ if (x >= width) { \
+ y++; \
+ if (y >= height) \
+ return 0; \
+ x = 0; \
}
while (src_end - src >= 2) {
@@ -84,9 +93,9 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr
int length = FFMIN(v, width - x);
if (length <= 0)
break;
- memset(dst + y*linesize + x, RGB332_TO_BGR8(*src), length);
+ memset(dst + y * linesize + x, RBG323_TO_BGR8(*src), length);
INC_XY(length);
- v -= length;
+ v -= length;
} while (v > 0);
src++;
} else if (v >= 0xC1) {
@@ -95,7 +104,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr
int length = FFMIN3(v, width - x, src_end - src);
if (src_end - src < length || length <= 0)
break;
- memcpy_rgb332_to_bgr8(dst + y*linesize + x, src, length);
+ rbg323_to_bgr8(dst + y * linesize + x, src, length);
INC_XY(length);
src += length;
v -= length;
@@ -108,9 +117,8 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr
return 0;
}
-static int sgirle_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt)
+static int sgirle_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame, AVPacket *avpkt)
{
SGIRLEContext *s = avctx->priv_data;
int ret;
@@ -118,11 +126,12 @@ static int sgirle_decode_frame(AVCodecContext *avctx,
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
- ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size, avctx->width, avctx->height, s->frame->linesize[0]);
+ ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size,
+ avctx->width, avctx->height, s->frame->linesize[0]);
if (ret < 0)
return ret;
- *got_frame = 1;
+ *got_frame = 1;
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
@@ -140,7 +149,7 @@ static av_cold int sgirle_decode_end(AVCodecContext *avctx)
AVCodec ff_sgirle_decoder = {
.name = "sgirle",
- .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"),
+ .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SGIRLE,
.priv_data_size = sizeof(SGIRLEContext),
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/Makefile b/chromium/third_party/ffmpeg/libavcodec/sh4/Makefile
deleted file mode 100644
index 01a573b9579..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sh4/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-OBJS += sh4/dsputil_sh4.o \
- sh4/idct_sh4.o \
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/README b/chromium/third_party/ffmpeg/libavcodec/sh4/README
new file mode 100644
index 00000000000..8dd61fe8756
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/sh4/README
@@ -0,0 +1,6 @@
+SH4 optimizations have been removed in
+commit d6096a67422534918405abb46dafbbac4608cbc3
+The last revission with the optimizations is cbfc9046e1c7e295b74f252902ae6f255eef4e78
+
+If you want to maintain these (or other) SH4 optimizations in ffmpeg, then please
+contact ffmpeg-devel@ffmpeg.org
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.c b/chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.c
deleted file mode 100644
index 82b75ae6c34..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sh4/dsputil_sh4.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * sh4 dsputil
- *
- * Copyright (c) 2003 BERO <bero@geocities.co.jp>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_sh4.h"
-#include "sh4.h"
-
-static void memzero_align8(void *dst,size_t size)
-{
- int fpscr;
- fp_single_enter(fpscr);
- dst = (char *)dst + size;
- size /= 32;
- __asm__ volatile (
- " fldi0 fr0\n"
- " fldi0 fr1\n"
- " fschg\n" // double
- "1: \n" \
- " dt %1\n"
- " fmov dr0,@-%0\n"
- " fmov dr0,@-%0\n"
- " fmov dr0,@-%0\n"
- " bf.s 1b\n"
- " fmov dr0,@-%0\n"
- " fschg" //back to single
- : "+r"(dst),"+r"(size) :: "memory" );
- fp_single_leave(fpscr);
-}
-
-static void clear_blocks_sh4(int16_t *blocks)
-{
- memzero_align8(blocks,sizeof(int16_t)*6*64);
-}
-
-static void idct_put(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- ff_idct_sh4(block);
- for(i=0;i<8;i++) {
- dest[0] = cm[block[0]];
- dest[1] = cm[block[1]];
- dest[2] = cm[block[2]];
- dest[3] = cm[block[3]];
- dest[4] = cm[block[4]];
- dest[5] = cm[block[5]];
- dest[6] = cm[block[6]];
- dest[7] = cm[block[7]];
- dest+=line_size;
- block+=8;
- }
-}
-static void idct_add(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- ff_idct_sh4(block);
- for(i=0;i<8;i++) {
- dest[0] = cm[dest[0]+block[0]];
- dest[1] = cm[dest[1]+block[1]];
- dest[2] = cm[dest[2]+block[2]];
- dest[3] = cm[dest[3]+block[3]];
- dest[4] = cm[dest[4]+block[4]];
- dest[5] = cm[dest[5]+block[5]];
- dest[6] = cm[dest[6]+block[6]];
- dest[7] = cm[dest[7]+block[7]];
- dest+=line_size;
- block+=8;
- }
-}
-
-av_cold void ff_dsputil_init_sh4(DSPContext *c, AVCodecContext *avctx)
-{
- const int idct_algo= avctx->idct_algo;
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
- if (!high_bit_depth)
- c->clear_blocks = clear_blocks_sh4;
- if (avctx->bits_per_raw_sample <= 8 &&
- (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
- c->idct_put = idct_put;
- c->idct_add = idct_add;
- c->idct = ff_idct_sh4;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/idct_sh4.c b/chromium/third_party/ffmpeg/libavcodec/sh4/idct_sh4.c
deleted file mode 100644
index d4e87110971..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sh4/idct_sh4.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * idct for sh4
- *
- * Copyright (c) 2001-2003 BERO <bero@geocities.co.jp>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dsputil_sh4.h"
-#include "sh4.h"
-
-#define c1 1.38703984532214752434 /* sqrt(2)*cos(1*pi/16) */
-#define c2 1.30656296487637657577 /* sqrt(2)*cos(2*pi/16) */
-#define c3 1.17587560241935884520 /* sqrt(2)*cos(3*pi/16) */
-#define c4 1.00000000000000000000 /* sqrt(2)*cos(4*pi/16) */
-#define c5 0.78569495838710234903 /* sqrt(2)*cos(5*pi/16) */
-#define c6 0.54119610014619712324 /* sqrt(2)*cos(6*pi/16) */
-#define c7 0.27589937928294311353 /* sqrt(2)*cos(7*pi/16) */
-
-static const float even_table[] __attribute__ ((aligned(8))) = {
- c4, c4, c4, c4,
- c2, c6,-c6,-c2,
- c4,-c4,-c4, c4,
- c6,-c2, c2,-c6
-};
-
-static const float odd_table[] __attribute__ ((aligned(8))) = {
- c1, c3, c5, c7,
- c3,-c7,-c1,-c5,
- c5,-c1, c7, c3,
- c7,-c5, c3,-c1
-};
-
-#undef c1
-#undef c2
-#undef c3
-#undef c4
-#undef c5
-#undef c6
-#undef c7
-
-#define load_matrix(table) \
- do { \
- const float *t = table; \
- __asm__ volatile( \
- " fschg\n" \
- " fmov @%0+,xd0\n" \
- " fmov @%0+,xd2\n" \
- " fmov @%0+,xd4\n" \
- " fmov @%0+,xd6\n" \
- " fmov @%0+,xd8\n" \
- " fmov @%0+,xd10\n" \
- " fmov @%0+,xd12\n" \
- " fmov @%0+,xd14\n" \
- " fschg\n" \
- : "+r"(t) \
- ); \
- } while (0)
-
-#define ftrv() \
- __asm__ volatile("ftrv xmtrx,fv0" \
- : "+f"(fr0),"+f"(fr1),"+f"(fr2),"+f"(fr3));
-
-#define DEFREG \
- register float fr0 __asm__("fr0"); \
- register float fr1 __asm__("fr1"); \
- register float fr2 __asm__("fr2"); \
- register float fr3 __asm__("fr3")
-
-#define DESCALE(x,n) (x)*(1.0f/(1<<(n)))
-
-/* this code work worse on gcc cvs. 3.2.3 work fine */
-
-
-//optimized
-
-void ff_idct_sh4(int16_t *block)
-{
- DEFREG;
-
- int i;
- float tblock[8*8],*fblock;
- int ofs1,ofs2,ofs3;
- int fpscr;
-
- fp_single_enter(fpscr);
-
- /* row */
-
- /* even part */
- load_matrix(even_table);
-
- fblock = tblock+4;
- i = 8;
- do {
- fr0 = block[0];
- fr1 = block[2];
- fr2 = block[4];
- fr3 = block[6];
- block+=8;
- ftrv();
- *--fblock = fr3;
- *--fblock = fr2;
- *--fblock = fr1;
- *--fblock = fr0;
- fblock+=8+4;
- } while(--i);
- block-=8*8;
- fblock-=8*8+4;
-
- load_matrix(odd_table);
-
- i = 8;
-
- do {
- float t0,t1,t2,t3;
- fr0 = block[1];
- fr1 = block[3];
- fr2 = block[5];
- fr3 = block[7];
- block+=8;
- ftrv();
- t0 = *fblock++;
- t1 = *fblock++;
- t2 = *fblock++;
- t3 = *fblock++;
- fblock+=4;
- *--fblock = t0 - fr0;
- *--fblock = t1 - fr1;
- *--fblock = t2 - fr2;
- *--fblock = t3 - fr3;
- *--fblock = t3 + fr3;
- *--fblock = t2 + fr2;
- *--fblock = t1 + fr1;
- *--fblock = t0 + fr0;
- fblock+=8;
- } while(--i);
- block-=8*8;
- fblock-=8*8;
-
- /* col */
-
- /* even part */
- load_matrix(even_table);
-
- ofs1 = sizeof(float)*2*8;
- ofs2 = sizeof(float)*4*8;
- ofs3 = sizeof(float)*6*8;
-
- i = 8;
-
-#define OA(fblock,ofs) *(float*)((char*)fblock + ofs)
-
- do {
- fr0 = OA(fblock, 0);
- fr1 = OA(fblock,ofs1);
- fr2 = OA(fblock,ofs2);
- fr3 = OA(fblock,ofs3);
- ftrv();
- OA(fblock,0 ) = fr0;
- OA(fblock,ofs1) = fr1;
- OA(fblock,ofs2) = fr2;
- OA(fblock,ofs3) = fr3;
- fblock++;
- } while(--i);
- fblock-=8;
-
- load_matrix(odd_table);
-
- i=8;
- do {
- float t0,t1,t2,t3;
- t0 = OA(fblock, 0); /* [8*0] */
- t1 = OA(fblock,ofs1); /* [8*2] */
- t2 = OA(fblock,ofs2); /* [8*4] */
- t3 = OA(fblock,ofs3); /* [8*6] */
- fblock+=8;
- fr0 = OA(fblock, 0); /* [8*1] */
- fr1 = OA(fblock,ofs1); /* [8*3] */
- fr2 = OA(fblock,ofs2); /* [8*5] */
- fr3 = OA(fblock,ofs3); /* [8*7] */
- fblock+=-8+1;
- ftrv();
- block[8*0] = DESCALE(t0 + fr0,3);
- block[8*7] = DESCALE(t0 - fr0,3);
- block[8*1] = DESCALE(t1 + fr1,3);
- block[8*6] = DESCALE(t1 - fr1,3);
- block[8*2] = DESCALE(t2 + fr2,3);
- block[8*5] = DESCALE(t2 - fr2,3);
- block[8*3] = DESCALE(t3 + fr3,3);
- block[8*4] = DESCALE(t3 - fr3,3);
- block++;
- } while(--i);
-
- fp_single_leave(fpscr);
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sh4/sh4.h b/chromium/third_party/ffmpeg/libavcodec/sh4/sh4.h
deleted file mode 100644
index 5d46540cb62..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sh4/sh4.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SH4_SH4_H
-#define AVCODEC_SH4_SH4_H
-
-#ifdef __SH4__
-# define fp_single_enter(fpscr) \
- do { \
- __asm__ volatile ("sts fpscr, %0 \n\t" \
- "and %1, %0 \n\t" \
- "lds %0, fpscr \n\t" \
- : "=&r"(fpscr) : "r"(~(1<<19))); \
- } while (0)
-
-# define fp_single_leave(fpscr) \
- do { \
- __asm__ volatile ("or %1, %0 \n\t" \
- "lds %0, fpscr \n\t" \
- : "+r"(fpscr) : "r"(1<<19)); \
- } while (0)
-#else
-# define fp_single_enter(fpscr) ((void)fpscr)
-# define fp_single_leave(fpscr)
-#endif
-
-#endif /* AVCODEC_SH4_SH4_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/shorten.c b/chromium/third_party/ffmpeg/libavcodec/shorten.c
index 2bd35d22d04..5c4bf816b9e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/shorten.c
+++ b/chromium/third_party/ffmpeg/libavcodec/shorten.c
@@ -432,6 +432,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
return AVERROR(ENOMEM);
}
+ memset(tmp_ptr, 0, s->allocated_bitstream_size);
s->bitstream = tmp_ptr;
}
@@ -504,9 +505,16 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
while (len--)
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
break;
- case FN_BITSHIFT:
- s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
+ case FN_BITSHIFT: {
+ unsigned bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
+ if (bitshift > 31) {
+ av_log(avctx, AV_LOG_ERROR, "bitshift %d is invalid\n",
+ bitshift);
+ return AVERROR_PATCHWELCOME;
+ }
+ s->bitshift = bitshift;
break;
+ }
case FN_BLOCKSIZE: {
unsigned blocksize = get_uint(s, av_log2(s->blocksize));
if (blocksize > s->blocksize) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/simple_idct.c b/chromium/third_party/ffmpeg/libavcodec/simple_idct.c
index 73f62b40215..eeb627999c0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/simple_idct.c
+++ b/chromium/third_party/ffmpeg/libavcodec/simple_idct.c
@@ -232,6 +232,8 @@ void ff_prores_idct(int16_t *block, const int16_t *qmat)
for (i = 0; i < 8; i++)
idctRowCondDC_10(block + i*8, 2);
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++) {
+ block[i] += 8192;
idctSparseCol_10(block + i);
+ }
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/simple_idct_template.c b/chromium/third_party/ffmpeg/libavcodec/simple_idct_template.c
index 64a7be02c54..95844a2f33c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/simple_idct_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/simple_idct_template.c
@@ -30,6 +30,8 @@
written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
*/
+#include "simple_idct.h"
+
#include "bit_depth_template.c"
#undef W1
@@ -65,13 +67,13 @@
#elif BIT_DEPTH == 10 || BIT_DEPTH == 12
#if BIT_DEPTH == 10
-#define W1 90901
-#define W2 85627
-#define W3 77062
-#define W4 65535
-#define W5 51491
-#define W6 35468
-#define W7 18081
+#define W1 (22725*4) // 90901
+#define W2 (21407*4) // 85627
+#define W3 (19265*4) // 77062
+#define W4 (16384*4) // 65535
+#define W5 (12873*4) // 51491
+#define W6 ( 8867*4) // 35468
+#define W7 ( 4520*4) // 18081
#define ROW_SHIFT 15
#define COL_SHIFT 20
@@ -107,10 +109,10 @@ static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
uint64_t temp;
- if (DC_SHIFT - extra_shift > 0) {
+ if (DC_SHIFT - extra_shift >= 0) {
temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
} else {
- temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
+ temp = ((row[0] + (1<<(extra_shift - DC_SHIFT-1))) >> (extra_shift - DC_SHIFT)) & 0xffff;
}
temp += temp << 16;
temp += temp << 32;
@@ -124,10 +126,10 @@ static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
((uint32_t*)row)[3] |
row[1])) {
uint32_t temp;
- if (DC_SHIFT - extra_shift > 0) {
+ if (DC_SHIFT - extra_shift >= 0) {
temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
} else {
- temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
+ temp = ((row[0] + (1<<(extra_shift - DC_SHIFT-1))) >> (extra_shift - DC_SHIFT)) & 0xffff;
}
temp += temp << 16;
((uint32_t*)row)[0]=((uint32_t*)row)[1] =
@@ -136,7 +138,7 @@ static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
}
#endif
- a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
+ a0 = (W4 * row[0]) + (1 << (ROW_SHIFT + extra_shift - 1));
a1 = a0;
a2 = a0;
a3 = a0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/smacker.c b/chromium/third_party/ffmpeg/libavcodec/smacker.c
index 717e9ea033f..644beb34da0 100644
--- a/chromium/third_party/ffmpeg/libavcodec/smacker.c
+++ b/chromium/third_party/ffmpeg/libavcodec/smacker.c
@@ -271,7 +271,7 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
huff.length = ((size + 3) >> 2) + 4;
huff.maxlength = 0;
huff.current = 0;
- huff.values = av_mallocz(huff.length * sizeof(int));
+ huff.values = av_mallocz_array(huff.length, sizeof(int));
if (!huff.values) {
err = AVERROR(ENOMEM);
goto error;
@@ -662,7 +662,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
return AVERROR(EINVAL);
}
- if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
+ if (bits == (avctx->sample_fmt == AV_SAMPLE_FMT_U8)) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
return AVERROR(EINVAL);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/smvjpegdec.c b/chromium/third_party/ffmpeg/libavcodec/smvjpegdec.c
index f883ecf80ac..e546c3e49c9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/smvjpegdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/smvjpegdec.c
@@ -153,8 +153,11 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
/* We shouldn't get here if frames_per_jpeg <= 0 because this was rejected
in init */
- avcodec_set_dimensions(avctx, mjpeg_data->width,
- mjpeg_data->height / s->frames_per_jpeg);
+ ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
+ if (ret < 0) {
+ av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
+ return ret;
+ }
if (*data_size) {
s->picture[1]->extended_data = NULL;
diff --git a/chromium/third_party/ffmpeg/libavcodec/snow.c b/chromium/third_party/ffmpeg/libavcodec/snow.c
index c645b120fbf..3961e678703 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snow.c
+++ b/chromium/third_party/ffmpeg/libavcodec/snow.c
@@ -88,7 +88,7 @@ int ff_snow_alloc_blocks(SnowContext *s){
s->b_height= h;
av_free(s->block);
- s->block= av_mallocz(w * h * sizeof(BlockNode) << (s->block_max_depth*2));
+ s->block= av_mallocz_array(w * h, sizeof(BlockNode) << (s->block_max_depth*2));
if (!s->block)
return AVERROR(ENOMEM);
@@ -455,11 +455,11 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
width= s->avctx->width;
height= s->avctx->height;
- FF_ALLOCZ_OR_GOTO(avctx, s->spatial_idwt_buffer, width * height * sizeof(IDWTELEM), fail);
- FF_ALLOCZ_OR_GOTO(avctx, s->spatial_dwt_buffer, width * height * sizeof(DWTELEM), fail); //FIXME this does not belong here
- FF_ALLOCZ_OR_GOTO(avctx, s->temp_dwt_buffer, width * sizeof(DWTELEM), fail);
- FF_ALLOCZ_OR_GOTO(avctx, s->temp_idwt_buffer, width * sizeof(IDWTELEM), fail);
- FF_ALLOC_OR_GOTO(avctx, s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) * sizeof(*s->run_buffer), fail);
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->spatial_idwt_buffer, width, height * sizeof(IDWTELEM), fail);
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->spatial_dwt_buffer, width, height * sizeof(DWTELEM), fail); //FIXME this does not belong here
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->temp_dwt_buffer, width, sizeof(DWTELEM), fail);
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->temp_idwt_buffer, width, sizeof(IDWTELEM), fail);
+ FF_ALLOC_ARRAY_OR_GOTO(avctx, s->run_buffer, ((width + 1) >> 1), ((height + 1) >> 1) * sizeof(*s->run_buffer), fail);
for(i=0; i<MAX_REF_FRAMES; i++) {
for(j=0; j<MAX_REF_FRAMES; j++)
@@ -488,7 +488,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
- FF_ALLOCZ_OR_GOTO(avctx, s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256)*7*MB_SIZE, fail);
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256), 7*MB_SIZE, fail);
emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
FF_ALLOC_OR_GOTO(avctx, s->emu_edge_buffer, emu_buf_size, fail);
}
@@ -537,7 +537,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
b->parent= &s->plane[plane_index].band[level-1][orientation];
//FIXME avoid this realloc
av_freep(&b->x_coeff);
- b->x_coeff=av_mallocz(((b->width+1) * b->height+1)*sizeof(x_and_coeff));
+ b->x_coeff=av_mallocz_array(((b->width+1) * b->height+1), sizeof(x_and_coeff));
if (!b->x_coeff)
goto fail;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/snow.h b/chromium/third_party/ffmpeg/libavcodec/snow.h
index 1222a776de6..60b00623a0f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snow.h
+++ b/chromium/third_party/ffmpeg/libavcodec/snow.h
@@ -318,7 +318,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
if(!sliced && !offset_dst)
dst -= src_x;
src_x=0;
- }else if(src_x + b_w > w){
+ }
+ if(src_x + b_w > w){
b_w = w - src_x;
}
if(src_y<0){
@@ -327,7 +328,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
if(!sliced && !offset_dst)
dst -= src_y*dst_stride;
src_y=0;
- }else if(src_y + b_h> h){
+ }
+ if(src_y + b_h> h){
b_h = h - src_y;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/snow_dwt.c b/chromium/third_party/ffmpeg/libavcodec/snow_dwt.c
index 28edf6aafb8..cd94c13309b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snow_dwt.c
+++ b/chromium/third_party/ffmpeg/libavcodec/snow_dwt.c
@@ -35,17 +35,17 @@ int ff_slice_buffer_init(slice_buffer *buf, int line_count,
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
- buf->line = av_mallocz(sizeof(IDWTELEM *) * line_count);
+ buf->line = av_mallocz_array(line_count, sizeof(IDWTELEM *));
if (!buf->line)
return AVERROR(ENOMEM);
- buf->data_stack = av_malloc(sizeof(IDWTELEM *) * max_allocated_lines);
+ buf->data_stack = av_malloc_array(max_allocated_lines, sizeof(IDWTELEM *));
if (!buf->data_stack) {
av_freep(&buf->line);
return AVERROR(ENOMEM);
}
for (i = 0; i < max_allocated_lines; i++) {
- buf->data_stack[i] = av_malloc(sizeof(IDWTELEM) * line_width);
+ buf->data_stack[i] = av_malloc_array(line_width, sizeof(IDWTELEM));
if (!buf->data_stack[i]) {
for (i--; i >=0; i--)
av_freep(&buf->data_stack[i]);
@@ -745,7 +745,7 @@ void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height,
decomposition_count, y);
}
-static inline int w_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
+static inline int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size,
int w, int h, int type)
{
int s, i, j;
@@ -814,32 +814,32 @@ static inline int w_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
return s >> 9;
}
-static int w53_8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int w53_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 8, h, 1);
}
-static int w97_8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int w97_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 8, h, 0);
}
-static int w53_16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int w53_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 16, h, 1);
}
-static int w97_16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int w97_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 16, h, 0);
}
-int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 32, h, 1);
}
-int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
return w_c(v, pix1, pix2, line_size, 32, h, 0);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/snow_dwt.h b/chromium/third_party/ffmpeg/libavcodec/snow_dwt.h
index 0806b389e26..e9291896729 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snow_dwt.h
+++ b/chromium/third_party/ffmpeg/libavcodec/snow_dwt.h
@@ -105,8 +105,8 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride,
int src_y, int src_stride, slice_buffer *sb,
int add, uint8_t *dst8);
-int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
+int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
+int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
void ff_spatial_dwt(int *buffer, int *temp, int width, int height, int stride,
int type, int decomposition_count);
diff --git a/chromium/third_party/ffmpeg/libavcodec/snowdec.c b/chromium/third_party/ffmpeg/libavcodec/snowdec.c
index c9d40b84e34..7287a2e64c8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snowdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/snowdec.c
@@ -262,7 +262,7 @@ static void decode_qlogs(SnowContext *s){
tmp= get_symbol(&s->c, s->header_state, 0);\
if(!(check)){\
av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
- return -1;\
+ return AVERROR_INVALIDDATA;\
}\
dst= tmp;
@@ -332,7 +332,7 @@ static int decode_header(SnowContext *s){
p->diag_mc= get_rac(&s->c, s->header_state);
htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2;
if((unsigned)htaps > HTAPS_MAX || htaps==0)
- return -1;
+ return AVERROR_INVALIDDATA;
p->htaps= htaps;
for(i= htaps/2; i; i--){
p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
@@ -353,12 +353,12 @@ static int decode_header(SnowContext *s){
s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
if(s->spatial_decomposition_type > 1U){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported\n", s->spatial_decomposition_type);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if(FFMIN(s->avctx-> width>>s->chroma_h_shift,
s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 1){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size\n", s->spatial_decomposition_count);
- return -1;
+ return AVERROR_INVALIDDATA;
}
@@ -369,7 +369,7 @@ static int decode_header(SnowContext *s){
if(s->block_max_depth > 1 || s->block_max_depth < 0){
av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large\n", s->block_max_depth);
s->block_max_depth= 0;
- return -1;
+ return AVERROR_INVALIDDATA;
}
return 0;
@@ -418,8 +418,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
- if(decode_header(s)<0)
- return -1;
+ if ((res = decode_header(s)) < 0)
+ return res;
if ((res=ff_snow_common_init_after_header(avctx)) < 0)
return res;
@@ -441,11 +441,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
ff_snow_alloc_blocks(s);
- if(ff_snow_frame_start(s) < 0)
- return -1;
+ if((res = ff_snow_frame_start(s)) < 0)
+ return res;
//keyframe flag duplication mess FIXME
if(avctx->debug&FF_DEBUG_PICT_INFO)
- av_log(avctx, AV_LOG_ERROR, "keyframe:%d qlog:%d\n", s->keyframe, s->qlog);
+ av_log(avctx, AV_LOG_ERROR,
+ "keyframe:%d qlog:%d qbias: %d mvscale: %d "
+ "decomposition_type:%d decomposition_count:%d\n",
+ s->keyframe, s->qlog, s->qbias, s->mv_scale,
+ s->spatial_decomposition_type,
+ s->spatial_decomposition_count
+ );
if ((res = decode_blocks(s)) < 0)
return res;
@@ -562,9 +568,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
ff_snow_release_buffer(avctx);
if(!(s->avctx->debug&2048))
- av_frame_ref(picture, s->current_picture);
+ res = av_frame_ref(picture, s->current_picture);
else
- av_frame_ref(picture, s->mconly_picture);
+ res = av_frame_ref(picture, s->mconly_picture);
+
+ if (res < 0)
+ return res;
*got_frame = 1;
diff --git a/chromium/third_party/ffmpeg/libavcodec/snowenc.c b/chromium/third_party/ffmpeg/libavcodec/snowenc.c
index 517728586a0..5067a363ceb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/snowenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/snowenc.c
@@ -38,12 +38,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
SnowContext *s = avctx->priv_data;
int plane_index, ret;
- if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
- av_log(avctx, AV_LOG_ERROR, "This codec is under development, files encoded with it may not be decodable with future versions!!!\n"
- "Use vstrict=-2 / -strict -2 to use it anyway.\n");
- return -1;
- }
-
if(avctx->prediction_method == DWT_97
&& (avctx->flags & CODEC_FLAG_QSCALE)
&& avctx->global_quality == 0){
@@ -78,7 +72,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->m.bit_rate= avctx->bit_rate;
s->m.me.temp =
- s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t));
+ s->m.me.scratchpad= av_mallocz_array((avctx->width+64), 2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
@@ -137,8 +131,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
int i;
int size= s->b_width * s->b_height << 2*s->block_max_depth;
for(i=0; i<s->max_ref_frames; i++){
- s->ref_mvs[i]= av_mallocz(size*sizeof(int16_t[2]));
- s->ref_scores[i]= av_mallocz(size*sizeof(uint32_t));
+ s->ref_mvs[i]= av_mallocz_array(size, sizeof(int16_t[2]));
+ s->ref_scores[i]= av_mallocz_array(size, sizeof(uint32_t));
if (!s->ref_mvs[i] || !s->ref_scores[i])
return AVERROR(ENOMEM);
}
@@ -167,7 +161,7 @@ static int pix_sum(uint8_t * pix, int line_size, int w, int h)
static int pix_norm1(uint8_t * pix, int line_size, int w)
{
int s, i, j;
- uint32_t *sq = ff_squareTbl + 256;
+ uint32_t *sq = ff_square_tab + 256;
s = 0;
for (i = 0; i < w; i++) {
@@ -1502,8 +1496,8 @@ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
}
/* ugly, ratecontrol just takes a sqrt again */
- coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
av_assert0(coef_sum < INT_MAX);
+ coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
if(pict->pict_type == AV_PICTURE_TYPE_I){
s->m.current_picture.mb_var_sum= coef_sum;
@@ -1549,7 +1543,7 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
}
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
- AVFrame *pict, int *got_packet)
+ const AVFrame *pict, int *got_packet)
{
SnowContext *s = avctx->priv_data;
RangeCoder * const c= &s->c;
@@ -1611,8 +1605,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
avctx->coded_frame= s->current_picture;
s->m.current_picture_ptr= &s->m.current_picture;
- s->m.last_picture.f.pts = s->m.current_picture.f.pts;
- s->m.current_picture.f.pts = pict->pts;
+ s->m.current_picture.f = s->current_picture;
+ s->m.current_picture.f->pts = pict->pts;
if(pic->pict_type == AV_PICTURE_TYPE_P){
int block_width = (width +15)>>4;
int block_height= (height+15)>>4;
@@ -1622,14 +1616,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
av_assert0(s->last_picture[0]->data[0]);
s->m.avctx= s->avctx;
- s->m.current_picture.f.data[0] = s->current_picture->data[0];
- s->m. last_picture.f.data[0] = s->last_picture[0]->data[0];
- s->m. new_picture.f.data[0] = s-> input_picture->data[0];
+ s->m. last_picture.f = s->last_picture[0];
+ s->m. new_picture.f = s->input_picture;
s->m. last_picture_ptr= &s->m. last_picture;
- s->m.linesize=
- s->m. last_picture.f.linesize[0] =
- s->m. new_picture.f.linesize[0] =
- s->m.current_picture.f.linesize[0] = stride;
+ s->m.linesize = stride;
s->m.uvlinesize= s->current_picture->linesize[1];
s->m.width = width;
s->m.height= height;
@@ -1664,10 +1654,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
redo_frame:
- if (pic->pict_type == AV_PICTURE_TYPE_I)
- s->spatial_decomposition_count= 5;
- else
- s->spatial_decomposition_count= 5;
+ s->spatial_decomposition_count= 5;
while( !(width >>(s->chroma_h_shift + s->spatial_decomposition_count))
|| !(height>>(s->chroma_v_shift + s->spatial_decomposition_count)))
@@ -1824,9 +1811,9 @@ redo_frame:
s->current_picture->quality = pict->quality;
s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start);
s->m.p_tex_bits = s->m.frame_bits - s->m.misc_bits - s->m.mv_bits;
- s->m.current_picture.f.display_picture_number =
- s->m.current_picture.f.coded_picture_number = avctx->frame_number;
- s->m.current_picture.f.quality = pic->quality;
+ s->m.current_picture.f->display_picture_number =
+ s->m.current_picture.f->coded_picture_number = avctx->frame_number;
+ s->m.current_picture.f->quality = pic->quality;
s->m.total_bits += 8*(s->c.bytestream - s->c.bytestream_start);
if(s->pass1_rc)
if (ff_rate_estimate_qscale(&s->m, 0) < 0)
diff --git a/chromium/third_party/ffmpeg/libavcodec/sonic.c b/chromium/third_party/ffmpeg/libavcodec/sonic.c
index 31bbe46a445..a5e573a7aa4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sonic.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sonic.c
@@ -22,6 +22,8 @@
#include "get_bits.h"
#include "golomb.h"
#include "internal.h"
+#include "rangecoder.h"
+
/**
* @file
@@ -45,6 +47,8 @@
#define RIGHT_SIDE 2
typedef struct SonicContext {
+ int version;
+ int minor_version;
int lossless, decorrelation;
int num_taps, downsampling;
@@ -85,7 +89,94 @@ static inline int shift_down(int a,int b)
return (a>>b)+(a<0);
}
+static av_always_inline av_flatten void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed, uint64_t rc_stat[256][2], uint64_t rc_stat2[32][2]){
+ int i;
+
+#define put_rac(C,S,B) \
+do{\
+ if(rc_stat){\
+ rc_stat[*(S)][B]++;\
+ rc_stat2[(S)-state][B]++;\
+ }\
+ put_rac(C,S,B);\
+}while(0)
+
+ if(v){
+ const int a= FFABS(v);
+ const int e= av_log2(a);
+ put_rac(c, state+0, 0);
+ if(e<=9){
+ for(i=0; i<e; i++){
+ put_rac(c, state+1+i, 1); //1..10
+ }
+ put_rac(c, state+1+i, 0);
+
+ for(i=e-1; i>=0; i--){
+ put_rac(c, state+22+i, (a>>i)&1); //22..31
+ }
+
+ if(is_signed)
+ put_rac(c, state+11 + e, v < 0); //11..21
+ }else{
+ for(i=0; i<e; i++){
+ put_rac(c, state+1+FFMIN(i,9), 1); //1..10
+ }
+ put_rac(c, state+1+9, 0);
+
+ for(i=e-1; i>=0; i--){
+ put_rac(c, state+22+FFMIN(i,9), (a>>i)&1); //22..31
+ }
+
+ if(is_signed)
+ put_rac(c, state+11 + 10, v < 0); //11..21
+ }
+ }else{
+ put_rac(c, state+0, 1);
+ }
+#undef put_rac
+}
+
+static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
+ if(get_rac(c, state+0))
+ return 0;
+ else{
+ int i, e, a;
+ e= 0;
+ while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
+ e++;
+ }
+
+ a= 1;
+ for(i=e-1; i>=0; i--){
+ a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
+ }
+
+ e= -(is_signed && get_rac(c, state+11 + FFMIN(e, 10))); //11..21
+ return (a^e)-e;
+ }
+}
+
#if 1
+static inline int intlist_write(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part)
+{
+ int i;
+
+ for (i = 0; i < entries; i++)
+ put_symbol(c, state, buf[i], 1, NULL, NULL);
+
+ return 1;
+}
+
+static inline int intlist_read(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part)
+{
+ int i;
+
+ for (i = 0; i < entries; i++)
+ buf[i] = get_symbol(c, state, 1);
+
+ return 1;
+}
+#elif 1
static inline int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part)
{
int i;
@@ -193,7 +284,7 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa
bits = av_calloc(entries*max, sizeof(*bits));
if (!bits)
{
-// av_free(copy);
+ av_free(copy);
return AVERROR(ENOMEM);
}
@@ -249,8 +340,8 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa
if (buf[i])
put_bits(pb, 1, buf[i] < 0);
-// av_free(bits);
-// av_free(copy);
+ av_free(bits);
+ av_free(copy);
return 0;
}
@@ -341,7 +432,7 @@ static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_par
pos++;
}
-// av_free(bits);
+ av_free(bits);
// read signs
for (i = 0; i < entries; i++)
@@ -499,7 +590,9 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
PutBitContext pb;
- int i, version = 0;
+ int i;
+
+ s->version = 2;
if (avctx->channels > MAX_CHANNELS)
{
@@ -571,9 +664,13 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
init_put_bits(&pb, avctx->extradata, 16*8);
- put_bits(&pb, 2, version); // version
- if (version == 1)
+ put_bits(&pb, 2, s->version); // version
+ if (s->version >= 1)
{
+ if (s->version >= 2) {
+ put_bits(&pb, 8, s->version);
+ put_bits(&pb, 8, s->minor_version);
+ }
put_bits(&pb, 2, s->channels);
put_bits(&pb, 4, code_samplerate(s->samplerate));
}
@@ -588,8 +685,8 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
flush_put_bits(&pb);
avctx->extradata_size = put_bits_count(&pb)/8;
- av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
- version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
+ av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
+ s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
avctx->frame_size = s->block_align*s->downsampling;
@@ -617,15 +714,18 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
SonicContext *s = avctx->priv_data;
- PutBitContext pb;
+ RangeCoder c;
int i, j, ch, quant = 0, x = 0;
int ret;
const short *samples = (const int16_t*)frame->data[0];
+ uint8_t state[32];
if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size * 5 + 1000)) < 0)
return ret;
- init_put_bits(&pb, avpkt->data, avpkt->size);
+ ff_init_range_encoder(&c, avpkt->data, avpkt->size);
+ ff_build_rac_states(&c, 0.05*(1LL<<32), 256-8);
+ memset(state, 128, sizeof(state));
// short -> internal
for (i = 0; i < s->frame_size; i++)
@@ -671,7 +771,7 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
// generate taps
modified_levinson_durbin(s->window, s->window_size,
s->predictor_k, s->num_taps, s->channels, s->tap_quant);
- if ((ret = intlist_write(&pb, s->predictor_k, s->num_taps, 0)) < 0)
+ if ((ret = intlist_write(&c, state, s->predictor_k, s->num_taps, 0)) < 0)
return ret;
for (ch = 0; ch < s->channels; ch++)
@@ -701,7 +801,7 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
}
energy2 = sqrt(energy2/(s->channels*s->block_align));
- energy1 = sqrt(2.0)*energy1/(s->channels*s->block_align);
+ energy1 = M_SQRT2*energy1/(s->channels*s->block_align);
// increase bitrate when samples are like a gaussian distribution
// reduce bitrate when samples are like a two-tailed exponential distribution
@@ -714,7 +814,7 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
quant = av_clip(quant, 1, 65534);
- set_ue_golomb(&pb, quant);
+ put_symbol(&c, state, quant, 0, NULL, NULL);
quant *= SAMPLE_FACTOR;
}
@@ -726,16 +826,16 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
for (i = 0; i < s->block_align; i++)
s->coded_samples[ch][i] = ROUNDED_DIV(s->coded_samples[ch][i], quant);
- if ((ret = intlist_write(&pb, s->coded_samples[ch], s->block_align, 1)) < 0)
+ if ((ret = intlist_write(&c, state, s->coded_samples[ch], s->block_align, 1)) < 0)
return ret;
}
// av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8);
- flush_put_bits(&pb);
- avpkt->size = (put_bits_count(&pb)+7)/8;
+ avpkt->size = ff_rac_terminate(&c);
*got_packet_ptr = 1;
return 0;
+
}
#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */
@@ -747,7 +847,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
GetBitContext gb;
- int i, version;
+ int i;
s->channels = avctx->channels;
s->samplerate = avctx->sample_rate;
@@ -760,14 +860,18 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
- version = get_bits(&gb, 2);
- if (version > 1)
+ s->version = get_bits(&gb, 2);
+ if (s->version >= 2) {
+ s->version = get_bits(&gb, 8);
+ s->minor_version = get_bits(&gb, 8);
+ }
+ if (s->version != 2)
{
av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n");
return AVERROR_INVALIDDATA;
}
- if (version == 1)
+ if (s->version >= 1)
{
s->channels = get_bits(&gb, 2);
s->samplerate = samplerate_table[get_bits(&gb, 4)];
@@ -804,8 +908,8 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
s->frame_size = s->channels*s->block_align*s->downsampling;
// avctx->frame_size = s->block_align;
- av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
- version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
+ av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
+ s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
// generate taps
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
@@ -858,7 +962,8 @@ static int sonic_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
SonicContext *s = avctx->priv_data;
- GetBitContext gb;
+ RangeCoder c;
+ uint8_t state[32];
int i, quant, ch, j, ret;
int16_t *samples;
AVFrame *frame = data;
@@ -872,9 +977,11 @@ static int sonic_decode_frame(AVCodecContext *avctx,
// av_log(NULL, AV_LOG_INFO, "buf_size: %d\n", buf_size);
- init_get_bits8(&gb, buf, buf_size);
+ memset(state, 128, sizeof(state));
+ ff_init_range_decoder(&c, buf, buf_size);
+ ff_build_rac_states(&c, 0.05*(1LL<<32), 256-8);
- intlist_read(&gb, s->predictor_k, s->num_taps, 0);
+ intlist_read(&c, state, s->predictor_k, s->num_taps, 0);
// dequantize
for (i = 0; i < s->num_taps; i++)
@@ -883,7 +990,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
if (s->lossless)
quant = 1;
else
- quant = get_ue_golomb(&gb) * SAMPLE_FACTOR;
+ quant = get_symbol(&c, state, 0) * SAMPLE_FACTOR;
// av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant);
@@ -893,7 +1000,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
predictor_init_state(s->predictor_k, s->predictor_state[ch], s->num_taps);
- intlist_read(&gb, s->coded_samples[ch], s->block_align, 1);
+ intlist_read(&c, state, s->coded_samples[ch], s->block_align, 1);
for (i = 0; i < s->block_align; i++)
{
@@ -938,11 +1045,9 @@ static int sonic_decode_frame(AVCodecContext *avctx,
for (i = 0; i < s->frame_size; i++)
samples[i] = av_clip_int16(s->int_samples[i]);
- align_get_bits(&gb);
-
*got_frame_ptr = 1;
- return (get_bits_count(&gb)+7)/8;
+ return buf_size;
}
AVCodec ff_sonic_decoder = {
diff --git a/chromium/third_party/ffmpeg/libavcodec/sp5xdec.c b/chromium/third_party/ffmpeg/libavcodec/sp5xdec.c
index 81f3c24a099..74961984201 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sp5xdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sp5xdec.c
@@ -117,5 +117,6 @@ AVCodec ff_amv_decoder = {
.init = ff_mjpeg_decode_init,
.close = ff_mjpeg_decode_end,
.decode = sp5x_decode_frame,
+ .max_lowres = 3,
};
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/Makefile b/chromium/third_party/ffmpeg/libavcodec/sparc/Makefile
deleted file mode 100644
index aeb0f475372..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-VIS-OBJS += sparc/dsputil_vis.o \
- sparc/simple_idct_vis.o \
-
-VIS-OBJS-$(CONFIG_HPELDSP) += sparc/hpeldsp_vis.o
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/README b/chromium/third_party/ffmpeg/libavcodec/sparc/README
new file mode 100644
index 00000000000..f9f2349cd45
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/sparc/README
@@ -0,0 +1,6 @@
+SPARC optimizations have been removed in
+commit b4dd424d96f09f9bafb88e47f37df65dc4529143
+The last revission with the optimizations is fb1b70c1ed50951c5fc1a309c3c446b2eaaf564b
+
+If you want to maintain these (or other) SPARC optimizations in ffmpeg, then please
+contact ffmpeg-devel@ffmpeg.org
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/hpeldsp_vis.c b/chromium/third_party/ffmpeg/libavcodec/sparc/hpeldsp_vis.c
deleted file mode 100644
index be2a85d8f69..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/hpeldsp_vis.c
+++ /dev/null
@@ -1,3524 +0,0 @@
-/*
- * Copyright (C) 2003 David S. Miller <davem@redhat.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* The *no_round* functions have been added by James A. Morrison, 2003,2004.
- The vis code from libmpeg2 was adapted for libavcodec by James A. Morrison.
- */
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/mem.h"
-#include "libavcodec/hpeldsp.h"
-#include "vis.h"
-
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y+1)>>1 == (x|y)-((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16. So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- * fxor f0, f2, f10
- * fand f10, f4, f10
- * fmul8x16 f8, f10, f10
- * fand f10, f6, f10
- * for f0, f2, f12
- * fpsub16 f12, f10, f10
- */
-
-#define DUP4(x) {x, x, x, x}
-#define DUP8(x) {x, x, x, x, x, x, x, x}
-DECLARE_ALIGNED(8, static const int16_t, constants1)[] = DUP4 (1);
-DECLARE_ALIGNED(8, static const int16_t, constants2)[] = DUP4 (2);
-DECLARE_ALIGNED(8, static const int16_t, constants3)[] = DUP4 (3);
-DECLARE_ALIGNED(8, static const int16_t, constants6)[] = DUP4 (6);
-DECLARE_ALIGNED(8, static const int8_t, constants_fe)[] = DUP8 (0xfe);
-DECLARE_ALIGNED(8, static const int8_t, constants_7f)[] = DUP8 (0x7f);
-DECLARE_ALIGNED(8, static const int8_t, constants128)[] = DUP8 (128);
-DECLARE_ALIGNED(8, static const int16_t, constants256_512)[] =
- {256, 512, 256, 512};
-DECLARE_ALIGNED(8, static const int16_t, constants256_1024)[] =
- {256, 1024, 256, 1024};
-
-#define REF_0 0
-#define REF_0_1 1
-#define REF_2 2
-#define REF_2_1 3
-#define REF_4 4
-#define REF_4_1 5
-#define REF_6 6
-#define REF_6_1 7
-#define REF_S0 8
-#define REF_S0_1 9
-#define REF_S2 10
-#define REF_S2_1 11
-#define REF_S4 12
-#define REF_S4_1 13
-#define REF_S6 14
-#define REF_S6_1 15
-#define DST_0 16
-#define DST_1 17
-#define DST_2 18
-#define DST_3 19
-#define CONST_1 20
-#define CONST_2 20
-#define CONST_3 20
-#define CONST_6 20
-#define MASK_fe 20
-#define CONST_128 22
-#define CONST_256 22
-#define CONST_512 22
-#define CONST_1024 22
-#define TMP0 24
-#define TMP1 25
-#define TMP2 26
-#define TMP3 27
-#define TMP4 28
-#define TMP5 29
-#define ZERO 30
-#define MASK_7f 30
-
-#define TMP6 32
-#define TMP8 34
-#define TMP10 36
-#define TMP12 38
-#define TMP14 40
-#define TMP16 42
-#define TMP18 44
-#define TMP20 46
-#define TMP22 48
-#define TMP24 50
-#define TMP26 52
-#define TMP28 54
-#define TMP30 56
-#define TMP32 58
-
-static void MC_put_o_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- do { /* 5 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_st64(REF_0, dest[0]);
-
- vis_faligndata(TMP2, TMP4, REF_2);
- vis_st64_2(REF_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_o_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- do { /* 4 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
- ref += stride;
-
- /* stall */
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_st64(REF_0, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-
-static void MC_avg_o_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- int stride_8 = stride + 8;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(dest[0], DST_0);
-
- vis_ld64(dest[8], DST_2);
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP2, TMP4, REF_2);
-
- vis_ld64(constants128[0], CONST_128);
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 24 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_xor(DST_2, REF_2, TMP8);
-
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_or(DST_0, REF_0, TMP10);
- vis_ld64_2(dest, stride, DST_0);
- vis_mul8x16(CONST_128, TMP8, TMP8);
-
- vis_or(DST_2, REF_2, TMP12);
- vis_ld64_2(dest, stride_8, DST_2);
-
- vis_ld64(ref[0], TMP14);
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-
- dest += stride;
- vis_ld64_2(ref, 8, TMP16);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 16, TMP18);
- vis_faligndata(TMP2, TMP4, REF_2);
- ref += stride;
-
- vis_xor(DST_0, REF_0, TMP20);
-
- vis_and(TMP20, MASK_fe, TMP20);
-
- vis_xor(DST_2, REF_2, TMP22);
- vis_mul8x16(CONST_128, TMP20, TMP20);
-
- vis_and(TMP22, MASK_fe, TMP22);
-
- vis_or(DST_0, REF_0, TMP24);
- vis_mul8x16(CONST_128, TMP22, TMP22);
-
- vis_or(DST_2, REF_2, TMP26);
-
- vis_ld64_2(dest, stride, DST_0);
- vis_faligndata(TMP14, TMP16, REF_0);
-
- vis_ld64_2(dest, stride_8, DST_2);
- vis_faligndata(TMP16, TMP18, REF_2);
-
- vis_and(TMP20, MASK_7f, TMP20);
-
- vis_and(TMP22, MASK_7f, TMP22);
-
- vis_psub16(TMP24, TMP20, TMP20);
- vis_st64(TMP20, dest[0]);
-
- vis_psub16(TMP26, TMP22, TMP22);
- vis_st64_2(TMP22, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_xor(DST_2, REF_2, TMP8);
-
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_or(DST_0, REF_0, TMP10);
- vis_ld64_2(dest, stride, DST_0);
- vis_mul8x16(CONST_128, TMP8, TMP8);
-
- vis_or(DST_2, REF_2, TMP12);
- vis_ld64_2(dest, stride_8, DST_2);
-
- vis_ld64(ref[0], TMP14);
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-
- dest += stride;
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_2);
-
- vis_xor(DST_0, REF_0, TMP20);
-
- vis_and(TMP20, MASK_fe, TMP20);
-
- vis_xor(DST_2, REF_2, TMP22);
- vis_mul8x16(CONST_128, TMP20, TMP20);
-
- vis_and(TMP22, MASK_fe, TMP22);
-
- vis_or(DST_0, REF_0, TMP24);
- vis_mul8x16(CONST_128, TMP22, TMP22);
-
- vis_or(DST_2, REF_2, TMP26);
-
- vis_and(TMP20, MASK_7f, TMP20);
-
- vis_and(TMP22, MASK_7f, TMP22);
-
- vis_psub16(TMP24, TMP20, TMP20);
- vis_st64(TMP20, dest[0]);
-
- vis_psub16(TMP26, TMP22, TMP22);
- vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_avg_o_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_ld64(dest[0], DST_0);
-
- vis_ld64(constants_fe[0], MASK_fe);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants128[0], CONST_128);
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 12 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP4);
-
- vis_ld64(ref[8], TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_or(DST_0, REF_0, TMP6);
- vis_ld64_2(dest, stride, DST_0);
- ref += stride;
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_ld64(ref[0], TMP12);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(ref[8], TMP2);
- vis_xor(DST_0, REF_0, TMP0);
- ref += stride;
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_psub16(TMP6, TMP4, TMP4);
- vis_st64(TMP4, dest[0]);
- dest += stride;
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_or(DST_0, REF_0, TMP6);
- vis_ld64_2(dest, stride, DST_0);
-
- vis_faligndata(TMP12, TMP2, REF_0);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_psub16(TMP6, TMP0, TMP4);
- vis_st64(TMP4, dest[0]);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP4);
-
- vis_ld64(ref[8], TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_or(DST_0, REF_0, TMP6);
- vis_ld64_2(dest, stride, DST_0);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_xor(DST_0, REF_0, TMP0);
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_psub16(TMP6, TMP4, TMP4);
- vis_st64(TMP4, dest[0]);
- dest += stride;
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_or(DST_0, REF_0, TMP6);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_psub16(TMP6, TMP0, TMP4);
- vis_st64(TMP4, dest[0]);
-}
-
-static void MC_put_x_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
-
- vis_ld64(constants_fe[0], MASK_fe);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants128[0], CONST_128);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 34 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_and(TMP6, MASK_fe, TMP6);
- ref += stride;
-
- vis_ld64(ref[0], TMP14);
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_ld64_2(ref, 8, TMP16);
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_or(REF_0, REF_2, TMP10);
-
- vis_ld64_2(ref, 16, TMP18);
- ref += stride;
- vis_or(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_or(REF_0, REF_2, TMP10);
-
- vis_or(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP14, TMP16, REF_0);
-
- vis_faligndata(TMP16, TMP18, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP14, TMP16, REF_2);
- vis_faligndata(TMP16, TMP18, REF_6);
- } else {
- vis_src1(TMP16, REF_2);
- vis_src1(TMP18, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_or(REF_0, REF_2, TMP10);
-
- vis_or(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_or(REF_0, REF_2, TMP10);
-
- vis_or(REF_4, REF_6, TMP12);
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_psub16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_psub16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_x_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_ld64(constants_fe[0], MASK_fe);
-
- vis_ld64(constants_7f[0], MASK_7f);
-
- vis_ld64(constants128[0], CONST_128);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 20 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
- ref += stride;
-
- vis_ld64(ref[0], TMP8);
- vis_or(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, 8, TMP10);
- ref += stride;
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_psub16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_or(REF_0, REF_2, TMP14);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_alignaddr_g0((void *)off);
- vis_faligndata(TMP8, TMP10, REF_0);
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP8, TMP10, REF_2);
- } else {
- vis_src1(TMP10, REF_2);
- }
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_psub16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_or(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_psub16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_or(REF_0, REF_2, TMP14);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_psub16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-}
-
-static void MC_avg_x_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- vis_ld64(constants3[0], CONST_3);
- vis_fzero(ZERO);
- vis_ld64(constants256_512[0], CONST_256);
-
- ref = vis_alignaddr(ref);
- do { /* 26 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(dest[8], DST_2);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_mul8x16au(REF_0, CONST_256, TMP0);
-
- vis_pmerge(ZERO, REF_2, TMP4);
- vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_mul8x16al(DST_0, CONST_512, TMP4);
- vis_padd16(TMP2, TMP6, TMP2);
-
- vis_mul8x16al(DST_1, CONST_512, TMP6);
-
- vis_mul8x16au(REF_6, CONST_256, TMP12);
-
- vis_padd16(TMP0, TMP4, TMP0);
- vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_4, CONST_256, TMP16);
-
- vis_padd16(TMP0, CONST_3, TMP8);
- vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
- vis_padd16(TMP2, CONST_3, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_padd16(TMP16, TMP12, TMP0);
-
- vis_st64(DST_0, dest[0]);
- vis_mul8x16al(DST_2, CONST_512, TMP4);
- vis_padd16(TMP18, TMP14, TMP2);
-
- vis_mul8x16al(DST_3, CONST_512, TMP6);
- vis_padd16(TMP0, CONST_3, TMP0);
-
- vis_padd16(TMP2, CONST_3, TMP2);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_pack16(TMP0, DST_2);
-
- vis_pack16(TMP2, DST_3);
- vis_st64(DST_2, dest[8]);
-
- ref += stride;
- dest += stride;
- } while (--height);
-}
-
-static void MC_avg_x_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_times_2 = stride << 1;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- vis_ld64(constants3[0], CONST_3);
- vis_fzero(ZERO);
- vis_ld64(constants256_512[0], CONST_256);
-
- ref = vis_alignaddr(ref);
- height >>= 2;
- do { /* 47 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64(ref[0], TMP4);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 8, TMP6);
- ref += stride;
-
- vis_ld64(ref[0], TMP8);
-
- vis_ld64_2(ref, 8, TMP10);
- ref += stride;
- vis_faligndata(TMP4, TMP6, REF_4);
-
- vis_ld64(ref[0], TMP12);
-
- vis_ld64_2(ref, 8, TMP14);
- ref += stride;
- vis_faligndata(TMP8, TMP10, REF_S0);
-
- vis_faligndata(TMP12, TMP14, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_ld64_2(dest, stride, DST_2);
- vis_faligndata(TMP4, TMP6, REF_6);
-
- vis_faligndata(TMP8, TMP10, REF_S2);
-
- vis_faligndata(TMP12, TMP14, REF_S6);
- } else {
- vis_ld64(dest[0], DST_0);
- vis_src1(TMP2, REF_2);
-
- vis_ld64_2(dest, stride, DST_2);
- vis_src1(TMP6, REF_6);
-
- vis_src1(TMP10, REF_S2);
-
- vis_src1(TMP14, REF_S6);
- }
-
- vis_pmerge(ZERO, REF_0, TMP0);
- vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
- vis_pmerge(ZERO, REF_2, TMP4);
- vis_mul8x16au(REF_2_1, CONST_256, TMP6);
-
- vis_padd16(TMP0, CONST_3, TMP0);
- vis_mul8x16al(DST_0, CONST_512, TMP16);
-
- vis_padd16(TMP2, CONST_3, TMP2);
- vis_mul8x16al(DST_1, CONST_512, TMP18);
-
- vis_padd16(TMP0, TMP4, TMP0);
- vis_mul8x16au(REF_4, CONST_256, TMP8);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_4_1, CONST_256, TMP10);
-
- vis_padd16(TMP0, TMP16, TMP0);
- vis_mul8x16au(REF_6, CONST_256, TMP12);
-
- vis_padd16(TMP2, TMP18, TMP2);
- vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
- vis_padd16(TMP8, CONST_3, TMP8);
- vis_mul8x16al(DST_2, CONST_512, TMP16);
-
- vis_padd16(TMP8, TMP12, TMP8);
- vis_mul8x16al(DST_3, CONST_512, TMP18);
-
- vis_padd16(TMP10, TMP14, TMP10);
- vis_pack16(TMP0, DST_0);
-
- vis_pack16(TMP2, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- vis_padd16(TMP10, CONST_3, TMP10);
-
- vis_ld64_2(dest, stride, DST_0);
- vis_padd16(TMP8, TMP16, TMP8);
-
- vis_ld64_2(dest, stride_times_2, TMP4/*DST_2*/);
- vis_padd16(TMP10, TMP18, TMP10);
- vis_pack16(TMP8, DST_2);
-
- vis_pack16(TMP10, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
-
- vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
- vis_pmerge(ZERO, REF_S0, TMP0);
-
- vis_pmerge(ZERO, REF_S2, TMP24);
- vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-
- vis_padd16(TMP0, CONST_3, TMP0);
- vis_mul8x16au(REF_S4, CONST_256, TMP8);
-
- vis_padd16(TMP2, CONST_3, TMP2);
- vis_mul8x16au(REF_S4_1, CONST_256, TMP10);
-
- vis_padd16(TMP0, TMP24, TMP0);
- vis_mul8x16au(REF_S6, CONST_256, TMP12);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_S6_1, CONST_256, TMP14);
-
- vis_padd16(TMP8, CONST_3, TMP8);
- vis_mul8x16al(DST_0, CONST_512, TMP16);
-
- vis_padd16(TMP10, CONST_3, TMP10);
- vis_mul8x16al(DST_1, CONST_512, TMP18);
-
- vis_padd16(TMP8, TMP12, TMP8);
- vis_mul8x16al(TMP4/*DST_2*/, CONST_512, TMP20);
-
- vis_mul8x16al(TMP5/*DST_3*/, CONST_512, TMP22);
- vis_padd16(TMP0, TMP16, TMP0);
-
- vis_padd16(TMP2, TMP18, TMP2);
- vis_pack16(TMP0, DST_0);
-
- vis_padd16(TMP10, TMP14, TMP10);
- vis_pack16(TMP2, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_padd16(TMP8, TMP20, TMP8);
-
- vis_padd16(TMP10, TMP22, TMP10);
- vis_pack16(TMP8, DST_2);
-
- vis_pack16(TMP10, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_y_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
-
- vis_ld64(ref[0], TMP6);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 8, TMP8);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64_2(ref, 16, TMP10);
- ref += stride;
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP6, TMP8, REF_2);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP8, TMP10, REF_6);
-
- vis_ld64(constants128[0], CONST_128);
- height = (height >> 1) - 1;
- do { /* 24 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP16);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
- vis_or(REF_0, REF_2, TMP14);
-
- vis_ld64(ref[0], TMP6);
- vis_or(REF_4, REF_6, TMP18);
-
- vis_ld64_2(ref, 8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(TMP16, MASK_fe, TMP16);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_mul8x16(CONST_128, TMP16, TMP16);
- vis_xor(REF_0, REF_2, TMP0);
-
- vis_xor(REF_4, REF_6, TMP2);
-
- vis_or(REF_0, REF_2, TMP20);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_and(TMP16, MASK_7f, TMP16);
-
- vis_psub16(TMP14, TMP12, TMP12);
- vis_st64(TMP12, dest[0]);
-
- vis_psub16(TMP18, TMP16, TMP16);
- vis_st64_2(TMP16, dest, 8);
- dest += stride;
-
- vis_or(REF_4, REF_6, TMP18);
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP2, MASK_fe, TMP2);
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_faligndata(TMP6, TMP8, REF_2);
- vis_mul8x16(CONST_128, TMP2, TMP2);
-
- vis_faligndata(TMP8, TMP10, REF_6);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_and(TMP2, MASK_7f, TMP2);
-
- vis_psub16(TMP20, TMP0, TMP0);
- vis_st64(TMP0, dest[0]);
-
- vis_psub16(TMP18, TMP2, TMP2);
- vis_st64_2(TMP2, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP16);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_or(REF_0, REF_2, TMP14);
-
- vis_or(REF_4, REF_6, TMP18);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(TMP16, MASK_fe, TMP16);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_mul8x16(CONST_128, TMP16, TMP16);
- vis_xor(REF_0, REF_2, TMP0);
-
- vis_xor(REF_4, REF_6, TMP2);
-
- vis_or(REF_0, REF_2, TMP20);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_and(TMP16, MASK_7f, TMP16);
-
- vis_psub16(TMP14, TMP12, TMP12);
- vis_st64(TMP12, dest[0]);
-
- vis_psub16(TMP18, TMP16, TMP16);
- vis_st64_2(TMP16, dest, 8);
- dest += stride;
-
- vis_or(REF_4, REF_6, TMP18);
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP2, MASK_fe, TMP2);
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_mul8x16(CONST_128, TMP2, TMP2);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_and(TMP2, MASK_7f, TMP2);
-
- vis_psub16(TMP20, TMP0, TMP0);
- vis_st64(TMP0, dest[0]);
-
- vis_psub16(TMP18, TMP2, TMP2);
- vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_y_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
-
- vis_ld64(ref[0], TMP4);
-
- vis_ld64_2(ref, 8, TMP6);
- ref += stride;
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP4, TMP6, REF_2);
-
- vis_ld64(constants128[0], CONST_128);
- height = (height >> 1) - 1;
- do { /* 12 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_or(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_mul8x16(CONST_128, TMP12, TMP12);
- vis_or(REF_0, REF_2, TMP14);
-
- vis_psub16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_psub16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_or(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_mul8x16(CONST_128, TMP12, TMP12);
- vis_or(REF_0, REF_2, TMP14);
-
- vis_psub16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_psub16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_y_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants3[0], CONST_3);
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_6);
- height >>= 1;
-
- do { /* 31 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_pmerge(ZERO, REF_2, TMP12);
- vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_pmerge(ZERO, REF_6, TMP16);
- vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(dest, 8, DST_2);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_pmerge(ZERO, REF_0, TMP0);
- vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_pmerge(ZERO, REF_4, TMP4);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
-
- vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
- vis_faligndata(TMP6, TMP8, REF_2);
- vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
- vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
- vis_faligndata(TMP8, TMP10, REF_6);
- vis_mul8x16al(DST_0, CONST_512, TMP20);
-
- vis_padd16(TMP0, CONST_3, TMP0);
- vis_mul8x16al(DST_1, CONST_512, TMP22);
-
- vis_padd16(TMP2, CONST_3, TMP2);
- vis_mul8x16al(DST_2, CONST_512, TMP24);
-
- vis_padd16(TMP4, CONST_3, TMP4);
- vis_mul8x16al(DST_3, CONST_512, TMP26);
-
- vis_padd16(TMP6, CONST_3, TMP6);
-
- vis_padd16(TMP12, TMP20, TMP12);
- vis_mul8x16al(REF_S0, CONST_512, TMP20);
-
- vis_padd16(TMP14, TMP22, TMP14);
- vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
- vis_padd16(TMP16, TMP24, TMP16);
- vis_mul8x16al(REF_S2, CONST_512, TMP24);
-
- vis_padd16(TMP18, TMP26, TMP18);
- vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
- vis_padd16(TMP12, TMP0, TMP12);
- vis_mul8x16au(REF_2, CONST_256, TMP28);
-
- vis_padd16(TMP14, TMP2, TMP14);
- vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
- vis_padd16(TMP16, TMP4, TMP16);
- vis_mul8x16au(REF_6, CONST_256, REF_S4);
-
- vis_padd16(TMP18, TMP6, TMP18);
- vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
- vis_pack16(TMP12, DST_0);
- vis_padd16(TMP28, TMP0, TMP12);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP30, TMP2, TMP14);
-
- vis_pack16(TMP16, DST_2);
- vis_padd16(REF_S4, TMP4, TMP16);
-
- vis_pack16(TMP18, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- vis_padd16(REF_S6, TMP6, TMP18);
-
- vis_padd16(TMP12, TMP20, TMP12);
-
- vis_padd16(TMP14, TMP22, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_padd16(TMP16, TMP24, TMP16);
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
-
- vis_padd16(TMP18, TMP26, TMP18);
- vis_pack16(TMP16, DST_2);
-
- vis_pack16(TMP18, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_avg_y_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- int stride_8 = stride + 8;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(constants3[0], CONST_3);
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_ld64(constants256_512[0], CONST_256);
-
- height >>= 1;
- do { /* 20 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_pmerge(ZERO, REF_2, TMP8);
- vis_mul8x16au(REF_2_1, CONST_256, TMP10);
-
- vis_ld64_2(ref, stride_8, TMP2);
- ref += stride;
-
- vis_ld64(dest[0], DST_0);
-
- vis_ld64_2(dest, stride, DST_2);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, stride, TMP4);
- vis_mul8x16al(DST_0, CONST_512, TMP16);
- vis_pmerge(ZERO, REF_0, TMP12);
-
- vis_ld64_2(ref, stride_8, TMP6);
- ref += stride;
- vis_mul8x16al(DST_1, CONST_512, TMP18);
- vis_pmerge(ZERO, REF_0_1, TMP14);
-
- vis_padd16(TMP12, CONST_3, TMP12);
- vis_mul8x16al(DST_2, CONST_512, TMP24);
-
- vis_padd16(TMP14, CONST_3, TMP14);
- vis_mul8x16al(DST_3, CONST_512, TMP26);
-
- vis_faligndata(TMP4, TMP6, REF_2);
-
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
- vis_mul8x16au(REF_2, CONST_256, TMP20);
-
- vis_padd16(TMP8, TMP16, TMP0);
- vis_mul8x16au(REF_2_1, CONST_256, TMP22);
-
- vis_padd16(TMP10, TMP18, TMP2);
- vis_pack16(TMP0, DST_0);
-
- vis_pack16(TMP2, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- vis_padd16(TMP12, TMP20, TMP12);
-
- vis_padd16(TMP14, TMP22, TMP14);
-
- vis_padd16(TMP12, TMP24, TMP0);
-
- vis_padd16(TMP14, TMP26, TMP2);
- vis_pack16(TMP0, DST_2);
-
- vis_pack16(TMP2, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_xy_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants2[0], CONST_2);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- vis_faligndata(TMP2, TMP4, REF_S6);
- } else {
- vis_src1(TMP2, REF_S2);
- vis_src1(TMP4, REF_S6);
- }
-
- height >>= 1;
- do {
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP12);
- vis_pmerge(ZERO, REF_S0_1, TMP14);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_mul8x16au(REF_S2, CONST_256, TMP16);
- vis_pmerge(ZERO, REF_S2_1, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
- vis_mul8x16au(REF_S4, CONST_256, TMP20);
- vis_pmerge(ZERO, REF_S4_1, TMP22);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_mul8x16au(REF_S6, CONST_256, TMP24);
- vis_pmerge(ZERO, REF_S6_1, TMP26);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_faligndata(TMP6, TMP8, REF_S0);
-
- vis_faligndata(TMP8, TMP10, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- vis_faligndata(TMP6, TMP8, REF_S2);
- vis_faligndata(TMP8, TMP10, REF_S6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- vis_src1(TMP8, REF_S2);
- vis_src1(TMP10, REF_S6);
- }
-
- vis_mul8x16au(REF_0, CONST_256, TMP0);
- vis_pmerge(ZERO, REF_0_1, TMP2);
-
- vis_mul8x16au(REF_2, CONST_256, TMP4);
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_padd16(TMP0, CONST_2, TMP8);
- vis_mul8x16au(REF_4, CONST_256, TMP0);
-
- vis_padd16(TMP2, CONST_2, TMP10);
- vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
- vis_padd16(TMP8, TMP4, TMP8);
- vis_mul8x16au(REF_6, CONST_256, TMP4);
-
- vis_padd16(TMP10, TMP6, TMP10);
- vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
- vis_padd16(TMP12, TMP8, TMP12);
-
- vis_padd16(TMP14, TMP10, TMP14);
-
- vis_padd16(TMP12, TMP16, TMP12);
-
- vis_padd16(TMP14, TMP18, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP0, CONST_2, TMP12);
-
- vis_mul8x16au(REF_S0, CONST_256, TMP0);
- vis_padd16(TMP2, CONST_2, TMP14);
-
- vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
- vis_padd16(TMP12, TMP4, TMP12);
-
- vis_mul8x16au(REF_S2, CONST_256, TMP4);
- vis_padd16(TMP14, TMP6, TMP14);
-
- vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
- vis_padd16(TMP20, TMP12, TMP20);
-
- vis_padd16(TMP22, TMP14, TMP22);
-
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP22, TMP26, TMP22);
- vis_pack16(TMP20, DST_2);
-
- vis_pack16(TMP22, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- vis_padd16(TMP0, TMP4, TMP24);
-
- vis_mul8x16au(REF_S4, CONST_256, TMP0);
- vis_padd16(TMP2, TMP6, TMP26);
-
- vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
- vis_padd16(TMP24, TMP8, TMP24);
-
- vis_padd16(TMP26, TMP10, TMP26);
- vis_pack16(TMP24, DST_0);
-
- vis_pack16(TMP26, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_pmerge(ZERO, REF_S6, TMP4);
-
- vis_pmerge(ZERO, REF_S6_1, TMP6);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_padd16(TMP2, TMP6, TMP2);
-
- vis_padd16(TMP0, TMP12, TMP0);
-
- vis_padd16(TMP2, TMP14, TMP2);
- vis_pack16(TMP0, DST_2);
-
- vis_pack16(TMP2, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_xy_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(constants2[0], CONST_2);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- } else {
- vis_src1(TMP2, REF_S2);
- }
-
- height >>= 1;
- do { /* 26 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP8);
- vis_pmerge(ZERO, REF_S2, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- ref += stride;
- vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
- vis_pmerge(ZERO, REF_S2_1, TMP14);
-
- vis_ld64_2(ref, stride, TMP4);
-
- vis_ld64_2(ref, stride_8, TMP6);
- ref += stride;
- vis_faligndata(TMP0, TMP2, REF_S4);
-
- vis_pmerge(ZERO, REF_S4, TMP18);
-
- vis_pmerge(ZERO, REF_S4_1, TMP20);
-
- vis_faligndata(TMP4, TMP6, REF_S0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S6);
- vis_faligndata(TMP4, TMP6, REF_S2);
- } else {
- vis_src1(TMP2, REF_S6);
- vis_src1(TMP6, REF_S2);
- }
-
- vis_padd16(TMP18, CONST_2, TMP18);
- vis_mul8x16au(REF_S6, CONST_256, TMP22);
-
- vis_padd16(TMP20, CONST_2, TMP20);
- vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
- vis_mul8x16au(REF_S0, CONST_256, TMP26);
- vis_pmerge(ZERO, REF_S0_1, TMP28);
-
- vis_mul8x16au(REF_S2, CONST_256, TMP30);
- vis_padd16(TMP18, TMP22, TMP18);
-
- vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP8, TMP18, TMP8);
-
- vis_padd16(TMP10, TMP20, TMP10);
-
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- vis_padd16(TMP18, TMP26, TMP18);
-
- vis_padd16(TMP20, TMP28, TMP20);
-
- vis_padd16(TMP18, TMP30, TMP18);
-
- vis_padd16(TMP20, TMP32, TMP20);
- vis_pack16(TMP18, DST_2);
-
- vis_pack16(TMP20, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-static void MC_avg_xy_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants6[0], CONST_6);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- vis_ld64(constants256_1024[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- vis_faligndata(TMP2, TMP4, REF_S6);
- } else {
- vis_src1(TMP2, REF_S2);
- vis_src1(TMP4, REF_S6);
- }
-
- height >>= 1;
- do { /* 55 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP12);
- vis_pmerge(ZERO, REF_S0_1, TMP14);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_mul8x16au(REF_S2, CONST_256, TMP16);
- vis_pmerge(ZERO, REF_S2_1, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
- vis_mul8x16au(REF_S4, CONST_256, TMP20);
- vis_pmerge(ZERO, REF_S4_1, TMP22);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_mul8x16au(REF_S6, CONST_256, TMP24);
- vis_pmerge(ZERO, REF_S6_1, TMP26);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP6, TMP8, REF_S0);
-
- vis_ld64_2(dest, 8, DST_2);
- vis_faligndata(TMP8, TMP10, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- vis_faligndata(TMP6, TMP8, REF_S2);
- vis_faligndata(TMP8, TMP10, REF_S6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- vis_src1(TMP8, REF_S2);
- vis_src1(TMP10, REF_S6);
- }
-
- vis_mul8x16al(DST_0, CONST_1024, TMP30);
- vis_pmerge(ZERO, REF_0, TMP0);
-
- vis_mul8x16al(DST_1, CONST_1024, TMP32);
- vis_pmerge(ZERO, REF_0_1, TMP2);
-
- vis_mul8x16au(REF_2, CONST_256, TMP4);
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_mul8x16al(DST_2, CONST_1024, REF_0);
- vis_padd16(TMP0, CONST_6, TMP0);
-
- vis_mul8x16al(DST_3, CONST_1024, REF_2);
- vis_padd16(TMP2, CONST_6, TMP2);
-
- vis_padd16(TMP0, TMP4, TMP0);
- vis_mul8x16au(REF_4, CONST_256, TMP4);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
- vis_padd16(TMP12, TMP0, TMP12);
- vis_mul8x16au(REF_6, CONST_256, TMP8);
-
- vis_padd16(TMP14, TMP2, TMP14);
- vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
- vis_padd16(TMP12, TMP16, TMP12);
- vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
- vis_padd16(TMP14, TMP18, TMP14);
- vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
- vis_padd16(TMP12, TMP30, TMP12);
-
- vis_padd16(TMP14, TMP32, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP4, CONST_6, TMP4);
-
- vis_ld64_2(dest, stride, DST_0);
- vis_padd16(TMP6, CONST_6, TMP6);
- vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
- vis_padd16(TMP4, TMP8, TMP4);
- vis_mul8x16au(REF_S2_1, CONST_256, TMP14);
-
- vis_padd16(TMP6, TMP10, TMP6);
-
- vis_padd16(TMP20, TMP4, TMP20);
-
- vis_padd16(TMP22, TMP6, TMP22);
-
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP22, TMP26, TMP22);
-
- vis_padd16(TMP20, REF_0, TMP20);
- vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
- vis_padd16(TMP22, REF_2, TMP22);
- vis_pack16(TMP20, DST_2);
-
- vis_pack16(TMP22, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
-
- vis_ld64_2(dest, 8, DST_2);
- vis_mul8x16al(DST_0, CONST_1024, TMP30);
- vis_pmerge(ZERO, REF_S4_1, REF_2);
-
- vis_mul8x16al(DST_1, CONST_1024, TMP32);
- vis_padd16(REF_4, TMP0, TMP8);
-
- vis_mul8x16au(REF_S6, CONST_256, REF_4);
- vis_padd16(REF_6, TMP2, TMP10);
-
- vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
-
- vis_padd16(TMP8, TMP30, TMP8);
-
- vis_padd16(TMP10, TMP32, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_st64(DST_0, dest[0]);
-
- vis_padd16(REF_0, TMP4, REF_0);
-
- vis_mul8x16al(DST_2, CONST_1024, TMP30);
- vis_padd16(REF_2, TMP6, REF_2);
-
- vis_mul8x16al(DST_3, CONST_1024, TMP32);
- vis_padd16(REF_0, REF_4, REF_0);
-
- vis_padd16(REF_2, REF_6, REF_2);
-
- vis_padd16(REF_0, TMP30, REF_0);
-
- /* stall */
-
- vis_padd16(REF_2, TMP32, REF_2);
- vis_pack16(REF_0, DST_2);
-
- vis_pack16(REF_2, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_avg_xy_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
-
- vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64(constants6[0], CONST_6);
-
- vis_ld64(constants256_1024[0], CONST_256);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- } else {
- vis_src1(TMP2, REF_S2);
- }
-
- height >>= 1;
- do { /* 31 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP8);
- vis_pmerge(ZERO, REF_S0_1, TMP10);
-
- vis_ld64_2(ref, stride_8, TMP2);
- ref += stride;
- vis_mul8x16au(REF_S2, CONST_256, TMP12);
- vis_pmerge(ZERO, REF_S2_1, TMP14);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride, TMP4);
- vis_faligndata(TMP0, TMP2, REF_S4);
-
- vis_ld64_2(ref, stride_8, TMP6);
- ref += stride;
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP4, TMP6, REF_S0);
-
- vis_ld64_2(dest, stride, DST_2);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S6);
- vis_faligndata(TMP4, TMP6, REF_S2);
- } else {
- vis_src1(TMP2, REF_S6);
- vis_src1(TMP6, REF_S2);
- }
-
- vis_mul8x16al(DST_0, CONST_1024, TMP30);
- vis_pmerge(ZERO, REF_S4, TMP22);
-
- vis_mul8x16al(DST_1, CONST_1024, TMP32);
- vis_pmerge(ZERO, REF_S4_1, TMP24);
-
- vis_mul8x16au(REF_S6, CONST_256, TMP26);
- vis_pmerge(ZERO, REF_S6_1, TMP28);
-
- vis_mul8x16au(REF_S0, CONST_256, REF_S4);
- vis_padd16(TMP22, CONST_6, TMP22);
-
- vis_mul8x16au(REF_S0_1, CONST_256, REF_S6);
- vis_padd16(TMP24, CONST_6, TMP24);
-
- vis_mul8x16al(DST_2, CONST_1024, REF_0);
- vis_padd16(TMP22, TMP26, TMP22);
-
- vis_mul8x16al(DST_3, CONST_1024, REF_2);
- vis_padd16(TMP24, TMP28, TMP24);
-
- vis_mul8x16au(REF_S2, CONST_256, TMP26);
- vis_padd16(TMP8, TMP22, TMP8);
-
- vis_mul8x16au(REF_S2_1, CONST_256, TMP28);
- vis_padd16(TMP10, TMP24, TMP10);
-
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
-
- vis_padd16(TMP8, TMP30, TMP8);
-
- vis_padd16(TMP10, TMP32, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_padd16(REF_S4, TMP22, TMP12);
-
- vis_padd16(REF_S6, TMP24, TMP14);
-
- vis_padd16(TMP12, TMP26, TMP12);
-
- vis_padd16(TMP14, TMP28, TMP14);
-
- vis_padd16(TMP12, REF_0, TMP12);
-
- vis_padd16(TMP14, REF_2, TMP14);
- vis_pack16(TMP12, DST_2);
-
- vis_pack16(TMP14, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-/* End of rounding code */
-
-/* Start of no rounding code */
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y)>>1 == (x&y)+((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16. So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- * fxor f0, f2, f10
- * fand f10, f4, f10
- * fmul8x16 f8, f10, f10
- * fand f10, f6, f10
- * fand f0, f2, f12
- * fpadd16 f12, f10, f10
- */
-
-static void MC_put_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- do { /* 5 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_st64(REF_0, dest[0]);
-
- vis_faligndata(TMP2, TMP4, REF_2);
- vis_st64_2(REF_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_no_round_o_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- do { /* 4 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
- ref += stride;
-
- /* stall */
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_st64(REF_0, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-
-static void MC_avg_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- int stride_8 = stride + 8;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(dest[0], DST_0);
-
- vis_ld64(dest[8], DST_2);
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP2, TMP4, REF_2);
-
- vis_ld64(constants128[0], CONST_128);
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 24 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_xor(DST_2, REF_2, TMP8);
-
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_and(DST_0, REF_0, TMP10);
- vis_ld64_2(dest, stride, DST_0);
- vis_mul8x16(CONST_128, TMP8, TMP8);
-
- vis_and(DST_2, REF_2, TMP12);
- vis_ld64_2(dest, stride_8, DST_2);
-
- vis_ld64(ref[0], TMP14);
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-
- dest += stride;
- vis_ld64_2(ref, 8, TMP16);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 16, TMP18);
- vis_faligndata(TMP2, TMP4, REF_2);
- ref += stride;
-
- vis_xor(DST_0, REF_0, TMP20);
-
- vis_and(TMP20, MASK_fe, TMP20);
-
- vis_xor(DST_2, REF_2, TMP22);
- vis_mul8x16(CONST_128, TMP20, TMP20);
-
- vis_and(TMP22, MASK_fe, TMP22);
-
- vis_and(DST_0, REF_0, TMP24);
- vis_mul8x16(CONST_128, TMP22, TMP22);
-
- vis_and(DST_2, REF_2, TMP26);
-
- vis_ld64_2(dest, stride, DST_0);
- vis_faligndata(TMP14, TMP16, REF_0);
-
- vis_ld64_2(dest, stride_8, DST_2);
- vis_faligndata(TMP16, TMP18, REF_2);
-
- vis_and(TMP20, MASK_7f, TMP20);
-
- vis_and(TMP22, MASK_7f, TMP22);
-
- vis_padd16(TMP24, TMP20, TMP20);
- vis_st64(TMP20, dest[0]);
-
- vis_padd16(TMP26, TMP22, TMP22);
- vis_st64_2(TMP22, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(DST_0, REF_0, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_xor(DST_2, REF_2, TMP8);
-
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_and(DST_0, REF_0, TMP10);
- vis_ld64_2(dest, stride, DST_0);
- vis_mul8x16(CONST_128, TMP8, TMP8);
-
- vis_and(DST_2, REF_2, TMP12);
- vis_ld64_2(dest, stride_8, DST_2);
-
- vis_ld64(ref[0], TMP14);
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-
- dest += stride;
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_2);
-
- vis_xor(DST_0, REF_0, TMP20);
-
- vis_and(TMP20, MASK_fe, TMP20);
-
- vis_xor(DST_2, REF_2, TMP22);
- vis_mul8x16(CONST_128, TMP20, TMP20);
-
- vis_and(TMP22, MASK_fe, TMP22);
-
- vis_and(DST_0, REF_0, TMP24);
- vis_mul8x16(CONST_128, TMP22, TMP22);
-
- vis_and(DST_2, REF_2, TMP26);
-
- vis_and(TMP20, MASK_7f, TMP20);
-
- vis_and(TMP22, MASK_7f, TMP22);
-
- vis_padd16(TMP24, TMP20, TMP20);
- vis_st64(TMP20, dest[0]);
-
- vis_padd16(TMP26, TMP22, TMP22);
- vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_put_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
-
- vis_ld64(constants_fe[0], MASK_fe);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants128[0], CONST_128);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 34 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_and(TMP6, MASK_fe, TMP6);
- ref += stride;
-
- vis_ld64(ref[0], TMP14);
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_ld64_2(ref, 8, TMP16);
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_and(REF_0, REF_2, TMP10);
-
- vis_ld64_2(ref, 16, TMP18);
- ref += stride;
- vis_and(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_and(REF_0, REF_2, TMP10);
-
- vis_and(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP14, TMP16, REF_0);
-
- vis_faligndata(TMP16, TMP18, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP14, TMP16, REF_2);
- vis_faligndata(TMP16, TMP18, REF_6);
- } else {
- vis_src1(TMP16, REF_2);
- vis_src1(TMP18, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_and(REF_0, REF_2, TMP10);
-
- vis_and(REF_4, REF_6, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP6);
-
- vis_xor(REF_4, REF_6, TMP8);
-
- vis_and(TMP6, MASK_fe, TMP6);
-
- vis_mul8x16(CONST_128, TMP6, TMP6);
- vis_and(TMP8, MASK_fe, TMP8);
-
- vis_mul8x16(CONST_128, TMP8, TMP8);
- vis_and(REF_0, REF_2, TMP10);
-
- vis_and(REF_4, REF_6, TMP12);
-
- vis_and(TMP6, MASK_7f, TMP6);
-
- vis_and(TMP8, MASK_7f, TMP8);
-
- vis_padd16(TMP10, TMP6, TMP6);
- vis_st64(TMP6, dest[0]);
-
- vis_padd16(TMP12, TMP8, TMP8);
- vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_no_round_x_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_ld64(constants_fe[0], MASK_fe);
-
- vis_ld64(constants_7f[0], MASK_7f);
-
- vis_ld64(constants128[0], CONST_128);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- ref += stride;
- height = (height >> 1) - 1;
-
- do { /* 20 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
- ref += stride;
-
- vis_ld64(ref[0], TMP8);
- vis_and(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, 8, TMP10);
- ref += stride;
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_padd16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(REF_0, REF_2, TMP14);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_alignaddr_g0((void *)off);
- vis_faligndata(TMP8, TMP10, REF_0);
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP8, TMP10, REF_2);
- } else {
- vis_src1(TMP10, REF_2);
- }
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_padd16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_and(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_alignaddr_g0((void *)off);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- } else {
- vis_src1(TMP2, REF_2);
- }
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_padd16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(REF_0, REF_2, TMP14);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_padd16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-}
-
-static void MC_avg_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- vis_ld64(constants3[0], CONST_3);
- vis_fzero(ZERO);
- vis_ld64(constants256_512[0], CONST_256);
-
- ref = vis_alignaddr(ref);
- do { /* 26 cycles */
- vis_ld64(ref[0], TMP0);
-
- vis_ld64(ref[8], TMP2);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(dest[8], DST_2);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- }
-
- vis_mul8x16au(REF_0, CONST_256, TMP0);
-
- vis_pmerge(ZERO, REF_2, TMP4);
- vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_mul8x16al(DST_0, CONST_512, TMP4);
- vis_padd16(TMP2, TMP6, TMP2);
-
- vis_mul8x16al(DST_1, CONST_512, TMP6);
-
- vis_mul8x16au(REF_6, CONST_256, TMP12);
-
- vis_padd16(TMP0, TMP4, TMP0);
- vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_4, CONST_256, TMP16);
-
- vis_padd16(TMP0, CONST_3, TMP8);
- vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
- vis_padd16(TMP2, CONST_3, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_padd16(TMP16, TMP12, TMP0);
-
- vis_st64(DST_0, dest[0]);
- vis_mul8x16al(DST_2, CONST_512, TMP4);
- vis_padd16(TMP18, TMP14, TMP2);
-
- vis_mul8x16al(DST_3, CONST_512, TMP6);
- vis_padd16(TMP0, CONST_3, TMP0);
-
- vis_padd16(TMP2, CONST_3, TMP2);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_pack16(TMP0, DST_2);
-
- vis_pack16(TMP2, DST_3);
- vis_st64(DST_2, dest[8]);
-
- ref += stride;
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
-
- vis_ld64(ref[0], TMP6);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 8, TMP8);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64_2(ref, 16, TMP10);
- ref += stride;
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP6, TMP8, REF_2);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP8, TMP10, REF_6);
-
- vis_ld64(constants128[0], CONST_128);
- height = (height >> 1) - 1;
- do { /* 24 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP16);
-
- vis_ld64_2(ref, 16, TMP4);
- ref += stride;
- vis_and(REF_0, REF_2, TMP14);
-
- vis_ld64(ref[0], TMP6);
- vis_and(REF_4, REF_6, TMP18);
-
- vis_ld64_2(ref, 8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, 16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(TMP16, MASK_fe, TMP16);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_mul8x16(CONST_128, TMP16, TMP16);
- vis_xor(REF_0, REF_2, TMP0);
-
- vis_xor(REF_4, REF_6, TMP2);
-
- vis_and(REF_0, REF_2, TMP20);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_and(TMP16, MASK_7f, TMP16);
-
- vis_padd16(TMP14, TMP12, TMP12);
- vis_st64(TMP12, dest[0]);
-
- vis_padd16(TMP18, TMP16, TMP16);
- vis_st64_2(TMP16, dest, 8);
- dest += stride;
-
- vis_and(REF_4, REF_6, TMP18);
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP2, MASK_fe, TMP2);
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_faligndata(TMP6, TMP8, REF_2);
- vis_mul8x16(CONST_128, TMP2, TMP2);
-
- vis_faligndata(TMP8, TMP10, REF_6);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_and(TMP2, MASK_7f, TMP2);
-
- vis_padd16(TMP20, TMP0, TMP0);
- vis_st64(TMP0, dest[0]);
-
- vis_padd16(TMP18, TMP2, TMP2);
- vis_st64_2(TMP2, dest, 8);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_xor(REF_4, REF_6, TMP16);
-
- vis_ld64_2(ref, 16, TMP4);
- vis_and(REF_0, REF_2, TMP14);
-
- vis_and(REF_4, REF_6, TMP18);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_and(TMP16, MASK_fe, TMP16);
- vis_mul8x16(CONST_128, TMP12, TMP12);
-
- vis_mul8x16(CONST_128, TMP16, TMP16);
- vis_xor(REF_0, REF_2, TMP0);
-
- vis_xor(REF_4, REF_6, TMP2);
-
- vis_and(REF_0, REF_2, TMP20);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_and(TMP16, MASK_7f, TMP16);
-
- vis_padd16(TMP14, TMP12, TMP12);
- vis_st64(TMP12, dest[0]);
-
- vis_padd16(TMP18, TMP16, TMP16);
- vis_st64_2(TMP16, dest, 8);
- dest += stride;
-
- vis_and(REF_4, REF_6, TMP18);
-
- vis_and(TMP0, MASK_fe, TMP0);
-
- vis_and(TMP2, MASK_fe, TMP2);
- vis_mul8x16(CONST_128, TMP0, TMP0);
-
- vis_mul8x16(CONST_128, TMP2, TMP2);
-
- vis_and(TMP0, MASK_7f, TMP0);
-
- vis_and(TMP2, MASK_7f, TMP2);
-
- vis_padd16(TMP20, TMP0, TMP0);
- vis_st64(TMP0, dest[0]);
-
- vis_padd16(TMP18, TMP2, TMP2);
- vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_no_round_y_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- ref = vis_alignaddr(ref);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
-
- vis_ld64(ref[0], TMP4);
-
- vis_ld64_2(ref, 8, TMP6);
- ref += stride;
-
- vis_ld64(constants_fe[0], MASK_fe);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64(constants_7f[0], MASK_7f);
- vis_faligndata(TMP4, TMP6, REF_2);
-
- vis_ld64(constants128[0], CONST_128);
- height = (height >> 1) - 1;
- do { /* 12 cycles */
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_and(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_faligndata(TMP0, TMP2, REF_0);
- vis_ld64(ref[0], TMP0);
-
- vis_ld64_2(ref, 8, TMP2);
- ref += stride;
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_mul8x16(CONST_128, TMP12, TMP12);
- vis_and(REF_0, REF_2, TMP14);
-
- vis_padd16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_padd16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- } while (--height);
-
- vis_ld64(ref[0], TMP0);
- vis_xor(REF_0, REF_2, TMP4);
-
- vis_ld64_2(ref, 8, TMP2);
- vis_and(TMP4, MASK_fe, TMP4);
-
- vis_and(REF_0, REF_2, TMP6);
- vis_mul8x16(CONST_128, TMP4, TMP4);
-
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_xor(REF_0, REF_2, TMP12);
-
- vis_and(TMP4, MASK_7f, TMP4);
-
- vis_and(TMP12, MASK_fe, TMP12);
-
- vis_mul8x16(CONST_128, TMP12, TMP12);
- vis_and(REF_0, REF_2, TMP14);
-
- vis_padd16(TMP6, TMP4, DST_0);
- vis_st64(DST_0, dest[0]);
- dest += stride;
-
- vis_and(TMP12, MASK_7f, TMP12);
-
- vis_padd16(TMP14, TMP12, DST_0);
- vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants3[0], CONST_3);
- vis_faligndata(TMP0, TMP2, REF_2);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_6);
- height >>= 1;
-
- do { /* 31 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_pmerge(ZERO, REF_2, TMP12);
- vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_pmerge(ZERO, REF_6, TMP16);
- vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(dest, 8, DST_2);
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_pmerge(ZERO, REF_0, TMP0);
- vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_pmerge(ZERO, REF_4, TMP4);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
-
- vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
- vis_faligndata(TMP6, TMP8, REF_2);
- vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
- vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
- vis_faligndata(TMP8, TMP10, REF_6);
- vis_mul8x16al(DST_0, CONST_512, TMP20);
-
- vis_padd16(TMP0, CONST_3, TMP0);
- vis_mul8x16al(DST_1, CONST_512, TMP22);
-
- vis_padd16(TMP2, CONST_3, TMP2);
- vis_mul8x16al(DST_2, CONST_512, TMP24);
-
- vis_padd16(TMP4, CONST_3, TMP4);
- vis_mul8x16al(DST_3, CONST_512, TMP26);
-
- vis_padd16(TMP6, CONST_3, TMP6);
-
- vis_padd16(TMP12, TMP20, TMP12);
- vis_mul8x16al(REF_S0, CONST_512, TMP20);
-
- vis_padd16(TMP14, TMP22, TMP14);
- vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
- vis_padd16(TMP16, TMP24, TMP16);
- vis_mul8x16al(REF_S2, CONST_512, TMP24);
-
- vis_padd16(TMP18, TMP26, TMP18);
- vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
- vis_padd16(TMP12, TMP0, TMP12);
- vis_mul8x16au(REF_2, CONST_256, TMP28);
-
- vis_padd16(TMP14, TMP2, TMP14);
- vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
- vis_padd16(TMP16, TMP4, TMP16);
- vis_mul8x16au(REF_6, CONST_256, REF_S4);
-
- vis_padd16(TMP18, TMP6, TMP18);
- vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
- vis_pack16(TMP12, DST_0);
- vis_padd16(TMP28, TMP0, TMP12);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP30, TMP2, TMP14);
-
- vis_pack16(TMP16, DST_2);
- vis_padd16(REF_S4, TMP4, TMP16);
-
- vis_pack16(TMP18, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- vis_padd16(REF_S6, TMP6, TMP18);
-
- vis_padd16(TMP12, TMP20, TMP12);
-
- vis_padd16(TMP14, TMP22, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_padd16(TMP16, TMP24, TMP16);
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
-
- vis_padd16(TMP18, TMP26, TMP18);
- vis_pack16(TMP16, DST_2);
-
- vis_pack16(TMP18, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants1[0], CONST_1);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- vis_faligndata(TMP2, TMP4, REF_S6);
- } else {
- vis_src1(TMP2, REF_S2);
- vis_src1(TMP4, REF_S6);
- }
-
- height >>= 1;
- do {
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP12);
- vis_pmerge(ZERO, REF_S0_1, TMP14);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_mul8x16au(REF_S2, CONST_256, TMP16);
- vis_pmerge(ZERO, REF_S2_1, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
- vis_mul8x16au(REF_S4, CONST_256, TMP20);
- vis_pmerge(ZERO, REF_S4_1, TMP22);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_mul8x16au(REF_S6, CONST_256, TMP24);
- vis_pmerge(ZERO, REF_S6_1, TMP26);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_faligndata(TMP6, TMP8, REF_S0);
-
- vis_faligndata(TMP8, TMP10, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- vis_faligndata(TMP6, TMP8, REF_S2);
- vis_faligndata(TMP8, TMP10, REF_S6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- vis_src1(TMP8, REF_S2);
- vis_src1(TMP10, REF_S6);
- }
-
- vis_mul8x16au(REF_0, CONST_256, TMP0);
- vis_pmerge(ZERO, REF_0_1, TMP2);
-
- vis_mul8x16au(REF_2, CONST_256, TMP4);
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_padd16(TMP0, CONST_2, TMP8);
- vis_mul8x16au(REF_4, CONST_256, TMP0);
-
- vis_padd16(TMP2, CONST_1, TMP10);
- vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
- vis_padd16(TMP8, TMP4, TMP8);
- vis_mul8x16au(REF_6, CONST_256, TMP4);
-
- vis_padd16(TMP10, TMP6, TMP10);
- vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
- vis_padd16(TMP12, TMP8, TMP12);
-
- vis_padd16(TMP14, TMP10, TMP14);
-
- vis_padd16(TMP12, TMP16, TMP12);
-
- vis_padd16(TMP14, TMP18, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP0, CONST_1, TMP12);
-
- vis_mul8x16au(REF_S0, CONST_256, TMP0);
- vis_padd16(TMP2, CONST_1, TMP14);
-
- vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
- vis_padd16(TMP12, TMP4, TMP12);
-
- vis_mul8x16au(REF_S2, CONST_256, TMP4);
- vis_padd16(TMP14, TMP6, TMP14);
-
- vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
- vis_padd16(TMP20, TMP12, TMP20);
-
- vis_padd16(TMP22, TMP14, TMP22);
-
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP22, TMP26, TMP22);
- vis_pack16(TMP20, DST_2);
-
- vis_pack16(TMP22, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- vis_padd16(TMP0, TMP4, TMP24);
-
- vis_mul8x16au(REF_S4, CONST_256, TMP0);
- vis_padd16(TMP2, TMP6, TMP26);
-
- vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
- vis_padd16(TMP24, TMP8, TMP24);
-
- vis_padd16(TMP26, TMP10, TMP26);
- vis_pack16(TMP24, DST_0);
-
- vis_pack16(TMP26, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_pmerge(ZERO, REF_S6, TMP4);
-
- vis_pmerge(ZERO, REF_S6_1, TMP6);
-
- vis_padd16(TMP0, TMP4, TMP0);
-
- vis_padd16(TMP2, TMP6, TMP2);
-
- vis_padd16(TMP0, TMP12, TMP0);
-
- vis_padd16(TMP2, TMP14, TMP2);
- vis_pack16(TMP0, DST_2);
-
- vis_pack16(TMP2, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-static void MC_put_no_round_xy_8_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
-
- vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(constants1[0], CONST_1);
-
- vis_ld64(constants256_512[0], CONST_256);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- } else {
- vis_src1(TMP2, REF_S2);
- }
-
- height >>= 1;
- do { /* 26 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP8);
- vis_pmerge(ZERO, REF_S2, TMP12);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- ref += stride;
- vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
- vis_pmerge(ZERO, REF_S2_1, TMP14);
-
- vis_ld64_2(ref, stride, TMP4);
-
- vis_ld64_2(ref, stride_8, TMP6);
- ref += stride;
- vis_faligndata(TMP0, TMP2, REF_S4);
-
- vis_pmerge(ZERO, REF_S4, TMP18);
-
- vis_pmerge(ZERO, REF_S4_1, TMP20);
-
- vis_faligndata(TMP4, TMP6, REF_S0);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S6);
- vis_faligndata(TMP4, TMP6, REF_S2);
- } else {
- vis_src1(TMP2, REF_S6);
- vis_src1(TMP6, REF_S2);
- }
-
- vis_padd16(TMP18, CONST_1, TMP18);
- vis_mul8x16au(REF_S6, CONST_256, TMP22);
-
- vis_padd16(TMP20, CONST_1, TMP20);
- vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
- vis_mul8x16au(REF_S0, CONST_256, TMP26);
- vis_pmerge(ZERO, REF_S0_1, TMP28);
-
- vis_mul8x16au(REF_S2, CONST_256, TMP30);
- vis_padd16(TMP18, TMP22, TMP18);
-
- vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP8, TMP18, TMP8);
-
- vis_padd16(TMP10, TMP20, TMP10);
-
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_st64(DST_0, dest[0]);
- dest += stride;
- vis_padd16(TMP18, TMP26, TMP18);
-
- vis_padd16(TMP20, TMP28, TMP20);
-
- vis_padd16(TMP18, TMP30, TMP18);
-
- vis_padd16(TMP20, TMP32, TMP20);
- vis_pack16(TMP18, DST_2);
-
- vis_pack16(TMP20, DST_3);
- vis_st64(DST_2, dest[0]);
- dest += stride;
- } while (--height);
-}
-
-static void MC_avg_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
- const ptrdiff_t stride, int height)
-{
- unsigned long off = (unsigned long) ref & 0x7;
- unsigned long off_plus_1 = off + 1;
- int stride_8 = stride + 8;
- int stride_16 = stride + 16;
-
- vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
- ref = vis_alignaddr(ref);
-
- vis_ld64(ref[ 0], TMP0);
- vis_fzero(ZERO);
-
- vis_ld64(ref[ 8], TMP2);
-
- vis_ld64(ref[16], TMP4);
-
- vis_ld64(constants6[0], CONST_6);
- vis_faligndata(TMP0, TMP2, REF_S0);
-
- vis_ld64(constants256_1024[0], CONST_256);
- vis_faligndata(TMP2, TMP4, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_S2);
- vis_faligndata(TMP2, TMP4, REF_S6);
- } else {
- vis_src1(TMP2, REF_S2);
- vis_src1(TMP4, REF_S6);
- }
-
- height >>= 1;
- do { /* 55 cycles */
- vis_ld64_2(ref, stride, TMP0);
- vis_mul8x16au(REF_S0, CONST_256, TMP12);
- vis_pmerge(ZERO, REF_S0_1, TMP14);
-
- vis_alignaddr_g0((void *)off);
-
- vis_ld64_2(ref, stride_8, TMP2);
- vis_mul8x16au(REF_S2, CONST_256, TMP16);
- vis_pmerge(ZERO, REF_S2_1, TMP18);
-
- vis_ld64_2(ref, stride_16, TMP4);
- ref += stride;
- vis_mul8x16au(REF_S4, CONST_256, TMP20);
- vis_pmerge(ZERO, REF_S4_1, TMP22);
-
- vis_ld64_2(ref, stride, TMP6);
- vis_mul8x16au(REF_S6, CONST_256, TMP24);
- vis_pmerge(ZERO, REF_S6_1, TMP26);
-
- vis_ld64_2(ref, stride_8, TMP8);
- vis_faligndata(TMP0, TMP2, REF_0);
-
- vis_ld64_2(ref, stride_16, TMP10);
- ref += stride;
- vis_faligndata(TMP2, TMP4, REF_4);
-
- vis_ld64(dest[0], DST_0);
- vis_faligndata(TMP6, TMP8, REF_S0);
-
- vis_ld64_2(dest, 8, DST_2);
- vis_faligndata(TMP8, TMP10, REF_S4);
-
- if (off != 0x7) {
- vis_alignaddr_g0((void *)off_plus_1);
- vis_faligndata(TMP0, TMP2, REF_2);
- vis_faligndata(TMP2, TMP4, REF_6);
- vis_faligndata(TMP6, TMP8, REF_S2);
- vis_faligndata(TMP8, TMP10, REF_S6);
- } else {
- vis_src1(TMP2, REF_2);
- vis_src1(TMP4, REF_6);
- vis_src1(TMP8, REF_S2);
- vis_src1(TMP10, REF_S6);
- }
-
- vis_mul8x16al(DST_0, CONST_1024, TMP30);
- vis_pmerge(ZERO, REF_0, TMP0);
-
- vis_mul8x16al(DST_1, CONST_1024, TMP32);
- vis_pmerge(ZERO, REF_0_1, TMP2);
-
- vis_mul8x16au(REF_2, CONST_256, TMP4);
- vis_pmerge(ZERO, REF_2_1, TMP6);
-
- vis_mul8x16al(DST_2, CONST_1024, REF_0);
- vis_padd16(TMP0, CONST_6, TMP0);
-
- vis_mul8x16al(DST_3, CONST_1024, REF_2);
- vis_padd16(TMP2, CONST_6, TMP2);
-
- vis_padd16(TMP0, TMP4, TMP0);
- vis_mul8x16au(REF_4, CONST_256, TMP4);
-
- vis_padd16(TMP2, TMP6, TMP2);
- vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
- vis_padd16(TMP12, TMP0, TMP12);
- vis_mul8x16au(REF_6, CONST_256, TMP8);
-
- vis_padd16(TMP14, TMP2, TMP14);
- vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
- vis_padd16(TMP12, TMP16, TMP12);
- vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
- vis_padd16(TMP14, TMP18, TMP14);
- vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
- vis_padd16(TMP12, TMP30, TMP12);
-
- vis_padd16(TMP14, TMP32, TMP14);
- vis_pack16(TMP12, DST_0);
-
- vis_pack16(TMP14, DST_1);
- vis_st64(DST_0, dest[0]);
- vis_padd16(TMP4, CONST_6, TMP4);
-
- vis_ld64_2(dest, stride, DST_0);
- vis_padd16(TMP6, CONST_6, TMP6);
- vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
- vis_padd16(TMP4, TMP8, TMP4);
- vis_mul8x16au(REF_S2_1, CONST_256, TMP14);
-
- vis_padd16(TMP6, TMP10, TMP6);
-
- vis_padd16(TMP20, TMP4, TMP20);
-
- vis_padd16(TMP22, TMP6, TMP22);
-
- vis_padd16(TMP20, TMP24, TMP20);
-
- vis_padd16(TMP22, TMP26, TMP22);
-
- vis_padd16(TMP20, REF_0, TMP20);
- vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
- vis_padd16(TMP22, REF_2, TMP22);
- vis_pack16(TMP20, DST_2);
-
- vis_pack16(TMP22, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
-
- vis_ld64_2(dest, 8, DST_2);
- vis_mul8x16al(DST_0, CONST_1024, TMP30);
- vis_pmerge(ZERO, REF_S4_1, REF_2);
-
- vis_mul8x16al(DST_1, CONST_1024, TMP32);
- vis_padd16(REF_4, TMP0, TMP8);
-
- vis_mul8x16au(REF_S6, CONST_256, REF_4);
- vis_padd16(REF_6, TMP2, TMP10);
-
- vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
- vis_padd16(TMP8, TMP12, TMP8);
-
- vis_padd16(TMP10, TMP14, TMP10);
-
- vis_padd16(TMP8, TMP30, TMP8);
-
- vis_padd16(TMP10, TMP32, TMP10);
- vis_pack16(TMP8, DST_0);
-
- vis_pack16(TMP10, DST_1);
- vis_st64(DST_0, dest[0]);
-
- vis_padd16(REF_0, TMP4, REF_0);
-
- vis_mul8x16al(DST_2, CONST_1024, TMP30);
- vis_padd16(REF_2, TMP6, REF_2);
-
- vis_mul8x16al(DST_3, CONST_1024, TMP32);
- vis_padd16(REF_0, REF_4, REF_0);
-
- vis_padd16(REF_2, REF_6, REF_2);
-
- vis_padd16(REF_0, TMP30, REF_0);
-
- /* stall */
-
- vis_padd16(REF_2, TMP32, REF_2);
- vis_pack16(REF_0, DST_2);
-
- vis_pack16(REF_2, DST_3);
- vis_st64_2(DST_2, dest, 8);
- dest += stride;
- } while (--height);
-}
-
-/* End of no rounding code */
-
-av_cold void ff_hpeldsp_init_vis(HpelDSPContext *c, int flags)
-{
- /* VIS-specific optimizations */
- int accel = vis_level ();
-
- if (accel & ACCEL_SPARC_VIS) {
- c->put_pixels_tab[0][0] = MC_put_o_16_vis;
- c->put_pixels_tab[0][1] = MC_put_x_16_vis;
- c->put_pixels_tab[0][2] = MC_put_y_16_vis;
- c->put_pixels_tab[0][3] = MC_put_xy_16_vis;
-
- c->put_pixels_tab[1][0] = MC_put_o_8_vis;
- c->put_pixels_tab[1][1] = MC_put_x_8_vis;
- c->put_pixels_tab[1][2] = MC_put_y_8_vis;
- c->put_pixels_tab[1][3] = MC_put_xy_8_vis;
-
- c->avg_pixels_tab[0][0] = MC_avg_o_16_vis;
- c->avg_pixels_tab[0][1] = MC_avg_x_16_vis;
- c->avg_pixels_tab[0][2] = MC_avg_y_16_vis;
- c->avg_pixels_tab[0][3] = MC_avg_xy_16_vis;
-
- c->avg_pixels_tab[1][0] = MC_avg_o_8_vis;
- c->avg_pixels_tab[1][1] = MC_avg_x_8_vis;
- c->avg_pixels_tab[1][2] = MC_avg_y_8_vis;
- c->avg_pixels_tab[1][3] = MC_avg_xy_8_vis;
-
- c->put_no_rnd_pixels_tab[0][0] = MC_put_no_round_o_16_vis;
- c->put_no_rnd_pixels_tab[0][1] = MC_put_no_round_x_16_vis;
- c->put_no_rnd_pixels_tab[0][2] = MC_put_no_round_y_16_vis;
- c->put_no_rnd_pixels_tab[0][3] = MC_put_no_round_xy_16_vis;
-
- c->put_no_rnd_pixels_tab[1][0] = MC_put_no_round_o_8_vis;
- c->put_no_rnd_pixels_tab[1][1] = MC_put_no_round_x_8_vis;
- c->put_no_rnd_pixels_tab[1][2] = MC_put_no_round_y_8_vis;
- c->put_no_rnd_pixels_tab[1][3] = MC_put_no_round_xy_8_vis;
-
- c->avg_no_rnd_pixels_tab[0] = MC_avg_no_round_o_16_vis;
- c->avg_no_rnd_pixels_tab[1] = MC_avg_no_round_x_16_vis;
- c->avg_no_rnd_pixels_tab[2] = MC_avg_no_round_y_16_vis;
- c->avg_no_rnd_pixels_tab[3] = MC_avg_no_round_xy_16_vis;
- }
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/simple_idct_vis.c b/chromium/third_party/ffmpeg/libavcodec/sparc/simple_idct_vis.c
deleted file mode 100644
index c9923e09251..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/simple_idct_vis.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * SPARC VIS optimized inverse DCT
- * Copyright (c) 2007 Denes Balatoni < dbalatoni XatX interware XdotX hu >
- *
- * I did consult the following fine web page about dct
- * http://www.geocities.com/ssavekar/dct.htm
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "dsputil_vis.h"
-#include "libavutil/mem.h"
-
-static const DECLARE_ALIGNED(8, int16_t, coeffs)[28] = {
- - 1259,- 1259,- 1259,- 1259,
- - 4989,- 4989,- 4989,- 4989,
- -11045,-11045,-11045,-11045,
- -19195,-19195,-19195,-19195,
- -29126,-29126,-29126,-29126,
- 25080, 25080, 25080, 25080,
- 12785, 12785, 12785, 12785
-};
-static const DECLARE_ALIGNED(8, uint16_t, scale)[4] = {
- 65536>>6, 65536>>6, 65536>>6, 65536>>6
-};
-static const DECLARE_ALIGNED(8, uint16_t, rounder)[4] = {
- 1<<5, 1<<5, 1<<5, 1<<5
-};
-static const DECLARE_ALIGNED(8, uint16_t, expand)[4] = {
- 1<<14, 1<<14, 1<<14, 1<<14
-};
-
-#define INIT_IDCT \
- "ldd [%1], %%f32 \n\t"\
- "ldd [%1+8], %%f34 \n\t"\
- "ldd [%1+16], %%f36 \n\t"\
- "ldd [%1+24], %%f38 \n\t"\
- "ldd [%1+32], %%f40 \n\t"\
- "ldd [%1+40], %%f42 \n\t"\
- "ldd [%1+48], %%f44 \n\t"\
- "ldd [%0], %%f46 \n\t"\
- "fzero %%f62 \n\t"\
-
-#define LOADSCALE(in) \
- "ldd [" in "], %%f0 \n\t"\
- "ldd [" in "+16], %%f2 \n\t"\
- "ldd [" in "+32], %%f4 \n\t"\
- "ldd [" in "+48], %%f6 \n\t"\
- "ldd [" in "+64], %%f8 \n\t"\
- "ldd [" in "+80], %%f10 \n\t"\
- "ldd [" in "+96], %%f12 \n\t"\
- "ldd [" in "+112], %%f14 \n\t"\
- "fpadd16 %%f0, %%f0, %%f0 \n\t"\
- "fpadd16 %%f2, %%f2, %%f2 \n\t"\
- "fpadd16 %%f4, %%f4, %%f4 \n\t"\
- "fpadd16 %%f6, %%f6, %%f6 \n\t"\
- "fpadd16 %%f8, %%f8, %%f8 \n\t"\
- "fpadd16 %%f10, %%f10, %%f10 \n\t"\
- "fpadd16 %%f12, %%f12, %%f12 \n\t"\
- "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
- "fpadd16 %%f0, %%f0, %%f0 \n\t"\
- "fpadd16 %%f2, %%f2, %%f2 \n\t"\
- "fpadd16 %%f4, %%f4, %%f4 \n\t"\
- "fpadd16 %%f6, %%f6, %%f6 \n\t"\
- "fpadd16 %%f8, %%f8, %%f8 \n\t"\
- "fpadd16 %%f10, %%f10, %%f10 \n\t"\
- "fpadd16 %%f12, %%f12, %%f12 \n\t"\
- "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
- "fpadd16 %%f0, %%f0, %%f0 \n\t"\
- "fpadd16 %%f2, %%f2, %%f2 \n\t"\
- "fpadd16 %%f4, %%f4, %%f4 \n\t"\
- "fpadd16 %%f6, %%f6, %%f6 \n\t"\
- "fpadd16 %%f8, %%f8, %%f8 \n\t"\
- "fpadd16 %%f10, %%f10, %%f10 \n\t"\
- "fpadd16 %%f12, %%f12, %%f12 \n\t"\
- "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
- "fpadd16 %%f0, %%f0, %%f0 \n\t"\
- "fpadd16 %%f2, %%f2, %%f2 \n\t"\
- "fpadd16 %%f4, %%f4, %%f4 \n\t"\
- "fpadd16 %%f6, %%f6, %%f6 \n\t"\
- "fpadd16 %%f8, %%f8, %%f8 \n\t"\
- "fpadd16 %%f10, %%f10, %%f10 \n\t"\
- "fpadd16 %%f12, %%f12, %%f12 \n\t"\
- "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-
-#define LOAD(in) \
- "ldd [" in "], %%f16 \n\t"\
- "ldd [" in "+8], %%f18 \n\t"\
- "ldd [" in "+16], %%f20 \n\t"\
- "ldd [" in "+24], %%f22 \n\t"\
- "ldd [" in "+32], %%f24 \n\t"\
- "ldd [" in "+40], %%f26 \n\t"\
- "ldd [" in "+48], %%f28 \n\t"\
- "ldd [" in "+56], %%f30 \n\t"\
-
-#define TRANSPOSE \
- "fpmerge %%f16, %%f24, %%f0 \n\t"\
- "fpmerge %%f20, %%f28, %%f2 \n\t"\
- "fpmerge %%f17, %%f25, %%f4 \n\t"\
- "fpmerge %%f21, %%f29, %%f6 \n\t"\
- "fpmerge %%f18, %%f26, %%f8 \n\t"\
- "fpmerge %%f22, %%f30, %%f10 \n\t"\
- "fpmerge %%f19, %%f27, %%f12 \n\t"\
- "fpmerge %%f23, %%f31, %%f14 \n\t"\
-\
- "fpmerge %%f0, %%f2, %%f16 \n\t"\
- "fpmerge %%f1, %%f3, %%f18 \n\t"\
- "fpmerge %%f4, %%f6, %%f20 \n\t"\
- "fpmerge %%f5, %%f7, %%f22 \n\t"\
- "fpmerge %%f8, %%f10, %%f24 \n\t"\
- "fpmerge %%f9, %%f11, %%f26 \n\t"\
- "fpmerge %%f12, %%f14, %%f28 \n\t"\
- "fpmerge %%f13, %%f15, %%f30 \n\t"\
-\
- "fpmerge %%f16, %%f17, %%f0 \n\t"\
- "fpmerge %%f18, %%f19, %%f2 \n\t"\
- "fpmerge %%f20, %%f21, %%f4 \n\t"\
- "fpmerge %%f22, %%f23, %%f6 \n\t"\
- "fpmerge %%f24, %%f25, %%f8 \n\t"\
- "fpmerge %%f26, %%f27, %%f10 \n\t"\
- "fpmerge %%f28, %%f29, %%f12 \n\t"\
- "fpmerge %%f30, %%f31, %%f14 \n\t"\
-
-#define IDCT4ROWS \
- /* 1. column */\
- "fmul8ulx16 %%f0, %%f38, %%f28 \n\t"\
- "for %%f4, %%f6, %%f60 \n\t"\
- "fmul8ulx16 %%f2, %%f32, %%f18 \n\t"\
- "fmul8ulx16 %%f2, %%f36, %%f22 \n\t"\
- "fmul8ulx16 %%f2, %%f40, %%f26 \n\t"\
- "fmul8ulx16 %%f2, %%f44, %%f30 \n\t"\
-\
- ADDROUNDER\
-\
- "fmul8sux16 %%f0, %%f38, %%f48 \n\t"\
- "fcmpd %%fcc0, %%f62, %%f60 \n\t"\
- "for %%f8, %%f10, %%f60 \n\t"\
- "fmul8sux16 %%f2, %%f32, %%f50 \n\t"\
- "fmul8sux16 %%f2, %%f36, %%f52 \n\t"\
- "fmul8sux16 %%f2, %%f40, %%f54 \n\t"\
- "fmul8sux16 %%f2, %%f44, %%f56 \n\t"\
-\
- "fpadd16 %%f48, %%f28, %%f28 \n\t"\
- "fcmpd %%fcc1, %%f62, %%f60 \n\t"\
- "for %%f12, %%f14, %%f60 \n\t"\
- "fpadd16 %%f50, %%f18, %%f18 \n\t"\
- "fpadd16 %%f52, %%f22, %%f22 \n\t"\
- "fpadd16 %%f54, %%f26, %%f26 \n\t"\
- "fpadd16 %%f56, %%f30, %%f30 \n\t"\
-\
- "fpadd16 %%f28, %%f0, %%f16 \n\t"\
- "fcmpd %%fcc2, %%f62, %%f60 \n\t"\
- "fpadd16 %%f28, %%f0, %%f20 \n\t"\
- "fpadd16 %%f28, %%f0, %%f24 \n\t"\
- "fpadd16 %%f28, %%f0, %%f28 \n\t"\
- "fpadd16 %%f18, %%f2, %%f18 \n\t"\
- "fpadd16 %%f22, %%f2, %%f22 \n\t"\
- /* 2. column */\
- "fbe %%fcc0, 3f \n\t"\
- "fpadd16 %%f26, %%f2, %%f26 \n\t"\
- "fmul8ulx16 %%f4, %%f34, %%f48 \n\t"\
- "fmul8ulx16 %%f4, %%f42, %%f50 \n\t"\
- "fmul8ulx16 %%f6, %%f36, %%f52 \n\t"\
- "fmul8ulx16 %%f6, %%f44, %%f54 \n\t"\
- "fmul8ulx16 %%f6, %%f32, %%f56 \n\t"\
- "fmul8ulx16 %%f6, %%f40, %%f58 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpadd16 %%f20, %%f50, %%f20 \n\t"\
- "fpsub16 %%f24, %%f50, %%f24 \n\t"\
- "fpsub16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f52, %%f18 \n\t"\
- "fpsub16 %%f22, %%f54, %%f22 \n\t"\
- "fpsub16 %%f26, %%f56, %%f26 \n\t"\
- "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
- "fmul8sux16 %%f4, %%f34, %%f48 \n\t"\
- "fmul8sux16 %%f4, %%f42, %%f50 \n\t"\
- "fmul8sux16 %%f6, %%f36, %%f52 \n\t"\
- "fmul8sux16 %%f6, %%f44, %%f54 \n\t"\
- "fmul8sux16 %%f6, %%f32, %%f56 \n\t"\
- "fmul8sux16 %%f6, %%f40, %%f58 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpadd16 %%f20, %%f50, %%f20 \n\t"\
- "fpsub16 %%f24, %%f50, %%f24 \n\t"\
- "fpsub16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f52, %%f18 \n\t"\
- "fpsub16 %%f22, %%f54, %%f22 \n\t"\
- "fpsub16 %%f26, %%f56, %%f26 \n\t"\
- "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
- "fpadd16 %%f16, %%f4, %%f16 \n\t"\
- "fpsub16 %%f28, %%f4, %%f28 \n\t"\
- "fpadd16 %%f18, %%f6, %%f18 \n\t"\
- "fpsub16 %%f26, %%f6, %%f26 \n\t"\
- /* 3. column */\
- "3: \n\t"\
- "fbe %%fcc1, 4f \n\t"\
- "fpsub16 %%f30, %%f6, %%f30 \n\t"\
- "fmul8ulx16 %%f8, %%f38, %%f48 \n\t"\
- "fmul8ulx16 %%f10, %%f40, %%f50 \n\t"\
- "fmul8ulx16 %%f10, %%f32, %%f52 \n\t"\
- "fmul8ulx16 %%f10, %%f44, %%f54 \n\t"\
- "fmul8ulx16 %%f10, %%f36, %%f56 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpsub16 %%f20, %%f48, %%f20 \n\t"\
- "fpsub16 %%f24, %%f48, %%f24 \n\t"\
- "fpadd16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f50, %%f18 \n\t"\
- "fpsub16 %%f22, %%f52, %%f22 \n\t"\
- "fpadd16 %%f26, %%f54, %%f26 \n\t"\
- "fpadd16 %%f30, %%f56, %%f30 \n\t"\
-\
- "fmul8sux16 %%f8, %%f38, %%f48 \n\t"\
- "fmul8sux16 %%f10, %%f40, %%f50 \n\t"\
- "fmul8sux16 %%f10, %%f32, %%f52 \n\t"\
- "fmul8sux16 %%f10, %%f44, %%f54 \n\t"\
- "fmul8sux16 %%f10, %%f36, %%f56 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpsub16 %%f20, %%f48, %%f20 \n\t"\
- "fpsub16 %%f24, %%f48, %%f24 \n\t"\
- "fpadd16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f50, %%f18 \n\t"\
- "fpsub16 %%f22, %%f52, %%f22 \n\t"\
- "fpadd16 %%f26, %%f54, %%f26 \n\t"\
- "fpadd16 %%f30, %%f56, %%f30 \n\t"\
-\
- "fpadd16 %%f16, %%f8, %%f16 \n\t"\
- "fpsub16 %%f20, %%f8, %%f20 \n\t"\
- "fpsub16 %%f24, %%f8, %%f24 \n\t"\
- "fpadd16 %%f28, %%f8, %%f28 \n\t"\
- "fpadd16 %%f18, %%f10, %%f18 \n\t"\
- "fpsub16 %%f22, %%f10, %%f22 \n\t"\
- /* 4. column */\
- "4: \n\t"\
- "fbe %%fcc2, 5f \n\t"\
- "fpadd16 %%f30, %%f10, %%f30 \n\t"\
- "fmul8ulx16 %%f12, %%f42, %%f48 \n\t"\
- "fmul8ulx16 %%f12, %%f34, %%f50 \n\t"\
- "fmul8ulx16 %%f14, %%f44, %%f52 \n\t"\
- "fmul8ulx16 %%f14, %%f40, %%f54 \n\t"\
- "fmul8ulx16 %%f14, %%f36, %%f56 \n\t"\
- "fmul8ulx16 %%f14, %%f32, %%f58 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpsub16 %%f20, %%f50, %%f20 \n\t"\
- "fpadd16 %%f24, %%f50, %%f24 \n\t"\
- "fpsub16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f52, %%f18 \n\t"\
- "fpsub16 %%f22, %%f54, %%f22 \n\t"\
- "fpadd16 %%f26, %%f56, %%f26 \n\t"\
- "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
- "fmul8sux16 %%f12, %%f42, %%f48 \n\t"\
- "fmul8sux16 %%f12, %%f34, %%f50 \n\t"\
- "fmul8sux16 %%f14, %%f44, %%f52 \n\t"\
- "fmul8sux16 %%f14, %%f40, %%f54 \n\t"\
- "fmul8sux16 %%f14, %%f36, %%f56 \n\t"\
- "fmul8sux16 %%f14, %%f32, %%f58 \n\t"\
-\
- "fpadd16 %%f16, %%f48, %%f16 \n\t"\
- "fpsub16 %%f20, %%f50, %%f20 \n\t"\
- "fpadd16 %%f24, %%f50, %%f24 \n\t"\
- "fpsub16 %%f28, %%f48, %%f28 \n\t"\
- "fpadd16 %%f18, %%f52, %%f18 \n\t"\
- "fpsub16 %%f22, %%f54, %%f22 \n\t"\
- "fpadd16 %%f26, %%f56, %%f26 \n\t"\
- "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
- "fpsub16 %%f20, %%f12, %%f20 \n\t"\
- "fpadd16 %%f24, %%f12, %%f24 \n\t"\
- "fpsub16 %%f22, %%f14, %%f22 \n\t"\
- "fpadd16 %%f26, %%f14, %%f26 \n\t"\
- "fpsub16 %%f30, %%f14, %%f30 \n\t"\
- /* final butterfly */\
- "5: \n\t"\
- "fpsub16 %%f16, %%f18, %%f48 \n\t"\
- "fpsub16 %%f20, %%f22, %%f50 \n\t"\
- "fpsub16 %%f24, %%f26, %%f52 \n\t"\
- "fpsub16 %%f28, %%f30, %%f54 \n\t"\
- "fpadd16 %%f16, %%f18, %%f16 \n\t"\
- "fpadd16 %%f20, %%f22, %%f20 \n\t"\
- "fpadd16 %%f24, %%f26, %%f24 \n\t"\
- "fpadd16 %%f28, %%f30, %%f28 \n\t"\
-
-#define STOREROWS(out) \
- "std %%f48, [" out "+112] \n\t"\
- "std %%f50, [" out "+96] \n\t"\
- "std %%f52, [" out "+80] \n\t"\
- "std %%f54, [" out "+64] \n\t"\
- "std %%f16, [" out "] \n\t"\
- "std %%f20, [" out "+16] \n\t"\
- "std %%f24, [" out "+32] \n\t"\
- "std %%f28, [" out "+48] \n\t"\
-
-#define SCALEROWS \
- "fmul8sux16 %%f46, %%f48, %%f48 \n\t"\
- "fmul8sux16 %%f46, %%f50, %%f50 \n\t"\
- "fmul8sux16 %%f46, %%f52, %%f52 \n\t"\
- "fmul8sux16 %%f46, %%f54, %%f54 \n\t"\
- "fmul8sux16 %%f46, %%f16, %%f16 \n\t"\
- "fmul8sux16 %%f46, %%f20, %%f20 \n\t"\
- "fmul8sux16 %%f46, %%f24, %%f24 \n\t"\
- "fmul8sux16 %%f46, %%f28, %%f28 \n\t"\
-
-#define PUTPIXELSCLAMPED(dest) \
- "fpack16 %%f48, %%f14 \n\t"\
- "fpack16 %%f50, %%f12 \n\t"\
- "fpack16 %%f16, %%f0 \n\t"\
- "fpack16 %%f20, %%f2 \n\t"\
- "fpack16 %%f24, %%f4 \n\t"\
- "fpack16 %%f28, %%f6 \n\t"\
- "fpack16 %%f54, %%f8 \n\t"\
- "fpack16 %%f52, %%f10 \n\t"\
- "st %%f0, [%3+" dest "] \n\t"\
- "st %%f2, [%5+" dest "] \n\t"\
- "st %%f4, [%6+" dest "] \n\t"\
- "st %%f6, [%7+" dest "] \n\t"\
- "st %%f8, [%8+" dest "] \n\t"\
- "st %%f10, [%9+" dest "] \n\t"\
- "st %%f12, [%10+" dest "] \n\t"\
- "st %%f14, [%11+" dest "] \n\t"\
-
-#define ADDPIXELSCLAMPED(dest) \
- "ldd [%5], %%f18 \n\t"\
- "ld [%3+" dest"], %%f0 \n\t"\
- "ld [%6+" dest"], %%f2 \n\t"\
- "ld [%7+" dest"], %%f4 \n\t"\
- "ld [%8+" dest"], %%f6 \n\t"\
- "ld [%9+" dest"], %%f8 \n\t"\
- "ld [%10+" dest"], %%f10 \n\t"\
- "ld [%11+" dest"], %%f12 \n\t"\
- "ld [%12+" dest"], %%f14 \n\t"\
- "fmul8x16 %%f0, %%f18, %%f0 \n\t"\
- "fmul8x16 %%f2, %%f18, %%f2 \n\t"\
- "fmul8x16 %%f4, %%f18, %%f4 \n\t"\
- "fmul8x16 %%f6, %%f18, %%f6 \n\t"\
- "fmul8x16 %%f8, %%f18, %%f8 \n\t"\
- "fmul8x16 %%f10, %%f18, %%f10 \n\t"\
- "fmul8x16 %%f12, %%f18, %%f12 \n\t"\
- "fmul8x16 %%f14, %%f18, %%f14 \n\t"\
- "fpadd16 %%f0, %%f16, %%f0 \n\t"\
- "fpadd16 %%f2, %%f20, %%f2 \n\t"\
- "fpadd16 %%f4, %%f24, %%f4 \n\t"\
- "fpadd16 %%f6, %%f28, %%f6 \n\t"\
- "fpadd16 %%f8, %%f54, %%f8 \n\t"\
- "fpadd16 %%f10, %%f52, %%f10 \n\t"\
- "fpadd16 %%f12, %%f50, %%f12 \n\t"\
- "fpadd16 %%f14, %%f48, %%f14 \n\t"\
- "fpack16 %%f0, %%f0 \n\t"\
- "fpack16 %%f2, %%f2 \n\t"\
- "fpack16 %%f4, %%f4 \n\t"\
- "fpack16 %%f6, %%f6 \n\t"\
- "fpack16 %%f8, %%f8 \n\t"\
- "fpack16 %%f10, %%f10 \n\t"\
- "fpack16 %%f12, %%f12 \n\t"\
- "fpack16 %%f14, %%f14 \n\t"\
- "st %%f0, [%3+" dest "] \n\t"\
- "st %%f2, [%6+" dest "] \n\t"\
- "st %%f4, [%7+" dest "] \n\t"\
- "st %%f6, [%8+" dest "] \n\t"\
- "st %%f8, [%9+" dest "] \n\t"\
- "st %%f10, [%10+" dest "] \n\t"\
- "st %%f12, [%11+" dest "] \n\t"\
- "st %%f14, [%12+" dest "] \n\t"\
-
-
-void ff_simple_idct_vis(int16_t *data) {
- int out1, out2, out3, out4;
- DECLARE_ALIGNED(8, int16_t, temp)[8*8];
-
- __asm__ volatile(
- INIT_IDCT
-
-#define ADDROUNDER
-
- // shift right 16-4=12
- LOADSCALE("%2+8")
- IDCT4ROWS
- STOREROWS("%3+8")
- LOADSCALE("%2+0")
- IDCT4ROWS
- "std %%f48, [%3+112] \n\t"
- "std %%f50, [%3+96] \n\t"
- "std %%f52, [%3+80] \n\t"
- "std %%f54, [%3+64] \n\t"
-
- // shift right 16+4
- "ldd [%3+8], %%f18 \n\t"
- "ldd [%3+24], %%f22 \n\t"
- "ldd [%3+40], %%f26 \n\t"
- "ldd [%3+56], %%f30 \n\t"
- TRANSPOSE
- IDCT4ROWS
- SCALEROWS
- STOREROWS("%2+0")
- LOAD("%3+64")
- TRANSPOSE
- IDCT4ROWS
- SCALEROWS
- STOREROWS("%2+8")
-
- : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4)
- : "0" (scale), "1" (coeffs), "2" (data), "3" (temp)
- );
-}
-
-void ff_simple_idct_put_vis(uint8_t *dest, int line_size, int16_t *data) {
- int out1, out2, out3, out4, out5;
- int r1, r2, r3, r4, r5, r6, r7;
-
- __asm__ volatile(
- "wr %%g0, 0x8, %%gsr \n\t"
-
- INIT_IDCT
-
- "add %3, %4, %5 \n\t"
- "add %5, %4, %6 \n\t"
- "add %6, %4, %7 \n\t"
- "add %7, %4, %8 \n\t"
- "add %8, %4, %9 \n\t"
- "add %9, %4, %10 \n\t"
- "add %10, %4, %11 \n\t"
-
- // shift right 16-4=12
- LOADSCALE("%2+8")
- IDCT4ROWS
- STOREROWS("%2+8")
- LOADSCALE("%2+0")
- IDCT4ROWS
- "std %%f48, [%2+112] \n\t"
- "std %%f50, [%2+96] \n\t"
- "std %%f52, [%2+80] \n\t"
- "std %%f54, [%2+64] \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER "fpadd16 %%f28, %%f46, %%f28 \n\t"
-
- // shift right 16+4
- "ldd [%2+8], %%f18 \n\t"
- "ldd [%2+24], %%f22 \n\t"
- "ldd [%2+40], %%f26 \n\t"
- "ldd [%2+56], %%f30 \n\t"
- TRANSPOSE
- IDCT4ROWS
- PUTPIXELSCLAMPED("0")
- LOAD("%2+64")
- TRANSPOSE
- IDCT4ROWS
- PUTPIXELSCLAMPED("4")
-
- : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5),
- "=r" (r1), "=r" (r2), "=r" (r3), "=r" (r4), "=r" (r5), "=r" (r6), "=r" (r7)
- : "0" (rounder), "1" (coeffs), "2" (data), "3" (dest), "4" (line_size)
- );
-}
-
-void ff_simple_idct_add_vis(uint8_t *dest, int line_size, int16_t *data) {
- int out1, out2, out3, out4, out5, out6;
- int r1, r2, r3, r4, r5, r6, r7;
-
- __asm__ volatile(
- "wr %%g0, 0x8, %%gsr \n\t"
-
- INIT_IDCT
-
- "add %3, %4, %6 \n\t"
- "add %6, %4, %7 \n\t"
- "add %7, %4, %8 \n\t"
- "add %8, %4, %9 \n\t"
- "add %9, %4, %10 \n\t"
- "add %10, %4, %11 \n\t"
- "add %11, %4, %12 \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER
-
- // shift right 16-4=12
- LOADSCALE("%2+8")
- IDCT4ROWS
- STOREROWS("%2+8")
- LOADSCALE("%2+0")
- IDCT4ROWS
- "std %%f48, [%2+112] \n\t"
- "std %%f50, [%2+96] \n\t"
- "std %%f52, [%2+80] \n\t"
- "std %%f54, [%2+64] \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER "fpadd16 %%f28, %%f46, %%f28 \n\t"
-
- // shift right 16+4
- "ldd [%2+8], %%f18 \n\t"
- "ldd [%2+24], %%f22 \n\t"
- "ldd [%2+40], %%f26 \n\t"
- "ldd [%2+56], %%f30 \n\t"
- TRANSPOSE
- IDCT4ROWS
- ADDPIXELSCLAMPED("0")
- LOAD("%2+64")
- TRANSPOSE
- IDCT4ROWS
- ADDPIXELSCLAMPED("4")
-
- : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6),
- "=r" (r1), "=r" (r2), "=r" (r3), "=r" (r4), "=r" (r5), "=r" (r6), "=r" (r7)
- : "0" (rounder), "1" (coeffs), "2" (data), "3" (dest), "4" (line_size), "5" (expand)
- );
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/vis.h b/chromium/third_party/ffmpeg/libavcodec/sparc/vis.h
deleted file mode 100644
index 107ff96d8e2..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/vis.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2003 David S. Miller <davem@redhat.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* You may be asking why I hard-code the instruction opcodes and don't
- * use the normal VIS assembler mnenomics for the VIS instructions.
- *
- * The reason is that Sun, in their infinite wisdom, decided that a binary
- * using a VIS instruction will cause it to be marked (in the ELF headers)
- * as doing so, and this prevents the OS from loading such binaries if the
- * current cpu doesn't have VIS. There is no way to easily override this
- * behavior of the assembler that I am aware of.
- *
- * This totally defeats what libmpeg2 is trying to do which is allow a
- * single binary to be created, and then detect the availability of VIS
- * at runtime.
- *
- * I'm not saying that tainting the binary by default is bad, rather I'm
- * saying that not providing a way to override this easily unnecessarily
- * ties people's hands.
- *
- * Thus, we do the opcode encoding by hand and output 32-bit words in
- * the assembler to keep the binary from becoming tainted.
- */
-
-#ifndef AVCODEC_SPARC_VIS_H
-#define AVCODEC_SPARC_VIS_H
-
-#define ACCEL_SPARC_VIS 1
-#define ACCEL_SPARC_VIS2 2
-
-static inline int vis_level(void)
-{
- int accel = 0;
- accel |= ACCEL_SPARC_VIS;
- accel |= ACCEL_SPARC_VIS2;
- return accel;
-}
-
-#define vis_opc_base ((0x1 << 31) | (0x36 << 19))
-#define vis_opf(X) ((X) << 5)
-#define vis_sreg(X) (X)
-#define vis_dreg(X) (((X)&0x1f)|((X)>>5))
-#define vis_rs1_s(X) (vis_sreg(X) << 14)
-#define vis_rs1_d(X) (vis_dreg(X) << 14)
-#define vis_rs2_s(X) (vis_sreg(X) << 0)
-#define vis_rs2_d(X) (vis_dreg(X) << 0)
-#define vis_rd_s(X) (vis_sreg(X) << 25)
-#define vis_rd_d(X) (vis_dreg(X) << 25)
-
-#define vis_ss2s(opf,rs1,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_s(rs1) | \
- vis_rs2_s(rs2) | \
- vis_rd_s(rd)))
-
-#define vis_dd2d(opf,rs1,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_d(rs1) | \
- vis_rs2_d(rs2) | \
- vis_rd_d(rd)))
-
-#define vis_ss2d(opf,rs1,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_s(rs1) | \
- vis_rs2_s(rs2) | \
- vis_rd_d(rd)))
-
-#define vis_sd2d(opf,rs1,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_s(rs1) | \
- vis_rs2_d(rs2) | \
- vis_rd_d(rd)))
-
-#define vis_d2s(opf,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs2_d(rs2) | \
- vis_rd_s(rd)))
-
-#define vis_s2d(opf,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs2_s(rs2) | \
- vis_rd_d(rd)))
-
-#define vis_d12d(opf,rs1,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_d(rs1) | \
- vis_rd_d(rd)))
-
-#define vis_d22d(opf,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs2_d(rs2) | \
- vis_rd_d(rd)))
-
-#define vis_s12s(opf,rs1,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs1_s(rs1) | \
- vis_rd_s(rd)))
-
-#define vis_s22s(opf,rs2,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rs2_s(rs2) | \
- vis_rd_s(rd)))
-
-#define vis_s(opf,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rd_s(rd)))
-
-#define vis_d(opf,rd) \
- __asm__ volatile (".word %0" \
- : : "i" (vis_opc_base | vis_opf(opf) | \
- vis_rd_d(rd)))
-
-#define vis_r2m(op,rd,mem) \
- __asm__ volatile (#op "\t%%f" #rd ", [%0]" : : "r" (&(mem)) )
-
-#define vis_r2m_2(op,rd,mem1,mem2) \
- __asm__ volatile (#op "\t%%f" #rd ", [%0 + %1]" : : "r" (mem1), "r" (mem2) )
-
-#define vis_m2r(op,mem,rd) \
- __asm__ volatile (#op "\t[%0], %%f" #rd : : "r" (&(mem)) )
-
-#define vis_m2r_2(op,mem1,mem2,rd) \
- __asm__ volatile (#op "\t[%0 + %1], %%f" #rd : : "r" (mem1), "r" (mem2) )
-
-static inline void vis_set_gsr(unsigned int val)
-{
- __asm__ volatile("mov %0,%%asr19"
- : : "r" (val));
-}
-
-#define VIS_GSR_ALIGNADDR_MASK 0x0000007
-#define VIS_GSR_ALIGNADDR_SHIFT 0
-#define VIS_GSR_SCALEFACT_MASK 0x0000078
-#define VIS_GSR_SCALEFACT_SHIFT 3
-
-#define vis_ld32(mem,rs1) vis_m2r(ld, mem, rs1)
-#define vis_ld32_2(mem1,mem2,rs1) vis_m2r_2(ld, mem1, mem2, rs1)
-#define vis_st32(rs1,mem) vis_r2m(st, rs1, mem)
-#define vis_st32_2(rs1,mem1,mem2) vis_r2m_2(st, rs1, mem1, mem2)
-#define vis_ld64(mem,rs1) vis_m2r(ldd, mem, rs1)
-#define vis_ld64_2(mem1,mem2,rs1) vis_m2r_2(ldd, mem1, mem2, rs1)
-#define vis_st64(rs1,mem) vis_r2m(std, rs1, mem)
-#define vis_st64_2(rs1,mem1,mem2) vis_r2m_2(std, rs1, mem1, mem2)
-
-/* 16 and 32 bit partitioned addition and subtraction. The normal
- * versions perform 4 16-bit or 2 32-bit additions or subtractions.
- * The 's' versions perform 2 16-bit or 1 32-bit additions or
- * subtractions.
- */
-
-#define vis_padd16(rs1,rs2,rd) vis_dd2d(0x50, rs1, rs2, rd)
-#define vis_padd16s(rs1,rs2,rd) vis_ss2s(0x51, rs1, rs2, rd)
-#define vis_padd32(rs1,rs2,rd) vis_dd2d(0x52, rs1, rs2, rd)
-#define vis_padd32s(rs1,rs2,rd) vis_ss2s(0x53, rs1, rs2, rd)
-#define vis_psub16(rs1,rs2,rd) vis_dd2d(0x54, rs1, rs2, rd)
-#define vis_psub16s(rs1,rs2,rd) vis_ss2s(0x55, rs1, rs2, rd)
-#define vis_psub32(rs1,rs2,rd) vis_dd2d(0x56, rs1, rs2, rd)
-#define vis_psub32s(rs1,rs2,rd) vis_ss2s(0x57, rs1, rs2, rd)
-
-/* Pixel formatting instructions. */
-
-#define vis_pack16(rs2,rd) vis_d2s( 0x3b, rs2, rd)
-#define vis_pack32(rs1,rs2,rd) vis_dd2d(0x3a, rs1, rs2, rd)
-#define vis_packfix(rs2,rd) vis_d2s( 0x3d, rs2, rd)
-#define vis_expand(rs2,rd) vis_s2d( 0x4d, rs2, rd)
-#define vis_pmerge(rs1,rs2,rd) vis_ss2d(0x4b, rs1, rs2, rd)
-
-/* Partitioned multiply instructions. */
-
-#define vis_mul8x16(rs1,rs2,rd) vis_sd2d(0x31, rs1, rs2, rd)
-#define vis_mul8x16au(rs1,rs2,rd) vis_ss2d(0x33, rs1, rs2, rd)
-#define vis_mul8x16al(rs1,rs2,rd) vis_ss2d(0x35, rs1, rs2, rd)
-#define vis_mul8sux16(rs1,rs2,rd) vis_dd2d(0x36, rs1, rs2, rd)
-#define vis_mul8ulx16(rs1,rs2,rd) vis_dd2d(0x37, rs1, rs2, rd)
-#define vis_muld8sux16(rs1,rs2,rd) vis_ss2d(0x38, rs1, rs2, rd)
-#define vis_muld8ulx16(rs1,rs2,rd) vis_ss2d(0x39, rs1, rs2, rd)
-
-/* Alignment instructions. */
-
-static inline const void *vis_alignaddr(const void *ptr)
-{
- __asm__ volatile("alignaddr %0, %%g0, %0"
- : "=&r" (ptr)
- : "0" (ptr));
-
- return ptr;
-}
-
-static inline void vis_alignaddr_g0(void *ptr)
-{
- __asm__ volatile("alignaddr %0, %%g0, %%g0"
- : : "r" (ptr));
-}
-
-#define vis_faligndata(rs1,rs2,rd) vis_dd2d(0x48, rs1, rs2, rd)
-
-/* Logical operate instructions. */
-
-#define vis_fzero(rd) vis_d( 0x60, rd)
-#define vis_fzeros(rd) vis_s( 0x61, rd)
-#define vis_fone(rd) vis_d( 0x7e, rd)
-#define vis_fones(rd) vis_s( 0x7f, rd)
-#define vis_src1(rs1,rd) vis_d12d(0x74, rs1, rd)
-#define vis_src1s(rs1,rd) vis_s12s(0x75, rs1, rd)
-#define vis_src2(rs2,rd) vis_d22d(0x78, rs2, rd)
-#define vis_src2s(rs2,rd) vis_s22s(0x79, rs2, rd)
-#define vis_not1(rs1,rd) vis_d12d(0x6a, rs1, rd)
-#define vis_not1s(rs1,rd) vis_s12s(0x6b, rs1, rd)
-#define vis_not2(rs2,rd) vis_d22d(0x66, rs2, rd)
-#define vis_not2s(rs2,rd) vis_s22s(0x67, rs2, rd)
-#define vis_or(rs1,rs2,rd) vis_dd2d(0x7c, rs1, rs2, rd)
-#define vis_ors(rs1,rs2,rd) vis_ss2s(0x7d, rs1, rs2, rd)
-#define vis_nor(rs1,rs2,rd) vis_dd2d(0x62, rs1, rs2, rd)
-#define vis_nors(rs1,rs2,rd) vis_ss2s(0x63, rs1, rs2, rd)
-#define vis_and(rs1,rs2,rd) vis_dd2d(0x70, rs1, rs2, rd)
-#define vis_ands(rs1,rs2,rd) vis_ss2s(0x71, rs1, rs2, rd)
-#define vis_nand(rs1,rs2,rd) vis_dd2d(0x6e, rs1, rs2, rd)
-#define vis_nands(rs1,rs2,rd) vis_ss2s(0x6f, rs1, rs2, rd)
-#define vis_xor(rs1,rs2,rd) vis_dd2d(0x6c, rs1, rs2, rd)
-#define vis_xors(rs1,rs2,rd) vis_ss2s(0x6d, rs1, rs2, rd)
-#define vis_xnor(rs1,rs2,rd) vis_dd2d(0x72, rs1, rs2, rd)
-#define vis_xnors(rs1,rs2,rd) vis_ss2s(0x73, rs1, rs2, rd)
-#define vis_ornot1(rs1,rs2,rd) vis_dd2d(0x7a, rs1, rs2, rd)
-#define vis_ornot1s(rs1,rs2,rd) vis_ss2s(0x7b, rs1, rs2, rd)
-#define vis_ornot2(rs1,rs2,rd) vis_dd2d(0x76, rs1, rs2, rd)
-#define vis_ornot2s(rs1,rs2,rd) vis_ss2s(0x77, rs1, rs2, rd)
-#define vis_andnot1(rs1,rs2,rd) vis_dd2d(0x68, rs1, rs2, rd)
-#define vis_andnot1s(rs1,rs2,rd) vis_ss2s(0x69, rs1, rs2, rd)
-#define vis_andnot2(rs1,rs2,rd) vis_dd2d(0x64, rs1, rs2, rd)
-#define vis_andnot2s(rs1,rs2,rd) vis_ss2s(0x65, rs1, rs2, rd)
-
-/* Pixel component distance. */
-
-#define vis_pdist(rs1,rs2,rd) vis_dd2d(0x3e, rs1, rs2, rd)
-
-#endif /* AVCODEC_SPARC_VIS_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/startcode.c b/chromium/third_party/ffmpeg/libavcodec/startcode.c
new file mode 100644
index 00000000000..5df76951505
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/startcode.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Accelerated start code search function for start codes common to
+ * MPEG-1/2/4 video, VC-1, H.264/5
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#include "startcode.h"
+#include "config.h"
+
+int ff_startcode_find_candidate_c(const uint8_t *buf, int size)
+{
+ int i = 0;
+#if HAVE_FAST_UNALIGNED
+ /* we check i < size instead of i + 3 / 7 because it is
+ * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE
+ * bytes at the end.
+ */
+# if HAVE_FAST_64BIT
+ while (i < size &&
+ !((~*(const uint64_t *)(buf + i) &
+ (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) &
+ 0x8080808080808080ULL))
+ i += 8;
+# else
+ while (i < size &&
+ !((~*(const uint32_t *)(buf + i) &
+ (*(const uint32_t *)(buf + i) - 0x01010101U)) &
+ 0x80808080U))
+ i += 4;
+# endif
+#endif
+ for (; i < size; i++)
+ if (!buf[i])
+ break;
+ return i;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/startcode.h b/chromium/third_party/ffmpeg/libavcodec/startcode.h
new file mode 100644
index 00000000000..cc55d5f642a
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/startcode.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Accelerated start code search function for start codes common to
+ * MPEG-1/2/4 video, VC-1, H.264/5
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#ifndef AVCODEC_STARTCODE_H
+#define AVCODEC_STARTCODE_H
+
+#include <stdint.h>
+
+int ff_startcode_find_candidate_c(const uint8_t *buf, int size);
+
+#endif /* AVCODEC_STARTCODE_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/svq1enc.c b/chromium/third_party/ffmpeg/libavcodec/svq1enc.c
index 2d7e848fc71..93a1cc16266 100644
--- a/chromium/third_party/ffmpeg/libavcodec/svq1enc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/svq1enc.c
@@ -32,9 +32,10 @@
#include "mpegvideo.h"
#include "h263.h"
#include "internal.h"
-#include "libavutil/avassert.h"
+#include "mpegutils.h"
#include "svq1.h"
#include "svq1enc_cb.h"
+#include "libavutil/avassert.h"
typedef struct SVQ1Context {
@@ -257,6 +258,15 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
return best_score;
}
+static void init_block_index(MpegEncContext *s){
+ s->block_index[0]= s->b8_stride*(s->mb_y*2 ) + s->mb_x*2;
+ s->block_index[1]= s->b8_stride*(s->mb_y*2 ) + 1 + s->mb_x*2;
+ s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) + s->mb_x*2;
+ s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) + 1 + s->mb_x*2;
+ s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x;
+ s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x;
+}
+
static int svq1_encode_plane(SVQ1Context *s, int plane,
unsigned char *src_plane,
unsigned char *ref_plane,
@@ -285,11 +295,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
s->m.avctx = s->avctx;
s->m.current_picture_ptr = &s->m.current_picture;
s->m.last_picture_ptr = &s->m.last_picture;
- s->m.last_picture.f.data[0] = ref_plane;
+ s->m.last_picture.f->data[0] = ref_plane;
s->m.linesize =
- s->m.last_picture.f.linesize[0] =
- s->m.new_picture.f.linesize[0] =
- s->m.current_picture.f.linesize[0] = stride;
+ s->m.last_picture.f->linesize[0] =
+ s->m.new_picture.f->linesize[0] =
+ s->m.current_picture.f->linesize[0] = stride;
s->m.width = width;
s->m.height = height;
s->m.mb_width = block_width;
@@ -337,7 +347,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
s->m.me.dia_size = s->avctx->dia_size;
s->m.first_slice_line = 1;
for (y = 0; y < block_height; y++) {
- s->m.new_picture.f.data[0] = src - y * 16 * stride; // ugly
+ s->m.new_picture.f->data[0] = src - y * 16 * stride; // ugly
s->m.mb_y = y;
for (i = 0; i < 16 && i + 16 * y < height; i++) {
@@ -352,8 +362,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
for (x = 0; x < block_width; x++) {
s->m.mb_x = x;
- ff_init_block_index(&s->m);
- ff_update_block_index(&s->m);
+ init_block_index(&s->m);
ff_estimate_p_frame_motion(&s->m, x, y);
}
@@ -393,8 +402,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
}
s->m.mb_x = x;
- ff_init_block_index(&s->m);
- ff_update_block_index(&s->m);
+ init_block_index(&s->m);
if (f->pict_type == AV_PICTURE_TYPE_I ||
(s->m.mb_type[x + y * s->m.mb_stride] &
@@ -507,6 +515,9 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
s->rd_total / (double)(avctx->width * avctx->height *
avctx->frame_number));
+ s->m.mb_type = NULL;
+ ff_MPV_common_end(&s->m);
+
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
av_freep(&s->m.me.score_map);
@@ -529,6 +540,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
static av_cold int svq1_encode_init(AVCodecContext *avctx)
{
SVQ1Context *const s = avctx->priv_data;
+ int ret;
ff_dsputil_init(&s->dsp, avctx);
ff_hpeldsp_init(&s->hdsp, avctx->flags);
@@ -552,6 +564,12 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->m.avctx = avctx;
+
+ if ((ret = ff_MPV_common_init(&s->m)) < 0) {
+ svq1_encode_end(avctx);
+ return ret;
+ }
+
s->m.picture_structure = PICT_FRAME;
s->m.me.temp =
s->m.me.scratchpad = av_mallocz((avctx->width + 64) *
diff --git a/chromium/third_party/ffmpeg/libavcodec/svq3.c b/chromium/third_party/ffmpeg/libavcodec/svq3.c
index 189be48c368..97233b19d61 100644
--- a/chromium/third_party/ffmpeg/libavcodec/svq3.c
+++ b/chromium/third_party/ffmpeg/libavcodec/svq3.c
@@ -40,10 +40,12 @@
* http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
*/
+#include <inttypes.h>
+
#include "libavutil/attributes.h"
#include "internal.h"
#include "avcodec.h"
-#include "mpegvideo.h"
+#include "mpegutils.h"
#include "h264.h"
#include "h264data.h" // FIXME FIXME FIXME
@@ -52,6 +54,7 @@
#include "golomb.h"
#include "hpeldsp.h"
#include "rectangle.h"
+#include "tpeldsp.h"
#include "vdpau_internal.h"
#if CONFIG_ZLIB
@@ -69,9 +72,10 @@
typedef struct {
H264Context h;
HpelDSPContext hdsp;
- Picture *cur_pic;
- Picture *next_pic;
- Picture *last_pic;
+ TpelDSPContext tdsp;
+ H264Picture *cur_pic;
+ H264Picture *next_pic;
+ H264Picture *last_pic;
int halfpel_flag;
int thirdpel_flag;
int unknown_flag;
@@ -158,6 +162,8 @@ static const uint32_t svq3_dequant_coeff[32] = {
61694, 68745, 77615, 89113, 100253, 109366, 126635, 141533
};
+static int svq3_decode_end(AVCodecContext *avctx);
+
void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
{
const int qmul = svq3_dequant_coeff[qp];
@@ -296,8 +302,8 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
int mx, int my, int dxy,
int thirdpel, int dir, int avg)
{
- H264Context *h = &s->h;
- const Picture *pic = (dir == 0) ? s->last_pic : s->next_pic;
+ H264Context *h = &s->h;
+ const H264Picture *pic = (dir == 0) ? s->last_pic : s->next_pic;
uint8_t *src, *dest;
int i, emu = 0;
int blocksize = 2 - (width >> 3); // 16->0, 8->1, 4->2
@@ -324,9 +330,9 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
src = h->edge_emu_buffer;
}
if (thirdpel)
- (avg ? h->dsp.avg_tpel_pixels_tab
- : h->dsp.put_tpel_pixels_tab)[dxy](dest, src, h->linesize,
- width, height);
+ (avg ? s->tdsp.avg_tpel_pixels_tab
+ : s->tdsp.put_tpel_pixels_tab)[dxy](dest, src, h->linesize,
+ width, height);
else
(avg ? s->hdsp.avg_pixels_tab
: s->hdsp.put_pixels_tab)[blocksize][dxy](dest, src, h->linesize,
@@ -352,10 +358,10 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
src = h->edge_emu_buffer;
}
if (thirdpel)
- (avg ? h->dsp.avg_tpel_pixels_tab
- : h->dsp.put_tpel_pixels_tab)[dxy](dest, src,
- h->uvlinesize,
- width, height);
+ (avg ? s->tdsp.avg_tpel_pixels_tab
+ : s->tdsp.put_tpel_pixels_tab)[dxy](dest, src,
+ h->uvlinesize,
+ width, height);
else
(avg ? s->hdsp.avg_pixels_tab
: s->hdsp.put_pixels_tab)[blocksize][dxy](dest, src,
@@ -619,7 +625,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
vlc = svq3_get_ue_golomb(&h->gb);
if (vlc >= 25U) {
- av_log(h->avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc);
+ av_log(h->avctx, AV_LOG_ERROR,
+ "luma prediction:%"PRIu32"\n", vlc);
return -1;
}
@@ -688,7 +695,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if (!IS_INTRA16x16(mb_type) &&
(!IS_SKIP(mb_type) || h->pict_type == AV_PICTURE_TYPE_B)) {
if ((vlc = svq3_get_ue_golomb(&h->gb)) >= 48U){
- av_log(h->avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc);
+ av_log(h->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\n", vlc);
return -1;
}
@@ -810,7 +817,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
}
if ((slice_id = svq3_get_ue_golomb(&h->gb)) >= 3) {
- av_log(h->avctx, AV_LOG_ERROR, "illegal slice type %d \n", slice_id);
+ av_log(h->avctx, AV_LOG_ERROR, "illegal slice type %u \n", slice_id);
return -1;
}
@@ -868,26 +875,28 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
unsigned char *extradata_end;
unsigned int size;
int marker_found = 0;
+ int ret;
s->cur_pic = av_mallocz(sizeof(*s->cur_pic));
s->last_pic = av_mallocz(sizeof(*s->last_pic));
s->next_pic = av_mallocz(sizeof(*s->next_pic));
if (!s->next_pic || !s->last_pic || !s->cur_pic) {
- av_freep(&s->cur_pic);
- av_freep(&s->last_pic);
- av_freep(&s->next_pic);
- return AVERROR(ENOMEM);
+ ret = AVERROR(ENOMEM);
+ goto fail;
}
- if (ff_h264_decode_init(avctx) < 0)
- return -1;
+ if ((ret = ff_h264_decode_init(avctx)) < 0)
+ goto fail;
ff_hpeldsp_init(&s->hdsp, avctx->flags);
+ ff_tpeldsp_init(&s->tdsp);
+
h->flags = avctx->flags;
h->is_complex = 1;
h->sps.chroma_format_idc = 1;
h->picture_structure = PICT_FRAME;
- avctx->pix_fmt = avctx->codec->pix_fmts[0];
+ avctx->pix_fmt = AV_PIX_FMT_YUVJ420P;
+ avctx->color_range = AVCOL_RANGE_JPEG;
h->chroma_qp[0] = h->chroma_qp[1] = 4;
h->chroma_x_shift = h->chroma_y_shift = 1;
@@ -915,8 +924,10 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
int frame_size_code;
size = AV_RB32(&extradata[4]);
- if (size > extradata_end - extradata - 8)
- return AVERROR_INVALIDDATA;
+ if (size > extradata_end - extradata - 8) {
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
init_get_bits(&gb, extradata + 8, size * 8);
/* 'frame size code' and optional 'width, height' */
@@ -970,8 +981,10 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
/* unknown field */
skip_bits1(&gb);
- if (skip_1stop_8data_bits(&gb) < 0)
- return AVERROR_INVALIDDATA;
+ if (skip_1stop_8data_bits(&gb) < 0) {
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
s->unknown_flag = get_bits1(&gb);
avctx->has_b_frames = !h->low_delay;
@@ -989,11 +1002,13 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
uint8_t *buf;
if (watermark_height <= 0 ||
- (uint64_t)watermark_width * 4 > UINT_MAX / watermark_height)
- return -1;
+ (uint64_t)watermark_width * 4 > UINT_MAX / watermark_height) {
+ ret = -1;
+ goto fail;
+ }
buf = av_malloc(buf_len);
- av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n",
+ av_log(avctx, AV_LOG_DEBUG, "watermark size: %ux%u\n",
watermark_width, watermark_height);
av_log(avctx, AV_LOG_DEBUG,
"u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n",
@@ -1003,17 +1018,19 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR,
"could not uncompress watermark logo\n");
av_free(buf);
- return -1;
+ ret = -1;
+ goto fail;
}
s->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
s->watermark_key = s->watermark_key << 16 | s->watermark_key;
av_log(avctx, AV_LOG_DEBUG,
- "watermark key %#x\n", s->watermark_key);
+ "watermark key %#"PRIx32"\n", s->watermark_key);
av_free(buf);
#else
av_log(avctx, AV_LOG_ERROR,
"this svq3 file contains watermark which need zlib support compiled in\n");
- return -1;
+ ret = -1;
+ goto fail;
#endif
}
}
@@ -1028,15 +1045,18 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
s->h_edge_pos = h->mb_width * 16;
s->v_edge_pos = h->mb_height * 16;
- if (ff_h264_alloc_tables(h) < 0) {
+ if ((ret = ff_h264_alloc_tables(h)) < 0) {
av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
- return AVERROR(ENOMEM);
+ goto fail;
}
return 0;
+fail:
+ svq3_decode_end(avctx);
+ return ret;
}
-static void free_picture(AVCodecContext *avctx, Picture *pic)
+static void free_picture(AVCodecContext *avctx, H264Picture *pic)
{
int i;
for (i = 0; i < 2; i++) {
@@ -1048,7 +1068,7 @@ static void free_picture(AVCodecContext *avctx, Picture *pic)
av_frame_unref(&pic->f);
}
-static int get_buffer(AVCodecContext *avctx, Picture *pic)
+static int get_buffer(AVCodecContext *avctx, H264Picture *pic)
{
SVQ3Context *s = avctx->priv_data;
H264Context *h = &s->h;
@@ -1142,7 +1162,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
h->pict_type = h->slice_type;
if (h->pict_type != AV_PICTURE_TYPE_B)
- FFSWAP(Picture*, s->next_pic, s->last_pic);
+ FFSWAP(H264Picture*, s->next_pic, s->last_pic);
av_frame_unref(&s->cur_pic->f);
@@ -1175,6 +1195,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
if (h->pict_type != AV_PICTURE_TYPE_I) {
if (!s->last_pic->f.data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
+ av_frame_unref(&s->last_pic->f);
ret = get_buffer(avctx, s->last_pic);
if (ret < 0)
return ret;
@@ -1187,6 +1208,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
if (h->pict_type == AV_PICTURE_TYPE_B && !s->next_pic->f.data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
+ av_frame_unref(&s->next_pic->f);
ret = get_buffer(avctx, s->next_pic);
if (ret < 0)
return ret;
@@ -1284,9 +1306,10 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
(h->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
}
- ff_draw_horiz_band(avctx, NULL, s->cur_pic, s->last_pic->f.data[0] ? s->last_pic : NULL,
- 16 * h->mb_y, 16, h->picture_structure, 0, 0,
- h->low_delay, h->mb_height * 16, h->mb_width * 16);
+ ff_draw_horiz_band(avctx, &s->cur_pic->f,
+ s->last_pic->f.data[0] ? &s->last_pic->f : NULL,
+ 16 * h->mb_y, 16, h->picture_structure, 0,
+ h->low_delay);
}
left = buf_size*8 - get_bits_count(&h->gb);
@@ -1313,7 +1336,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
*got_frame = 1;
if (h->pict_type != AV_PICTURE_TYPE_B) {
- FFSWAP(Picture*, s->cur_pic, s->next_pic);
+ FFSWAP(H264Picture*, s->cur_pic, s->next_pic);
} else {
av_frame_unref(&s->cur_pic->f);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/svq3.h b/chromium/third_party/ffmpeg/libavcodec/svq3.h
index 7a57d8ad017..5007a8c1c0d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/svq3.h
+++ b/chromium/third_party/ffmpeg/libavcodec/svq3.h
@@ -24,4 +24,4 @@
void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp);
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc);
-#endif /* AVCODEC_DSPUTIL_H */
+#endif /* AVCODEC_SVQ3_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/synth_filter.c b/chromium/third_party/ffmpeg/libavcodec/synth_filter.c
index 5f105309746..d49ffe642d6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/synth_filter.c
+++ b/chromium/third_party/ffmpeg/libavcodec/synth_filter.c
@@ -61,4 +61,5 @@ av_cold void ff_synth_filter_init(SynthFilterContext *c)
c->synth_filter_float = synth_filter_float;
if (ARCH_ARM) ff_synth_filter_init_arm(c);
+ if (ARCH_X86) ff_synth_filter_init_x86(c);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/synth_filter.h b/chromium/third_party/ffmpeg/libavcodec/synth_filter.h
index 33edcc437ff..b63fd779b5e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/synth_filter.h
+++ b/chromium/third_party/ffmpeg/libavcodec/synth_filter.h
@@ -33,5 +33,6 @@ typedef struct SynthFilterContext {
void ff_synth_filter_init(SynthFilterContext *c);
void ff_synth_filter_init_arm(SynthFilterContext *c);
+void ff_synth_filter_init_x86(SynthFilterContext *c);
#endif /* AVCODEC_SYNTH_FILTER_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/takdec.c b/chromium/third_party/ffmpeg/libavcodec/takdec.c
index fcbe10ad3cf..d76946f6ef4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/takdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/takdec.c
@@ -686,8 +686,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0)
return ret;
+ hsize = get_bits_count(gb) / 8;
if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_COMPLIANT)) {
- hsize = get_bits_count(gb) / 8;
if (ff_tak_check_crc(pkt->data, hsize)) {
av_log(avctx, AV_LOG_ERROR, "CRC error\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
@@ -721,11 +721,9 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
- if (s->ti.bps != avctx->bits_per_raw_sample) {
- avctx->bits_per_raw_sample = s->ti.bps;
- if ((ret = set_bps_params(avctx)) < 0)
- return ret;
- }
+ avctx->bits_per_raw_sample = s->ti.bps;
+ if ((ret = set_bps_params(avctx)) < 0)
+ return ret;
if (s->ti.sample_rate != avctx->sample_rate) {
avctx->sample_rate = s->ti.sample_rate;
set_sample_rate_params(avctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/tiff.c b/chromium/third_party/ffmpeg/libavcodec/tiff.c
index cd209674ca7..1caad84845f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tiff.c
+++ b/chromium/third_party/ffmpeg/libavcodec/tiff.c
@@ -53,11 +53,13 @@ typedef struct TiffContext {
int palette_is_set;
int le;
enum TiffCompr compr;
- int invert;
+ enum TiffPhotometric photometric;
int planar;
+ int subsampling[2];
int fax_opts;
int predictor;
int fill_order;
+ uint32_t res[4];
int strips, rps, sstype;
int sot;
@@ -66,6 +68,8 @@ typedef struct TiffContext {
uint8_t *deinvert_buf;
int deinvert_buf_size;
+ uint8_t *yuv_line;
+ unsigned int yuv_line_size;
int geotag_count;
TiffGeoTag *geotags;
@@ -79,6 +83,7 @@ static void free_geotags(TiffContext *const s)
av_freep(&s->geotags[i].val);
}
av_freep(&s->geotags);
+ s->geotag_count = 0;
}
#define RET_GEOKEY(TYPE, array, element)\
@@ -194,7 +199,7 @@ static char *doubles2str(double *dp, int count, const char *sep)
char *ap, *ap0;
uint64_t component_len;
if (!sep) sep = ", ";
- component_len = 15LL + strlen(sep);
+ component_len = 24LL + strlen(sep);
if (count >= (INT_MAX - 1)/component_len)
return NULL;
ap = av_malloc(component_len * count + 1);
@@ -203,7 +208,7 @@ static char *doubles2str(double *dp, int count, const char *sep)
ap0 = ap;
ap[0] = '\0';
for (i = 0; i < count; i++) {
- unsigned l = snprintf(ap, component_len, "%f%s", dp[i], sep);
+ unsigned l = snprintf(ap, component_len, "%.15g%s", dp[i], sep);
if(l >= component_len) {
av_free(ap0);
return NULL;
@@ -219,7 +224,7 @@ static int add_metadata(int count, int type,
{
switch(type) {
case TIFF_DOUBLE: return ff_tadd_doubles_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame));
- case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame));
+ case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, 0, avpriv_frame_get_metadatap(frame));
case TIFF_STRING: return ff_tadd_string_metadata(count, name, &s->gb, s->le, avpriv_frame_get_metadatap(frame));
default : return AVERROR_INVALIDDATA;
};
@@ -378,12 +383,43 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,
return ret;
}
-static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
- const uint8_t *src, int size, int lines)
+static void unpack_yuv(TiffContext *s, AVFrame *p,
+ const uint8_t *src, int lnum)
{
+ int i, j, k;
+ int w = (s->width - 1) / s->subsampling[0] + 1;
+ uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
+ uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
+ if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) {
+ for (i = 0; i < w; i++) {
+ for (j = 0; j < s->subsampling[1]; j++)
+ for (k = 0; k < s->subsampling[0]; k++)
+ p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] +
+ FFMIN(i * s->subsampling[0] + k, s->width-1)] = *src++;
+ *pu++ = *src++;
+ *pv++ = *src++;
+ }
+ }else{
+ for (i = 0; i < w; i++) {
+ for (j = 0; j < s->subsampling[1]; j++)
+ for (k = 0; k < s->subsampling[0]; k++)
+ p->data[0][(lnum + j) * p->linesize[0] +
+ i * s->subsampling[0] + k] = *src++;
+ *pu++ = *src++;
+ *pv++ = *src++;
+ }
+ }
+}
+
+
+static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int stride,
+ const uint8_t *src, int size, int strip_start, int lines)
+{
+ PutByteContext pb;
int c, line, pixels, code, ret;
const uint8_t *ssrc = src;
- int width = ((s->width * s->bpp) + 7) >> 3;
+ int width = ((s->width * s->bpp) + 7) >> 3;
+ int is_yuv = s->photometric == TIFF_PHOTOMETRIC_YCBCR;
if (s->planar)
width /= s->bppcount;
@@ -391,7 +427,26 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
if (size <= 0)
return AVERROR_INVALIDDATA;
+ if (is_yuv) {
+ int bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
+ s->subsampling[0] * s->subsampling[1] + 7) >> 3;
+ av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, bytes_per_row);
+ if (s->yuv_line == NULL) {
+ av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
+ return AVERROR(ENOMEM);
+ }
+ dst = s->yuv_line;
+ stride = 0;
+ width = s->width * s->subsampling[1] + 2*(s->width / s->subsampling[0]);
+ av_assert0(width <= bytes_per_row);
+ av_assert0(s->bpp == 24);
+ }
+
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
+ if (is_yuv) {
+ av_log(s->avctx, AV_LOG_ERROR, "YUV deflate is unsupported");
+ return AVERROR_PATCHWELCOME;
+ }
#if CONFIG_ZLIB
return tiff_unpack_zlib(s, dst, stride, src, size, width, lines);
#else
@@ -414,21 +469,49 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
return ret;
}
+ for (line = 0; line < lines; line++) {
+ pixels = ff_lzw_decode(s->lzw, dst, width);
+ if (pixels < width) {
+ av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n",
+ pixels, width);
+ return AVERROR_INVALIDDATA;
+ }
+ if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
+ horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
+ if (is_yuv) {
+ unpack_yuv(s, p, dst, strip_start + line);
+ line += s->subsampling[1] - 1;
+ }
+ dst += stride;
+ }
+ return 0;
}
if (s->compr == TIFF_CCITT_RLE ||
s->compr == TIFF_G3 ||
s->compr == TIFF_G4) {
+ if (is_yuv)
+ return AVERROR_INVALIDDATA;
+
return tiff_unpack_fax(s, dst, stride, src, size, width, lines);
}
+
+ bytestream2_init(&s->gb, src, size);
+ bytestream2_init_writer(&pb, dst, is_yuv ? s->yuv_line_size : (stride * lines));
+
for (line = 0; line < lines; line++) {
if (src - ssrc > size) {
av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
return AVERROR_INVALIDDATA;
}
+
+ if (bytestream2_get_bytes_left(&s->gb) == 0 || bytestream2_get_eof(&pb))
+ break;
+ bytestream2_seek_p(&pb, stride * line, SEEK_SET);
switch (s->compr) {
case TIFF_RAW:
if (ssrc + size - src < width)
return AVERROR_INVALIDDATA;
+
if (!s->fill_order) {
horizontal_fill(s->bpp * (s->avctx->pix_fmt == AV_PIX_FMT_PAL8),
dst, 1, src, 0, width, 0);
@@ -477,16 +560,10 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
dst[i] = ff_reverse[dst[i]];
}
break;
- case TIFF_LZW:
- pixels = ff_lzw_decode(s->lzw, dst, width);
- if (pixels < width) {
- av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n",
- pixels, width);
- return AVERROR_INVALIDDATA;
- }
- if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
- horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
- break;
+ }
+ if (is_yuv) {
+ unpack_yuv(s, p, dst, strip_start + line);
+ line += s->subsampling[1] - 1;
}
dst += stride;
}
@@ -510,7 +587,25 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case 243:
- s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
+ if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
+ if (s->subsampling[0] == 1 && s->subsampling[1] == 1) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+ } else if (s->subsampling[0] == 2 && s->subsampling[1] == 1) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+ } else if (s->subsampling[0] == 4 && s->subsampling[1] == 1) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV411P;
+ } else if (s->subsampling[0] == 1 && s->subsampling[1] == 2) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV440P;
+ } else if (s->subsampling[0] == 2 && s->subsampling[1] == 2) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ } else if (s->subsampling[0] == 4 && s->subsampling[1] == 4) {
+ s->avctx->pix_fmt = AV_PIX_FMT_YUV410P;
+ } else {
+ av_log(s->avctx, AV_LOG_ERROR, "Unsupported YCbCr subsampling\n");
+ return AVERROR_PATCHWELCOME;
+ }
+ } else
+ s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 161:
s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GRAY16LE : AV_PIX_FMT_GRAY16BE;
@@ -565,12 +660,22 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
return 0;
}
+static void set_sar(TiffContext *s, unsigned tag, unsigned num, unsigned den)
+{
+ int offset = tag == TIFF_YRES ? 2 : 0;
+ s->res[offset++] = num;
+ s->res[offset] = den;
+ if (s->res[0] && s->res[1] && s->res[2] && s->res[3])
+ av_reduce(&s->avctx->sample_aspect_ratio.num, &s->avctx->sample_aspect_ratio.den,
+ s->res[2] * (uint64_t)s->res[1], s->res[0] * (uint64_t)s->res[3], INT32_MAX);
+}
+
static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
{
- unsigned tag, type, count, off, value = 0;
- int i, j, k, pos, start;
+ unsigned tag, type, count, off, value = 0, value2 = 0;
+ int i, start;
+ int pos;
int ret;
- uint32_t *pal;
double *dp;
ret = ff_tread_tag(&s->gb, s->le, &tag, &type, &count, &start);
@@ -586,6 +691,10 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
case TIFF_LONG:
value = ff_tget(&s->gb, type, s->le);
break;
+ case TIFF_RATIONAL:
+ value = ff_tget(&s->gb, TIFF_LONG, s->le);
+ value2 = ff_tget(&s->gb, TIFF_LONG, s->le);
+ break;
case TIFF_STRING:
if (count <= 4) {
break;
@@ -675,46 +784,35 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
}
break;
case TIFF_ROWSPERSTRIP:
- if (type == TIFF_LONG && value == UINT_MAX)
+ if (!value || (type == TIFF_LONG && value == UINT_MAX))
value = s->height;
- if (value < 1) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Incorrect value of rows per strip\n");
- return AVERROR_INVALIDDATA;
- }
- s->rps = value;
+ s->rps = FFMIN(value, s->height);
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
- s->strippos = 0;
- s->stripoff = value;
+ s->strippos = 0;
+ s->stripoff = value;
} else
s->strippos = off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
- if (s->strippos > bytestream2_size(&s->gb)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Tag referencing position outside the image\n");
- return AVERROR_INVALIDDATA;
- }
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizesoff = 0;
- s->stripsize = value;
- s->strips = 1;
+ s->stripsize = value;
+ s->strips = 1;
} else {
s->stripsizesoff = off;
}
s->strips = count;
s->sstype = type;
- if (s->stripsizesoff > bytestream2_size(&s->gb)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Tag referencing position outside the image\n");
- return AVERROR_INVALIDDATA;
- }
+ break;
+ case TIFF_XRES:
+ case TIFF_YRES:
+ set_sar(s, tag, value, value2);
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
@@ -726,20 +824,31 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
case TIFF_PREDICTOR:
s->predictor = value;
break;
- case TIFF_INVERT:
+ case TIFF_PHOTOMETRIC:
switch (value) {
- case 0:
- s->invert = 1;
- break;
- case 1:
- s->invert = 0;
- break;
- case 2:
- case 3:
+ case TIFF_PHOTOMETRIC_WHITE_IS_ZERO:
+ case TIFF_PHOTOMETRIC_BLACK_IS_ZERO:
+ case TIFF_PHOTOMETRIC_RGB:
+ case TIFF_PHOTOMETRIC_PALETTE:
+ case TIFF_PHOTOMETRIC_YCBCR:
+ s->photometric = value;
break;
+ case TIFF_PHOTOMETRIC_ALPHA_MASK:
+ case TIFF_PHOTOMETRIC_SEPARATED:
+ case TIFF_PHOTOMETRIC_CIE_LAB:
+ case TIFF_PHOTOMETRIC_ICC_LAB:
+ case TIFF_PHOTOMETRIC_ITU_LAB:
+ case TIFF_PHOTOMETRIC_CFA:
+ case TIFF_PHOTOMETRIC_LOG_L:
+ case TIFF_PHOTOMETRIC_LOG_LUV:
+ case TIFF_PHOTOMETRIC_LINEAR_RAW:
+ avpriv_report_missing_feature(s->avctx,
+ "PhotometricInterpretation 0x%04X",
+ value);
+ return AVERROR_PATCHWELCOME;
default:
- av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
- value);
+ av_log(s->avctx, AV_LOG_ERROR, "PhotometricInterpretation %u is "
+ "unknown\n", value);
return AVERROR_INVALIDDATA;
}
break;
@@ -751,25 +860,39 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
}
s->fill_order = value - 1;
break;
- case TIFF_PAL:
- pal = (uint32_t *) s->palette;
+ case TIFF_PAL: {
+ GetByteContext pal_gb[3];
off = type_sizes[type];
- if (count / 3 > 256 || bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3)
+ if (count / 3 > 256 ||
+ bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3)
return AVERROR_INVALIDDATA;
+
+ pal_gb[0] = pal_gb[1] = pal_gb[2] = s->gb;
+ bytestream2_skip(&pal_gb[1], count / 3 * off);
+ bytestream2_skip(&pal_gb[2], count / 3 * off * 2);
+
off = (type_sizes[type] - 1) << 3;
- for (k = 2; k >= 0; k--) {
- for (i = 0; i < count / 3; i++) {
- if (k == 2)
- pal[i] = 0xFFU << 24;
- j = (ff_tget(&s->gb, type, s->le) >> off) << (k * 8);
- pal[i] |= j;
- }
+ for (i = 0; i < count / 3; i++) {
+ uint32_t p = 0xFF000000;
+ p |= (ff_tget(&pal_gb[0], type, s->le) >> off) << 16;
+ p |= (ff_tget(&pal_gb[1], type, s->le) >> off) << 8;
+ p |= ff_tget(&pal_gb[2], type, s->le) >> off;
+ s->palette[i] = p;
}
s->palette_is_set = 1;
break;
+ }
case TIFF_PLANAR:
s->planar = value == 2;
break;
+ case TIFF_YCBCR_SUBSAMPLING:
+ if (count != 2) {
+ av_log(s->avctx, AV_LOG_ERROR, "subsample count invalid\n");
+ return AVERROR_INVALIDDATA;
+ }
+ for (i = 0; i < count; i++)
+ s->subsampling[i] = ff_tget(&s->gb, type, s->le);
+ break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
@@ -804,7 +927,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
s->geotag_count = 0;
return -1;
}
- s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);
+ s->geotags = av_mallocz_array(s->geotag_count, sizeof(TiffGeoTag));
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
s->geotag_count = 0;
@@ -826,7 +949,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t))
return AVERROR_INVALIDDATA;
- dp = av_malloc(count * sizeof(double));
+ dp = av_malloc_array(count, sizeof(double));
if (!dp) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
goto end;
@@ -946,12 +1069,12 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
return AVERROR_INVALIDDATA;
}
- s->le = le;
+ s->le = le;
// TIFF_BPP is not a required tag and defaults to 1
- s->bppcount = s->bpp = 1;
- s->invert = 0;
- s->compr = TIFF_RAW;
- s->fill_order = 0;
+ s->bppcount = s->bpp = 1;
+ s->photometric = TIFF_PHOTOMETRIC_NONE;
+ s->compr = TIFF_RAW;
+ s->fill_order = 0;
free_geotags(s);
// Reset these offsets so we can tell if they were set this frame
@@ -999,12 +1122,14 @@ static int decode_frame(AVCodecContext *avctx,
if (s->stripsizesoff) {
if (s->stripsizesoff >= (unsigned)avpkt->size)
return AVERROR_INVALIDDATA;
- bytestream2_init(&stripsizes, avpkt->data + s->stripsizesoff, avpkt->size - s->stripsizesoff);
+ bytestream2_init(&stripsizes, avpkt->data + s->stripsizesoff,
+ avpkt->size - s->stripsizesoff);
}
if (s->strippos) {
if (s->strippos >= (unsigned)avpkt->size)
return AVERROR_INVALIDDATA;
- bytestream2_init(&stripdata, avpkt->data + s->strippos, avpkt->size - s->strippos);
+ bytestream2_init(&stripdata, avpkt->data + s->strippos,
+ avpkt->size - s->strippos);
}
if (s->rps <= 0) {
@@ -1018,12 +1143,12 @@ static int decode_frame(AVCodecContext *avctx,
dst = p->data[plane];
for (i = 0; i < s->height; i += s->rps) {
if (s->stripsizesoff)
- ssize = ff_tget(&stripsizes, s->sstype, s->le);
+ ssize = ff_tget(&stripsizes, s->sstype, le);
else
ssize = s->stripsize;
if (s->strippos)
- soff = ff_tget(&stripdata, s->sot, s->le);
+ soff = ff_tget(&stripdata, s->sot, le);
else
soff = s->stripoff;
@@ -1031,7 +1156,7 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
return AVERROR_INVALIDDATA;
}
- if ((ret = tiff_unpack_strip(s, dst, stride, avpkt->data + soff, ssize,
+ if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
FFMIN(s->rps, s->height - i))) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
@@ -1040,6 +1165,10 @@ static int decode_frame(AVCodecContext *avctx,
dst += s->rps * stride;
}
if (s->predictor == 2) {
+ if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
+ av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
+ return AVERROR_PATCHWELCOME;
+ }
dst = p->data[plane];
soff = s->bpp >> 3;
if (s->planar)
@@ -1072,12 +1201,12 @@ static int decode_frame(AVCodecContext *avctx,
}
}
- if (s->invert) {
+ if (s->photometric == TIFF_PHOTOMETRIC_WHITE_IS_ZERO) {
dst = p->data[plane];
for (i = 0; i < s->height; i++) {
for (j = 0; j < p->linesize[plane]; j++)
dst[j] = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255) - dst[j];
- dst += p->linesize[plane];
+ dst += stride;
}
}
}
@@ -1100,6 +1229,8 @@ static av_cold int tiff_init(AVCodecContext *avctx)
s->width = 0;
s->height = 0;
+ s->subsampling[0] =
+ s->subsampling[1] = 1;
s->avctx = avctx;
ff_lzw_decode_open(&s->lzw);
ff_ccitt_unpack_init();
diff --git a/chromium/third_party/ffmpeg/libavcodec/tiff.h b/chromium/third_party/ffmpeg/libavcodec/tiff.h
index ae189b6fdd9..11e9f1629df 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tiff.h
+++ b/chromium/third_party/ffmpeg/libavcodec/tiff.h
@@ -40,7 +40,7 @@ enum TiffTags {
TIFF_HEIGHT,
TIFF_BPP,
TIFF_COMPR,
- TIFF_INVERT = 0x106,
+ TIFF_PHOTOMETRIC = 0x106,
TIFF_FILL_ORDER = 0x10A,
TIFF_DOCUMENT_NAME = 0x10D,
TIFF_IMAGE_DESCRIPTION = 0x10E,
@@ -146,6 +146,24 @@ enum TiffGeoTagKey {
TIFF_VERTICAL_UNITS_GEOKEY = 4099
};
+enum TiffPhotometric {
+ TIFF_PHOTOMETRIC_NONE = -1,
+ TIFF_PHOTOMETRIC_WHITE_IS_ZERO, /* mono or grayscale, 0 is white */
+ TIFF_PHOTOMETRIC_BLACK_IS_ZERO, /* mono or grayscale, 0 is black */
+ TIFF_PHOTOMETRIC_RGB, /* RGB or RGBA*/
+ TIFF_PHOTOMETRIC_PALETTE, /* Uses a palette */
+ TIFF_PHOTOMETRIC_ALPHA_MASK, /* Transparency mask */
+ TIFF_PHOTOMETRIC_SEPARATED, /* CMYK or some other ink set */
+ TIFF_PHOTOMETRIC_YCBCR, /* YCbCr */
+ TIFF_PHOTOMETRIC_CIE_LAB = 8, /* 1976 CIE L*a*b* */
+ TIFF_PHOTOMETRIC_ICC_LAB, /* ICC L*a*b* */
+ TIFF_PHOTOMETRIC_ITU_LAB, /* ITU L*a*b* */
+ TIFF_PHOTOMETRIC_CFA = 32803, /* Color Filter Array (DNG) */
+ TIFF_PHOTOMETRIC_LOG_L = 32844, /* CIE Log2(L) */
+ TIFF_PHOTOMETRIC_LOG_LUV, /* CIE Log L*u*v* */
+ TIFF_PHOTOMETRIC_LINEAR_RAW = 34892, /* Linear Raw (DNG) */
+};
+
enum TiffGeoTagType {
GEOTIFF_SHORT = 0,
GEOTIFF_DOUBLE = 34736,
diff --git a/chromium/third_party/ffmpeg/libavcodec/tiff_common.c b/chromium/third_party/ffmpeg/libavcodec/tiff_common.c
index ce91219150d..35119af558b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tiff_common.c
+++ b/chromium/third_party/ffmpeg/libavcodec/tiff_common.c
@@ -42,15 +42,13 @@ int ff_tis_ifd(unsigned tag)
unsigned ff_tget_short(GetByteContext *gb, int le)
{
- unsigned v = le ? bytestream2_get_le16(gb) : bytestream2_get_be16(gb);
- return v;
+ return le ? bytestream2_get_le16(gb) : bytestream2_get_be16(gb);
}
unsigned ff_tget_long(GetByteContext *gb, int le)
{
- unsigned v = le ? bytestream2_get_le32(gb) : bytestream2_get_be32(gb);
- return v;
+ return le ? bytestream2_get_le32(gb) : bytestream2_get_be32(gb);
}
@@ -64,18 +62,14 @@ double ff_tget_double(GetByteContext *gb, int le)
unsigned ff_tget(GetByteContext *gb, int type, int le)
{
switch (type) {
- case TIFF_BYTE:
- return bytestream2_get_byte(gb);
- case TIFF_SHORT:
- return ff_tget_short(gb, le);
- case TIFF_LONG:
- return ff_tget_long(gb, le);
- default:
- return UINT_MAX;
+ case TIFF_BYTE: return bytestream2_get_byte(gb);
+ case TIFF_SHORT: return ff_tget_short(gb, le);
+ case TIFF_LONG: return ff_tget_long(gb, le);
+ default: return UINT_MAX;
}
}
-static char *auto_sep(int count, char *sep, int i, int columns)
+static const char *auto_sep(int count, const char *sep, int i, int columns)
{
if (sep)
return i ? sep : "";
@@ -165,7 +159,7 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
av_bprint_init(&bp, 10 * count, 100 * count);
for (i = 0; i < count; i++) {
- av_bprintf(&bp, "%s%f", auto_sep(count, sep, i, 4), ff_tget_double(gb, le));
+ av_bprintf(&bp, "%s%.15g", auto_sep(count, sep, i, 4), ff_tget_double(gb, le));
}
if ((i = av_bprint_finalize(&bp, &ap))) {
@@ -182,7 +176,7 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata)
+ GetByteContext *gb, int le, int is_signed, AVDictionary **metadata)
{
AVBPrint bp;
char *ap;
@@ -196,7 +190,8 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < count; i++) {
- av_bprintf(&bp, "%s%5i", auto_sep(count, sep, i, 8), ff_tget_short(gb, le));
+ int v = is_signed ? (int16_t)ff_tget_short(gb, le) : ff_tget_short(gb, le);
+ av_bprintf(&bp, "%s%5i", auto_sep(count, sep, i, 8), v);
}
if ((i = av_bprint_finalize(&bp, &ap))) {
@@ -213,7 +208,7 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata)
+ GetByteContext *gb, int le, int is_signed, AVDictionary **metadata)
{
AVBPrint bp;
char *ap;
@@ -227,7 +222,8 @@ int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < count; i++) {
- av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), bytestream2_get_byte(gb));
+ int v = is_signed ? (int8_t)bytestream2_get_byte(gb) : bytestream2_get_byte(gb);
+ av_bprintf(&bp, "%s%3i", auto_sep(count, sep, i, 16), v);
}
if ((i = av_bprint_finalize(&bp, &ap))) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/tiff_common.h b/chromium/third_party/ffmpeg/libavcodec/tiff_common.h
index 01a7b0891b7..16c9e50850d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tiff_common.h
+++ b/chromium/third_party/ffmpeg/libavcodec/tiff_common.h
@@ -121,13 +121,13 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
* into the metadata dictionary.
*/
int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata);
+ GetByteContext *gb, int le, int is_signed, AVDictionary **metadata);
/** Adds count bytes converted to a string
* into the metadata dictionary.
*/
int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
- GetByteContext *gb, int le, AVDictionary **metadata);
+ GetByteContext *gb, int le, int is_signed, AVDictionary **metadata);
/** Adds a string of count characters
* into the metadata dictionary.
diff --git a/chromium/third_party/ffmpeg/libavcodec/tiffenc.c b/chromium/third_party/ffmpeg/libavcodec/tiffenc.c
index 7b1e5104bda..456b3bf54ac 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tiffenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/tiffenc.c
@@ -58,7 +58,7 @@ typedef struct TiffEncoderContext {
unsigned int bpp; ///< bits per pixel
int compr; ///< compression level
int bpp_tab_size; ///< bpp_tab size
- int photometric_interpretation; ///< photometric interpretation
+ enum TiffPhotometric photometric_interpretation; ///< photometric interpretation
int strips; ///< number of strips
uint32_t *strip_sizes;
unsigned int strip_sizes_size;
@@ -254,7 +254,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
alpha = 1;
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_RGB24:
- s->photometric_interpretation = 2;
+ s->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;
break;
case AV_PIX_FMT_GRAY8:
avctx->bits_per_coded_sample = 0x28;
@@ -262,13 +262,13 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
alpha = avctx->pix_fmt == AV_PIX_FMT_GRAY8A;
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_MONOBLACK:
- s->photometric_interpretation = 1;
+ s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
break;
case AV_PIX_FMT_PAL8:
- s->photometric_interpretation = 3;
+ s->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;
break;
case AV_PIX_FMT_MONOWHITE:
- s->photometric_interpretation = 0;
+ s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
@@ -277,7 +277,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &shift_h, &shift_v);
- s->photometric_interpretation = 6;
+ s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;
s->subsampling[0] = 1 << shift_h;
s->subsampling[1] = 1 << shift_v;
is_yuv = 1;
@@ -426,9 +426,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (s->bpp_tab_size)
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
- add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
- add_entry1(s, TIFF_INVERT, TIFF_SHORT, s->photometric_interpretation);
- add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, s->strip_offsets);
+ add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
+ add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);
+ add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, s->strip_offsets);
if (s->bpp_tab_size)
add_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);
@@ -436,6 +436,13 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);
add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, s->strip_sizes);
add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);
+ if (avctx->sample_aspect_ratio.num > 0 &&
+ avctx->sample_aspect_ratio.den > 0) {
+ AVRational y = av_mul_q(av_make_q(s->dpi, 1),
+ avctx->sample_aspect_ratio);
+ res[0] = y.num;
+ res[1] = y.den;
+ }
add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);
add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);
diff --git a/chromium/third_party/ffmpeg/libavcodec/tpel_template.c b/chromium/third_party/ffmpeg/libavcodec/tpel_template.c
new file mode 100644
index 00000000000..6e2502507b2
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/tpel_template.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "libavutil/intreadwrite.h"
+#include "pixels.h"
+#include "rnd_avg.h"
+
+#include "bit_depth_template.c"
+
+#define DEF_TPEL(OPNAME, OP) \
+static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ OP(*((pixel2 *) block), AV_RN2P(pixels)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+} \
+ \
+static inline void FUNCC(OPNAME ## _pixels4)(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ OP(*((pixel4 *) block), AV_RN4P(pixels)); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+} \
+ \
+static inline void FUNCC(OPNAME ## _pixels8)(uint8_t *block, \
+ const uint8_t *pixels, \
+ ptrdiff_t line_size, \
+ int h) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++) { \
+ OP(*((pixel4 *) block), AV_RN4P(pixels)); \
+ OP(*((pixel4 *) (block + 4 * sizeof(pixel))), \
+ AV_RN4P(pixels + 4 * sizeof(pixel))); \
+ pixels += line_size; \
+ block += line_size; \
+ } \
+} \
+ \
+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16), \
+ FUNCC(OPNAME ## _pixels8), \
+ 8 * sizeof(pixel))
+
+#define op_avg(a, b) a = rnd_avg_pixel4(a, b)
+#define op_put(a, b) a = b
+
+DEF_TPEL(avg, op_avg)
+DEF_TPEL(put, op_put)
+#undef op_avg
+#undef op_put
diff --git a/chromium/third_party/ffmpeg/libavcodec/tpeldsp.c b/chromium/third_party/ffmpeg/libavcodec/tpeldsp.c
new file mode 100644
index 00000000000..b5af72cac06
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/tpeldsp.c
@@ -0,0 +1,333 @@
+/*
+ * thirdpel DSP functions
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * thirdpel DSP functions
+ */
+
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "tpeldsp.h"
+
+#define BIT_DEPTH 8
+#include "tpel_template.c"
+
+static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ switch (width) {
+ case 2:
+ put_pixels2_8_c(dst, src, stride, height);
+ break;
+ case 4:
+ put_pixels4_8_c(dst, src, stride, height);
+ break;
+ case 8:
+ put_pixels8_8_c(dst, src, stride, height);
+ break;
+ case 16:
+ put_pixels16_8_c(dst, src, stride, height);
+ break;
+ }
+}
+
+static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((2 * src[j] + src[j + 1] + 1) *
+ 683) >> 11;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
+ 683) >> 11;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((2 * src[j] + src[j + stride] + 1) *
+ 683) >> 11;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((4 * src[j] + 3 * src[j + 1] +
+ 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
+ 2731) >> 15;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((3 * src[j] + 2 * src[j + 1] +
+ 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+ 2731) >> 15;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
+ 683) >> 11;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((3 * src[j] + 4 * src[j + 1] +
+ 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+ 2731) >> 15;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = ((2 * src[j] + 3 * src[j + 1] +
+ 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
+ 2731) >> 15;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ switch (width) {
+ case 2:
+ avg_pixels2_8_c(dst, src, stride, height);
+ break;
+ case 4:
+ avg_pixels4_8_c(dst, src, stride, height);
+ break;
+ case 8:
+ avg_pixels8_8_c(dst, src, stride, height);
+ break;
+ case 16:
+ avg_pixels16_8_c(dst, src, stride, height);
+ break;
+ }
+}
+
+static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((2 * src[j] + src[j + 1] + 1) *
+ 683) >> 11) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((src[j] + 2 * src[j + 1] + 1) *
+ 683) >> 11) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((2 * src[j] + src[j + stride] + 1) *
+ 683) >> 11) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((4 * src[j] + 3 * src[j + 1] +
+ 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
+ 2731) >> 15) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((3 * src[j] + 2 * src[j + 1] +
+ 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+ 2731) >> 15) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((src[j] + 2 * src[j + stride] + 1) *
+ 683) >> 11) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((3 * src[j] + 4 * src[j + 1] +
+ 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+ 2731) >> 15) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
+ int stride, int width, int height)
+{
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ dst[j] = (dst[j] +
+ (((2 * src[j] + 3 * src[j + 1] +
+ 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
+ 2731) >> 15) + 1) >> 1;
+ src += stride;
+ dst += stride;
+ }
+}
+
+av_cold void ff_tpeldsp_init(TpelDSPContext *c)
+{
+ c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
+ c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
+ c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
+ c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
+ c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
+ c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
+ c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
+ c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
+ c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
+
+ c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
+ c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
+ c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
+ c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
+ c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
+ c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
+ c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
+ c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
+ c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/tpeldsp.h b/chromium/third_party/ffmpeg/libavcodec/tpeldsp.h
new file mode 100644
index 00000000000..3732f179f46
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/tpeldsp.h
@@ -0,0 +1,59 @@
+/*
+ * thirdpel DSP functions
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * thirdpel DSP functions
+ */
+
+#ifndef AVCODEC_TPELDSP_H
+#define AVCODEC_TPELDSP_H
+
+#include <stdint.h>
+
+/* add and put pixel (decoding) */
+// blocksizes for hpel_pixels_func are 8x4,8x8 16x8 16x16
+// h for hpel_pixels_func is limited to {width/2, width} but never larger
+// than 16 and never smaller than 4
+typedef void (*tpel_mc_func)(uint8_t *block /* align width (8 or 16) */,
+ const uint8_t *pixels /* align 1 */,
+ int line_size, int w, int h);
+
+/**
+ * thirdpel DSP context
+ */
+typedef struct TpelDSPContext {
+ /**
+ * Thirdpel motion compensation with rounding (a + b + 1) >> 1.
+ * this is an array[12] of motion compensation functions for the
+ * 9 thirdpel positions<br>
+ * *pixels_tab[xthirdpel + 4 * ythirdpel]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
+ tpel_mc_func put_tpel_pixels_tab[11]; // FIXME individual func ptr per width?
+ tpel_mc_func avg_tpel_pixels_tab[11]; // FIXME individual func ptr per width?
+} TpelDSPContext;
+
+void ff_tpeldsp_init(TpelDSPContext *c);
+
+#endif /* AVCODEC_TPELDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/truemotion1.c b/chromium/third_party/ffmpeg/libavcodec/truemotion1.c
index 6528a1f3912..ed799592407 100644
--- a/chromium/third_party/ffmpeg/libavcodec/truemotion1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/truemotion1.c
@@ -317,12 +317,17 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
const uint8_t *sel_vector_table;
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
- if (s->buf[0] < 0x10 || header.header_size >= s->size)
+ if (s->buf[0] < 0x10)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]);
return AVERROR_INVALIDDATA;
}
+ if (header.header_size + 1 > s->size) {
+ av_log(s->avctx, AV_LOG_ERROR, "Input packet too small.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* unscramble the header bytes with a XOR operation */
for (i = 1; i < header.header_size; i++)
header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1];
diff --git a/chromium/third_party/ffmpeg/libavcodec/truemotion2.c b/chromium/third_party/ffmpeg/libavcodec/truemotion2.c
index a1683f5b1ad..c3c2701ee54 100644
--- a/chromium/third_party/ffmpeg/libavcodec/truemotion2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/truemotion2.c
@@ -24,6 +24,8 @@
* Duck TrueMotion2 decoder.
*/
+#include <inttypes.h>
+
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
@@ -246,7 +248,8 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
case TM2_NEW_HEADER_MAGIC:
return 0;
default:
- av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic);
+ av_log(ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08"PRIX32"\n",
+ magic);
return AVERROR_INVALIDDATA;
}
}
@@ -259,7 +262,8 @@ static int tm2_read_deltas(TM2Context *ctx, int stream_id)
d = get_bits(&ctx->gb, 9);
mb = get_bits(&ctx->gb, 5);
- if ((d < 1) || (d > TM2_DELTAS) || (mb < 1) || (mb > 32)) {
+ av_assert2(mb < 32);
+ if ((d < 1) || (d > TM2_DELTAS) || (mb < 1)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb);
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/tscc2.c b/chromium/third_party/ffmpeg/libavcodec/tscc2.c
index bdc75256b3b..487af5462ca 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tscc2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/tscc2.c
@@ -24,6 +24,8 @@
* TechSmith Screen Codec 2 decoder
*/
+#include <inttypes.h>
+
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
@@ -227,7 +229,8 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
bytestream2_init(&gb, buf, buf_size);
frame_type = bytestream2_get_byte(&gb);
if (frame_type > 1) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect frame type %d\n", frame_type);
+ av_log(avctx, AV_LOG_ERROR, "Incorrect frame type %"PRIu32"\n",
+ frame_type);
return AVERROR_INVALIDDATA;
}
@@ -309,7 +312,7 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
}
}
if (bytestream2_get_bytes_left(&gb) < size) {
- av_log(avctx, AV_LOG_ERROR, "Invalid slice size (%d/%d)\n",
+ av_log(avctx, AV_LOG_ERROR, "Invalid slice size (%"PRIu32"/%u)\n",
size, bytestream2_get_bytes_left(&gb));
return AVERROR_INVALIDDATA;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/tta.c b/chromium/third_party/ffmpeg/libavcodec/tta.c
index b917881d652..87bfe7b8118 100644
--- a/chromium/third_party/ffmpeg/libavcodec/tta.c
+++ b/chromium/third_party/ffmpeg/libavcodec/tta.c
@@ -30,6 +30,7 @@
#define BITSTREAM_READER_LE
#include <limits.h>
#include "ttadata.h"
+#include "ttadsp.h"
#include "avcodec.h"
#include "get_bits.h"
#include "thread.h"
@@ -56,39 +57,9 @@ typedef struct TTAContext {
uint8_t crc_pass[8];
uint8_t *pass;
TTAChannel *ch_ctx;
+ TTADSPContext dsp;
} TTAContext;
-static inline void ttafilter_process(TTAFilter *c, int32_t *in)
-{
- register int32_t *dl = c->dl, *qm = c->qm, *dx = c->dx, sum = c->round;
-
- if (c->error < 0) {
- qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
- qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7];
- } else if (c->error > 0) {
- qm[0] += dx[0]; qm[1] += dx[1]; qm[2] += dx[2]; qm[3] += dx[3];
- qm[4] += dx[4]; qm[5] += dx[5]; qm[6] += dx[6]; qm[7] += dx[7];
- }
-
- sum += dl[0] * qm[0] + dl[1] * qm[1] + dl[2] * qm[2] + dl[3] * qm[3] +
- dl[4] * qm[4] + dl[5] * qm[5] + dl[6] * qm[6] + dl[7] * qm[7];
-
- dx[0] = dx[1]; dx[1] = dx[2]; dx[2] = dx[3]; dx[3] = dx[4];
- dl[0] = dl[1]; dl[1] = dl[2]; dl[2] = dl[3]; dl[3] = dl[4];
-
- dx[4] = ((dl[4] >> 30) | 1);
- dx[5] = ((dl[5] >> 30) | 2) & ~1;
- dx[6] = ((dl[6] >> 30) | 2) & ~1;
- dx[7] = ((dl[7] >> 30) | 4) & ~3;
-
- c->error = *in;
- *in += (sum >> c->shift);
-
- dl[4] = -dl[5]; dl[5] = -dl[6];
- dl[6] = *in - dl[7]; dl[7] = *in;
- dl[5] += dl[6]; dl[4] += dl[5];
-}
-
static const int64_t tta_channel_layouts[7] = {
AV_CH_LAYOUT_STEREO,
AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY,
@@ -133,12 +104,12 @@ static int allocate_buffers(AVCodecContext *avctx)
TTAContext *s = avctx->priv_data;
if (s->bps < 3) {
- s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels);
+ s->decode_buffer = av_mallocz_array(sizeof(int32_t)*s->frame_length, s->channels);
if (!s->decode_buffer)
return AVERROR(ENOMEM);
} else
s->decode_buffer = NULL;
- s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx));
+ s->ch_ctx = av_malloc_array(avctx->channels, sizeof(*s->ch_ctx));
if (!s->ch_ctx) {
av_freep(&s->decode_buffer);
return AVERROR(ENOMEM);
@@ -234,6 +205,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
return AVERROR_INVALIDDATA;
}
+ ff_ttadsp_init(&s->dsp);
+
return allocate_buffers(avctx);
}
@@ -335,7 +308,8 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
*p = 1 + ((value >> 1) ^ ((value & 1) - 1));
// run hybrid filter
- ttafilter_process(filter, p);
+ s->dsp.ttafilter_process_dec(filter->qm, filter->dx, filter->dl, &filter->error, p,
+ filter->shift, filter->round);
// fixed order prediction
#define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k)
diff --git a/chromium/third_party/ffmpeg/libavcodec/ttadsp.c b/chromium/third_party/ffmpeg/libavcodec/ttadsp.c
new file mode 100644
index 00000000000..30b7ab9eb7b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/ttadsp.c
@@ -0,0 +1,57 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "ttadsp.h"
+
+static void ttafilter_process_dec_c(int32_t *qm, int32_t *dx, int32_t *dl,
+ int32_t *error, int32_t *in, int32_t shift,
+ int32_t round) {
+ if (*error < 0) {
+ qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
+ qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7];
+ } else if (*error > 0) {
+ qm[0] += dx[0]; qm[1] += dx[1]; qm[2] += dx[2]; qm[3] += dx[3];
+ qm[4] += dx[4]; qm[5] += dx[5]; qm[6] += dx[6]; qm[7] += dx[7];
+ }
+
+ round += dl[0] * qm[0] + dl[1] * qm[1] + dl[2] * qm[2] + dl[3] * qm[3] +
+ dl[4] * qm[4] + dl[5] * qm[5] + dl[6] * qm[6] + dl[7] * qm[7];
+
+ dx[0] = dx[1]; dx[1] = dx[2]; dx[2] = dx[3]; dx[3] = dx[4];
+ dl[0] = dl[1]; dl[1] = dl[2]; dl[2] = dl[3]; dl[3] = dl[4];
+
+ dx[4] = ((dl[4] >> 30) | 1);
+ dx[5] = ((dl[5] >> 30) | 2) & ~1;
+ dx[6] = ((dl[6] >> 30) | 2) & ~1;
+ dx[7] = ((dl[7] >> 30) | 4) & ~3;
+
+ *error = *in;
+ *in += (round >> shift);
+
+ dl[4] = -dl[5]; dl[5] = -dl[6];
+ dl[6] = *in - dl[7]; dl[7] = *in;
+ dl[5] += dl[6]; dl[4] += dl[5];
+}
+
+av_cold void ff_ttadsp_init(TTADSPContext *c)
+{
+ c->ttafilter_process_dec = ttafilter_process_dec_c;
+
+ if (ARCH_X86)
+ ff_ttadsp_init_x86(c);
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/ttadsp.h b/chromium/third_party/ffmpeg/libavcodec/ttadsp.h
new file mode 100644
index 00000000000..56930f1c855
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/ttadsp.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_TTADSP_H
+#define AVCODEC_TTADSP_H
+
+#include <stdint.h>
+#include "ttadata.h"
+
+typedef struct TTADSPContext {
+ void (*ttafilter_process_dec)(int32_t *qm, int32_t *dx, int32_t *dl,
+ int32_t *error, int32_t *in, int32_t shift,
+ int32_t round);
+} TTADSPContext;
+
+void ff_ttadsp_init(TTADSPContext *c);
+void ff_ttadsp_init_x86(TTADSPContext *c);
+
+#endif /* AVCODEC_TTADSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/ttaenc.c b/chromium/third_party/ffmpeg/libavcodec/ttaenc.c
index e95dd6b22f1..75d16642ea8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/ttaenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/ttaenc.c
@@ -53,7 +53,7 @@ static av_cold int tta_encode_init(AVCodecContext *avctx)
s->bps = avctx->bits_per_raw_sample >> 3;
avctx->frame_size = 256 * avctx->sample_rate / 245;
- s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx));
+ s->ch_ctx = av_malloc_array(avctx->channels, sizeof(*s->ch_ctx));
if (!s->ch_ctx)
return AVERROR(ENOMEM);
diff --git a/chromium/third_party/ffmpeg/libavcodec/utils.c b/chromium/third_party/ffmpeg/libavcodec/utils.c
index a79d9b39fba..b1ba1f46829 100644
--- a/chromium/third_party/ffmpeg/libavcodec/utils.c
+++ b/chromium/third_party/ffmpeg/libavcodec/utils.c
@@ -46,6 +46,7 @@
#include "thread.h"
#include "frame_thread_encoder.h"
#include "internal.h"
+#include "raw.h"
#include "bytestream.h"
#include "version.h"
#include <stdlib.h>
@@ -117,18 +118,23 @@ static int volatile entangled_thread_counter = 0;
static void *codec_mutex;
static void *avformat_mutex;
-// TODO(dalecurtis): Reenable once AVCODEC 55 is standard.
-// #if FF_API_FAST_MALLOC && CONFIG_SHARED && HAVE_SYMVER
-// FF_SYMVER(void*, av_fast_realloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55")
-// {
-// return av_fast_realloc(ptr, size, min_size);
-// }
+#if CONFIG_RAISE_MAJOR
+# define LIBNAME "LIBAVCODEC_155"
+#else
+# define LIBNAME "LIBAVCODEC_55"
+#endif
+
+#if FF_API_FAST_MALLOC && CONFIG_SHARED && HAVE_SYMVER
+FF_SYMVER(void*, av_fast_realloc, (void *ptr, unsigned int *size, size_t min_size), LIBNAME)
+{
+ return av_fast_realloc(ptr, size, min_size);
+}
-// FF_SYMVER(void, av_fast_malloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55")
-// {
-// av_fast_malloc(ptr, size, min_size);
-// }
-// #endif
+FF_SYMVER(void, av_fast_malloc, (void *ptr, unsigned int *size, size_t min_size), LIBNAME)
+{
+ av_fast_malloc(ptr, size, min_size);
+}
+#endif
static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
{
@@ -170,6 +176,7 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
/* encoder management */
static AVCodec *first_avcodec = NULL;
+static AVCodec **last_avcodec = &first_avcodec;
AVCodec *av_codec_next(const AVCodec *c)
{
@@ -205,25 +212,31 @@ av_cold void avcodec_register(AVCodec *codec)
{
AVCodec **p;
avcodec_init();
- p = &first_avcodec;
+ p = last_avcodec;
codec->next = NULL;
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
p = &(*p)->next;
+ last_avcodec = &codec->next;
if (codec->init_static_data)
codec->init_static_data(codec);
}
+#if FF_API_EMU_EDGE
unsigned avcodec_get_edge_width(void)
{
return EDGE_WIDTH;
}
+#endif
#if FF_API_SET_DIMENSIONS
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
{
- ff_set_dimensions(s, width, height);
+ int ret = ff_set_dimensions(s, width, height);
+ if (ret < 0) {
+ av_log(s, AV_LOG_WARNING, "Failed to set dimensions %d %d\n", width, height);
+ }
}
#endif
@@ -242,11 +255,25 @@ int ff_set_dimensions(AVCodecContext *s, int width, int height)
return ret;
}
-#if HAVE_NEON || ARCH_PPC || HAVE_MMX
-# define STRIDE_ALIGN 16
-#else
-# define STRIDE_ALIGN 8
-#endif
+int ff_side_data_update_matrix_encoding(AVFrame *frame,
+ enum AVMatrixEncoding matrix_encoding)
+{
+ AVFrameSideData *side_data;
+ enum AVMatrixEncoding *data;
+
+ side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_MATRIXENCODING);
+ if (!side_data)
+ side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_MATRIXENCODING,
+ sizeof(enum AVMatrixEncoding));
+
+ if (!side_data)
+ return AVERROR(ENOMEM);
+
+ data = (enum AVMatrixEncoding*)side_data->data;
+ *data = matrix_encoding;
+
+ return 0;
+}
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS])
@@ -258,6 +285,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
switch (s->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUYV422:
+ case AV_PIX_FMT_YVYU422:
case AV_PIX_FMT_UYVY422:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV440P:
@@ -284,6 +312,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
case AV_PIX_FMT_YUV420P14BE:
case AV_PIX_FMT_YUV420P16LE:
case AV_PIX_FMT_YUV420P16BE:
+ case AV_PIX_FMT_YUVA420P9LE:
+ case AV_PIX_FMT_YUVA420P9BE:
+ case AV_PIX_FMT_YUVA420P10LE:
+ case AV_PIX_FMT_YUVA420P10BE:
+ case AV_PIX_FMT_YUVA420P16LE:
+ case AV_PIX_FMT_YUVA420P16BE:
case AV_PIX_FMT_YUV422P9LE:
case AV_PIX_FMT_YUV422P9BE:
case AV_PIX_FMT_YUV422P10LE:
@@ -294,6 +328,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
case AV_PIX_FMT_YUV422P14BE:
case AV_PIX_FMT_YUV422P16LE:
case AV_PIX_FMT_YUV422P16BE:
+ case AV_PIX_FMT_YUVA422P9LE:
+ case AV_PIX_FMT_YUVA422P9BE:
+ case AV_PIX_FMT_YUVA422P10LE:
+ case AV_PIX_FMT_YUVA422P10BE:
+ case AV_PIX_FMT_YUVA422P16LE:
+ case AV_PIX_FMT_YUVA422P16BE:
case AV_PIX_FMT_YUV444P9LE:
case AV_PIX_FMT_YUV444P9BE:
case AV_PIX_FMT_YUV444P10LE:
@@ -304,18 +344,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
case AV_PIX_FMT_YUV444P14BE:
case AV_PIX_FMT_YUV444P16LE:
case AV_PIX_FMT_YUV444P16BE:
- case AV_PIX_FMT_YUVA420P9LE:
- case AV_PIX_FMT_YUVA420P9BE:
- case AV_PIX_FMT_YUVA420P10LE:
- case AV_PIX_FMT_YUVA420P10BE:
- case AV_PIX_FMT_YUVA420P16LE:
- case AV_PIX_FMT_YUVA420P16BE:
- case AV_PIX_FMT_YUVA422P9LE:
- case AV_PIX_FMT_YUVA422P9BE:
- case AV_PIX_FMT_YUVA422P10LE:
- case AV_PIX_FMT_YUVA422P10BE:
- case AV_PIX_FMT_YUVA422P16LE:
- case AV_PIX_FMT_YUVA422P16BE:
case AV_PIX_FMT_YUVA444P9LE:
case AV_PIX_FMT_YUVA444P9BE:
case AV_PIX_FMT_YUVA444P10LE:
@@ -446,7 +474,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
planar = av_sample_fmt_is_planar(sample_fmt);
if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
- if (!(frame->extended_data = av_mallocz(nb_channels *
+ if (!(frame->extended_data = av_mallocz_array(nb_channels,
sizeof(*frame->extended_data))))
return AVERROR(ENOMEM);
} else {
@@ -581,9 +609,9 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
frame->linesize[0] = pool->linesize[0];
if (planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz(planes * sizeof(*frame->extended_data));
+ frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data));
frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
- frame->extended_buf = av_mallocz(frame->nb_extended_buf *
+ frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
sizeof(*frame->extended_buf));
if (!frame->extended_data || !frame->extended_buf) {
av_freep(&frame->extended_data);
@@ -719,11 +747,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
{
- if (avctx->internal->pkt) {
- frame->pkt_pts = avctx->internal->pkt->pts;
- av_frame_set_pkt_pos (frame, avctx->internal->pkt->pos);
- av_frame_set_pkt_duration(frame, avctx->internal->pkt->duration);
- av_frame_set_pkt_size (frame, avctx->internal->pkt->size);
+ AVPacket *pkt = avctx->internal->pkt;
+
+ if (pkt) {
+ uint8_t *packet_sd;
+ AVFrameSideData *frame_sd;
+ int size;
+ frame->pkt_pts = pkt->pts;
+ av_frame_set_pkt_pos (frame, pkt->pos);
+ av_frame_set_pkt_duration(frame, pkt->duration);
+ av_frame_set_pkt_size (frame, pkt->size);
+
+ /* copy the replaygain data to the output frame */
+ packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_REPLAYGAIN, &size);
+ if (packet_sd) {
+ frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_REPLAYGAIN, size);
+ if (!frame_sd)
+ return AVERROR(ENOMEM);
+
+ memcpy(frame_sd->data, packet_sd, size);
+ }
} else {
frame->pkt_pts = AV_NOPTS_VALUE;
av_frame_set_pkt_pos (frame, -1);
@@ -734,10 +777,7 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
switch (avctx->codec->type) {
case AVMEDIA_TYPE_VIDEO:
- frame->width = FFMAX(avctx->width, FF_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
- frame->height = FFMAX(avctx->height, FF_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
- if (frame->format < 0)
- frame->format = avctx->pix_fmt;
+ frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
@@ -784,6 +824,7 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
typedef struct CompatReleaseBufPriv {
AVCodecContext avctx;
AVFrame frame;
+ uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
} CompatReleaseBufPriv;
static void compat_free_buffer(void *opaque, uint8_t *data)
@@ -802,8 +843,15 @@ static void compat_release_buffer(void *opaque, uint8_t *data)
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
+{
+ return ff_init_buffer_info(avctx, frame);
+}
+
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
+ const AVHWAccel *hwaccel = avctx->hwaccel;
+ int override_dimensions = 1;
int ret;
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -812,9 +860,24 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
return AVERROR(EINVAL);
}
}
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (frame->width <= 0 || frame->height <= 0) {
+ frame->width = FFMAX(avctx->width, FF_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
+ frame->height = FFMAX(avctx->height, FF_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
+ override_dimensions = 0;
+ }
+ }
+ ret = ff_decode_frame_props(avctx, frame);
+ if (ret < 0)
+ return ret;
if ((ret = ff_init_buffer_info(avctx, frame)) < 0)
return ret;
+ if (hwaccel && hwaccel->alloc_frame) {
+ ret = hwaccel->alloc_frame(avctx, frame);
+ goto end;
+ }
+
#if FF_API_GET_BUFFER
FF_DISABLE_DEPRECATION_WARNINGS
/*
@@ -841,7 +904,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
* avcodec_default_get_buffer
*/
if (frame->buf[0])
- goto end;
+ goto end0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
@@ -898,7 +961,7 @@ do { \
if (planes > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
- frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) *
+ frame->extended_buf = av_malloc_array(sizeof(*frame->extended_buf),
frame->nb_extended_buf);
if (!frame->extended_buf) {
ret = AVERROR(ENOMEM);
@@ -917,7 +980,7 @@ do { \
av_buffer_unref(&dummy_buf);
-end:
+end0:
frame->width = avctx->width;
frame->height = avctx->height;
@@ -934,7 +997,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
ret = avctx->get_buffer2(avctx, frame, flags);
- if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+end:
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) {
frame->width = avctx->width;
frame->height = avctx->height;
}
@@ -952,7 +1016,7 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame)
{
- AVFrame tmp;
+ AVFrame *tmp;
int ret;
av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
@@ -969,20 +1033,22 @@ static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame)
return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (av_frame_is_writable(frame))
- return 0;
+ return ff_decode_frame_props(avctx, frame);
+
+ tmp = av_frame_alloc();
+ if (!tmp)
+ return AVERROR(ENOMEM);
- av_frame_move_ref(&tmp, frame);
+ av_frame_move_ref(tmp, frame);
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0) {
- av_frame_unref(&tmp);
+ av_frame_free(&tmp);
return ret;
}
- av_image_copy(frame->data, frame->linesize, tmp.data, tmp.linesize,
- frame->format, frame->width, frame->height);
-
- av_frame_unref(&tmp);
+ av_frame_copy(frame, tmp);
+ av_frame_free(&tmp);
return 0;
}
@@ -1034,6 +1100,17 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
return 0;
}
+enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
+ unsigned int fourcc)
+{
+ while (tags->pix_fmt >= 0) {
+ if (tags->fourcc == fourcc)
+ return tags->pix_fmt;
+ tags++;
+ }
+ return AV_PIX_FMT_NONE;
+}
+
static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
@@ -1047,6 +1124,65 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en
return fmt[0];
}
+static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
+ enum AVPixelFormat pix_fmt)
+{
+ AVHWAccel *hwaccel = NULL;
+
+ while ((hwaccel = av_hwaccel_next(hwaccel)))
+ if (hwaccel->id == codec_id
+ && hwaccel->pix_fmt == pix_fmt)
+ return hwaccel;
+ return NULL;
+}
+
+
+int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
+{
+ const AVPixFmtDescriptor *desc;
+ enum AVPixelFormat ret = avctx->get_format(avctx, fmt);
+
+ desc = av_pix_fmt_desc_get(ret);
+ if (!desc)
+ return AV_PIX_FMT_NONE;
+
+ if (avctx->hwaccel && avctx->hwaccel->uninit)
+ avctx->hwaccel->uninit(avctx);
+ av_freep(&avctx->internal->hwaccel_priv_data);
+ avctx->hwaccel = NULL;
+
+ if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+ AVHWAccel *hwaccel;
+ int err;
+
+ hwaccel = find_hwaccel(avctx->codec_id, ret);
+ if (!hwaccel) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Could not find an AVHWAccel for the pixel format: %s",
+ desc->name);
+ return AV_PIX_FMT_NONE;
+ }
+
+ if (hwaccel->priv_data_size) {
+ avctx->internal->hwaccel_priv_data = av_mallocz(hwaccel->priv_data_size);
+ if (!avctx->internal->hwaccel_priv_data)
+ return AV_PIX_FMT_NONE;
+ }
+
+ if (hwaccel->init) {
+ err = hwaccel->init(avctx);
+ if (err < 0) {
+ av_freep(&avctx->internal->hwaccel_priv_data);
+ return AV_PIX_FMT_NONE;
+ }
+ }
+ avctx->hwaccel = hwaccel;
+ }
+
+ return ret;
+}
+
+#if FF_API_AVFRAME_LAVC
void avcodec_get_frame_defaults(AVFrame *frame)
{
#if LIBAVCODEC_VERSION_MAJOR >= 55
@@ -1057,55 +1193,25 @@ void avcodec_get_frame_defaults(AVFrame *frame)
#endif
memset(frame, 0, sizeof(AVFrame));
-
- frame->pts =
- frame->pkt_dts =
- frame->pkt_pts = AV_NOPTS_VALUE;
- av_frame_set_best_effort_timestamp(frame, AV_NOPTS_VALUE);
- av_frame_set_pkt_duration (frame, 0);
- av_frame_set_pkt_pos (frame, -1);
- av_frame_set_pkt_size (frame, -1);
- frame->key_frame = 1;
- frame->sample_aspect_ratio = (AVRational) {0, 1 };
- frame->format = -1; /* unknown */
- frame->extended_data = frame->data;
- av_frame_set_colorspace(frame, AVCOL_SPC_UNSPECIFIED);
+ av_frame_unref(frame);
}
-#if FF_API_AVFRAME_LAVC
AVFrame *avcodec_alloc_frame(void)
{
- AVFrame *frame = av_malloc(sizeof(AVFrame));
-
- if (frame == NULL)
- return NULL;
-
- frame->extended_data = NULL;
- avcodec_get_frame_defaults(frame);
-
- return frame;
+ return av_frame_alloc();
}
-#endif
void avcodec_free_frame(AVFrame **frame)
{
- AVFrame *f;
-
- if (!frame || !*frame)
- return;
-
- f = *frame;
-
- if (f->extended_data != f->data)
- av_freep(&f->extended_data);
-
- av_freep(frame);
+ av_frame_free(frame);
}
+#endif
MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
MAKE_ACCESSORS(AVCodecContext, codec, int, lowres)
MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
+MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
int av_codec_get_max_lowres(const AVCodec *codec)
{
@@ -1524,7 +1630,11 @@ int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size);
avpkt->data = avctx->internal->byte_buffer;
avpkt->size = avctx->internal->byte_buffer_size;
+#if FF_API_DESTRUCT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = NULL;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
}
@@ -1608,7 +1718,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
const AVFrame *frame,
int *got_packet_ptr)
{
- AVFrame tmp;
+ AVFrame *extended_frame = NULL;
AVFrame *padded_frame = NULL;
int ret;
AVPacket user_pkt = *avpkt;
@@ -1633,9 +1743,13 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
}
av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
- tmp = *frame;
- tmp.extended_data = tmp.data;
- frame = &tmp;
+ extended_frame = av_frame_alloc();
+ if (!extended_frame)
+ return AVERROR(ENOMEM);
+
+ memcpy(extended_frame, frame, sizeof(AVFrame));
+ extended_frame->extended_data = extended_frame->data;
+ frame = extended_frame;
}
/* check for valid frame size */
@@ -1643,14 +1757,15 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
if (frame->nb_samples > avctx->frame_size) {
av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
- return AVERROR(EINVAL);
+ ret = AVERROR(EINVAL);
+ goto end;
}
} else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
if (frame->nb_samples < avctx->frame_size &&
!avctx->internal->last_audio_frame) {
ret = pad_last_frame(avctx, &padded_frame, frame);
if (ret < 0)
- return ret;
+ goto end;
frame = padded_frame;
avctx->internal->last_audio_frame = 1;
@@ -1691,7 +1806,11 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
+#if FF_API_DESTRUCT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
@@ -1722,6 +1841,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
end:
av_frame_free(&padded_frame);
+ av_free(extended_frame);
return ret;
}
@@ -1732,7 +1852,6 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
const short *samples)
{
AVPacket pkt;
- AVFrame frame0 = { { 0 } };
AVFrame *frame;
int ret, samples_size, got_packet;
@@ -1741,8 +1860,9 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
pkt.size = buf_size;
if (samples) {
- frame = &frame0;
- avcodec_get_frame_defaults(frame);
+ frame = av_frame_alloc();
+ if (!frame)
+ return AVERROR(ENOMEM);
if (avctx->frame_size) {
frame->nb_samples = avctx->frame_size;
@@ -1753,13 +1873,16 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
if (!av_get_bits_per_sample(avctx->codec_id)) {
av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
"support this codec\n");
+ av_frame_free(&frame);
return AVERROR(EINVAL);
}
nb_samples = (int64_t)buf_size * 8 /
(av_get_bits_per_sample(avctx->codec_id) *
avctx->channels);
- if (nb_samples >= INT_MAX)
+ if (nb_samples >= INT_MAX) {
+ av_frame_free(&frame);
return AVERROR(EINVAL);
+ }
frame->nb_samples = nb_samples;
}
@@ -1771,8 +1894,10 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
avctx->sample_fmt,
(const uint8_t *)samples,
- samples_size, 1)) < 0)
+ samples_size, 1)) < 0) {
+ av_frame_free(&frame);
return ret;
+ }
/* fabricate frame pts from sample count.
* this is needed because the avcodec_encode_audio() API does not have
@@ -1799,6 +1924,7 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
if (frame && frame->extended_data != frame->data)
av_freep(&frame->extended_data);
+ av_frame_free(&frame);
return ret ? ret : pkt.size;
}
@@ -1885,7 +2011,11 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
+#if FF_API_DESTRUCT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
@@ -1949,11 +2079,15 @@ static int64_t guess_correct_pts(AVCodecContext *ctx,
if (dts != AV_NOPTS_VALUE) {
ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts;
ctx->pts_correction_last_dts = dts;
- }
+ } else if (reordered_pts != AV_NOPTS_VALUE)
+ ctx->pts_correction_last_dts = reordered_pts;
+
if (reordered_pts != AV_NOPTS_VALUE) {
ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts;
ctx->pts_correction_last_pts = reordered_pts;
- }
+ } else if(dts != AV_NOPTS_VALUE)
+ ctx->pts_correction_last_pts = dts;
+
if ((ctx->pts_correction_num_faulty_pts<=ctx->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
&& reordered_pts != AV_NOPTS_VALUE)
pts = reordered_pts;
@@ -2050,7 +2184,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
if (avci->to_free->extended_data != avci->to_free->data) {
- int planes = av_get_channel_layout_nb_channels(avci->to_free->channel_layout);
+ int planes = av_frame_get_channels(avci->to_free);
int size = planes * sizeof(*frame->extended_data);
if (!size) {
@@ -2098,7 +2232,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return AVERROR(EINVAL);
- avcodec_get_frame_defaults(picture);
+ av_frame_unref(picture);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
int did_split = av_packet_split_side_data(&tmp);
@@ -2161,7 +2295,7 @@ fail:
/* many decoders assign whole AVFrames, thus overwriting extended_data;
* make sure it's set correctly */
- picture->extended_data = picture->data;
+ av_assert0(!picture->extended_data || picture->extended_data == picture->data);
return ret;
}
@@ -2171,9 +2305,11 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
int *frame_size_ptr,
AVPacket *avpkt)
{
- AVFrame frame = { { 0 } };
+ AVFrame *frame = av_frame_alloc();
int ret, got_frame = 0;
+ if (!frame)
+ return AVERROR(ENOMEM);
if (avctx->get_buffer != avcodec_default_get_buffer) {
av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with"
"avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
@@ -2183,26 +2319,27 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
avctx->release_buffer = avcodec_default_release_buffer;
}
- ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);
+ ret = avcodec_decode_audio4(avctx, frame, &got_frame, avpkt);
if (ret >= 0 && got_frame) {
int ch, plane_size;
int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels,
- frame.nb_samples,
+ frame->nb_samples,
avctx->sample_fmt, 1);
if (*frame_size_ptr < data_size) {
av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for "
"the current frame (%d < %d)\n", *frame_size_ptr, data_size);
+ av_frame_free(&frame);
return AVERROR(EINVAL);
}
- memcpy(samples, frame.extended_data[0], plane_size);
+ memcpy(samples, frame->extended_data[0], plane_size);
if (planar && avctx->channels > 1) {
uint8_t *out = ((uint8_t *)samples) + plane_size;
for (ch = 1; ch < avctx->channels; ch++) {
- memcpy(out, frame.extended_data[ch], plane_size);
+ memcpy(out, frame->extended_data[ch], plane_size);
out += plane_size;
}
}
@@ -2210,6 +2347,7 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
} else {
*frame_size_ptr = 0;
}
+ av_frame_free(&frame);
return ret;
}
@@ -2236,7 +2374,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
return AVERROR(EINVAL);
}
- avcodec_get_frame_defaults(frame);
+ av_frame_unref(frame);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
uint8_t *side;
@@ -2405,8 +2543,6 @@ end:
iconv_close(cd);
return ret;
#else
- // ICONV is not on all platforms. Unblock compile by returning a
- // value. Assert with abort() is removed here, too.
return AVERROR(EINVAL);
#endif
}
@@ -2586,6 +2722,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
av_buffer_pool_uninit(&pool->pools[i]);
av_freep(&avctx->internal->pool);
+
+ if (avctx->hwaccel && avctx->hwaccel->uninit)
+ avctx->hwaccel->uninit(avctx);
+ av_freep(&avctx->internal->hwaccel_priv_data);
+
av_freep(&avctx->internal);
}
@@ -2608,15 +2749,25 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
//This is for future deprecatec codec ids, its empty since
//last major bump but will fill up again over time, please don't remove it
// case AV_CODEC_ID_UTVIDEO_DEPRECATED: return AV_CODEC_ID_UTVIDEO;
- case AV_CODEC_ID_OPUS_DEPRECATED: return AV_CODEC_ID_OPUS;
- case AV_CODEC_ID_TAK_DEPRECATED : return AV_CODEC_ID_TAK;
- case AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S24LE_PLANAR;
- case AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S32LE_PLANAR;
- case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130;
- case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M;
- case AV_CODEC_ID_WEBP_DEPRECATED: return AV_CODEC_ID_WEBP;
- case AV_CODEC_ID_HEVC_DEPRECATED: return AV_CODEC_ID_HEVC;
- default : return id;
+ case AV_CODEC_ID_BRENDER_PIX_DEPRECATED : return AV_CODEC_ID_BRENDER_PIX;
+ case AV_CODEC_ID_OPUS_DEPRECATED : return AV_CODEC_ID_OPUS;
+ case AV_CODEC_ID_TAK_DEPRECATED : return AV_CODEC_ID_TAK;
+ case AV_CODEC_ID_PAF_AUDIO_DEPRECATED : return AV_CODEC_ID_PAF_AUDIO;
+ case AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S24LE_PLANAR;
+ case AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S32LE_PLANAR;
+ case AV_CODEC_ID_ADPCM_VIMA_DEPRECATED : return AV_CODEC_ID_ADPCM_VIMA;
+ case AV_CODEC_ID_ESCAPE130_DEPRECATED : return AV_CODEC_ID_ESCAPE130;
+ case AV_CODEC_ID_EXR_DEPRECATED : return AV_CODEC_ID_EXR;
+ case AV_CODEC_ID_G2M_DEPRECATED : return AV_CODEC_ID_G2M;
+ case AV_CODEC_ID_PAF_VIDEO_DEPRECATED : return AV_CODEC_ID_PAF_VIDEO;
+ case AV_CODEC_ID_WEBP_DEPRECATED : return AV_CODEC_ID_WEBP;
+ case AV_CODEC_ID_HEVC_DEPRECATED : return AV_CODEC_ID_HEVC;
+ case AV_CODEC_ID_MVC1_DEPRECATED : return AV_CODEC_ID_MVC1;
+ case AV_CODEC_ID_MVC2_DEPRECATED : return AV_CODEC_ID_MVC2;
+ case AV_CODEC_ID_SANM_DEPRECATED : return AV_CODEC_ID_SANM;
+ case AV_CODEC_ID_SGIRLE_DEPRECATED : return AV_CODEC_ID_SGIRLE;
+ case AV_CODEC_ID_VP7_DEPRECATED : return AV_CODEC_ID_VP7;
+ default : return id;
}
}
@@ -2920,6 +3071,10 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_ADPCM_YAMAHA:
return 4;
+ case AV_CODEC_ID_DSD_LSBF:
+ case AV_CODEC_ID_DSD_MSBF:
+ case AV_CODEC_ID_DSD_LSBF_PLANAR:
+ case AV_CODEC_ID_DSD_MSBF_PLANAR:
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
case AV_CODEC_ID_PCM_S8:
@@ -3220,13 +3375,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_MISSING_SAMPLE */
static AVHWAccel *first_hwaccel = NULL;
+static AVHWAccel **last_hwaccel = &first_hwaccel;
void av_register_hwaccel(AVHWAccel *hwaccel)
{
- AVHWAccel **p = &first_hwaccel;
+ AVHWAccel **p = last_hwaccel;
hwaccel->next = NULL;
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
p = &(*p)->next;
+ last_hwaccel = &hwaccel->next;
}
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
@@ -3234,20 +3391,6 @@ AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
return hwaccel ? hwaccel->next : first_hwaccel;
}
-AVHWAccel *ff_find_hwaccel(AVCodecContext *avctx)
-{
- enum AVCodecID codec_id = avctx->codec->id;
- enum AVPixelFormat pix_fmt = avctx->pix_fmt;
-
- AVHWAccel *hwaccel = NULL;
-
- while ((hwaccel = av_hwaccel_next(hwaccel)))
- if (hwaccel->id == codec_id
- && hwaccel->pix_fmt == pix_fmt)
- return hwaccel;
- return NULL;
-}
-
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
{
if (lockmgr_cb) {
@@ -3349,7 +3492,7 @@ int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
{
- return avctx->get_format(avctx, fmt);
+ return ff_get_format(avctx, fmt);
}
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
@@ -3360,7 +3503,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
{
- av_frame_unref(f->f);
+ if (f->f)
+ av_frame_unref(f->f);
}
void ff_thread_finish_setup(AVCodecContext *avctx)
diff --git a/chromium/third_party/ffmpeg/libavcodec/utvideodec.c b/chromium/third_party/ffmpeg/libavcodec/utvideodec.c
index e3ef22d2a24..2bd177d0923 100644
--- a/chromium/third_party/ffmpeg/libavcodec/utvideodec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/utvideodec.c
@@ -24,6 +24,7 @@
* Ut Video decoder
*/
+#include <inttypes.h>
#include <stdlib.h>
#include "libavutil/intreadwrite.h"
@@ -367,7 +368,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
c->frame_info = bytestream2_get_le32u(&gb);
- av_log(avctx, AV_LOG_DEBUG, "frame information flags %X\n", c->frame_info);
+ av_log(avctx, AV_LOG_DEBUG, "frame information flags %"PRIX32"\n",
+ c->frame_info);
c->frame_pred = (c->frame_info >> 8) & 3;
@@ -481,14 +483,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d.%d.%d\n",
avctx->extradata[3], avctx->extradata[2],
avctx->extradata[1], avctx->extradata[0]);
- av_log(avctx, AV_LOG_DEBUG, "Original format %X\n",
+ av_log(avctx, AV_LOG_DEBUG, "Original format %"PRIX32"\n",
AV_RB32(avctx->extradata + 4));
c->frame_info_size = AV_RL32(avctx->extradata + 8);
c->flags = AV_RL32(avctx->extradata + 12);
if (c->frame_info_size != 4)
avpriv_request_sample(avctx, "Frame info not 4 bytes");
- av_log(avctx, AV_LOG_DEBUG, "Encoding parameters %08X\n", c->flags);
+ av_log(avctx, AV_LOG_DEBUG, "Encoding parameters %08"PRIX32"\n", c->flags);
c->slices = (c->flags >> 24) + 1;
c->compression = c->flags & 1;
c->interlaced = c->flags & 0x800;
diff --git a/chromium/third_party/ffmpeg/libavcodec/utvideoenc.c b/chromium/third_party/ffmpeg/libavcodec/utvideoenc.c
index e5a858d5ae1..0db85a871ff 100644
--- a/chromium/third_party/ffmpeg/libavcodec/utvideoenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/utvideoenc.c
@@ -58,7 +58,7 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
static av_cold int utvideo_encode_init(AVCodecContext *avctx)
{
UtvideoContext *c = avctx->priv_data;
- int i;
+ int i, subsampled_height;
uint32_t original_format;
c->avctx = avctx;
@@ -83,7 +83,10 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
c->planes = 3;
- avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
+ if (avctx->colorspace == AVCOL_SPC_BT709)
+ avctx->codec_tag = MKTAG('U', 'L', 'H', '0');
+ else
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
original_format = UTVIDEO_420;
break;
case AV_PIX_FMT_YUV422P:
@@ -93,7 +96,10 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
c->planes = 3;
- avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
+ if (avctx->colorspace == AVCOL_SPC_BT709)
+ avctx->codec_tag = MKTAG('U', 'L', 'H', '2');
+ else
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
original_format = UTVIDEO_422;
break;
default:
@@ -126,6 +132,26 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR_OPTION_NOT_FOUND;
}
+ /*
+ * Check the asked slice count for obviously invalid
+ * values (> 256 or negative).
+ */
+ if (avctx->slices > 256 || avctx->slices < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
+ avctx->slices);
+ return AVERROR(EINVAL);
+ }
+
+ /* Check that the slice count is not larger than the subsampled height */
+ subsampled_height = avctx->height >> av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_h;
+ if (avctx->slices > subsampled_height) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Slice count %d is larger than the subsampling-applied height %d.\n",
+ avctx->slices, subsampled_height);
+ return AVERROR(EINVAL);
+ }
+
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) {
@@ -175,9 +201,19 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
/*
* Set how many slices are going to be used.
- * Set one slice for now.
+ * By default uses multiple slices depending on the subsampled height.
+ * This enables multithreading in the official decoder.
*/
- c->slices = 1;
+ if (!avctx->slices) {
+ c->slices = subsampled_height / 120;
+
+ if (!c->slices)
+ c->slices = 1;
+ else if (c->slices > 256)
+ c->slices = 256;
+ } else {
+ c->slices = avctx->slices;
+ }
/* Set compression mode */
c->compression = COMP_HUFF;
@@ -363,6 +399,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
uint32_t offset = 0, slice_len = 0;
int i, sstart, send = 0;
int symbol;
+ int ret;
/* Do prediction / make planes */
switch (c->frame_pred) {
@@ -429,7 +466,8 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
}
/* Calculate huffman lengths */
- ff_huff_gen_len_table(lengths, counts);
+ if ((ret = ff_huff_gen_len_table(lengths, counts, 256)) < 0)
+ return ret;
/*
* Write the plane's header into the output packet:
@@ -456,7 +494,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
* get the offset in bits and convert to bytes.
*/
offset += write_huff_codes(dst + sstart * width, c->slice_bits,
- width * (send - sstart), width,
+ width * height + 4, width,
send - sstart, he) >> 3;
slice_len = offset - slice_len;
@@ -513,7 +551,7 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream2_init_writer(&pb, dst, pkt->size);
- av_fast_padded_malloc(&c->slice_bits, &c->slice_bits_size, width * height);
+ av_fast_padded_malloc(&c->slice_bits, &c->slice_bits_size, width * height + 4);
if (!c->slice_bits) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n");
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_h264.c b/chromium/third_party/ffmpeg/libavcodec/vaapi_h264.c
index ea0f43420da..8eb8a66f159 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_h264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_h264.c
@@ -22,6 +22,7 @@
#include "vaapi_internal.h"
#include "h264.h"
+#include "mpegutils.h"
/**
* @file
@@ -51,14 +52,14 @@ static void init_vaapi_pic(VAPictureH264 *va_pic)
* supersedes pic's field type if nonzero.
*/
static void fill_vaapi_pic(VAPictureH264 *va_pic,
- Picture *pic,
+ H264Picture *pic,
int pic_structure)
{
if (pic_structure == 0)
pic_structure = pic->reference;
pic_structure &= PICT_FRAME; /* PICT_TOP_FIELD|PICT_BOTTOM_FIELD */
- va_pic->picture_id = ff_vaapi_get_surface_id(pic);
+ va_pic->picture_id = ff_vaapi_get_surface_id(&pic->f);
va_pic->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
va_pic->flags = 0;
@@ -89,7 +90,7 @@ typedef struct DPB {
* available. The decoded picture buffer's size must be large enough
* to receive the new VA API picture object.
*/
-static int dpb_add(DPB *dpb, Picture *pic)
+static int dpb_add(DPB *dpb, H264Picture *pic)
{
int i;
@@ -98,7 +99,7 @@ static int dpb_add(DPB *dpb, Picture *pic)
for (i = 0; i < dpb->size; i++) {
VAPictureH264 * const va_pic = &dpb->va_pics[i];
- if (va_pic->picture_id == ff_vaapi_get_surface_id(pic)) {
+ if (va_pic->picture_id == ff_vaapi_get_surface_id(&pic->f)) {
VAPictureH264 temp_va_pic;
fill_vaapi_pic(&temp_va_pic, pic, 0);
@@ -133,13 +134,13 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param,
init_vaapi_pic(&dpb.va_pics[i]);
for (i = 0; i < h->short_ref_count; i++) {
- Picture * const pic = h->short_ref[i];
+ H264Picture * const pic = h->short_ref[i];
if (pic && pic->reference && dpb_add(&dpb, pic) < 0)
return -1;
}
for (i = 0; i < 16; i++) {
- Picture * const pic = h->long_ref[i];
+ H264Picture * const pic = h->long_ref[i];
if (pic && pic->reference && dpb_add(&dpb, pic) < 0)
return -1;
}
@@ -155,7 +156,7 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param,
* @param[in] ref_count The number of reference pictures in ref_list
*/
static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32],
- Picture *ref_list,
+ H264Picture *ref_list,
unsigned int ref_count)
{
unsigned int i, n = 0;
@@ -298,7 +299,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
if (ret < 0)
goto finish;
- ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(h->cur_pic_ptr));
+ ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(&h->cur_pic_ptr->f));
if (ret < 0)
goto finish;
@@ -333,8 +334,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = h->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
- slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2 - 26;
- slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26;
+ slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
+ slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_internal.h b/chromium/third_party/ffmpeg/libavcodec/vaapi_internal.h
index 1ac0e9fe35d..918c718d14b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_internal.h
@@ -35,10 +35,10 @@
* @{
*/
-/** Extract VASurfaceID from a Picture */
-static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic)
+/** Extract VASurfaceID from an AVFrame */
+static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
{
- return (uintptr_t)pic->f.data[3];
+ return (uintptr_t)pic->data[3];
}
/** Common AVHWAccel.end_frame() implementation */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg.c b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg.c
index 5afa4060013..63879e5fe43 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg.c
@@ -35,7 +35,7 @@ int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
goto finish;
ret = ff_vaapi_render_picture(vactx,
- ff_vaapi_get_surface_id(s->current_picture_ptr));
+ ff_vaapi_get_surface_id(s->current_picture_ptr->f));
if (ret < 0)
goto finish;
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg2.c b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg2.c
index cdc70eefa87..0988433487e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg2.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "mpegutils.h"
#include "vaapi_internal.h"
/** Reconstruct bitstream f_code */
@@ -72,10 +73,10 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
- pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture);
+ pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f);
// fall-through
case AV_PICTURE_TYPE_P:
- pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture);
+ pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f);
break;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg4.c b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg4.c
index 9ed007f2d8f..28c12a0812a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg4.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_mpeg4.c
@@ -81,7 +81,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
pic_param->quant_precision = s->quant_precision;
pic_param->vop_fields.value = 0; /* reset all bits */
pic_param->vop_fields.bits.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I;
- pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0;
+ pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f->pict_type - AV_PICTURE_TYPE_I : 0;
pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding;
pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(ctx);
pic_param->vop_fields.bits.top_field_first = s->top_field_first;
@@ -95,9 +95,9 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
pic_param->TRD = s->pp_time;
if (s->pict_type == AV_PICTURE_TYPE_B)
- pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture);
+ pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f);
if (s->pict_type != AV_PICTURE_TYPE_I)
- pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture);
+ pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f);
/* Fill in VAIQMatrixBufferMPEG4 */
/* Only the first inverse quantisation method uses the weighting matrices */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vaapi_vc1.c b/chromium/third_party/ffmpeg/libavcodec/vaapi_vc1.c
index 266fa3c5bad..bba46d337ff 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vaapi_vc1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vaapi_vc1.c
@@ -258,10 +258,10 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
- pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture);
+ pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f);
// fall-through
case AV_PICTURE_TYPE_P:
- pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture);
+ pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f);
break;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vble.c b/chromium/third_party/ffmpeg/libavcodec/vble.c
index a8c71ed9c94..ed08b832a9a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vble.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vble.c
@@ -189,7 +189,7 @@ static av_cold int vble_decode_init(AVCodecContext *avctx)
ctx->size = avpicture_get_size(avctx->pix_fmt,
avctx->width, avctx->height);
- ctx->val = av_malloc(ctx->size * sizeof(*ctx->val));
+ ctx->val = av_malloc_array(ctx->size, sizeof(*ctx->val));
if (!ctx->val) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate values buffer.\n");
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1.c b/chromium/third_party/ffmpeg/libavcodec/vc1.c
index 181a4df3780..c7f3561cbc7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1.c
@@ -47,21 +47,6 @@
* @{
*/
-/**
- * Imode types
- * @{
- */
-enum Imode {
- IMODE_RAW,
- IMODE_NORM2,
- IMODE_DIFF2,
- IMODE_NORM6,
- IMODE_DIFF6,
- IMODE_ROWSKIP,
- IMODE_COLSKIP
-};
-/** @} */ //imode defines
-
/** Decode rows by checking if they are skipped
* @param plane Buffer to store decoded bits
* @param[in] width Width of this buffer
@@ -137,12 +122,16 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
case IMODE_NORM2:
if ((height * width) & 1) {
*planep++ = get_bits1(gb);
- offset = 1;
+ y = offset = 1;
+ if (offset == width) {
+ offset = 0;
+ planep += stride - width;
+ }
}
else
- offset = 0;
+ y = offset = 0;
// decode bitplane as one long line
- for (y = offset; y < height * width; y += 2) {
+ for (; y < height * width; y += 2) {
code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);
*planep++ = code & 1;
offset++;
@@ -304,6 +293,7 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo
v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz;
return decode_sequence_header_adv(v, gb);
} else {
+ v->chromaformat = 1;
v->zz_8x4 = ff_wmv2_scantableA;
v->zz_4x8 = ff_wmv2_scantableB;
v->res_y411 = get_bits1(gb);
@@ -382,7 +372,11 @@ int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitCo
if (v->res_sprite) {
int w = get_bits(gb, 11);
int h = get_bits(gb, 11);
- avcodec_set_dimensions(v->s.avctx, w, h);
+ int ret = ff_set_dimensions(v->s.avctx, w, h);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to set dimensions %d %d\n", w, h);
+ return ret;
+ }
skip_bits(gb, 5); //frame rate
v->res_x8 = get_bits1(gb);
if (get_bits1(gb)) { // something to do with DC VLC selection
@@ -526,6 +520,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex
{
int i;
int w,h;
+ int ret;
av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32));
v->broken_link = get_bits1(gb);
@@ -555,7 +550,11 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContex
w = v->max_coded_width;
h = v->max_coded_height;
}
- avcodec_set_dimensions(avctx, w, h);
+ if ((ret = ff_set_dimensions(avctx, w, h)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to set dimensions %d %d\n", w, h);
+ return ret;
+ }
+
if (v->extended_mv)
v->extended_dmv = get_bits1(gb);
if ((v->range_mapy_flag = get_bits1(gb))) {
@@ -607,26 +606,40 @@ static void rotate_luts(VC1Context *v)
C = A; \
} else { \
DEF; \
- memcpy(&tmp, &L , sizeof(tmp)); \
- memcpy(&L , &N , sizeof(tmp)); \
- memcpy(&N , &tmp, sizeof(tmp)); \
+ memcpy(&tmp, L , sizeof(tmp)); \
+ memcpy(L , N , sizeof(tmp)); \
+ memcpy(N , &tmp, sizeof(tmp)); \
C = N; \
} \
} while(0)
- ROTATE(int tmp, v->last_use_ic, v->next_use_ic, v->curr_use_ic, v->aux_use_ic);
+ ROTATE(int tmp, &v->last_use_ic, &v->next_use_ic, v->curr_use_ic, &v->aux_use_ic);
ROTATE(uint8_t tmp[2][256], v->last_luty, v->next_luty, v->curr_luty, v->aux_luty);
ROTATE(uint8_t tmp[2][256], v->last_lutuv, v->next_lutuv, v->curr_lutuv, v->aux_lutuv);
INIT_LUT(32, 0, v->curr_luty[0], v->curr_lutuv[0], 0);
INIT_LUT(32, 0, v->curr_luty[1], v->curr_lutuv[1], 0);
- v->curr_use_ic = 0;
+ *v->curr_use_ic = 0;
+}
+
+static int read_bfraction(VC1Context *v, GetBitContext* gb) {
+ int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
+
+ if (bfraction_lut_index == 21 || bfraction_lut_index < 0) {
+ av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n");
+ return AVERROR_INVALIDDATA;
+ }
+ v->bfraction_lut_index = bfraction_lut_index;
+ v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
+ return 0;
}
int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant, status;
+ v->field_mode = 0;
+ v->fcm = 0;
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (!v->s.avctx->codec)
@@ -654,8 +667,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
- v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
- v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
+ if (read_bfraction(v, gb) < 0)
+ return AVERROR_INVALIDDATA;
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI;
}
@@ -847,7 +860,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
int field_mode, fcm;
- v->numref=0;
+ v->numref = 0;
v->p_frame_skipped = 0;
if (v->second_field) {
if(v->fcm!=2 || v->field_mode!=1)
@@ -855,7 +868,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4)
v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
- v->s.current_picture_ptr->f.pict_type = v->s.pict_type;
+ v->s.current_picture_ptr->f->pict_type = v->s.pict_type;
if (!v->pic_header_flag)
goto parse_common_info;
}
@@ -875,12 +888,17 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->field_mode = field_mode;
v->fcm = fcm;
+ av_assert0( v->s.mb_height == v->s.height + 15 >> 4
+ || v->s.mb_height == FFALIGN(v->s.height + 15 >> 4, 2));
if (v->field_mode) {
+ v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2);
v->fptype = get_bits(gb, 3);
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
if (v->fptype & 4) // B-picture
v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
+
} else {
+ v->s.mb_height = v->s.height + 15 >> 4;
switch (get_unary(gb, 0, 4)) {
case 0:
v->s.pict_type = AV_PICTURE_TYPE_P;
@@ -933,8 +951,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->refdist += get_unary(gb, 0, 16);
}
if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {
- v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
- v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
+ if (read_bfraction(v, gb) < 0)
+ return AVERROR_INVALIDDATA;
v->frfd = (v->bfraction * v->refdist) >> 8;
v->brfd = v->refdist - v->frfd - 1;
if (v->brfd < 0)
@@ -946,8 +964,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
- v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
- v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
+ if (read_bfraction(v, gb) < 0)
+ return AVERROR_INVALIDDATA;
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
}
@@ -1021,8 +1039,6 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
v->reffield = get_bits1(gb);
v->ref_field_type[0] = v->reffield ^ !v->cur_field_type;
}
- } else {
- v->numref = 0;
}
if (v->extended_mv)
v->mvrange = get_unary(gb, 0, 3);
@@ -1110,7 +1126,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
INIT_LUT(v->lumscale2, v->lumshift2, v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[v->cur_field_type ], v->last_lutuv[v->cur_field_type ], 1);
}
- v->next_use_ic = v->curr_use_ic = 1;
+ v->next_use_ic = *v->curr_use_ic = 1;
} else {
INIT_LUT(v->lumscale , v->lumshift , v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[1], v->last_lutuv[1], 1);
@@ -1193,8 +1209,8 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
break;
case AV_PICTURE_TYPE_B:
if (v->fcm == ILACE_FRAME) {
- v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
- v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
+ if (read_bfraction(v, gb) < 0)
+ return AVERROR_INVALIDDATA;
if (v->bfraction == 0) {
return -1;
}
@@ -1699,5 +1715,7 @@ av_cold int ff_vc1_init_common(VC1Context *v)
v->pq = -1;
v->mvrange = 0; /* 7.1.1.18, p80 */
+ ff_vc1dsp_init(&v->vc1dsp);
+
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1.h b/chromium/third_party/ffmpeg/libavcodec/vc1.h
index 0cf4e0f9f77..662b58b4d9b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1.h
@@ -175,6 +175,21 @@ enum FrameCodingMode {
ILACE_FIELD ///< in the bitstream is reported as 11b
};
+/**
+ * Imode types
+ * @{
+ */
+enum Imode {
+ IMODE_RAW,
+ IMODE_NORM2,
+ IMODE_DIFF2,
+ IMODE_NORM6,
+ IMODE_DIFF6,
+ IMODE_ROWSKIP,
+ IMODE_COLSKIP
+};
+/** @} */ //imode defines
+
/** The VC1 Context
* @todo Change size wherever another size is more efficient
* Many members are only used for Advanced Profile
@@ -300,7 +315,7 @@ typedef struct VC1Context{
uint8_t aux_luty[2][256], aux_lutuv[2][256]; ///< lookup tables used for intensity compensation
uint8_t next_luty[2][256], next_lutuv[2][256]; ///< lookup tables used for intensity compensation
uint8_t (*curr_luty)[256] ,(*curr_lutuv)[256];
- int last_use_ic, curr_use_ic, next_use_ic, aux_use_ic;
+ int last_use_ic, *curr_use_ic, next_use_ic, aux_use_ic;
int rnd; ///< rounding control
/** Frame decoding info for S/M profiles only */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1_parser.c b/chromium/third_party/ffmpeg/libavcodec/vc1_parser.c
index cc29ce148b1..0021febaf56 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1_parser.c
@@ -30,122 +30,88 @@
#include "vc1.h"
#include "get_bits.h"
+/** The maximum number of bytes of a sequence, entry point or
+ * frame header whose values we pay any attention to */
+#define UNESCAPED_THRESHOLD 37
+
+/** The maximum number of bytes of a sequence, entry point or
+ * frame header which must be valid memory (because they are
+ * used to update the bitstream cache in skip_bits() calls)
+ */
+#define UNESCAPED_LIMIT 144
+
+typedef enum {
+ NO_MATCH,
+ ONE_ZERO,
+ TWO_ZEROS,
+ ONE
+} VC1ParseSearchState;
+
typedef struct {
ParseContext pc;
VC1Context v;
+ uint8_t prev_start_code;
+ size_t bytes_to_skip;
+ uint8_t unesc_buffer[UNESCAPED_LIMIT];
+ size_t unesc_index;
+ VC1ParseSearchState search_state;
} VC1ParseContext;
-static void vc1_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
+static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
{
+ /* Parse the header we just finished unescaping */
VC1ParseContext *vpc = s->priv_data;
GetBitContext gb;
- const uint8_t *start, *end, *next;
- uint8_t *buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
-
+ int ret;
vpc->v.s.avctx = avctx;
vpc->v.parse_only = 1;
- vpc->v.first_pic_header_flag = 1;
- next = buf;
- s->repeat_pict = 0;
-
- for(start = buf, end = buf + buf_size; next < end; start = next){
- int buf2_size, size;
- int ret;
-
- next = find_next_marker(start + 4, end);
- size = next - start - 4;
- buf2_size = vc1_unescape_buffer(start + 4, size, buf2);
- init_get_bits(&gb, buf2, buf2_size * 8);
- if(size <= 0) continue;
- switch(AV_RB32(start)){
- case VC1_CODE_SEQHDR:
- ff_vc1_decode_sequence_header(avctx, &vpc->v, &gb);
- break;
- case VC1_CODE_ENTRYPOINT:
- ff_vc1_decode_entry_point(avctx, &vpc->v, &gb);
- break;
- case VC1_CODE_FRAME:
- if(vpc->v.profile < PROFILE_ADVANCED)
- ret = ff_vc1_parse_frame_header (&vpc->v, &gb);
- else
- ret = ff_vc1_parse_frame_header_adv(&vpc->v, &gb);
-
- if (ret < 0)
- break;
-
- /* keep AV_PICTURE_TYPE_BI internal to VC1 */
- if (vpc->v.s.pict_type == AV_PICTURE_TYPE_BI)
- s->pict_type = AV_PICTURE_TYPE_B;
- else
- s->pict_type = vpc->v.s.pict_type;
-
- if (avctx->ticks_per_frame > 1){
- // process pulldown flags
- s->repeat_pict = 1;
- // Pulldown flags are only valid when 'broadcast' has been set.
- // So ticks_per_frame will be 2
- if (vpc->v.rff){
- // repeat field
- s->repeat_pict = 2;
- }else if (vpc->v.rptfrm){
- // repeat frames
- s->repeat_pict = vpc->v.rptfrm * 2 + 1;
- }
- }
-
- if (vpc->v.broadcast && vpc->v.interlace && !vpc->v.psf)
- s->field_order = vpc->v.tff ? AV_FIELD_TT : AV_FIELD_BB;
- else
- s->field_order = AV_FIELD_PROGRESSIVE;
+ init_get_bits(&gb, buf, buf_size * 8);
+ switch (vpc->prev_start_code) {
+ case VC1_CODE_SEQHDR & 0xFF:
+ ff_vc1_decode_sequence_header(avctx, &vpc->v, &gb);
+ break;
+ case VC1_CODE_ENTRYPOINT & 0xFF:
+ ff_vc1_decode_entry_point(avctx, &vpc->v, &gb);
+ break;
+ case VC1_CODE_FRAME & 0xFF:
+ if(vpc->v.profile < PROFILE_ADVANCED)
+ ret = ff_vc1_parse_frame_header (&vpc->v, &gb);
+ else
+ ret = ff_vc1_parse_frame_header_adv(&vpc->v, &gb);
+ if (ret < 0)
break;
- }
- }
- av_free(buf2);
-}
+ /* keep AV_PICTURE_TYPE_BI internal to VC1 */
+ if (vpc->v.s.pict_type == AV_PICTURE_TYPE_BI)
+ s->pict_type = AV_PICTURE_TYPE_B;
+ else
+ s->pict_type = vpc->v.s.pict_type;
-/**
- * Find the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-static int vc1_find_frame_end(ParseContext *pc, const uint8_t *buf,
- int buf_size) {
- int pic_found, i;
- uint32_t state;
-
- pic_found= pc->frame_start_found;
- state= pc->state;
-
- i=0;
- if(!pic_found){
- for(i=0; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state == VC1_CODE_FRAME || state == VC1_CODE_FIELD){
- i++;
- pic_found=1;
- break;
+ if (avctx->ticks_per_frame > 1){
+ // process pulldown flags
+ s->repeat_pict = 1;
+ // Pulldown flags are only valid when 'broadcast' has been set.
+ // So ticks_per_frame will be 2
+ if (vpc->v.rff){
+ // repeat field
+ s->repeat_pict = 2;
+ }else if (vpc->v.rptfrm){
+ // repeat frames
+ s->repeat_pict = vpc->v.rptfrm * 2 + 1;
}
+ }else{
+ s->repeat_pict = 0;
}
- }
- if(pic_found){
- /* EOF considered as end of frame */
- if (buf_size == 0)
- return 0;
- for(; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(IS_MARKER(state) && state != VC1_CODE_FIELD && state != VC1_CODE_SLICE){
- pc->frame_start_found=0;
- pc->state=-1;
- return i-3;
- }
- }
+ if (vpc->v.broadcast && vpc->v.interlace && !vpc->v.psf)
+ s->field_order = vpc->v.tff ? AV_FIELD_TT : AV_FIELD_BB;
+ else
+ s->field_order = AV_FIELD_PROGRESSIVE;
+
+ break;
}
- pc->frame_start_found= pic_found;
- pc->state= state;
- return END_NOT_FOUND;
}
static int vc1_parse(AVCodecParserContext *s,
@@ -153,22 +119,127 @@ static int vc1_parse(AVCodecParserContext *s,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
+ /* Here we do the searching for frame boundaries and headers at
+ * the same time. Only a minimal amount at the start of each
+ * header is unescaped. */
VC1ParseContext *vpc = s->priv_data;
- int next;
+ int pic_found = vpc->pc.frame_start_found;
+ uint8_t *unesc_buffer = vpc->unesc_buffer;
+ size_t unesc_index = vpc->unesc_index;
+ VC1ParseSearchState search_state = vpc->search_state;
+ int next = END_NOT_FOUND;
+ int i = vpc->bytes_to_skip;
+
+ if (pic_found && buf_size == 0) {
+ /* EOF considered as end of frame */
+ memset(unesc_buffer + unesc_index, 0, UNESCAPED_THRESHOLD - unesc_index);
+ vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
+ next = 0;
+ }
+ while (i < buf_size) {
+ int start_code_found = 0;
+ uint8_t b;
+ while (i < buf_size && unesc_index < UNESCAPED_THRESHOLD) {
+ b = buf[i++];
+ unesc_buffer[unesc_index++] = b;
+ if (search_state <= ONE_ZERO)
+ search_state = b ? NO_MATCH : search_state + 1;
+ else if (search_state == TWO_ZEROS) {
+ if (b == 1)
+ search_state = ONE;
+ else if (b > 1) {
+ if (b == 3)
+ unesc_index--; // swallow emulation prevention byte
+ search_state = NO_MATCH;
+ }
+ }
+ else { // search_state == ONE
+ // Header unescaping terminates early due to detection of next start code
+ search_state = NO_MATCH;
+ start_code_found = 1;
+ break;
+ }
+ }
+ if ((s->flags & PARSER_FLAG_COMPLETE_FRAMES) &&
+ unesc_index >= UNESCAPED_THRESHOLD &&
+ vpc->prev_start_code == (VC1_CODE_FRAME & 0xFF))
+ {
+ // No need to keep scanning the rest of the buffer for
+ // start codes if we know it contains a complete frame and
+ // we've already unescaped all we need of the frame header
+ vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
+ break;
+ }
+ if (unesc_index >= UNESCAPED_THRESHOLD && !start_code_found) {
+ while (i < buf_size) {
+ if (search_state == NO_MATCH) {
+ i += vpc->v.vc1dsp.vc1_find_start_code_candidate(buf + i, buf_size - i);
+ if (i < buf_size) {
+ search_state = ONE_ZERO;
+ }
+ i++;
+ } else {
+ b = buf[i++];
+ if (search_state == ONE_ZERO)
+ search_state = b ? NO_MATCH : TWO_ZEROS;
+ else if (search_state == TWO_ZEROS) {
+ if (b >= 1)
+ search_state = b == 1 ? ONE : NO_MATCH;
+ }
+ else { // search_state == ONE
+ search_state = NO_MATCH;
+ start_code_found = 1;
+ break;
+ }
+ }
+ }
+ }
+ if (start_code_found) {
+ vc1_extract_header(s, avctx, unesc_buffer, unesc_index);
+
+ vpc->prev_start_code = b;
+ unesc_index = 0;
+
+ if (!(s->flags & PARSER_FLAG_COMPLETE_FRAMES)) {
+ if (!pic_found && (b == (VC1_CODE_FRAME & 0xFF) || b == (VC1_CODE_FIELD & 0xFF))) {
+ pic_found = 1;
+ }
+ else if (pic_found && b != (VC1_CODE_FIELD & 0xFF) && b != (VC1_CODE_SLICE & 0xFF)) {
+ next = i - 4;
+ pic_found = b == (VC1_CODE_FRAME & 0xFF);
+ break;
+ }
+ }
+ }
+ }
- if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
- next= buf_size;
- }else{
- next= vc1_find_frame_end(&vpc->pc, buf, buf_size);
+ vpc->pc.frame_start_found = pic_found;
+ vpc->unesc_index = unesc_index;
+ vpc->search_state = search_state;
+ if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+ next = buf_size;
+ } else {
if (ff_combine_frame(&vpc->pc, next, &buf, &buf_size) < 0) {
+ vpc->bytes_to_skip = 0;
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
- vc1_extract_headers(s, avctx, buf, buf_size);
+ vpc->v.first_pic_header_flag = 1;
+
+ /* If we return with a valid pointer to a combined frame buffer
+ * then on the next call then we'll have been unhelpfully rewound
+ * by up to 4 bytes (depending upon whether the start code
+ * overlapped the input buffer, and if so by how much). We don't
+ * want this: it will either cause spurious second detections of
+ * the start code we've already seen, or cause extra bytes to be
+ * inserted at the start of the unescaped buffer. */
+ vpc->bytes_to_skip = 4;
+ if (next < 0 && next != END_NOT_FOUND)
+ vpc->bytes_to_skip += next;
*poutbuf = buf;
*poutbuf_size = buf_size;
@@ -199,6 +270,11 @@ static av_cold int vc1_parse_init(AVCodecParserContext *s)
{
VC1ParseContext *vpc = s->priv_data;
vpc->v.s.slice_context_count = 1;
+ vpc->v.first_pic_header_flag = 1;
+ vpc->prev_start_code = 0;
+ vpc->bytes_to_skip = 0;
+ vpc->unesc_index = 0;
+ vpc->search_state = NO_MATCH;
return ff_vc1_init_common(&vpc->v);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1dec.c b/chromium/third_party/ffmpeg/libavcodec/vc1dec.c
index 87846449ec7..c53c594bbe8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1dec.c
@@ -29,6 +29,7 @@
#include "internal.h"
#include "avcodec.h"
#include "error_resilience.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "h264chroma.h"
@@ -59,29 +60,15 @@ static const int offset_table2[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
* @{
*/
-/**
- * Imode types
- * @{
- */
-enum Imode {
- IMODE_RAW,
- IMODE_NORM2,
- IMODE_DIFF2,
- IMODE_NORM6,
- IMODE_DIFF6,
- IMODE_ROWSKIP,
- IMODE_COLSKIP
-};
-/** @} */ //imode defines
static void init_block_index(VC1Context *v)
{
MpegEncContext *s = &v->s;
ff_init_block_index(s);
if (v->field_mode && !(v->second_field ^ v->tff)) {
- s->dest[0] += s->current_picture_ptr->f.linesize[0];
- s->dest[1] += s->current_picture_ptr->f.linesize[1];
- s->dest[2] += s->current_picture_ptr->f.linesize[2];
+ s->dest[0] += s->current_picture_ptr->f->linesize[0];
+ s->dest[1] += s->current_picture_ptr->f->linesize[1];
+ s->dest[2] += s->current_picture_ptr->f->linesize[2];
}
}
@@ -354,7 +341,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
if ((!v->field_mode ||
(v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
- !v->s.last_picture.f.data[0])
+ !v->s.last_picture.f->data[0])
return;
mx = s->mv[dir][0][0];
@@ -386,24 +373,24 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
}
if (!dir) {
if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
- srcY = s->current_picture.f.data[0];
- srcU = s->current_picture.f.data[1];
- srcV = s->current_picture.f.data[2];
+ srcY = s->current_picture.f->data[0];
+ srcU = s->current_picture.f->data[1];
+ srcV = s->current_picture.f->data[2];
luty = v->curr_luty;
lutuv = v->curr_lutuv;
- use_ic = v->curr_use_ic;
+ use_ic = *v->curr_use_ic;
} else {
- srcY = s->last_picture.f.data[0];
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
+ srcY = s->last_picture.f->data[0];
+ srcU = s->last_picture.f->data[1];
+ srcV = s->last_picture.f->data[2];
luty = v->last_luty;
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
}
} else {
- srcY = s->next_picture.f.data[0];
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
+ srcY = s->next_picture.f->data[0];
+ srcU = s->next_picture.f->data[1];
+ srcV = s->next_picture.f->data[2];
luty = v->next_luty;
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
@@ -436,9 +423,9 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if (v->field_mode && v->ref_field_type[dir]) {
- srcY += s->current_picture_ptr->f.linesize[0];
- srcU += s->current_picture_ptr->f.linesize[1];
- srcV += s->current_picture_ptr->f.linesize[2];
+ srcY += s->current_picture_ptr->f->linesize[0];
+ srcU += s->current_picture_ptr->f->linesize[1];
+ srcV += s->current_picture_ptr->f->linesize[2];
}
/* for grayscale we should not try to read from unknown area */
@@ -523,11 +510,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd);
- srcY += s->linesize * 8;
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[0][dxy](s->dest[0] , srcY , s->linesize, v->rnd);
} else { // hpel mc - always used for luma
dxy = (my & 2) | ((mx & 2) >> 1);
if (!v->rnd)
@@ -575,7 +558,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
if ((!v->field_mode ||
(v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
- !v->s.last_picture.f.data[0])
+ !v->s.last_picture.f->data[0])
return;
mx = s->mv[dir][n][0];
@@ -583,16 +566,16 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
if (!dir) {
if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
- srcY = s->current_picture.f.data[0];
+ srcY = s->current_picture.f->data[0];
luty = v->curr_luty;
- use_ic = v->curr_use_ic;
+ use_ic = *v->curr_use_ic;
} else {
- srcY = s->last_picture.f.data[0];
+ srcY = s->last_picture.f->data[0];
luty = v->last_luty;
use_ic = v->last_use_ic;
}
} else {
- srcY = s->next_picture.f.data[0];
+ srcY = s->next_picture.f->data[0];
luty = v->next_luty;
use_ic = v->next_use_ic;
}
@@ -692,7 +675,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
srcY += src_y * s->linesize + src_x;
if (v->field_mode && v->ref_field_type[dir])
- srcY += s->current_picture_ptr->f.linesize[0];
+ srcY += s->current_picture_ptr->f->linesize[0];
if (fieldmv && !(src_y & 1))
v_edge_pos--;
@@ -741,9 +724,9 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
if (avg)
- v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
else
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
+ v->vc1dsp.put_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
} else { // hpel mc - always used for luma
dxy = (my & 2) | ((mx & 2) >> 1);
if (!v->rnd)
@@ -822,7 +805,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
uint8_t (*lutuv)[256];
int use_ic;
- if (!v->field_mode && !v->s.last_picture.f.data[0])
+ if (!v->field_mode && !v->s.last_picture.f->data[0])
return;
if (s->flags & CODEC_FLAG_GRAY)
return;
@@ -853,7 +836,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
if (dominant)
chroma_ref_type = !v->cur_field_type;
}
- if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])
+ if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f->data[0])
return;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
@@ -884,19 +867,19 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
if (!dir) {
if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
- srcU = s->current_picture.f.data[1];
- srcV = s->current_picture.f.data[2];
+ srcU = s->current_picture.f->data[1];
+ srcV = s->current_picture.f->data[2];
lutuv = v->curr_lutuv;
- use_ic = v->curr_use_ic;
+ use_ic = *v->curr_use_ic;
} else {
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
+ srcU = s->last_picture.f->data[1];
+ srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
}
} else {
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
+ srcU = s->next_picture.f->data[1];
+ srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
}
@@ -911,8 +894,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
if (v->field_mode) {
if (chroma_ref_type) {
- srcU += s->current_picture_ptr->f.linesize[1];
- srcV += s->current_picture_ptr->f.linesize[2];
+ srcU += s->current_picture_ptr->f->linesize[1];
+ srcV += s->current_picture_ptr->f->linesize[2];
}
}
@@ -1017,13 +1000,13 @@ static void vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
if (i < 2 ? dir : dir2) {
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
+ srcU = s->next_picture.f->data[1];
+ srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
} else {
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
+ srcU = s->last_picture.f->data[1];
+ srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
}
@@ -1918,7 +1901,7 @@ static void vc1_interp_mc(VC1Context *v)
int v_edge_pos = s->v_edge_pos >> v->field_mode;
int use_ic = v->next_use_ic;
- if (!v->field_mode && !v->s.next_picture.f.data[0])
+ if (!v->field_mode && !v->s.next_picture.f->data[0])
return;
mx = s->mv[1][0][0];
@@ -1926,17 +1909,18 @@ static void vc1_interp_mc(VC1Context *v)
uvmx = (mx + ((mx & 3) == 3)) >> 1;
uvmy = (my + ((my & 3) == 3)) >> 1;
if (v->field_mode) {
- if (v->cur_field_type != v->ref_field_type[1])
+ if (v->cur_field_type != v->ref_field_type[1]) {
my = my - 2 + 4 * v->cur_field_type;
uvmy = uvmy - 2 + 4 * v->cur_field_type;
+ }
}
if (v->fastuvmc) {
uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
}
- srcY = s->next_picture.f.data[0];
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
+ srcY = s->next_picture.f->data[0];
+ srcU = s->next_picture.f->data[1];
+ srcV = s->next_picture.f->data[2];
src_x = s->mb_x * 16 + (mx >> 2);
src_y = s->mb_y * 16 + (my >> 2);
@@ -1960,9 +1944,9 @@ static void vc1_interp_mc(VC1Context *v)
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if (v->field_mode && v->ref_field_type[1]) {
- srcY += s->current_picture_ptr->f.linesize[0];
- srcU += s->current_picture_ptr->f.linesize[1];
- srcV += s->current_picture_ptr->f.linesize[2];
+ srcY += s->current_picture_ptr->f->linesize[0];
+ srcU += s->current_picture_ptr->f->linesize[1];
+ srcV += s->current_picture_ptr->f->linesize[2];
}
/* for grayscale we should not try to read from unknown area */
@@ -2051,11 +2035,7 @@ static void vc1_interp_mc(VC1Context *v)
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
- v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
- v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);
- srcY += s->linesize * 8;
- v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd);
- v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
+ v->vc1dsp.avg_vc1_mspel_pixels_tab[0][dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
} else { // hpel mc
dxy = (my & 2) | ((mx & 2) >> 1);
@@ -2127,6 +2107,8 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
int r_x, r_y;
const uint8_t *is_intra = v->mb_type[0];
+ av_assert0(!v->field_mode);
+
r_x = v->range_x;
r_y = v->range_y;
/* scale MV difference to be quad-pel */
@@ -2139,13 +2121,15 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
xy = s->block_index[0];
if (s->mb_intra) {
- s->current_picture.motion_val[0][xy + v->blocks_off][0] =
- s->current_picture.motion_val[0][xy + v->blocks_off][1] =
- s->current_picture.motion_val[1][xy + v->blocks_off][0] =
- s->current_picture.motion_val[1][xy + v->blocks_off][1] = 0;
+ s->current_picture.motion_val[0][xy][0] =
+ s->current_picture.motion_val[0][xy][1] =
+ s->current_picture.motion_val[1][xy][0] =
+ s->current_picture.motion_val[1][xy][1] = 0;
return;
}
- if (!v->field_mode) {
+ if (direct && s->next_picture_ptr->field_picture)
+ av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n");
+
s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample);
s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample);
s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample);
@@ -2156,12 +2140,11 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6));
s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6));
s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6));
- }
if (direct) {
- s->current_picture.motion_val[0][xy + v->blocks_off][0] = s->mv[0][0][0];
- s->current_picture.motion_val[0][xy + v->blocks_off][1] = s->mv[0][0][1];
- s->current_picture.motion_val[1][xy + v->blocks_off][0] = s->mv[1][0][0];
- s->current_picture.motion_val[1][xy + v->blocks_off][1] = s->mv[1][0][1];
+ s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0];
+ s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1];
+ s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0];
+ s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1];
return;
}
@@ -4356,6 +4339,10 @@ static void vc1_decode_b_mb_intfi(VC1Context *v)
if (bmvtype == BMV_TYPE_DIRECT) {
dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
+ if (!s->next_picture_ptr->field_picture) {
+ av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n");
+ return;
+ }
}
vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);
vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);
@@ -4463,6 +4450,8 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
direct = v->direct_mb_plane[mb_pos];
if (direct) {
+ if (s->next_picture_ptr->field_picture)
+ av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n");
s->mv[0][0][0] = s->current_picture.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample);
s->mv[0][0][1] = s->current_picture.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample);
s->mv[1][0][0] = s->current_picture.motion_val[1][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 1, s->quarter_sample);
@@ -5173,7 +5162,7 @@ static void vc1_decode_skip_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
- if (!v->s.last_picture.f.data[0])
+ if (!v->s.last_picture.f->data[0])
return;
ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
@@ -5182,9 +5171,9 @@ static void vc1_decode_skip_blocks(VC1Context *v)
s->mb_x = 0;
init_block_index(v);
ff_update_block_index(s);
- memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
- memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
- memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
+ memcpy(s->dest[0], s->last_picture.f->data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
+ memcpy(s->dest[1], s->last_picture.f->data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
+ memcpy(s->dest[2], s->last_picture.f->data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
@@ -5288,7 +5277,7 @@ static void vc1_sprite_parse_transform(GetBitContext* gb, int c[7])
c[6] = 1 << 16;
}
-static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd)
+static int vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd)
{
AVCodecContext *avctx = v->s.avctx;
int sprite, i;
@@ -5332,7 +5321,7 @@ static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd)
sd->effect_pcount2 = get_bits(gb, 16);
if (sd->effect_pcount2 > 10) {
av_log(avctx, AV_LOG_ERROR, "Too many effect parameters\n");
- return;
+ return AVERROR_INVALIDDATA;
} else if (sd->effect_pcount2) {
i = -1;
av_log(avctx, AV_LOG_DEBUG, "Effect params 2: ");
@@ -5349,10 +5338,14 @@ static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd)
av_log(avctx, AV_LOG_DEBUG, "Effect flag set\n");
if (get_bits_count(gb) >= gb->size_in_bits +
- (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE ? 64 : 0))
+ (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE ? 64 : 0)) {
av_log(avctx, AV_LOG_ERROR, "Buffer overrun\n");
+ return AVERROR_INVALIDDATA;
+ }
if (get_bits_count(gb) < gb->size_in_bits - 8)
av_log(avctx, AV_LOG_WARNING, "Buffer not fully read\n");
+
+ return 0;
}
static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
@@ -5364,7 +5357,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
int ysub[2];
MpegEncContext *s = &v->s;
- for (i = 0; i < 2; i++) {
+ for (i = 0; i <= v->two_sprites; i++) {
xoff[i] = av_clip(sd->coefs[i][2], 0, v->sprite_width-1 << 16);
xadv[i] = sd->coefs[i][0];
if (xadv[i] != 1<<16 || (v->sprite_width << 16) - (v->output_width << 16) - xoff[i])
@@ -5383,15 +5376,15 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
v->sprite_output_frame->linesize[plane] * row;
for (sprite = 0; sprite <= v->two_sprites; sprite++) {
- uint8_t *iplane = s->current_picture.f.data[plane];
- int iline = s->current_picture.f.linesize[plane];
+ uint8_t *iplane = s->current_picture.f->data[plane];
+ int iline = s->current_picture.f->linesize[plane];
int ycoord = yoff[sprite] + yadv[sprite] * row;
int yline = ycoord >> 16;
int next_line;
ysub[sprite] = ycoord & 0xFFFF;
if (sprite) {
- iplane = s->last_picture.f.data[plane];
- iline = s->last_picture.f.linesize[plane];
+ iplane = s->last_picture.f->data[plane];
+ iline = s->last_picture.f->linesize[plane];
}
next_line = FFMIN(yline + 1, (v->sprite_height >> !!plane) - 1) * iline;
if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
@@ -5442,7 +5435,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
}
if (!plane) {
- for (i = 0; i < 2; i++) {
+ for (i = 0; i <= v->two_sprites; i++) {
xoff[i] >>= 1;
yoff[i] >>= 1;
}
@@ -5459,14 +5452,18 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
AVCodecContext *avctx = s->avctx;
SpriteData sd;
- vc1_parse_sprites(v, gb, &sd);
+ memset(&sd, 0, sizeof(sd));
+
+ ret = vc1_parse_sprites(v, gb, &sd);
+ if (ret < 0)
+ return ret;
- if (!s->current_picture.f.data[0]) {
+ if (!s->current_picture.f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
return -1;
}
- if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f.data[0])) {
+ if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
v->two_sprites = 0;
}
@@ -5484,7 +5481,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
- AVFrame *f = &s->current_picture.f;
+ AVFrame *f = s->current_picture.f;
int plane, i;
/* Windows Media Image codecs have a convergence interval of two keyframes.
@@ -5504,14 +5501,15 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
{
MpegEncContext *s = &v->s;
int i;
+ int mb_height = FFALIGN(s->mb_height, 2);
/* Allocate mb bitplanes */
- v->mv_type_mb_plane = av_malloc (s->mb_stride * s->mb_height);
- v->direct_mb_plane = av_malloc (s->mb_stride * s->mb_height);
- v->forward_mb_plane = av_malloc (s->mb_stride * s->mb_height);
- v->fieldtx_plane = av_mallocz(s->mb_stride * s->mb_height);
- v->acpred_plane = av_malloc (s->mb_stride * s->mb_height);
- v->over_flags_plane = av_malloc (s->mb_stride * s->mb_height);
+ v->mv_type_mb_plane = av_malloc (s->mb_stride * mb_height);
+ v->direct_mb_plane = av_malloc (s->mb_stride * mb_height);
+ v->forward_mb_plane = av_malloc (s->mb_stride * mb_height);
+ v->fieldtx_plane = av_mallocz(s->mb_stride * mb_height);
+ v->acpred_plane = av_malloc (s->mb_stride * mb_height);
+ v->over_flags_plane = av_malloc (s->mb_stride * mb_height);
v->n_allocated_blks = s->mb_width + 2;
v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
@@ -5521,24 +5519,24 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
v->ttblk = v->ttblk_base + s->mb_stride;
v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
v->is_intra = v->is_intra_base + s->mb_stride;
- v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
+ v->luma_mv_base = av_mallocz(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
v->luma_mv = v->luma_mv_base + s->mb_stride;
/* allocate block type info in that way so it could be used with s->block_index[] */
- v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
+ v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
v->mb_type[0] = v->mb_type_base + s->b8_stride + 1;
- v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1;
- v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1);
+ v->mb_type[1] = v->mb_type_base + s->b8_stride * (mb_height * 2 + 1) + s->mb_stride + 1;
+ v->mb_type[2] = v->mb_type[1] + s->mb_stride * (mb_height + 1);
/* allocate memory to store block level MV info */
- v->blk_mv_type_base = av_mallocz( s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
+ v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1;
- v->mv_f_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
+ v->mv_f_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2));
v->mv_f[0] = v->mv_f_base + s->b8_stride + 1;
- v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
- v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
+ v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
+ v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2));
v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
- v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
+ v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2);
/* Init coded blocks info */
if (v->profile == PROFILE_ADVANCED) {
@@ -5608,13 +5606,10 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
if (!avctx->extradata_size || !avctx->extradata)
return -1;
if (!(avctx->flags & CODEC_FLAG_GRAY))
- avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
+ avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
- avctx->hwaccel = ff_find_hwaccel(avctx);
v->s.avctx = avctx;
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
- v->s.flags |= CODEC_FLAG_EMU_EDGE;
if ((ret = ff_vc1_init_common(v)) < 0)
return ret;
@@ -5629,7 +5624,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
ff_vc1_decode_end(avctx);
ff_h264chroma_init(&v->h264chroma, 8);
- ff_vc1dsp_init(&v->vc1dsp);
if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
int count = 0;
@@ -5805,7 +5799,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
/* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) {
- if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr = NULL;
@@ -5850,7 +5844,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start_second_field = start;
- tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
+ tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
@@ -5863,7 +5857,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
buf_size3 << 3);
/* assuming that the field marker is at the exact middle,
hope it's correct */
- slices[n_slices].mby_start = s->mb_height >> 1;
+ slices[n_slices].mby_start = s->mb_height + 1 >> 1;
n_slices1 = n_slices - 1; // index of the last slice of the first field
n_slices++;
break;
@@ -5875,7 +5869,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
break;
case VC1_CODE_SLICE: {
int buf_size3;
- tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
+ tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
@@ -5904,7 +5898,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start_second_field = divider;
- tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
+ tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
@@ -5914,7 +5908,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
- slices[n_slices].mby_start = s->mb_height >> 1;
+ slices[n_slices].mby_start = s->mb_height + 1 >> 1;
n_slices1 = n_slices - 1;
n_slices++;
}
@@ -5997,12 +5991,13 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
}
// for skipping the frame
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
+ s->current_picture.f->pict_type = s->pict_type;
+ s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->droppable)) {
- goto err;
+ av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n");
+ goto end;
}
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
@@ -6021,19 +6016,20 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
goto err;
}
- v->s.current_picture_ptr->f.interlaced_frame = (v->fcm != PROGRESSIVE);
- v->s.current_picture_ptr->f.top_field_first = v->tff;
+ v->s.current_picture_ptr->field_picture = v->field_mode;
+ v->s.current_picture_ptr->f->interlaced_frame = (v->fcm != PROGRESSIVE);
+ v->s.current_picture_ptr->f->top_field_first = v->tff;
// process pulldown flags
- s->current_picture_ptr->f.repeat_pict = 0;
+ s->current_picture_ptr->f->repeat_pict = 0;
// Pulldown flags are only valid when 'broadcast' has been set.
// So ticks_per_frame will be 2
if (v->rff) {
// repeat field
- s->current_picture_ptr->f.repeat_pict = 1;
+ s->current_picture_ptr->f->repeat_pict = 1;
} else if (v->rptfrm) {
// repeat frames
- s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
+ s->current_picture_ptr->f->repeat_pict = v->rptfrm * 2;
}
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
@@ -6067,7 +6063,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "parsing header for second field failed");
goto err;
}
- v->s.current_picture_ptr->f.pict_type = v->s.pict_type;
+ v->s.current_picture_ptr->f->pict_type = v->s.pict_type;
if (avctx->hwaccel->start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
goto err;
@@ -6092,9 +6088,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
v->bits = buf_size * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
- s->current_picture.f.linesize[0] <<= 1;
- s->current_picture.f.linesize[1] <<= 1;
- s->current_picture.f.linesize[2] <<= 1;
+ s->current_picture.f->linesize[0] <<= 1;
+ s->current_picture.f->linesize[1] <<= 1;
+ s->current_picture.f->linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
}
@@ -6111,6 +6107,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
continue;
}
v->second_field = 1;
+ av_assert0((s->mb_height & 1) == 0);
v->blocks_off = s->b8_stride * (s->mb_height&~1);
v->mb_off = s->mb_stride * s->mb_height >> 1;
} else {
@@ -6163,9 +6160,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
}
if (v->field_mode) {
v->second_field = 0;
- s->current_picture.f.linesize[0] >>= 1;
- s->current_picture.f.linesize[1] >>= 1;
- s->current_picture.f.linesize[2] >>= 1;
+ s->current_picture.f->linesize[0] >>= 1;
+ s->current_picture.f->linesize[1] >>= 1;
+ s->current_picture.f->linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
if (v->s.pict_type != AV_PICTURE_TYPE_BI && v->s.pict_type != AV_PICTURE_TYPE_B) {
@@ -6200,12 +6197,12 @@ image:
*got_frame = 1;
} else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
goto err;
ff_print_debug_info(s, s->current_picture_ptr, pict);
*got_frame = 1;
} else if (s->last_picture_ptr != NULL) {
- if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
goto err;
ff_print_debug_info(s, s->last_picture_ptr, pict);
*got_frame = 1;
@@ -6237,13 +6234,13 @@ static const AVProfile profiles[] = {
};
static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_DXVA2
+#if CONFIG_VC1_DXVA2_HWACCEL
AV_PIX_FMT_DXVA2_VLD,
#endif
-#if CONFIG_VAAPI
+#if CONFIG_VC1_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI_VLD,
#endif
-#if CONFIG_VDPAU
+#if CONFIG_VC1_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU,
#endif
AV_PIX_FMT_YUV420P,
@@ -6326,7 +6323,10 @@ AVCodec ff_wmv3image_decoder = {
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1,
.flush = vc1_sprite_flush,
- .pix_fmts = ff_pixfmt_list_420
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
#endif
@@ -6342,6 +6342,9 @@ AVCodec ff_vc1image_decoder = {
.decode = vc1_decode_frame,
.capabilities = CODEC_CAP_DR1,
.flush = vc1_sprite_flush,
- .pix_fmts = ff_pixfmt_list_420
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1dsp.c b/chromium/third_party/ffmpeg/libavcodec/vc1dsp.c
index aab9d1aa6d5..787a6a63986 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1dsp.c
@@ -20,79 +20,79 @@
*/
/**
-* @file
+ * @file
* VC-1 and WMV3 decoder
*
*/
#include "libavutil/avassert.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+#include "dsputil.h"
#include "h264chroma.h"
#include "rnd_avg.h"
#include "vc1dsp.h"
+#include "startcode.h"
-
-/** Apply overlap transform to horizontal edge
-*/
-static void vc1_v_overlap_c(uint8_t* src, int stride)
+/* Apply overlap transform to horizontal edge */
+static void vc1_v_overlap_c(uint8_t *src, int stride)
{
int i;
int a, b, c, d;
int d1, d2;
int rnd = 1;
- for(i = 0; i < 8; i++) {
- a = src[-2*stride];
- b = src[-stride];
- c = src[0];
- d = src[stride];
+ for (i = 0; i < 8; i++) {
+ a = src[-2 * stride];
+ b = src[-stride];
+ c = src[0];
+ d = src[stride];
d1 = (a - d + 3 + rnd) >> 3;
d2 = (a - d + b - c + 4 - rnd) >> 3;
- src[-2*stride] = a - d1;
- src[-stride] = av_clip_uint8(b - d2);
- src[0] = av_clip_uint8(c + d2);
- src[stride] = d + d1;
+ src[-2 * stride] = a - d1;
+ src[-stride] = av_clip_uint8(b - d2);
+ src[0] = av_clip_uint8(c + d2);
+ src[stride] = d + d1;
src++;
rnd = !rnd;
}
}
-/** Apply overlap transform to vertical edge
-*/
-static void vc1_h_overlap_c(uint8_t* src, int stride)
+/* Apply overlap transform to vertical edge */
+static void vc1_h_overlap_c(uint8_t *src, int stride)
{
int i;
int a, b, c, d;
int d1, d2;
int rnd = 1;
- for(i = 0; i < 8; i++) {
- a = src[-2];
- b = src[-1];
- c = src[0];
- d = src[1];
+ for (i = 0; i < 8; i++) {
+ a = src[-2];
+ b = src[-1];
+ c = src[0];
+ d = src[1];
d1 = (a - d + 3 + rnd) >> 3;
d2 = (a - d + b - c + 4 - rnd) >> 3;
src[-2] = a - d1;
src[-1] = av_clip_uint8(b - d2);
- src[0] = av_clip_uint8(c + d2);
- src[1] = d + d1;
- src += stride;
- rnd = !rnd;
+ src[0] = av_clip_uint8(c + d2);
+ src[1] = d + d1;
+ src += stride;
+ rnd = !rnd;
}
}
-static void vc1_v_s_overlap_c(int16_t *top, int16_t *bottom)
+static void vc1_v_s_overlap_c(int16_t *top, int16_t *bottom)
{
int i;
int a, b, c, d;
int d1, d2;
int rnd1 = 4, rnd2 = 3;
- for(i = 0; i < 8; i++) {
- a = top[48];
- b = top[56];
- c = bottom[0];
- d = bottom[8];
+ for (i = 0; i < 8; i++) {
+ a = top[48];
+ b = top[56];
+ c = bottom[0];
+ d = bottom[8];
d1 = a - d;
d2 = a - d + b - c;
@@ -114,11 +114,11 @@ static void vc1_h_s_overlap_c(int16_t *left, int16_t *right)
int a, b, c, d;
int d1, d2;
int rnd1 = 4, rnd2 = 3;
- for(i = 0; i < 8; i++) {
- a = left[6];
- b = left[7];
- c = right[0];
- d = right[1];
+ for (i = 0; i < 8; i++) {
+ a = left[6];
+ b = left[7];
+ c = right[0];
+ d = right[1];
d1 = a - d;
d2 = a - d + b - c;
@@ -128,9 +128,9 @@ static void vc1_h_s_overlap_c(int16_t *left, int16_t *right)
right[1] = ((d << 3) + d1 + rnd2) >> 3;
right += 8;
- left += 8;
- rnd2 = 7 - rnd2;
- rnd1 = 7 - rnd1;
+ left += 8;
+ rnd2 = 7 - rnd2;
+ rnd1 = 7 - rnd1;
}
}
@@ -142,31 +142,38 @@ static void vc1_h_s_overlap_c(int16_t *left, int16_t *right)
* @return whether other 3 pairs should be filtered or not
* @see 8.6
*/
-static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
- int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
+static av_always_inline int vc1_filter_line(uint8_t *src, int stride, int pq)
+{
+ int a0 = (2 * (src[-2 * stride] - src[1 * stride]) -
+ 5 * (src[-1 * stride] - src[0 * stride]) + 4) >> 3;
int a0_sign = a0 >> 31; /* Store sign */
+
a0 = (a0 ^ a0_sign) - a0_sign; /* a0 = FFABS(a0); */
- if(a0 < pq){
- int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
- int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
- if(a1 < a0 || a2 < a0){
- int clip = src[-1*stride] - src[ 0*stride];
+ if (a0 < pq) {
+ int a1 = FFABS((2 * (src[-4 * stride] - src[-1 * stride]) -
+ 5 * (src[-3 * stride] - src[-2 * stride]) + 4) >> 3);
+ int a2 = FFABS((2 * (src[ 0 * stride] - src[ 3 * stride]) -
+ 5 * (src[ 1 * stride] - src[ 2 * stride]) + 4) >> 3);
+ if (a1 < a0 || a2 < a0) {
+ int clip = src[-1 * stride] - src[0 * stride];
int clip_sign = clip >> 31;
- clip = ((clip ^ clip_sign) - clip_sign)>>1;
- if(clip){
- int a3 = FFMIN(a1, a2);
- int d = 5 * (a3 - a0);
+
+ clip = ((clip ^ clip_sign) - clip_sign) >> 1;
+ if (clip) {
+ int a3 = FFMIN(a1, a2);
+ int d = 5 * (a3 - a0);
int d_sign = (d >> 31);
- d = ((d ^ d_sign) - d_sign) >> 3;
+
+ d = ((d ^ d_sign) - d_sign) >> 3;
d_sign ^= a0_sign;
- if( d_sign ^ clip_sign )
+ if (d_sign ^ clip_sign)
d = 0;
- else{
+ else {
d = FFMIN(d, clip);
- d = (d ^ d_sign) - d_sign; /* Restore sign */
- src[-1*stride] = av_clip_uint8(src[-1*stride] - d);
- src[ 0*stride] = av_clip_uint8(src[ 0*stride] + d);
+ d = (d ^ d_sign) - d_sign; /* Restore sign */
+ src[-1 * stride] = av_clip_uint8(src[-1 * stride] - d);
+ src[ 0 * stride] = av_clip_uint8(src[ 0 * stride] + d);
}
return 1;
}
@@ -184,17 +191,18 @@ static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
* @param pq block quantizer
* @see 8.6
*/
-static inline void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq)
+static inline void vc1_loop_filter(uint8_t *src, int step, int stride,
+ int len, int pq)
{
int i;
int filt3;
- for(i = 0; i < len; i += 4){
- filt3 = vc1_filter_line(src + 2*step, stride, pq);
- if(filt3){
- vc1_filter_line(src + 0*step, stride, pq);
- vc1_filter_line(src + 1*step, stride, pq);
- vc1_filter_line(src + 3*step, stride, pq);
+ for (i = 0; i < len; i += 4) {
+ filt3 = vc1_filter_line(src + 2 * step, stride, pq);
+ if (filt3) {
+ vc1_filter_line(src + 0 * step, stride, pq);
+ vc1_filter_line(src + 1 * step, stride, pq);
+ vc1_filter_line(src + 3 * step, stride, pq);
}
src += step * 4;
}
@@ -230,15 +238,16 @@ static void vc1_h_loop_filter16_c(uint8_t *src, int stride, int pq)
vc1_loop_filter(src, stride, 1, 16, pq);
}
-/** Do inverse transform on 8x8 block
-*/
+/* Do inverse transform on 8x8 block */
static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
+
dc = (3 * dc + 1) >> 1;
dc = (3 * dc + 16) >> 5;
- for(i = 0; i < 8; i++){
+
+ for (i = 0; i < 8; i++) {
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
@@ -254,12 +263,12 @@ static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
static void vc1_inv_trans_8x8_c(int16_t block[64])
{
int i;
- register int t1,t2,t3,t4,t5,t6,t7,t8;
+ register int t1, t2, t3, t4, t5, t6, t7, t8;
int16_t *src, *dst, temp[64];
src = block;
dst = temp;
- for(i = 0; i < 8; i++){
+ for (i = 0; i < 8; i++) {
t1 = 12 * (src[ 0] + src[32]) + 4;
t2 = 12 * (src[ 0] - src[32]) + 4;
t3 = 16 * src[16] + 6 * src[48];
@@ -290,7 +299,7 @@ static void vc1_inv_trans_8x8_c(int16_t block[64])
src = temp;
dst = block;
- for(i = 0; i < 8; i++){
+ for (i = 0; i < 8; i++) {
t1 = 12 * (src[ 0] + src[32]) + 64;
t2 = 12 * (src[ 0] - src[32]) + 64;
t3 = 16 * src[16] + 6 * src[48];
@@ -320,15 +329,16 @@ static void vc1_inv_trans_8x8_c(int16_t block[64])
}
}
-/** Do inverse transform on 8x4 part of block
-*/
+/* Do inverse transform on 8x4 part of block */
static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
- dc = ( 3 * dc + 1) >> 1;
+
+ dc = (3 * dc + 1) >> 1;
dc = (17 * dc + 64) >> 7;
- for(i = 0; i < 4; i++){
+
+ for (i = 0; i < 4; i++) {
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
@@ -344,12 +354,13 @@ static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
- register int t1,t2,t3,t4,t5,t6,t7,t8;
+ register int t1, t2, t3, t4, t5, t6, t7, t8;
int16_t *src, *dst;
src = block;
dst = block;
- for(i = 0; i < 4; i++){
+
+ for (i = 0; i < 4; i++) {
t1 = 12 * (src[0] + src[4]) + 4;
t2 = 12 * (src[0] - src[4]) + 4;
t3 = 16 * src[2] + 6 * src[6];
@@ -379,31 +390,32 @@ static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, int16_t *block)
}
src = block;
- for(i = 0; i < 8; i++){
+ for (i = 0; i < 8; i++) {
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
- dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t1 + t3) >> 7));
- dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t2 - t4) >> 7));
- dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t2 + t4) >> 7));
- dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t1 - t3) >> 7));
+ dest[0 * linesize] = av_clip_uint8(dest[0 * linesize] + ((t1 + t3) >> 7));
+ dest[1 * linesize] = av_clip_uint8(dest[1 * linesize] + ((t2 - t4) >> 7));
+ dest[2 * linesize] = av_clip_uint8(dest[2 * linesize] + ((t2 + t4) >> 7));
+ dest[3 * linesize] = av_clip_uint8(dest[3 * linesize] + ((t1 - t3) >> 7));
- src ++;
+ src++;
dest++;
}
}
-/** Do inverse transform on 4x8 parts of block
-*/
+/* Do inverse transform on 4x8 parts of block */
static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
+
dc = (17 * dc + 4) >> 3;
dc = (12 * dc + 64) >> 7;
- for(i = 0; i < 8; i++){
+
+ for (i = 0; i < 8; i++) {
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
@@ -415,12 +427,13 @@ static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
- register int t1,t2,t3,t4,t5,t6,t7,t8;
+ register int t1, t2, t3, t4, t5, t6, t7, t8;
int16_t *src, *dst;
src = block;
dst = block;
- for(i = 0; i < 8; i++){
+
+ for (i = 0; i < 8; i++) {
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
@@ -436,7 +449,7 @@ static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, int16_t *block)
}
src = block;
- for(i = 0; i < 4; i++){
+ for (i = 0; i < 4; i++) {
t1 = 12 * (src[ 0] + src[32]) + 64;
t2 = 12 * (src[ 0] - src[32]) + 64;
t3 = 16 * src[16] + 6 * src[48];
@@ -452,29 +465,30 @@ static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, int16_t *block)
t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
- dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t5 + t1) >> 7));
- dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t6 + t2) >> 7));
- dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t7 + t3) >> 7));
- dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t8 + t4) >> 7));
- dest[4*linesize] = av_clip_uint8(dest[4*linesize] + ((t8 - t4 + 1) >> 7));
- dest[5*linesize] = av_clip_uint8(dest[5*linesize] + ((t7 - t3 + 1) >> 7));
- dest[6*linesize] = av_clip_uint8(dest[6*linesize] + ((t6 - t2 + 1) >> 7));
- dest[7*linesize] = av_clip_uint8(dest[7*linesize] + ((t5 - t1 + 1) >> 7));
+ dest[0 * linesize] = av_clip_uint8(dest[0 * linesize] + ((t5 + t1) >> 7));
+ dest[1 * linesize] = av_clip_uint8(dest[1 * linesize] + ((t6 + t2) >> 7));
+ dest[2 * linesize] = av_clip_uint8(dest[2 * linesize] + ((t7 + t3) >> 7));
+ dest[3 * linesize] = av_clip_uint8(dest[3 * linesize] + ((t8 + t4) >> 7));
+ dest[4 * linesize] = av_clip_uint8(dest[4 * linesize] + ((t8 - t4 + 1) >> 7));
+ dest[5 * linesize] = av_clip_uint8(dest[5 * linesize] + ((t7 - t3 + 1) >> 7));
+ dest[6 * linesize] = av_clip_uint8(dest[6 * linesize] + ((t6 - t2 + 1) >> 7));
+ dest[7 * linesize] = av_clip_uint8(dest[7 * linesize] + ((t5 - t1 + 1) >> 7));
- src ++;
+ src++;
dest++;
}
}
-/** Do inverse transform on 4x4 part of block
-*/
+/* Do inverse transform on 4x4 part of block */
static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
+
dc = (17 * dc + 4) >> 3;
dc = (17 * dc + 64) >> 7;
- for(i = 0; i < 4; i++){
+
+ for (i = 0; i < 4; i++) {
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
@@ -486,12 +500,12 @@ static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
- register int t1,t2,t3,t4;
+ register int t1, t2, t3, t4;
int16_t *src, *dst;
src = block;
dst = block;
- for(i = 0; i < 4; i++){
+ for (i = 0; i < 4; i++) {
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
@@ -507,117 +521,186 @@ static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, int16_t *block)
}
src = block;
- for(i = 0; i < 4; i++){
- t1 = 17 * (src[ 0] + src[16]) + 64;
- t2 = 17 * (src[ 0] - src[16]) + 64;
- t3 = 22 * src[ 8] + 10 * src[24];
- t4 = 22 * src[24] - 10 * src[ 8];
+ for (i = 0; i < 4; i++) {
+ t1 = 17 * (src[0] + src[16]) + 64;
+ t2 = 17 * (src[0] - src[16]) + 64;
+ t3 = 22 * src[8] + 10 * src[24];
+ t4 = 22 * src[24] - 10 * src[8];
- dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t1 + t3) >> 7));
- dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t2 - t4) >> 7));
- dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t2 + t4) >> 7));
- dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t1 - t3) >> 7));
+ dest[0 * linesize] = av_clip_uint8(dest[0 * linesize] + ((t1 + t3) >> 7));
+ dest[1 * linesize] = av_clip_uint8(dest[1 * linesize] + ((t2 - t4) >> 7));
+ dest[2 * linesize] = av_clip_uint8(dest[2 * linesize] + ((t2 + t4) >> 7));
+ dest[3 * linesize] = av_clip_uint8(dest[3 * linesize] + ((t1 - t3) >> 7));
- src ++;
+ src++;
dest++;
}
}
/* motion compensation functions */
-/** Filter in case of 2 filters */
-#define VC1_MSPEL_FILTER_16B(DIR, TYPE) \
-static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
-{ \
- switch(mode){ \
- case 0: /* no shift - should not occur */ \
- return 0; \
- case 1: /* 1/4 shift */ \
- return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
- case 2: /* 1/2 shift */ \
- return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
- case 3: /* 3/4 shift */ \
- return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
- } \
- return 0; /* should not occur */ \
+
+/* Filter in case of 2 filters */
+#define VC1_MSPEL_FILTER_16B(DIR, TYPE) \
+static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, \
+ int stride, \
+ int mode) \
+{ \
+ switch(mode) { \
+ case 0: /* no shift - should not occur */ \
+ return 0; \
+ case 1: /* 1/4 shift */ \
+ return -4 * src[-stride] + 53 * src[0] + \
+ 18 * src[stride] - 3 * src[stride * 2]; \
+ case 2: /* 1/2 shift */ \
+ return -1 * src[-stride] + 9 * src[0] + \
+ 9 * src[stride] - 1 * src[stride * 2]; \
+ case 3: /* 3/4 shift */ \
+ return -3 * src[-stride] + 18 * src[0] + \
+ 53 * src[stride] - 4 * src[stride * 2]; \
+ } \
+ return 0; /* should not occur */ \
}
VC1_MSPEL_FILTER_16B(ver, uint8_t)
VC1_MSPEL_FILTER_16B(hor, int16_t)
-
-/** Filter used to interpolate fractional pel values
- */
-static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
+/* Filter used to interpolate fractional pel values */
+static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride,
+ int mode, int r)
{
- switch(mode){
- case 0: //no shift
+ switch (mode) {
+ case 0: // no shift
return src[0];
case 1: // 1/4 shift
- return (-4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2] + 32 - r) >> 6;
+ return (-4 * src[-stride] + 53 * src[0] +
+ 18 * src[stride] - 3 * src[stride * 2] + 32 - r) >> 6;
case 2: // 1/2 shift
- return (-src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2] + 8 - r) >> 4;
+ return (-1 * src[-stride] + 9 * src[0] +
+ 9 * src[stride] - 1 * src[stride * 2] + 8 - r) >> 4;
case 3: // 3/4 shift
- return (-3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2] + 32 - r) >> 6;
+ return (-3 * src[-stride] + 18 * src[0] +
+ 53 * src[stride] - 4 * src[stride * 2] + 32 - r) >> 6;
}
- return 0; //should not occur
+ return 0; // should not occur
}
-/** Function used to do motion compensation with bicubic interpolation
- */
-#define VC1_MSPEL_MC(OP, OP4, OPNAME)\
-static av_always_inline void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int hmode, int vmode, int rnd)\
-{\
- int i, j;\
-\
- if (vmode) { /* Horizontal filter to apply */\
- int r;\
-\
- if (hmode) { /* Vertical filter to apply, output to tmp */\
- static const int shift_value[] = { 0, 5, 1, 5 };\
- int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
- int16_t tmp[11*8], *tptr = tmp;\
-\
- r = (1<<(shift-1)) + rnd-1;\
-\
- src -= 1;\
- for(j = 0; j < 8; j++) {\
- for(i = 0; i < 11; i++)\
- tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;\
- src += stride;\
- tptr += 11;\
- }\
-\
- r = 64-rnd;\
- tptr = tmp+1;\
- for(j = 0; j < 8; j++) {\
- for(i = 0; i < 8; i++)\
- OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);\
- dst += stride;\
- tptr += 11;\
- }\
-\
- return;\
- }\
- else { /* No horizontal filter, output 8 lines to dst */\
- r = 1-rnd;\
-\
- for(j = 0; j < 8; j++) {\
- for(i = 0; i < 8; i++)\
- OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r));\
- src += stride;\
- dst += stride;\
- }\
- return;\
- }\
- }\
-\
- /* Horizontal mode with no vertical mode */\
- for(j = 0; j < 8; j++) {\
- for(i = 0; i < 8; i++)\
- OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd));\
- dst += stride;\
- src += stride;\
- }\
+/* Function used to do motion compensation with bicubic interpolation */
+#define VC1_MSPEL_MC(OP, OP4, OPNAME) \
+static av_always_inline void OPNAME ## vc1_mspel_mc(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, \
+ int hmode, \
+ int vmode, \
+ int rnd) \
+{ \
+ int i, j; \
+ \
+ if (vmode) { /* Horizontal filter to apply */ \
+ int r; \
+ \
+ if (hmode) { /* Vertical filter to apply, output to tmp */ \
+ static const int shift_value[] = { 0, 5, 1, 5 }; \
+ int shift = (shift_value[hmode] + shift_value[vmode]) >> 1; \
+ int16_t tmp[11 * 8], *tptr = tmp; \
+ \
+ r = (1 << (shift - 1)) + rnd - 1; \
+ \
+ src -= 1; \
+ for (j = 0; j < 8; j++) { \
+ for (i = 0; i < 11; i++) \
+ tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode) + r) >> shift; \
+ src += stride; \
+ tptr += 11; \
+ } \
+ \
+ r = 64 - rnd; \
+ tptr = tmp + 1; \
+ for (j = 0; j < 8; j++) { \
+ for (i = 0; i < 8; i++) \
+ OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode) + r) >> 7); \
+ dst += stride; \
+ tptr += 11; \
+ } \
+ \
+ return; \
+ } else { /* No horizontal filter, output 8 lines to dst */ \
+ r = 1 - rnd; \
+ \
+ for (j = 0; j < 8; j++) { \
+ for (i = 0; i < 8; i++) \
+ OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r)); \
+ src += stride; \
+ dst += stride; \
+ } \
+ return; \
+ } \
+ } \
+ \
+ /* Horizontal mode with no vertical mode */ \
+ for (j = 0; j < 8; j++) { \
+ for (i = 0; i < 8; i++) \
+ OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd)); \
+ dst += stride; \
+ src += stride; \
+ } \
+}\
+static av_always_inline void OPNAME ## vc1_mspel_mc_16(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, \
+ int hmode, \
+ int vmode, \
+ int rnd) \
+{ \
+ int i, j; \
+ \
+ if (vmode) { /* Horizontal filter to apply */ \
+ int r; \
+ \
+ if (hmode) { /* Vertical filter to apply, output to tmp */ \
+ static const int shift_value[] = { 0, 5, 1, 5 }; \
+ int shift = (shift_value[hmode] + shift_value[vmode]) >> 1; \
+ int16_t tmp[19 * 16], *tptr = tmp; \
+ \
+ r = (1 << (shift - 1)) + rnd - 1; \
+ \
+ src -= 1; \
+ for (j = 0; j < 16; j++) { \
+ for (i = 0; i < 19; i++) \
+ tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode) + r) >> shift; \
+ src += stride; \
+ tptr += 19; \
+ } \
+ \
+ r = 64 - rnd; \
+ tptr = tmp + 1; \
+ for (j = 0; j < 16; j++) { \
+ for (i = 0; i < 16; i++) \
+ OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode) + r) >> 7); \
+ dst += stride; \
+ tptr += 19; \
+ } \
+ \
+ return; \
+ } else { /* No horizontal filter, output 8 lines to dst */ \
+ r = 1 - rnd; \
+ \
+ for (j = 0; j < 16; j++) { \
+ for (i = 0; i < 16; i++) \
+ OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r)); \
+ src += stride; \
+ dst += stride; \
+ } \
+ return; \
+ } \
+ } \
+ \
+ /* Horizontal mode with no vertical mode */ \
+ for (j = 0; j < 16; j++) { \
+ for (i = 0; i < 16; i++) \
+ OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd)); \
+ dst += stride; \
+ src += stride; \
+ } \
}\
static void OPNAME ## pixels8x8_c(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int rnd){\
int i;\
@@ -627,6 +710,17 @@ static void OPNAME ## pixels8x8_c(uint8_t *block, const uint8_t *pixels, ptrdiff
pixels+=line_size;\
block +=line_size;\
}\
+}\
+static void OPNAME ## pixels16x16_c(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int rnd){\
+ int i;\
+ for(i=0; i<16; i++){\
+ OP4(*(uint32_t*)(block ), AV_RN32(pixels ));\
+ OP4(*(uint32_t*)(block+ 4), AV_RN32(pixels+ 4));\
+ OP4(*(uint32_t*)(block+ 8), AV_RN32(pixels+ 8));\
+ OP4(*(uint32_t*)(block+12), AV_RN32(pixels+12));\
+ pixels+=line_size;\
+ block +=line_size;\
+ }\
}
#define op_put(a, b) a = av_clip_uint8(b)
@@ -639,18 +733,30 @@ VC1_MSPEL_MC(op_avg, op4_avg, avg_)
/* pixel functions - really are entry points to vc1_mspel_mc */
-#define PUT_VC1_MSPEL(a, b)\
-static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, \
- const uint8_t *src, \
- ptrdiff_t stride, int rnd) \
-{ \
- put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
-} \
-static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, \
- const uint8_t *src, \
- ptrdiff_t stride, int rnd) \
-{ \
- avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+#define PUT_VC1_MSPEL(a, b) \
+static void put_vc1_mspel_mc ## a ## b ## _c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+} \
+static void avg_vc1_mspel_mc ## a ## b ## _c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+} \
+static void put_vc1_mspel_mc ## a ## b ## _16_c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ put_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
+} \
+static void avg_vc1_mspel_mc ## a ## b ## _16_c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ avg_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
}
PUT_VC1_MSPEL(1, 0)
@@ -672,110 +778,128 @@ PUT_VC1_MSPEL(1, 3)
PUT_VC1_MSPEL(2, 3)
PUT_VC1_MSPEL(3, 3)
-static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
+#define chroma_mc(a) \
+ ((A * src[a] + B * src[a + 1] + \
+ C * src[stride + a] + D * src[stride + a + 1] + 32 - 4) >> 6)
+static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
+ uint8_t *src /* align 1 */,
+ int stride, int h, int x, int y)
+{
+ const int A = (8 - x) * (8 - y);
+ const int B = (x) * (8 - y);
+ const int C = (8 - x) * (y);
+ const int D = (x) * (y);
int i;
- av_assert2(x<8 && y<8 && x>=0 && y>=0);
-
- for(i=0; i<h; i++)
- {
- dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
- dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
- dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
- dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
- dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
- dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
- dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
- dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
- dst+= stride;
- src+= stride;
+ av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
+
+ for (i = 0; i < h; i++) {
+ dst[0] = chroma_mc(0);
+ dst[1] = chroma_mc(1);
+ dst[2] = chroma_mc(2);
+ dst[3] = chroma_mc(3);
+ dst[4] = chroma_mc(4);
+ dst[5] = chroma_mc(5);
+ dst[6] = chroma_mc(6);
+ dst[7] = chroma_mc(7);
+ dst += stride;
+ src += stride;
}
}
-static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
+static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y)
+{
+ const int A = (8 - x) * (8 - y);
+ const int B = (x) * (8 - y);
+ const int C = (8 - x) * (y);
+ const int D = (x) * (y);
int i;
- av_assert2(x<8 && y<8 && x>=0 && y>=0);
+ av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
- for(i=0; i<h; i++)
- {
- dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
- dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
- dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
- dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
- dst+= stride;
- src+= stride;
+ for (i = 0; i < h; i++) {
+ dst[0] = chroma_mc(0);
+ dst[1] = chroma_mc(1);
+ dst[2] = chroma_mc(2);
+ dst[3] = chroma_mc(3);
+ dst += stride;
+ src += stride;
}
}
-#define avg2(a,b) ((a+b+1)>>1)
-static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
+#define avg2(a, b) (((a) + (b) + 1) >> 1)
+static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
+ uint8_t *src /* align 1 */,
+ int stride, int h, int x, int y)
+{
+ const int A = (8 - x) * (8 - y);
+ const int B = (x) * (8 - y);
+ const int C = (8 - x) * (y);
+ const int D = (x) * (y);
int i;
- av_assert2(x<8 && y<8 && x>=0 && y>=0);
-
- for(i=0; i<h; i++)
- {
- dst[0] = avg2(dst[0], ((A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6));
- dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
- dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
- dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
- dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6));
- dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6));
- dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6));
- dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6));
- dst+= stride;
- src+= stride;
+ av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
+
+ for (i = 0; i < h; i++) {
+ dst[0] = avg2(dst[0], chroma_mc(0));
+ dst[1] = avg2(dst[1], chroma_mc(1));
+ dst[2] = avg2(dst[2], chroma_mc(2));
+ dst[3] = avg2(dst[3], chroma_mc(3));
+ dst[4] = avg2(dst[4], chroma_mc(4));
+ dst[5] = avg2(dst[5], chroma_mc(5));
+ dst[6] = avg2(dst[6], chroma_mc(6));
+ dst[7] = avg2(dst[7], chroma_mc(7));
+ dst += stride;
+ src += stride;
}
}
-static void avg_no_rnd_vc1_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
- const int A=(8-x)*(8-y);
- const int B=( x)*(8-y);
- const int C=(8-x)*( y);
- const int D=( x)*( y);
+static void avg_no_rnd_vc1_chroma_mc4_c(uint8_t *dst /* align 8 */,
+ uint8_t *src /* align 1 */,
+ int stride, int h, int x, int y)
+{
+ const int A = (8 - x) * (8 - y);
+ const int B = ( x) * (8 - y);
+ const int C = (8 - x) * ( y);
+ const int D = ( x) * ( y);
int i;
- av_assert2(x<8 && y<8 && x>=0 && y>=0);
+ av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
- for(i=0; i<h; i++)
- {
- dst[0] = avg2(dst[0], ((A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6));
- dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
- dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
- dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
- dst+= stride;
- src+= stride;
+ for (i = 0; i < h; i++) {
+ dst[0] = avg2(dst[0], chroma_mc(0));
+ dst[1] = avg2(dst[1], chroma_mc(1));
+ dst[2] = avg2(dst[2], chroma_mc(2));
+ dst[3] = avg2(dst[3], chroma_mc(3));
+ dst += stride;
+ src += stride;
}
}
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
-static void sprite_h_c(uint8_t *dst, const uint8_t *src, int offset, int advance, int count)
+static void sprite_h_c(uint8_t *dst, const uint8_t *src, int offset,
+ int advance, int count)
{
while (count--) {
- int a = src[(offset >> 16) ];
+ int a = src[(offset >> 16)];
int b = src[(offset >> 16) + 1];
- *dst++ = a + ((b - a) * (offset&0xFFFF) >> 16);
+ *dst++ = a + ((b - a) * (offset & 0xFFFF) >> 16);
offset += advance;
}
}
-static av_always_inline void sprite_v_template(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
- int two_sprites, const uint8_t *src2a, const uint8_t *src2b, int offset2,
- int alpha, int scaled, int width)
+static av_always_inline void sprite_v_template(uint8_t *dst,
+ const uint8_t *src1a,
+ const uint8_t *src1b,
+ int offset1,
+ int two_sprites,
+ const uint8_t *src2a,
+ const uint8_t *src2b,
+ int offset2,
+ int alpha, int scaled,
+ int width)
{
int a1, b1, a2, b2;
while (width--) {
@@ -796,98 +920,117 @@ static av_always_inline void sprite_v_template(uint8_t *dst, const uint8_t *src1
}
}
-static void sprite_v_single_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset, int width)
+static void sprite_v_single_c(uint8_t *dst, const uint8_t *src1a,
+ const uint8_t *src1b,
+ int offset, int width)
{
sprite_v_template(dst, src1a, src1b, offset, 0, NULL, NULL, 0, 0, 1, width);
}
-static void sprite_v_double_noscale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src2a, int alpha, int width)
+static void sprite_v_double_noscale_c(uint8_t *dst, const uint8_t *src1a,
+ const uint8_t *src2a,
+ int alpha, int width)
{
sprite_v_template(dst, src1a, NULL, 0, 1, src2a, NULL, 0, alpha, 0, width);
}
-static void sprite_v_double_onescale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
- const uint8_t *src2a, int alpha, int width)
+static void sprite_v_double_onescale_c(uint8_t *dst,
+ const uint8_t *src1a,
+ const uint8_t *src1b,
+ int offset1,
+ const uint8_t *src2a,
+ int alpha, int width)
{
- sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, NULL, 0, alpha, 1, width);
+ sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, NULL, 0, alpha, 1,
+ width);
}
-static void sprite_v_double_twoscale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
- const uint8_t *src2a, const uint8_t *src2b, int offset2,
- int alpha, int width)
+static void sprite_v_double_twoscale_c(uint8_t *dst,
+ const uint8_t *src1a,
+ const uint8_t *src1b,
+ int offset1,
+ const uint8_t *src2a,
+ const uint8_t *src2b,
+ int offset2,
+ int alpha,
+ int width)
{
- sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, src2b, offset2, alpha, 2, width);
+ sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, src2b, offset2,
+ alpha, 2, width);
}
-#endif
+#endif /* CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER */
+#define FN_ASSIGN(X, Y) \
+ dsp->put_vc1_mspel_pixels_tab[1][X+4*Y] = put_vc1_mspel_mc##X##Y##_c; \
+ dsp->put_vc1_mspel_pixels_tab[0][X+4*Y] = put_vc1_mspel_mc##X##Y##_16_c; \
+ dsp->avg_vc1_mspel_pixels_tab[1][X+4*Y] = avg_vc1_mspel_mc##X##Y##_c; \
+ dsp->avg_vc1_mspel_pixels_tab[0][X+4*Y] = avg_vc1_mspel_mc##X##Y##_16_c
-av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) {
- dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
- dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
- dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
- dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
+av_cold void ff_vc1dsp_init(VC1DSPContext *dsp)
+{
+ dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
+ dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
+ dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
+ dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_c;
dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_c;
dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_c;
dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_c;
- dsp->vc1_h_overlap = vc1_h_overlap_c;
- dsp->vc1_v_overlap = vc1_v_overlap_c;
- dsp->vc1_h_s_overlap = vc1_h_s_overlap_c;
- dsp->vc1_v_s_overlap = vc1_v_s_overlap_c;
- dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
- dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
- dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
- dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c;
- dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
- dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
-
- dsp->put_vc1_mspel_pixels_tab[ 0] = put_pixels8x8_c;
- dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
- dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
- dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
- dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_c;
- dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_c;
- dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_c;
- dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_c;
- dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_c;
- dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_c;
- dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_c;
- dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
- dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
- dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
- dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
- dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
-
- dsp->avg_vc1_mspel_pixels_tab[ 0] = avg_pixels8x8_c;
- dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
- dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
- dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
- dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_c;
- dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_c;
- dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_c;
- dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_c;
- dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_c;
- dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_c;
- dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_c;
- dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_c;
- dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_c;
- dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
- dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
- dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
-
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
+
+ dsp->vc1_h_overlap = vc1_h_overlap_c;
+ dsp->vc1_v_overlap = vc1_v_overlap_c;
+ dsp->vc1_h_s_overlap = vc1_h_s_overlap_c;
+ dsp->vc1_v_s_overlap = vc1_v_s_overlap_c;
+
+ dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
+ dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
+ dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
+ dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c;
+ dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
+ dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
+
+ dsp->put_vc1_mspel_pixels_tab[0][0] = put_pixels16x16_c;
+ dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_pixels16x16_c;
+ dsp->put_vc1_mspel_pixels_tab[1][0] = put_pixels8x8_c;
+ dsp->avg_vc1_mspel_pixels_tab[1][0] = avg_pixels8x8_c;
+ FN_ASSIGN(0, 1);
+ FN_ASSIGN(0, 2);
+ FN_ASSIGN(0, 3);
+
+ FN_ASSIGN(1, 0);
+ FN_ASSIGN(1, 1);
+ FN_ASSIGN(1, 2);
+ FN_ASSIGN(1, 3);
+
+ FN_ASSIGN(2, 0);
+ FN_ASSIGN(2, 1);
+ FN_ASSIGN(2, 2);
+ FN_ASSIGN(2, 3);
+
+ FN_ASSIGN(3, 0);
+ FN_ASSIGN(3, 1);
+ FN_ASSIGN(3, 2);
+ FN_ASSIGN(3, 3);
+
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_c;
+ dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_c;
dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = put_no_rnd_vc1_chroma_mc4_c;
dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = avg_no_rnd_vc1_chroma_mc4_c;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
- dsp->sprite_h = sprite_h_c;
- dsp->sprite_v_single = sprite_v_single_c;
- dsp->sprite_v_double_noscale = sprite_v_double_noscale_c;
+ dsp->sprite_h = sprite_h_c;
+ dsp->sprite_v_single = sprite_v_single_c;
+ dsp->sprite_v_double_noscale = sprite_v_double_noscale_c;
dsp->sprite_v_double_onescale = sprite_v_double_onescale_c;
dsp->sprite_v_double_twoscale = sprite_v_double_twoscale_c;
-#endif
+#endif /* CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER */
+
+ dsp->vc1_find_start_code_candidate = ff_startcode_find_candidate_c;
+ if (ARCH_AARCH64)
+ ff_vc1dsp_init_aarch64(dsp);
+ if (ARCH_ARM)
+ ff_vc1dsp_init_arm(dsp);
if (ARCH_PPC)
ff_vc1dsp_init_ppc(dsp);
if (ARCH_X86)
diff --git a/chromium/third_party/ffmpeg/libavcodec/vc1dsp.h b/chromium/third_party/ffmpeg/libavcodec/vc1dsp.h
index a0d60480546..aa5b6d34fd7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vc1dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vc1dsp.h
@@ -28,7 +28,6 @@
#ifndef AVCODEC_VC1DSP_H
#define AVCODEC_VC1DSP_H
-#include "dsputil.h"
#include "hpeldsp.h"
#include "h264chroma.h"
@@ -58,8 +57,8 @@ typedef struct VC1DSPContext {
/* put 8x8 block with bicubic interpolation and quarterpel precision
* last argument is actually round value instead of height
*/
- vc1op_pixels_func put_vc1_mspel_pixels_tab[16];
- vc1op_pixels_func avg_vc1_mspel_pixels_tab[16];
+ vc1op_pixels_func put_vc1_mspel_pixels_tab[2][16];
+ vc1op_pixels_func avg_vc1_mspel_pixels_tab[2][16];
/* This is really one func used in VC-1 decoding */
h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
@@ -74,9 +73,19 @@ typedef struct VC1DSPContext {
void (*sprite_v_double_twoscale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
const uint8_t *src2a, const uint8_t *src2b, int offset2,
int alpha, int width);
+
+ /**
+ * Search buf from the start for up to size bytes. Return the index
+ * of a zero byte, or >= size if not found. Ideally, use lookahead
+ * to filter out any zero bytes that are known to not be followed by
+ * one or more further zero bytes and a one byte.
+ */
+ int (*vc1_find_start_code_candidate)(const uint8_t *buf, int size);
} VC1DSPContext;
void ff_vc1dsp_init(VC1DSPContext* c);
+void ff_vc1dsp_init_aarch64(VC1DSPContext* dsp);
+void ff_vc1dsp_init_arm(VC1DSPContext* dsp);
void ff_vc1dsp_init_ppc(VC1DSPContext *c);
void ff_vc1dsp_init_x86(VC1DSPContext* dsp);
diff --git a/chromium/third_party/ffmpeg/libavcodec/vda.c b/chromium/third_party/ffmpeg/libavcodec/vda.c
new file mode 100644
index 00000000000..170580f16ab
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/vda.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/mem.h"
+
+#include "vda.h"
+#include "vda_internal.h"
+
+#if CONFIG_H264_VDA_HWACCEL
+AVVDAContext *av_vda_alloc_context(void)
+{
+ AVVDAContext *ret = av_mallocz(sizeof(*ret));
+
+ if (ret)
+ ret->output_callback = ff_vda_output_callback;
+
+ return ret;
+}
+
+int av_vda_default_init(AVCodecContext *avctx)
+{
+ avctx->hwaccel_context = av_vda_alloc_context();
+ if (!avctx->hwaccel_context)
+ return AVERROR(ENOMEM);
+ return ff_vda_default_init(avctx);
+}
+
+void av_vda_default_free(AVCodecContext *avctx)
+{
+ ff_vda_default_free(avctx);
+ av_freep(&avctx->hwaccel_context);
+}
+
+void ff_vda_default_free(AVCodecContext *avctx)
+{
+ AVVDAContext *vda = avctx->hwaccel_context;
+ if (vda && vda->decoder)
+ VDADecoderDestroy(vda->decoder);
+}
+
+#else
+AVVDAContext *av_vda_alloc_context(void)
+{
+ return NULL;
+}
+
+int av_vda_default_init(AVCodecContext *avctx)
+{
+ return AVERROR(ENOSYS);
+}
+
+void av_vda_default_free(AVCodecContext *ctx)
+{
+}
+#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/vda.h b/chromium/third_party/ffmpeg/libavcodec/vda.h
index b3d6399a655..12330aa3637 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vda.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vda.h
@@ -29,6 +29,8 @@
* Public libavcodec VDA header.
*/
+#include "libavcodec/avcodec.h"
+
#include <stdint.h>
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
@@ -41,6 +43,12 @@
#include "libavcodec/version.h"
+// extra flags not defined in VDADecoder.h
+enum {
+ kVDADecodeInfo_Asynchronous = 1UL << 0,
+ kVDADecodeInfo_FrameDropped = 1UL << 1
+};
+
/**
* @defgroup lavc_codec_hwaccel_vda VDA
* @ingroup lavc_codec_hwaccel
@@ -112,26 +120,17 @@ struct vda_context {
OSType cv_pix_fmt_type;
/**
- * The current bitstream buffer.
- *
- * - encoding: unused
- * - decoding: Set/Unset by libavcodec.
+ * unused
*/
uint8_t *priv_bitstream;
/**
- * The current size of the bitstream.
- *
- * - encoding: unused
- * - decoding: Set/Unset by libavcodec.
+ * unused
*/
int priv_bitstream_size;
/**
- * The reference size used for fast reallocation.
- *
- * - encoding: unused
- * - decoding: Set/Unset by libavcodec.
+ * unused
*/
int priv_allocated_size;
@@ -156,6 +155,58 @@ int ff_vda_create_decoder(struct vda_context *vda_ctx,
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
/**
+ * This struct holds all the information that needs to be passed
+ * between the caller and libavcodec for initializing VDA decoding.
+ * Its size is not a part of the public ABI, it must be allocated with
+ * av_vda_alloc_context() and freed with av_free().
+ */
+typedef struct AVVDAContext {
+ /**
+ * VDA decoder object. Created and freed by the caller.
+ */
+ VDADecoder decoder;
+
+ /**
+ * The output callback that must be passed to VDADecoderCreate.
+ * Set by av_vda_alloc_context().
+ */
+ VDADecoderOutputCallback output_callback;
+} AVVDAContext;
+
+/**
+ * Allocate and initialize a VDA context.
+ *
+ * This function should be called from the get_format() callback when the caller
+ * selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
+ * object (using the output callback provided by libavcodec) that will be used
+ * for VDA-accelerated decoding.
+ *
+ * When decoding with VDA is finished, the caller must destroy the decoder
+ * object and free the VDA context using av_free().
+ *
+ * @return the newly allocated context or NULL on failure
+ */
+AVVDAContext *av_vda_alloc_context(void);
+
+/**
+ * This is a convenience function that creates and sets up the VDA context using
+ * an internal implementation.
+ *
+ * @param avctx the corresponding codec context
+ *
+ * @return >= 0 on success, a negative AVERROR code on failure
+ */
+int av_vda_default_init(AVCodecContext *avctx);
+
+/**
+ * This function must be called to free the VDA context initialized with
+ * av_vda_default_init().
+ *
+ * @param avctx the corresponding codec context
+ */
+void av_vda_default_free(AVCodecContext *avctx);
+
+/**
* @}
*/
diff --git a/chromium/third_party/ffmpeg/libavcodec/vda_h264.c b/chromium/third_party/ffmpeg/libavcodec/vda_h264.c
index e0561e2914d..61fb3c02c95 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vda_h264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vda_h264.c
@@ -31,6 +31,21 @@
struct vda_buffer {
CVPixelBufferRef cv_buffer;
};
+#include "internal.h"
+#include "vda_internal.h"
+
+typedef struct VDAContext {
+ // The current bitstream buffer.
+ uint8_t *bitstream;
+
+ // The current size of the bitstream.
+ int bitstream_size;
+
+ // The reference size used for fast reallocation.
+ int allocated_size;
+
+ CVImageBufferRef frame;
+} VDAContext;
/* Decoder callback that adds the vda frame to the queue in display order. */
static void vda_decoder_callback(void *vda_hw_ctx,
@@ -41,6 +56,9 @@ static void vda_decoder_callback(void *vda_hw_ctx,
{
struct vda_context *vda_ctx = vda_hw_ctx;
+ if (infoFlags & kVDADecodeInfo_FrameDropped)
+ vda_ctx->cv_buffer = NULL;
+
if (!image_buffer)
return;
@@ -50,15 +68,15 @@ static void vda_decoder_callback(void *vda_hw_ctx,
vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer);
}
-static int vda_sync_decode(struct vda_context *vda_ctx)
+static int vda_sync_decode(VDAContext *ctx, struct vda_context *vda_ctx)
{
OSStatus status;
CFDataRef coded_frame;
uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
coded_frame = CFDataCreate(kCFAllocatorDefault,
- vda_ctx->priv_bitstream,
- vda_ctx->priv_bitstream_size);
+ ctx->bitstream,
+ ctx->bitstream_size);
status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
@@ -71,42 +89,44 @@ static int vda_sync_decode(struct vda_context *vda_ctx)
}
-static int vda_h264_start_frame(AVCodecContext *avctx,
+static int vda_old_h264_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
if (!vda_ctx->decoder)
return -1;
- vda_ctx->priv_bitstream_size = 0;
+ vda->bitstream_size = 0;
return 0;
}
-static int vda_h264_decode_slice(AVCodecContext *avctx,
+static int vda_old_h264_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer,
uint32_t size)
{
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
void *tmp;
if (!vda_ctx->decoder)
return -1;
- tmp = av_fast_realloc(vda_ctx->priv_bitstream,
- &vda_ctx->priv_allocated_size,
- vda_ctx->priv_bitstream_size + size + 4);
+ tmp = av_fast_realloc(vda->bitstream,
+ &vda->allocated_size,
+ vda->bitstream_size + size + 4);
if (!tmp)
return AVERROR(ENOMEM);
- vda_ctx->priv_bitstream = tmp;
+ vda->bitstream = tmp;
- AV_WB32(vda_ctx->priv_bitstream + vda_ctx->priv_bitstream_size, size);
- memcpy(vda_ctx->priv_bitstream + vda_ctx->priv_bitstream_size + 4, buffer, size);
+ AV_WB32(vda->bitstream + vda->bitstream_size, size);
+ memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
- vda_ctx->priv_bitstream_size += size + 4;
+ vda->bitstream_size += size + 4;
return 0;
}
@@ -118,19 +138,20 @@ static void vda_h264_release_buffer(void *opaque, uint8_t *data)
av_free(context);
}
-static int vda_h264_end_frame(AVCodecContext *avctx)
+static int vda_old_h264_end_frame(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
AVFrame *frame = &h->cur_pic_ptr->f;
struct vda_buffer *context;
AVBufferRef *buffer;
int status;
- if (!vda_ctx->decoder || !vda_ctx->priv_bitstream)
+ if (!vda_ctx->decoder || !vda->bitstream)
return -1;
- status = vda_sync_decode(vda_ctx);
+ status = vda_sync_decode(vda, vda_ctx);
frame->data[3] = (void*)vda_ctx->cv_buffer;
if (status)
@@ -224,7 +245,7 @@ int ff_vda_create_decoder(struct vda_context *vda_ctx,
status = VDADecoderCreate(config_info,
buffer_attributes,
- vda_decoder_callback,
+ (VDADecoderOutputCallback *)vda_decoder_callback,
vda_ctx,
&vda_ctx->decoder);
@@ -247,17 +268,264 @@ int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
if (vda_ctx->decoder)
status = VDADecoderDestroy(vda_ctx->decoder);
- av_freep(&vda_ctx->priv_bitstream);
-
return status;
}
-AVHWAccel ff_h264_vda_hwaccel = {
+static int vda_h264_uninit(AVCodecContext *avctx)
+{
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
+ if (vda) {
+ av_freep(&vda->bitstream);
+ if (vda->frame)
+ CVPixelBufferRelease(vda->frame);
+ }
+ return 0;
+}
+
+AVHWAccel ff_h264_vda_old_hwaccel = {
.name = "h264_vda",
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264,
.pix_fmt = AV_PIX_FMT_VDA_VLD,
+ .start_frame = vda_old_h264_start_frame,
+ .decode_slice = vda_old_h264_decode_slice,
+ .end_frame = vda_old_h264_end_frame,
+ .uninit = vda_h264_uninit,
+ .priv_data_size = sizeof(VDAContext),
+};
+
+void ff_vda_output_callback(void *opaque,
+ CFDictionaryRef user_info,
+ OSStatus status,
+ uint32_t infoFlags,
+ CVImageBufferRef image_buffer)
+{
+ AVCodecContext *ctx = opaque;
+ VDAContext *vda = ctx->internal->hwaccel_priv_data;
+
+
+ if (vda->frame) {
+ CVPixelBufferRelease(vda->frame);
+ vda->frame = NULL;
+ }
+
+ if (!image_buffer)
+ return;
+
+ vda->frame = CVPixelBufferRetain(image_buffer);
+}
+
+static int vda_h264_start_frame(AVCodecContext *avctx,
+ const uint8_t *buffer,
+ uint32_t size)
+{
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
+
+ vda->bitstream_size = 0;
+
+ return 0;
+}
+
+static int vda_h264_decode_slice(AVCodecContext *avctx,
+ const uint8_t *buffer,
+ uint32_t size)
+{
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
+ void *tmp;
+
+ tmp = av_fast_realloc(vda->bitstream,
+ &vda->allocated_size,
+ vda->bitstream_size + size + 4);
+ if (!tmp)
+ return AVERROR(ENOMEM);
+
+ vda->bitstream = tmp;
+
+ AV_WB32(vda->bitstream + vda->bitstream_size, size);
+ memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
+
+ vda->bitstream_size += size + 4;
+
+ return 0;
+}
+
+static void release_buffer(void *opaque, uint8_t *data)
+{
+ CVImageBufferRef frame = (CVImageBufferRef)data;
+ CVPixelBufferRelease(frame);
+}
+
+static int vda_h264_end_frame(AVCodecContext *avctx)
+{
+ H264Context *h = avctx->priv_data;
+ VDAContext *vda = avctx->internal->hwaccel_priv_data;
+ AVVDAContext *vda_ctx = avctx->hwaccel_context;
+ AVFrame *frame = &h->cur_pic_ptr->f;
+ uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
+ CFDataRef coded_frame;
+ OSStatus status;
+
+ if (!vda->bitstream_size)
+ return AVERROR_INVALIDDATA;
+
+
+ coded_frame = CFDataCreate(kCFAllocatorDefault,
+ vda->bitstream,
+ vda->bitstream_size);
+
+ status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
+
+ if (status == kVDADecoderNoErr)
+ status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
+
+ CFRelease(coded_frame);
+
+ if (status != kVDADecoderNoErr) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
+ return AVERROR_UNKNOWN;
+ }
+
+ if (vda->frame) {
+ av_buffer_unref(&frame->buf[0]);
+
+ frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
+ sizeof(vda->frame),
+ release_buffer, NULL,
+ AV_BUFFER_FLAG_READONLY);
+ if (!frame->buf)
+ return AVERROR(ENOMEM);
+
+ frame->data[3] = (uint8_t*)vda->frame;
+ vda->frame = NULL;
+ }
+
+ return 0;
+}
+
+int ff_vda_default_init(AVCodecContext *avctx)
+{
+ AVVDAContext *vda_ctx = avctx->hwaccel_context;
+ OSStatus status = kVDADecoderNoErr;
+ CFNumberRef height;
+ CFNumberRef width;
+ CFNumberRef format;
+ CFDataRef avc_data;
+ CFMutableDictionaryRef config_info;
+ CFMutableDictionaryRef buffer_attributes;
+ CFMutableDictionaryRef io_surface_properties;
+ CFNumberRef cv_pix_fmt;
+ int32_t fmt = 'avc1', pix_fmt = kCVPixelFormatType_422YpCbCr8;
+
+ // kCVPixelFormatType_420YpCbCr8Planar;
+
+ /* Each VCL NAL in the bitstream sent to the decoder
+ * is preceded by a 4 bytes length header.
+ * Change the avcC atom header if needed, to signal headers of 4 bytes. */
+ if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) {
+ uint8_t *rw_extradata;
+
+ if (!(rw_extradata = av_malloc(avctx->extradata_size)))
+ return AVERROR(ENOMEM);
+
+ memcpy(rw_extradata, avctx->extradata, avctx->extradata_size);
+
+ rw_extradata[4] |= 0x03;
+
+ avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size);
+
+ av_freep(&rw_extradata);
+ } else {
+ avc_data = CFDataCreate(kCFAllocatorDefault,
+ avctx->extradata, avctx->extradata_size);
+ }
+
+ config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 4,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+
+ height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->height);
+ width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->width);
+ format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &fmt);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
+ CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
+
+ buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 2,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberSInt32Type,
+ &pix_fmt);
+
+ CFDictionarySetValue(buffer_attributes,
+ kCVPixelBufferPixelFormatTypeKey,
+ cv_pix_fmt);
+ CFDictionarySetValue(buffer_attributes,
+ kCVPixelBufferIOSurfacePropertiesKey,
+ io_surface_properties);
+
+ status = VDADecoderCreate(config_info,
+ buffer_attributes,
+ (VDADecoderOutputCallback *)ff_vda_output_callback,
+ avctx,
+ &vda_ctx->decoder);
+
+ CFRelease(format);
+ CFRelease(height);
+ CFRelease(width);
+ CFRelease(avc_data);
+ CFRelease(config_info);
+ CFRelease(cv_pix_fmt);
+ CFRelease(io_surface_properties);
+ CFRelease(buffer_attributes);
+
+ if (status != kVDADecoderNoErr) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot initialize VDA %d\n", status);
+ }
+
+ switch (status) {
+ case kVDADecoderHardwareNotSupportedErr:
+ case kVDADecoderFormatNotSupportedErr:
+ return AVERROR(ENOSYS);
+ case kVDADecoderConfigurationError:
+ return AVERROR(EINVAL);
+ case kVDADecoderDecoderFailedErr:
+ return AVERROR_INVALIDDATA;
+ case kVDADecoderNoErr:
+ return 0;
+ default:
+ return AVERROR_UNKNOWN;
+ }
+}
+
+static int vda_h264_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+ frame->width = avctx->width;
+ frame->height = avctx->height;
+ frame->format = avctx->pix_fmt;
+ frame->buf[0] = av_buffer_alloc(1);
+
+ if (!frame->buf[0])
+ return AVERROR(ENOMEM);
+ return 0;
+}
+
+AVHWAccel ff_h264_vda_hwaccel = {
+ .name = "h264_vda",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_H264,
+ .pix_fmt = AV_PIX_FMT_VDA,
+ .alloc_frame = vda_h264_alloc_frame,
.start_frame = vda_h264_start_frame,
.decode_slice = vda_h264_decode_slice,
.end_frame = vda_h264_end_frame,
+ .uninit = vda_h264_uninit,
+ .priv_data_size = sizeof(VDAContext),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/vda_h264_dec.c b/chromium/third_party/ffmpeg/libavcodec/vda_h264_dec.c
index e5fa8071b3b..c00e7e4e155 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vda_h264_dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vda_h264_dec.c
@@ -180,7 +180,7 @@ static av_cold int vdadec_init(AVCodecContext *avctx)
VDADecoderContext *ctx = avctx->priv_data;
struct vda_context *vda_ctx = &ctx->vda_ctx;
OSStatus status;
- int ret;
+ int ret, i;
ctx->h264_initialized = 0;
@@ -235,6 +235,16 @@ static av_cold int vdadec_init(AVCodecContext *avctx)
}
ctx->h264_initialized = 1;
+ for (i = 0; i < MAX_SPS_COUNT; i++) {
+ SPS *sps = ctx->h264ctx.sps_buffers[i];
+ if (sps && (sps->bit_depth_luma != 8 ||
+ sps->chroma_format_idc == 2 ||
+ sps->chroma_format_idc == 3)) {
+ av_log(avctx, AV_LOG_ERROR, "Format is not supported.\n");
+ goto failed;
+ }
+ }
+
return 0;
failed:
diff --git a/chromium/third_party/ffmpeg/libavcodec/vda_internal.h b/chromium/third_party/ffmpeg/libavcodec/vda_internal.h
new file mode 100644
index 00000000000..457916b0588
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/vda_internal.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VDA_INTERNAL_H
+#define AVCODEC_VDA_INTERNAL_H
+
+#include "vda.h"
+
+void ff_vda_output_callback(void *vda_hw_ctx,
+ CFDictionaryRef user_info,
+ OSStatus status,
+ uint32_t infoFlags,
+ CVImageBufferRef image_buffer);
+
+int ff_vda_default_init(AVCodecContext *avctx);
+void ff_vda_default_free(AVCodecContext *avctx);
+
+#endif /* AVCODEC_VDA_INTERNAL_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau.c b/chromium/third_party/ffmpeg/libavcodec/vdpau.c
index 32a3843e9bd..0dc5355262f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau.c
@@ -45,12 +45,10 @@ AVVDPAUContext *av_alloc_vdpaucontext(void)
MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
-int ff_vdpau_common_start_frame(Picture *pic,
+int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
- struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-
pic_ctx->bitstream_buffers_allocated = 0;
pic_ctx->bitstream_buffers_used = 0;
pic_ctx->bitstream_buffers = NULL;
@@ -67,10 +65,19 @@ int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
MpegEncContext *s = avctx->priv_data;
Picture *pic = s->current_picture_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
- VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(pic->f);
+
+#if FF_API_BUFS_VDPAU
+FF_DISABLE_DEPRECATION_WARNINGS
+ hwctx->info = pic_ctx->info;
+ hwctx->bitstream_buffers = pic_ctx->bitstream_buffers;
+ hwctx->bitstream_buffers_used = pic_ctx->bitstream_buffers_used;
+ hwctx->bitstream_buffers_allocated = pic_ctx->bitstream_buffers_allocated;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (!hwctx->render) {
- res = hwctx->render2(avctx, &pic->f, (void *)&pic_ctx->info,
+ res = hwctx->render2(avctx, pic->f, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
} else
hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
@@ -79,13 +86,21 @@ int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
av_freep(&pic_ctx->bitstream_buffers);
+#if FF_API_BUFS_VDPAU
+FF_DISABLE_DEPRECATION_WARNINGS
+ hwctx->bitstream_buffers = NULL;
+ hwctx->bitstream_buffers_used = 0;
+ hwctx->bitstream_buffers_allocated = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
return res;
}
#endif
-int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t size)
+int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx,
+ const uint8_t *buf, uint32_t size)
{
- struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
@@ -108,7 +123,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
{
struct vdpau_render_state *render, *render_ref;
VdpReferenceFrameH264 *rf, *rf2;
- Picture *pic;
+ H264Picture *pic;
int i, list, pic_frame_idx;
render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
@@ -118,7 +133,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
#define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
for (list = 0; list < 2; ++list) {
- Picture **lp = list ? h->long_ref : h->short_ref;
+ H264Picture **lp = list ? h->long_ref : h->short_ref;
int ls = list ? 16 : h->short_ref_count;
for (i = 0; i < ls; ++i) {
@@ -261,7 +276,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
if (!s->current_picture_ptr) return;
- render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
+ render = (struct vdpau_render_state *)s->current_picture_ptr->f->data[0];
assert(render);
/* fill VdpPictureInfoMPEG1Or2 struct */
@@ -290,18 +305,18 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
switch(s->pict_type){
case AV_PICTURE_TYPE_B:
- next = (struct vdpau_render_state *)s->next_picture.f.data[0];
+ next = (struct vdpau_render_state *)s->next_picture.f->data[0];
assert(next);
render->info.mpeg.backward_reference = next->surface;
// no return here, going to set forward prediction
case AV_PICTURE_TYPE_P:
- last = (struct vdpau_render_state *)s->last_picture.f.data[0];
+ last = (struct vdpau_render_state *)s->last_picture.f->data[0];
if (!last) // FIXME: Does this test make sense?
last = render; // predict second field from the first
render->info.mpeg.forward_reference = last->surface;
}
- ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
+ ff_vdpau_add_data_chunk(s->current_picture_ptr->f->data[0], buf, buf_size);
render->info.mpeg.slice_count = slice_count;
@@ -318,7 +333,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
VC1Context *v = s->avctx->priv_data;
struct vdpau_render_state *render, *last, *next;
- render = (struct vdpau_render_state *)s->current_picture.f.data[0];
+ render = (struct vdpau_render_state *)s->current_picture.f->data[0];
assert(render);
/* fill LvPictureInfoVC1 struct */
@@ -362,18 +377,18 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
switch(s->pict_type){
case AV_PICTURE_TYPE_B:
- next = (struct vdpau_render_state *)s->next_picture.f.data[0];
+ next = (struct vdpau_render_state *)s->next_picture.f->data[0];
assert(next);
render->info.vc1.backward_reference = next->surface;
// no break here, going to set forward prediction
case AV_PICTURE_TYPE_P:
- last = (struct vdpau_render_state *)s->last_picture.f.data[0];
+ last = (struct vdpau_render_state *)s->last_picture.f->data[0];
if (!last) // FIXME: Does this test make sense?
last = render; // predict second field from the first
render->info.vc1.forward_reference = last->surface;
}
- ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
+ ff_vdpau_add_data_chunk(s->current_picture_ptr->f->data[0], buf, buf_size);
render->info.vc1.slice_count = 1;
@@ -392,7 +407,7 @@ void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *ctx, const uint8_t *buf,
if (!s->current_picture_ptr) return;
- render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
+ render = (struct vdpau_render_state *)s->current_picture_ptr->f->data[0];
assert(render);
/* fill VdpPictureInfoMPEG4Part2 struct */
@@ -421,18 +436,18 @@ void ff_vdpau_mpeg4_decode_picture(Mpeg4DecContext *ctx, const uint8_t *buf,
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
- next = (struct vdpau_render_state *)s->next_picture.f.data[0];
+ next = (struct vdpau_render_state *)s->next_picture.f->data[0];
assert(next);
render->info.mpeg4.backward_reference = next->surface;
render->info.mpeg4.vop_coding_type = 2;
// no break here, going to set forward prediction
case AV_PICTURE_TYPE_P:
- last = (struct vdpau_render_state *)s->last_picture.f.data[0];
+ last = (struct vdpau_render_state *)s->last_picture.f->data[0];
assert(last);
render->info.mpeg4.forward_reference = last->surface;
}
- ff_vdpau_add_data_chunk(s->current_picture_ptr->f.data[0], buf, buf_size);
+ ff_vdpau_add_data_chunk(s->current_picture_ptr->f->data[0], buf, buf_size);
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
@@ -463,7 +478,7 @@ do { \
default: return AVERROR(EINVAL);
}
case AV_CODEC_ID_H264:
- switch (avctx->profile) {
+ switch (avctx->profile & ~FF_PROFILE_H264_INTRA) {
case FF_PROFILE_H264_CONSTRAINED_BASELINE:
case FF_PROFILE_H264_BASELINE: PROFILE(VDP_DECODER_PROFILE_H264_BASELINE);
case FF_PROFILE_H264_MAIN: PROFILE(VDP_DECODER_PROFILE_H264_MAIN);
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau_h264.c b/chromium/third_party/ffmpeg/libavcodec/vdpau_h264.c
index 3f6415d4f85..05a41d04026 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau_h264.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau_h264.c
@@ -25,6 +25,7 @@
#include "avcodec.h"
#include "h264.h"
+#include "mpegutils.h"
#include "vdpau.h"
#include "vdpau_internal.h"
@@ -46,10 +47,10 @@ static void vdpau_h264_clear_rf(VdpReferenceFrameH264 *rf)
rf->frame_idx = 0;
}
-static void vdpau_h264_set_rf(VdpReferenceFrameH264 *rf, Picture *pic,
+static void vdpau_h264_set_rf(VdpReferenceFrameH264 *rf, H264Picture *pic,
int pic_structure)
{
- VdpVideoSurface surface = ff_vdpau_get_surface_id(pic);
+ VdpVideoSurface surface = ff_vdpau_get_surface_id(&pic->f);
if (pic_structure == 0)
pic_structure = pic->reference;
@@ -74,11 +75,11 @@ static void vdpau_h264_set_reference_frames(AVCodecContext *avctx)
#define H264_RF_COUNT FF_ARRAY_ELEMS(info->referenceFrames)
for (list = 0; list < 2; ++list) {
- Picture **lp = list ? h->long_ref : h->short_ref;
+ H264Picture **lp = list ? h->long_ref : h->short_ref;
int i, ls = list ? 16 : h->short_ref_count;
for (i = 0; i < ls; ++i) {
- Picture *pic = lp[i];
+ H264Picture *pic = lp[i];
VdpReferenceFrameH264 *rf2;
VdpVideoSurface surface_ref;
int pic_frame_idx;
@@ -86,7 +87,7 @@ static void vdpau_h264_set_reference_frames(AVCodecContext *avctx)
if (!pic || !pic->reference)
continue;
pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
- surface_ref = ff_vdpau_get_surface_id(pic);
+ surface_ref = ff_vdpau_get_surface_id(&pic->f);
rf2 = &info->referenceFrames[0];
while (rf2 != rf) {
@@ -118,7 +119,7 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
H264Context * const h = avctx->priv_data;
- Picture *pic = h->cur_pic_ptr;
+ H264Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpPictureInfoH264 *info = &pic_ctx->info.h264;
@@ -161,7 +162,7 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx,
vdpau_h264_set_reference_frames(avctx);
- return ff_vdpau_common_start_frame(pic, buffer, size);
+ return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
}
static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 };
@@ -170,15 +171,15 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
H264Context *h = avctx->priv_data;
- Picture *pic = h->cur_pic_ptr;
+ H264Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(pic, start_code_prefix, 3);
+ val = ff_vdpau_add_buffer(pic_ctx, start_code_prefix, 3);
if (val)
return val;
- val = ff_vdpau_add_buffer(pic, buffer, size);
+ val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
if (val)
return val;
@@ -191,9 +192,18 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
int res = 0;
AVVDPAUContext *hwctx = avctx->hwaccel_context;
H264Context *h = avctx->priv_data;
- Picture *pic = h->cur_pic_ptr;
+ H264Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
- VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(&pic->f);
+
+#if FF_API_BUFS_VDPAU
+FF_DISABLE_DEPRECATION_WARNINGS
+ hwctx->info = pic_ctx->info;
+ hwctx->bitstream_buffers = pic_ctx->bitstream_buffers;
+ hwctx->bitstream_buffers_used = pic_ctx->bitstream_buffers_used;
+ hwctx->bitstream_buffers_allocated = pic_ctx->bitstream_buffers_allocated;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (!hwctx->render) {
res = hwctx->render2(avctx, &pic->f, (void *)&pic_ctx->info,
@@ -205,6 +215,14 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
ff_h264_draw_horiz_band(h, 0, h->avctx->height);
av_freep(&pic_ctx->bitstream_buffers);
+#if FF_API_BUFS_VDPAU
+FF_DISABLE_DEPRECATION_WARNINGS
+ hwctx->bitstream_buffers = NULL;
+ hwctx->bitstream_buffers_used = 0;
+ hwctx->bitstream_buffers_allocated = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
return res;
}
@@ -216,5 +234,5 @@ AVHWAccel ff_h264_vdpau_hwaccel = {
.start_frame = vdpau_h264_start_frame,
.end_frame = vdpau_h264_end_frame,
.decode_slice = vdpau_h264_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau_internal.h b/chromium/third_party/ffmpeg/libavcodec/vdpau_internal.h
index cc634111b44..a7319ed77e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau_internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau_internal.h
@@ -36,10 +36,10 @@
#include "mpegvideo.h"
#include "version.h"
-/** Extract VdpVideoSurface from a Picture */
-static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic)
+/** Extract VdpVideoSurface from an AVFrame */
+static inline uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
{
- return (uintptr_t)pic->f.data[3];
+ return (uintptr_t)pic->data[3];
}
#if CONFIG_VDPAU
@@ -75,12 +75,15 @@ struct vdpau_picture_context {
*/
VdpBitstreamBuffer *bitstream_buffers;
};
+#else
+struct vdpau_picture_context;
#endif
-int ff_vdpau_common_start_frame(Picture *pic,
+int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
const uint8_t *buffer, uint32_t size);
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
-int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t buf_size);
+int ff_vdpau_add_buffer(struct vdpau_picture_context *pic, const uint8_t *buf,
+ uint32_t buf_size);
void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf,
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg12.c b/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg12.c
index f21b34152b6..84a971c5b17 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg12.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg12.c
@@ -43,12 +43,12 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
- ref = ff_vdpau_get_surface_id(&s->next_picture);
+ ref = ff_vdpau_get_surface_id(s->next_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->backward_reference = ref;
/* fall through to forward prediction */
case AV_PICTURE_TYPE_P:
- ref = ff_vdpau_get_surface_id(&s->last_picture);
+ ref = ff_vdpau_get_surface_id(s->last_picture.f);
info->forward_reference = ref;
}
@@ -75,7 +75,7 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
}
- return ff_vdpau_common_start_frame(pic, buffer, size);
+ return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
}
static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
@@ -86,7 +86,7 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(pic, buffer, size);
+ val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
if (val < 0)
return val;
@@ -103,7 +103,7 @@ AVHWAccel ff_mpeg1_vdpau_hwaccel = {
.start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
@@ -116,6 +116,6 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = {
.start_frame = vdpau_mpeg_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg4.c b/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg4.c
index 282796eafad..64669a6e0f1 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg4.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau_mpeg4.c
@@ -46,13 +46,13 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
- ref = ff_vdpau_get_surface_id(&s->next_picture);
+ ref = ff_vdpau_get_surface_id(s->next_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->backward_reference = ref;
info->vop_coding_type = 2;
/* fall-through */
case AV_PICTURE_TYPE_P:
- ref = ff_vdpau_get_surface_id(&s->last_picture);
+ ref = ff_vdpau_get_surface_id(s->last_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->forward_reference = ref;
}
@@ -77,8 +77,8 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
}
- ff_vdpau_common_start_frame(pic, buffer, size);
- return ff_vdpau_add_buffer(pic, buffer, size);
+ ff_vdpau_common_start_frame(pic_ctx, buffer, size);
+ return ff_vdpau_add_buffer(pic_ctx, buffer, size);
}
static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx,
@@ -97,7 +97,7 @@ AVHWAccel ff_h263_vdpau_hwaccel = {
.start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
@@ -110,6 +110,6 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = {
.start_frame = vdpau_mpeg4_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_mpeg4_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/vdpau_vc1.c b/chromium/third_party/ffmpeg/libavcodec/vdpau_vc1.c
index c655529aaff..13c41df66ad 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vdpau_vc1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vdpau_vc1.c
@@ -45,14 +45,14 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
if (s->next_picture_ptr) {
- ref = ff_vdpau_get_surface_id(&s->next_picture);
+ ref = ff_vdpau_get_surface_id(s->next_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->backward_reference = ref;
}
/* fall-through */
case AV_PICTURE_TYPE_P:
if (s->last_picture_ptr) {
- ref = ff_vdpau_get_surface_id(&s->last_picture);
+ ref = ff_vdpau_get_surface_id(s->last_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->forward_reference = ref;
}
@@ -93,7 +93,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
info->deblockEnable = v->postprocflag & 1;
info->pquant = v->pq;
- return ff_vdpau_common_start_frame(pic, buffer, size);
+ return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
}
static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
@@ -105,7 +105,7 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val;
- val = ff_vdpau_add_buffer(pic, buffer, size);
+ val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
if (val < 0)
return val;
@@ -122,7 +122,7 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = {
.start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
#endif
@@ -134,5 +134,5 @@ AVHWAccel ff_vc1_vdpau_hwaccel = {
.start_frame = vdpau_vc1_start_frame,
.end_frame = ff_vdpau_mpeg_end_frame,
.decode_slice = vdpau_vc1_decode_slice,
- .priv_data_size = sizeof(struct vdpau_picture_context),
+ .frame_priv_data_size = sizeof(struct vdpau_picture_context),
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/version.h b/chromium/third_party/ffmpeg/libavcodec/version.h
index eab162284ca..680c0603256 100644
--- a/chromium/third_party/ffmpeg/libavcodec/version.h
+++ b/chromium/third_party/ffmpeg/libavcodec/version.h
@@ -26,10 +26,10 @@
* Libavcodec version macros.
*/
-#include "libavutil/avutil.h"
+#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 45
+#define LIBAVCODEC_VERSION_MINOR 62
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -138,5 +138,29 @@
#ifndef FF_API_NEG_LINESIZES
#define FF_API_NEG_LINESIZES (LIBAVCODEC_VERSION_MAJOR < 56)
#endif
+#ifndef FF_API_EMU_EDGE
+#define FF_API_EMU_EDGE (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
+#ifndef FF_API_ARCH_SH4
+#define FF_API_ARCH_SH4 (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
+#ifndef FF_API_ARCH_SPARC
+#define FF_API_ARCH_SPARC (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
+#ifndef FF_API_INPUT_PRESERVED
+#define FF_API_INPUT_PRESERVED (LIBAVCODEC_VERSION_MAJOR < 57)
+#endif
+#ifndef FF_API_NORMALIZE_AQP
+#define FF_API_NORMALIZE_AQP (LIBAVCODEC_VERSION_MAJOR < 57)
+#endif
+#ifndef FF_API_GMC
+#define FF_API_GMC (LIBAVCODEC_VERSION_MAJOR < 57)
+#endif
+#ifndef FF_API_MV0
+#define FF_API_MV0 (LIBAVCODEC_VERSION_MAJOR < 57)
+#endif
+#ifndef FF_API_CODEC_NAME
+#define FF_API_CODEC_NAME (LIBAVCODEC_VERSION_MAJOR < 57)
+#endif
#endif /* AVCODEC_VERSION_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/videodsp.c b/chromium/third_party/ffmpeg/libavcodec/videodsp.c
index 13e4a7b4b14..ba618a7bbc6 100644
--- a/chromium/third_party/ffmpeg/libavcodec/videodsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/videodsp.c
@@ -44,6 +44,8 @@ av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
ctx->emulated_edge_mc = ff_emulated_edge_mc_16;
}
+ if (ARCH_AARCH64)
+ ff_videodsp_init_aarch64(ctx, bpc);
if (ARCH_ARM)
ff_videodsp_init_arm(ctx, bpc);
if (ARCH_PPC)
diff --git a/chromium/third_party/ffmpeg/libavcodec/videodsp.h b/chromium/third_party/ffmpeg/libavcodec/videodsp.h
index 0bb15f2c942..fc01a31dcac 100644
--- a/chromium/third_party/ffmpeg/libavcodec/videodsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/videodsp.h
@@ -79,6 +79,7 @@ typedef struct VideoDSPContext {
void ff_videodsp_init(VideoDSPContext *ctx, int bpc);
/* for internal use only (i.e. called by ff_videodsp_init() */
+void ff_videodsp_init_aarch64(VideoDSPContext *ctx, int bpc);
void ff_videodsp_init_arm(VideoDSPContext *ctx, int bpc);
void ff_videodsp_init_ppc(VideoDSPContext *ctx, int bpc);
void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc);
diff --git a/chromium/third_party/ffmpeg/libavcodec/videodsp_template.c b/chromium/third_party/ffmpeg/libavcodec/videodsp_template.c
index c569c30d607..f4ff2ba6469 100644
--- a/chromium/third_party/ffmpeg/libavcodec/videodsp_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/videodsp_template.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <assert.h>
+
#include "bit_depth_template.c"
void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
ptrdiff_t buf_linesize,
diff --git a/chromium/third_party/ffmpeg/libavcodec/vima.c b/chromium/third_party/ffmpeg/libavcodec/vima.c
index f040e1b16b5..ba3f07aad6f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vima.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vima.c
@@ -26,16 +26,16 @@
*/
#include "libavutil/channel_layout.h"
+
+#include "adpcm_data.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
-#include "adpcm_data.h"
static int predict_table_init = 0;
static uint16_t predict_table[5786 * 2];
-static const uint8_t size_table[] =
-{
+static const uint8_t size_table[] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
@@ -44,64 +44,42 @@ static const uint8_t size_table[] =
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
-static const int8_t index_table1[] =
-{
+static const int8_t index_table1[] = {
-1, 4, -1, 4
};
-static const int8_t index_table2[] =
-{
+static const int8_t index_table2[] = {
-1, -1, 2, 6, -1, -1, 2, 6
};
-static const int8_t index_table3[] =
-{
- -1, -1, -1, -1, 1, 2, 4, 6,
- -1, -1, -1, -1, 1, 2, 4, 6
+static const int8_t index_table3[] = {
+ -1, -1, -1, -1, 1, 2, 4, 6, -1, -1, -1, -1, 1, 2, 4, 6
};
-static const int8_t index_table4[] =
-{
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 2, 2, 4, 5, 6,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 2, 2, 4, 5, 6
+static const int8_t index_table4[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 2, 2, 4, 5, 6,
+ -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 2, 2, 4, 5, 6
};
-static const int8_t index_table5[] =
-{
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 1, 1, 2, 2, 2,
- 2, 4, 4, 4, 5, 5, 6, 6,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 1, 1, 2, 2, 2,
- 2, 4, 4, 4, 5, 5, 6, 6
+static const int8_t index_table5[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 5, 5, 6, 6,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 5, 5, 6, 6
};
-static const int8_t index_table6[] =
-{
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6
+static const int8_t index_table6[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6
};
-static const int8_t* const step_index_tables[] =
-{
+static const int8_t *const step_index_tables[] = {
index_table1, index_table2, index_table3,
index_table4, index_table5, index_table6
};
@@ -140,12 +118,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *pkt)
{
- GetBitContext gb;
- AVFrame *frame = data;
- int16_t pcm_data[2];
- uint32_t samples;
- int8_t channel_hint[2];
- int ret, chan, channels = 1;
+ GetBitContext gb;
+ AVFrame *frame = data;
+ int16_t pcm_data[2];
+ uint32_t samples;
+ int8_t channel_hint[2];
+ int ret, chan;
+ int channels = 1;
if (pkt->size < 13)
return AVERROR_INVALIDDATA;
@@ -168,12 +147,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
channels = 2;
}
avctx->channels = channels;
- avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO :
- AV_CH_LAYOUT_MONO;
+ avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO
+ : AV_CH_LAYOUT_MONO;
pcm_data[0] = get_sbits(&gb, 16);
if (channels > 1) {
channel_hint[1] = get_sbits(&gb, 8);
- pcm_data[1] = get_sbits(&gb, 16);
+ pcm_data[1] = get_sbits(&gb, 16);
}
frame->nb_samples = samples;
@@ -181,7 +160,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return ret;
for (chan = 0; chan < channels; chan++) {
- uint16_t *dest = (uint16_t*)frame->data[0] + chan;
+ uint16_t *dest = (uint16_t *)frame->data[0] + chan;
int step_index = channel_hint[chan];
int output = pcm_data[chan];
int sample;
@@ -211,9 +190,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (lookup)
diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
if (highbit)
- diff = -diff;
+ diff = -diff;
- output = av_clip_int16(output + diff);
+ output = av_clip_int16(output + diff);
}
*dest = output;
@@ -223,17 +202,27 @@ static int decode_frame(AVCodecContext *avctx, void *data,
}
}
- *got_frame_ptr = 1;
+ *got_frame_ptr = 1;
return pkt->size;
}
+AVCodec ff_adpcm_vima_decoder = {
+ .name = "adpcm_vima",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_ADPCM_VIMA,
+ .init = decode_init,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+};
+
AVCodec ff_vima_decoder = {
- .name = "vima",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_VIMA,
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .name = "vima",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_ADPCM_VIMA,
+ .init = decode_init,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/vmdav.c b/chromium/third_party/ffmpeg/libavcodec/vmdav.c
index e67377acce2..c1fb80b97d9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vmdav.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vmdav.c
@@ -76,7 +76,7 @@ typedef struct VmdVideoContext {
#define QUEUE_SIZE 0x1000
#define QUEUE_MASK 0x0FFF
-static void lz_unpack(const unsigned char *src, int src_len,
+static int lz_unpack(const unsigned char *src, int src_len,
unsigned char *dest, int dest_len)
{
unsigned char *d;
@@ -97,7 +97,7 @@ static void lz_unpack(const unsigned char *src, int src_len,
dataleft = bytestream2_get_le32(&gb);
memset(queue, 0x20, QUEUE_SIZE);
if (bytestream2_get_bytes_left(&gb) < 4)
- return;
+ return AVERROR_INVALIDDATA;
if (bytestream2_peek_le32(&gb) == 0x56781234) {
bytestream2_skipu(&gb, 4);
qpos = 0x111;
@@ -111,7 +111,7 @@ static void lz_unpack(const unsigned char *src, int src_len,
tag = bytestream2_get_byteu(&gb);
if ((tag == 0xFF) && (dataleft > 8)) {
if (d_end - d < 8 || bytestream2_get_bytes_left(&gb) < 8)
- return;
+ return AVERROR_INVALIDDATA;
for (i = 0; i < 8; i++) {
queue[qpos++] = *d++ = bytestream2_get_byteu(&gb);
qpos &= QUEUE_MASK;
@@ -123,7 +123,7 @@ static void lz_unpack(const unsigned char *src, int src_len,
break;
if (tag & 0x01) {
if (d_end - d < 1 || bytestream2_get_bytes_left(&gb) < 1)
- return;
+ return AVERROR_INVALIDDATA;
queue[qpos++] = *d++ = bytestream2_get_byteu(&gb);
qpos &= QUEUE_MASK;
dataleft--;
@@ -135,7 +135,7 @@ static void lz_unpack(const unsigned char *src, int src_len,
chainlen = bytestream2_get_byte(&gb) + 0xF + 3;
}
if (d_end - d < chainlen)
- return;
+ return AVERROR_INVALIDDATA;
for (j = 0; j < chainlen; j++) {
*d = queue[chainofs++ & QUEUE_MASK];
queue[qpos++] = *d++;
@@ -147,6 +147,7 @@ static void lz_unpack(const unsigned char *src, int src_len,
}
}
}
+ return d - dest;
}
static int rle_unpack(const unsigned char *src, unsigned char *dest,
int src_count, int src_size, int dest_len)
@@ -279,15 +280,18 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
return AVERROR_INVALIDDATA;
meth = bytestream2_get_byteu(&gb);
if (meth & 0x80) {
+ int size;
if (!s->unpack_buffer_size) {
av_log(s->avctx, AV_LOG_ERROR,
"Trying to unpack LZ-compressed frame with no LZ buffer\n");
return AVERROR_INVALIDDATA;
}
- lz_unpack(gb.buffer, bytestream2_get_bytes_left(&gb),
- s->unpack_buffer, s->unpack_buffer_size);
+ size = lz_unpack(gb.buffer, bytestream2_get_bytes_left(&gb),
+ s->unpack_buffer, s->unpack_buffer_size);
+ if (size < 0)
+ return size;
meth &= 0x7F;
- bytestream2_init(&gb, s->unpack_buffer, s->unpack_buffer_size);
+ bytestream2_init(&gb, s->unpack_buffer, size);
}
dp = &frame->data[0][frame_y * frame->linesize[0] + frame_x];
diff --git a/chromium/third_party/ffmpeg/libavcodec/vmnc.c b/chromium/third_party/ffmpeg/libavcodec/vmnc.c
index 5f91ab1b319..46bd52ee267 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vmnc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vmnc.c
@@ -291,6 +291,11 @@ static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
xy = bytestream2_get_byte(gb);
wh = bytestream2_get_byte(gb);
+ if ( (xy >> 4) + (wh >> 4) + 1 > w - i
+ || (xy & 0xF) + (wh & 0xF)+1 > h - j) {
+ av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n");
+ return AVERROR_INVALIDDATA;
+ }
paint_rect(dst2, xy >> 4, xy & 0xF,
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vorbis.c b/chromium/third_party/ffmpeg/libavcodec/vorbis.c
index 6eb765d7d0f..86d10407f4a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vorbis.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vorbis.c
@@ -71,7 +71,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
codes[p] = 0;
if (bits[p] > 32)
- return 1;
+ return AVERROR_INVALIDDATA;
for (i = 0; i < bits[p]; ++i)
exit_at_level[i+1] = 1 << i;
@@ -85,9 +85,14 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
++p;
+ for (i = p; (bits[i] == 0) && (i < num); ++i)
+ ;
+ if (i == num)
+ return 0;
+
for (; p < num; ++p) {
if (bits[p] > 32)
- return 1;
+ return AVERROR_INVALIDDATA;
if (bits[p] == 0)
continue;
// find corresponding exit(node which the tree can grow further from)
@@ -95,7 +100,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
if (exit_at_level[i])
break;
if (!i) // overspecified tree
- return 1;
+ return AVERROR_INVALIDDATA;
code = exit_at_level[i];
exit_at_level[i] = 0;
// construct code (append 0s to end) and introduce new exits
@@ -116,7 +121,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
//no exits should be left (underspecified tree - ie. unused valid vlcs - not allowed by SPEC)
for (p = 1; p < 33; p++)
if (exit_at_level[p])
- return 1;
+ return AVERROR_INVALIDDATA;
return 0;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vorbisdec.c b/chromium/third_party/ffmpeg/libavcodec/vorbisdec.c
index a2f7dd27f8e..87d1bbb97a3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vorbisdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vorbisdec.c
@@ -151,7 +151,7 @@ typedef struct vorbis_context_s {
uint8_t mode_count;
vorbis_mode *modes;
uint8_t mode_number; // mode number for the current packet
- uint8_t previous_window;
+ int8_t previous_window;
float *channel_residues;
float *saved;
} vorbis_context;
@@ -378,7 +378,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
}
// Weed out unused vlcs and build codevector vector
- codebook_setup->codevectors = used_entries ? av_mallocz(used_entries *
+ codebook_setup->codevectors = used_entries ? av_mallocz_array(used_entries,
codebook_setup->dimensions *
sizeof(*codebook_setup->codevectors))
: NULL;
@@ -561,7 +561,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
for (j = 0; j < floor_setup->data.t1.partitions; ++j)
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
- floor_setup->data.t1.list = av_mallocz(floor_setup->data.t1.x_list_dim *
+ floor_setup->data.t1.list = av_mallocz_array(floor_setup->data.t1.x_list_dim,
sizeof(*floor_setup->data.t1.list));
if (!floor_setup->data.t1.list)
return AVERROR(ENOMEM);
@@ -640,8 +640,8 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
/* codebook dim is for padding if codebook dim doesn't *
* divide order+1 then we need to read more data */
floor_setup->data.t0.lsp =
- av_malloc((floor_setup->data.t0.order + 1 + max_codebook_dim)
- * sizeof(*floor_setup->data.t0.lsp));
+ av_malloc_array((floor_setup->data.t0.order + 1 + max_codebook_dim),
+ sizeof(*floor_setup->data.t0.lsp));
if (!floor_setup->data.t0.lsp)
return AVERROR(ENOMEM);
@@ -701,8 +701,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->partition_size = get_bits(gb, 24) + 1;
/* Validations to prevent a buffer overflow later. */
if (res_setup->begin>res_setup->end ||
- res_setup->end > (res_setup->type == 2 ? vc->audio_channels : 1) * vc->blocksize[1] / 2 ||
- (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
+ (res_setup->end-res_setup->begin) / res_setup->partition_size > FFMIN(V_MAX_PARTITIONS, 65535)) {
av_log(vc->avctx, AV_LOG_ERROR,
"partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
res_setup->type, res_setup->begin, res_setup->end,
@@ -715,7 +714,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->ptns_to_read =
(res_setup->end - res_setup->begin) / res_setup->partition_size;
- res_setup->classifs = av_malloc(res_setup->ptns_to_read *
+ res_setup->classifs = av_malloc_array(res_setup->ptns_to_read,
vc->audio_channels *
sizeof(*res_setup->classifs));
if (!res_setup->classifs)
@@ -808,7 +807,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
}
if (mapping_setup->submaps>1) {
- mapping_setup->mux = av_mallocz(vc->audio_channels *
+ mapping_setup->mux = av_mallocz_array(vc->audio_channels,
sizeof(*mapping_setup->mux));
if (!mapping_setup->mux)
return AVERROR(ENOMEM);
@@ -843,7 +842,7 @@ static int create_map(vorbis_context *vc, unsigned floor_number)
for (blockflag = 0; blockflag < 2; ++blockflag) {
n = vc->blocksize[blockflag] / 2;
floors[floor_number].data.t0.map[blockflag] =
- av_malloc((n + 1) * sizeof(int32_t)); // n + sentinel
+ av_malloc_array(n + 1, sizeof(int32_t)); // n + sentinel
if (!floors[floor_number].data.t0.map[blockflag])
return AVERROR(ENOMEM);
@@ -984,12 +983,12 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
return AVERROR_INVALIDDATA;
}
- vc->channel_residues = av_malloc((vc->blocksize[1] / 2) * vc->audio_channels * sizeof(*vc->channel_residues));
- vc->saved = av_mallocz((vc->blocksize[1] / 4) * vc->audio_channels * sizeof(*vc->saved));
+ vc->channel_residues = av_malloc_array(vc->blocksize[1] / 2, vc->audio_channels * sizeof(*vc->channel_residues));
+ vc->saved = av_mallocz_array(vc->blocksize[1] / 4, vc->audio_channels * sizeof(*vc->saved));
if (!vc->channel_residues || !vc->saved)
return AVERROR(ENOMEM);
- vc->previous_window = 0;
+ vc->previous_window = -1;
ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
@@ -1372,6 +1371,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
unsigned pass, ch_used, i, j, k, l;
unsigned max_output = (ch - 1) * vlen;
int ptns_to_read = vr->ptns_to_read;
+ int libvorbis_bug = 0;
if (vr_type == 2) {
for (j = 1; j < ch; ++j)
@@ -1386,8 +1386,13 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
}
if (max_output > ch_left * vlen) {
- av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
- return AVERROR_INVALIDDATA;
+ if (max_output <= ch_left * vlen + vr->partition_size*ch_used/ch) {
+ ptns_to_read--;
+ libvorbis_bug = 1;
+ } else {
+ av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
+ return AVERROR_INVALIDDATA;
+ }
}
av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
@@ -1496,6 +1501,14 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
voffset += vr->partition_size;
}
}
+ if (libvorbis_bug && !pass) {
+ for (j = 0; j < ch_used; ++j) {
+ if (!do_not_decode[j]) {
+ get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table,
+ vc->codebooks[vr->classbook].nb_bits, 3);
+ }
+ }
+ }
}
return 0;
}
@@ -1548,7 +1561,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
{
GetBitContext *gb = &vc->gb;
FFTContext *mdct;
- unsigned previous_window = vc->previous_window;
+ int previous_window = vc->previous_window;
unsigned mode_number, blockflag, blocksize;
int i, j;
uint8_t no_residue[255];
@@ -1581,9 +1594,11 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
blocksize = vc->blocksize[blockflag];
vlen = blocksize / 2;
if (blockflag) {
- previous_window = get_bits(gb, 1);
- skip_bits1(gb); // next_window
- }
+ int code = get_bits(gb, 2);
+ if (previous_window < 0)
+ previous_window = code>>1;
+ } else if (previous_window < 0)
+ previous_window = 0;
memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ?
for (i = 0; i < vc->audio_channels; ++i)
@@ -1812,7 +1827,8 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
memset(vc->saved, 0, (vc->blocksize[1] / 4) * vc->audio_channels *
sizeof(*vc->saved));
}
- vc->previous_window = 0;
+ vc->previous_window = -1;
+ vc->first_frame = 0;
}
AVCodec ff_vorbis_decoder = {
diff --git a/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.c b/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.c
index 784375697eb..362a276296b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.c
@@ -25,6 +25,8 @@ av_cold void ff_vorbisdsp_init(VorbisDSPContext *dsp)
{
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;
+ if (ARCH_AARCH64)
+ ff_vorbisdsp_init_aarch64(dsp);
if (ARCH_ARM)
ff_vorbisdsp_init_arm(dsp);
if (ARCH_PPC)
diff --git a/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.h b/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.h
index ed14049c8ce..7abec4e4b7b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vorbisdsp.h
@@ -30,6 +30,7 @@ typedef struct VorbisDSPContext {
void ff_vorbisdsp_init(VorbisDSPContext *dsp);
/* for internal use only */
+void ff_vorbisdsp_init_aarch64(VorbisDSPContext *dsp);
void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp);
void ff_vorbisdsp_init_arm(VorbisDSPContext *dsp);
void ff_vorbisdsp_init_ppc(VorbisDSPContext *dsp);
diff --git a/chromium/third_party/ffmpeg/libavcodec/vorbisenc.c b/chromium/third_party/ffmpeg/libavcodec/vorbisenc.c
index 9ef629681e3..fa6bccc1d0c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vorbisenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vorbisenc.c
@@ -25,9 +25,11 @@
*/
#include <float.h>
+
#include "avcodec.h"
#include "internal.h"
#include "fft.h"
+#include "mathops.h"
#include "vorbis.h"
#include "vorbis_enc_data.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp3.c b/chromium/third_party/ffmpeg/libavcodec/vp3.c
index 626642f4ad0..95b7994723c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp3.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp3.c
@@ -34,20 +34,21 @@
#include <string.h>
#include "libavutil/imgutils.h"
+
#include "avcodec.h"
-#include "internal.h"
-#include "dsputil.h"
#include "get_bits.h"
#include "hpeldsp.h"
+#include "internal.h"
+#include "mathops.h"
+#include "thread.h"
#include "videodsp.h"
#include "vp3data.h"
#include "vp3dsp.h"
#include "xiph.h"
-#include "thread.h"
#define FRAGMENT_PIXELS 8
-//FIXME split things out into their own arrays
+// FIXME split things out into their own arrays
typedef struct Vp3Fragment {
int16_t dc;
uint8_t coding_method;
@@ -81,51 +82,49 @@ static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb);
/* There are 6 preset schemes, plus a free-form scheme */
-static const int ModeAlphabet[6][CODING_MODE_COUNT] =
-{
+static const int ModeAlphabet[6][CODING_MODE_COUNT] = {
/* scheme 1: Last motion vector dominates */
- { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
- MODE_INTER_PLUS_MV, MODE_INTER_NO_MV,
- MODE_INTRA, MODE_USING_GOLDEN,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+ { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_PLUS_MV, MODE_INTER_NO_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
/* scheme 2 */
- { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
- MODE_INTER_NO_MV, MODE_INTER_PLUS_MV,
- MODE_INTRA, MODE_USING_GOLDEN,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+ { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_NO_MV, MODE_INTER_PLUS_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
/* scheme 3 */
- { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
- MODE_INTER_PRIOR_LAST, MODE_INTER_NO_MV,
- MODE_INTRA, MODE_USING_GOLDEN,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+ { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
+ MODE_INTER_PRIOR_LAST, MODE_INTER_NO_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
/* scheme 4 */
- { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
- MODE_INTER_NO_MV, MODE_INTER_PRIOR_LAST,
- MODE_INTRA, MODE_USING_GOLDEN,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+ { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
+ MODE_INTER_NO_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
/* scheme 5: No motion vector dominates */
- { MODE_INTER_NO_MV, MODE_INTER_LAST_MV,
- MODE_INTER_PRIOR_LAST, MODE_INTER_PLUS_MV,
- MODE_INTRA, MODE_USING_GOLDEN,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+ { MODE_INTER_NO_MV, MODE_INTER_LAST_MV,
+ MODE_INTER_PRIOR_LAST, MODE_INTER_PLUS_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
/* scheme 6 */
- { MODE_INTER_NO_MV, MODE_USING_GOLDEN,
- MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
- MODE_INTER_PLUS_MV, MODE_INTRA,
- MODE_GOLDEN_MV, MODE_INTER_FOURMV },
-
+ { MODE_INTER_NO_MV, MODE_USING_GOLDEN,
+ MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_PLUS_MV, MODE_INTRA,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
};
static const uint8_t hilbert_offset[16][2] = {
- {0,0}, {1,0}, {1,1}, {0,1},
- {0,2}, {0,3}, {1,3}, {1,2},
- {2,2}, {2,3}, {3,3}, {3,2},
- {3,1}, {2,1}, {2,0}, {3,0}
+ { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
+ { 0, 2 }, { 0, 3 }, { 1, 3 }, { 1, 2 },
+ { 2, 2 }, { 2, 3 }, { 3, 3 }, { 3, 2 },
+ { 3, 1 }, { 2, 1 }, { 2, 0 }, { 3, 0 }
};
#define MIN_DEQUANT_VAL 2
@@ -184,7 +183,7 @@ typedef struct Vp3DecodeContext {
uint32_t coded_ac_scale_factor[64];
uint8_t base_matrix[384][64];
uint8_t qr_count[2][3];
- uint8_t qr_size [2][3][64];
+ uint8_t qr_size[2][3][64];
uint16_t qr_base[2][3][64];
/**
@@ -211,7 +210,8 @@ typedef struct Vp3DecodeContext {
#define TOKEN_COEFF(coeff) (((coeff) << 2) + 2)
/**
- * number of blocks that contain DCT coefficients at the given level or higher
+ * number of blocks that contain DCT coefficients at
+ * the given level or higher
*/
int num_coded_frags[3][64];
int total_num_coded_frags;
@@ -255,7 +255,7 @@ typedef struct Vp3DecodeContext {
uint32_t huffman_table[80][32][2];
uint8_t filter_limit_values[64];
- DECLARE_ALIGNED(8, int, bounding_values_array)[256+2];
+ DECLARE_ALIGNED(8, int, bounding_values_array)[256 + 2];
} Vp3DecodeContext;
/************************************************************************
@@ -313,7 +313,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
ff_free_vlc(&s->mode_code_vlc);
ff_free_vlc(&s->motion_vector_vlc);
-
return 0;
}
@@ -330,19 +329,22 @@ static int init_block_mapping(Vp3DecodeContext *s)
int x, y, i, j = 0;
for (plane = 0; plane < 3; plane++) {
- int sb_width = plane ? s->c_superblock_width : s->y_superblock_width;
- int sb_height = plane ? s->c_superblock_height : s->y_superblock_height;
+ int sb_width = plane ? s->c_superblock_width
+ : s->y_superblock_width;
+ int sb_height = plane ? s->c_superblock_height
+ : s->y_superblock_height;
int frag_width = s->fragment_width[!!plane];
int frag_height = s->fragment_height[!!plane];
for (sb_y = 0; sb_y < sb_height; sb_y++)
for (sb_x = 0; sb_x < sb_width; sb_x++)
for (i = 0; i < 16; i++) {
- x = 4*sb_x + hilbert_offset[i][0];
- y = 4*sb_y + hilbert_offset[i][1];
+ x = 4 * sb_x + hilbert_offset[i][0];
+ y = 4 * sb_y + hilbert_offset[i][1];
if (x < frag_width && y < frag_height)
- s->superblock_fragments[j++] = s->fragment_start[plane] + y*frag_width + x;
+ s->superblock_fragments[j++] = s->fragment_start[plane] +
+ y * frag_width + x;
else
s->superblock_fragments[j++] = -1;
}
@@ -361,30 +363,31 @@ static void init_dequantizer(Vp3DecodeContext *s, int qpi)
int dc_scale_factor = s->coded_dc_scale_factor[s->qps[qpi]];
int i, plane, inter, qri, bmi, bmj, qistart;
- for(inter=0; inter<2; inter++){
- for(plane=0; plane<3; plane++){
- int sum=0;
- for(qri=0; qri<s->qr_count[inter][plane]; qri++){
- sum+= s->qr_size[inter][plane][qri];
- if(s->qps[qpi] <= sum)
+ for (inter = 0; inter < 2; inter++) {
+ for (plane = 0; plane < 3; plane++) {
+ int sum = 0;
+ for (qri = 0; qri < s->qr_count[inter][plane]; qri++) {
+ sum += s->qr_size[inter][plane][qri];
+ if (s->qps[qpi] <= sum)
break;
}
- qistart= sum - s->qr_size[inter][plane][qri];
- bmi= s->qr_base[inter][plane][qri ];
- bmj= s->qr_base[inter][plane][qri+1];
- for(i=0; i<64; i++){
- int coeff= ( 2*(sum -s->qps[qpi])*s->base_matrix[bmi][i]
- - 2*(qistart-s->qps[qpi])*s->base_matrix[bmj][i]
- + s->qr_size[inter][plane][qri])
- / (2*s->qr_size[inter][plane][qri]);
-
- int qmin= 8<<(inter + !i);
- int qscale= i ? ac_scale_factor : dc_scale_factor;
+ qistart = sum - s->qr_size[inter][plane][qri];
+ bmi = s->qr_base[inter][plane][qri];
+ bmj = s->qr_base[inter][plane][qri + 1];
+ for (i = 0; i < 64; i++) {
+ int coeff = (2 * (sum - s->qps[qpi]) * s->base_matrix[bmi][i] -
+ 2 * (qistart - s->qps[qpi]) * s->base_matrix[bmj][i] +
+ s->qr_size[inter][plane][qri]) /
+ (2 * s->qr_size[inter][plane][qri]);
+
+ int qmin = 8 << (inter + !i);
+ int qscale = i ? ac_scale_factor : dc_scale_factor;
s->qmat[qpi][inter][plane][s->idct_permutation[i]] =
av_clip((qscale * coeff) / 100 * 4, qmin, 4096);
}
- // all DC coefficients use the same quant so as not to interfere with DC prediction
+ /* all DC coefficients use the same quant so as not to interfere
+ * with DC prediction */
s->qmat[qpi][inter][plane][0] = s->qmat[0][inter][plane][0];
}
}
@@ -398,7 +401,7 @@ static void init_dequantizer(Vp3DecodeContext *s, int qpi)
*/
static void init_loop_filter(Vp3DecodeContext *s)
{
- int *bounding_values= s->bounding_values_array+127;
+ int *bounding_values = s->bounding_values_array + 127;
int filter_limit;
int x;
int value;
@@ -427,7 +430,9 @@ static void init_loop_filter(Vp3DecodeContext *s)
*/
static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
{
- int superblock_starts[3] = { 0, s->u_superblock_start, s->v_superblock_start };
+ int superblock_starts[3] = {
+ 0, s->u_superblock_start, s->v_superblock_start
+ };
int bit = 0;
int current_superblock = 0;
int current_run = 0;
@@ -439,11 +444,9 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
if (s->keyframe) {
memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count);
-
} else {
-
/* unpack the list of partially-coded superblocks */
- bit = get_bits1(gb) ^ 1;
+ bit = get_bits1(gb) ^ 1;
current_run = 0;
while (current_superblock < s->superblock_count && get_bits_left(gb) > 0) {
@@ -452,13 +455,14 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
else
bit ^= 1;
- current_run = get_vlc2(gb,
- s->superblock_run_length_vlc.table, 6, 2) + 1;
- if (current_run == 34)
- current_run += get_bits(gb, 12);
+ current_run = get_vlc2(gb, s->superblock_run_length_vlc.table,
+ 6, 2) + 1;
+ if (current_run == 34)
+ current_run += get_bits(gb, 12);
if (current_superblock + current_run > s->superblock_count) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid partially coded superblock run length\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid partially coded superblock run length\n");
return -1;
}
@@ -475,33 +479,33 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
int superblocks_decoded = 0;
current_superblock = 0;
- bit = get_bits1(gb) ^ 1;
- current_run = 0;
-
- while (superblocks_decoded < s->superblock_count - num_partial_superblocks
- && get_bits_left(gb) > 0) {
+ bit = get_bits1(gb) ^ 1;
+ current_run = 0;
+ while (superblocks_decoded < s->superblock_count - num_partial_superblocks &&
+ get_bits_left(gb) > 0) {
if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
bit = get_bits1(gb);
else
bit ^= 1;
- current_run = get_vlc2(gb,
- s->superblock_run_length_vlc.table, 6, 2) + 1;
- if (current_run == 34)
- current_run += get_bits(gb, 12);
+ current_run = get_vlc2(gb, s->superblock_run_length_vlc.table,
+ 6, 2) + 1;
+ if (current_run == 34)
+ current_run += get_bits(gb, 12);
for (j = 0; j < current_run; current_superblock++) {
if (current_superblock >= s->superblock_count) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid fully coded superblock run length\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid fully coded superblock run length\n");
return -1;
}
- /* skip any superblocks already marked as partially coded */
- if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
- s->superblock_coding[current_superblock] = 2*bit;
- j++;
- }
+ /* skip any superblocks already marked as partially coded */
+ if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
+ s->superblock_coding[current_superblock] = 2 * bit;
+ j++;
+ }
}
superblocks_decoded += current_run;
}
@@ -510,9 +514,8 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
/* if there were partial blocks, initialize bitstream for
* unpacking fragment codings */
if (num_partial_superblocks) {
-
current_run = 0;
- bit = get_bits1(gb);
+ bit = get_bits1(gb);
/* toggle the bit because as soon as the first run length is
* fetched the bit will be toggled again */
bit ^= 1;
@@ -526,30 +529,27 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
for (plane = 0; plane < 3; plane++) {
int sb_start = superblock_starts[plane];
- int sb_end = sb_start + (plane ? s->c_superblock_count : s->y_superblock_count);
+ int sb_end = sb_start + (plane ? s->c_superblock_count
+ : s->y_superblock_count);
int num_coded_frags = 0;
- for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
-
- /* iterate through all 16 fragments in a superblock */
- for (j = 0; j < 16; j++) {
-
- /* if the fragment is in bounds, check its coding status */
- current_fragment = s->superblock_fragments[i * 16 + j];
- if (current_fragment != -1) {
- int coded = s->superblock_coding[i];
-
- if (s->superblock_coding[i] == SB_PARTIALLY_CODED) {
-
- /* fragment may or may not be coded; this is the case
- * that cares about the fragment coding runs */
- if (current_run-- == 0) {
- bit ^= 1;
- current_run = get_vlc2(gb,
- s->fragment_run_length_vlc.table, 5, 2);
+ for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
+ /* iterate through all 16 fragments in a superblock */
+ for (j = 0; j < 16; j++) {
+ /* if the fragment is in bounds, check its coding status */
+ current_fragment = s->superblock_fragments[i * 16 + j];
+ if (current_fragment != -1) {
+ int coded = s->superblock_coding[i];
+
+ if (s->superblock_coding[i] == SB_PARTIALLY_CODED) {
+ /* fragment may or may not be coded; this is the case
+ * that cares about the fragment coding runs */
+ if (current_run-- == 0) {
+ bit ^= 1;
+ current_run = get_vlc2(gb, s->fragment_run_length_vlc.table, 5, 2);
+ }
+ coded = bit;
}
- coded = bit;
- }
if (coded) {
/* default mode; actual mode will be decoded in
@@ -563,14 +563,15 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
s->all_fragments[current_fragment].coding_method =
MODE_COPY;
}
+ }
}
}
- }
s->total_num_coded_frags += num_coded_frags;
for (i = 0; i < 64; i++)
s->num_coded_frags[plane][i] = num_coded_frags;
if (plane < 2)
- s->coded_fragment_list[plane+1] = s->coded_fragment_list[plane] + num_coded_frags;
+ s->coded_fragment_list[plane + 1] = s->coded_fragment_list[plane] +
+ num_coded_frags;
}
return 0;
}
@@ -593,9 +594,7 @@ static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
if (s->keyframe) {
for (i = 0; i < s->fragment_count; i++)
s->all_fragments[i].coding_method = MODE_INTRA;
-
} else {
-
/* fetch the mode coding scheme for this frame */
scheme = get_bits(gb, 3);
@@ -607,7 +606,7 @@ static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
custom_mode_alphabet[get_bits(gb, 3)] = i;
alphabet = custom_mode_alphabet;
} else
- alphabet = ModeAlphabet[scheme-1];
+ alphabet = ModeAlphabet[scheme - 1];
/* iterate through all of the macroblocks that contain 1 or more
* coded fragments */
@@ -616,65 +615,70 @@ static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
if (get_bits_left(gb) <= 0)
return -1;
- for (j = 0; j < 4; j++) {
- int mb_x = 2*sb_x + (j>>1);
- int mb_y = 2*sb_y + (((j>>1)+j)&1);
- current_macroblock = mb_y * s->macroblock_width + mb_x;
+ for (j = 0; j < 4; j++) {
+ int mb_x = 2 * sb_x + (j >> 1);
+ int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
+ current_macroblock = mb_y * s->macroblock_width + mb_x;
- if (mb_x >= s->macroblock_width || mb_y >= s->macroblock_height)
- continue;
+ if (mb_x >= s->macroblock_width ||
+ mb_y >= s->macroblock_height)
+ continue;
-#define BLOCK_X (2*mb_x + (k&1))
-#define BLOCK_Y (2*mb_y + (k>>1))
- /* coding modes are only stored if the macroblock has at least one
- * luma block coded, otherwise it must be INTER_NO_MV */
- for (k = 0; k < 4; k++) {
- current_fragment = BLOCK_Y*s->fragment_width[0] + BLOCK_X;
- if (s->all_fragments[current_fragment].coding_method != MODE_COPY)
- break;
- }
- if (k == 4) {
- s->macroblock_coding[current_macroblock] = MODE_INTER_NO_MV;
- continue;
- }
+#define BLOCK_X (2 * mb_x + (k & 1))
+#define BLOCK_Y (2 * mb_y + (k >> 1))
+ /* coding modes are only stored if the macroblock has
+ * at least one luma block coded, otherwise it must be
+ * INTER_NO_MV */
+ for (k = 0; k < 4; k++) {
+ current_fragment = BLOCK_Y *
+ s->fragment_width[0] + BLOCK_X;
+ if (s->all_fragments[current_fragment].coding_method != MODE_COPY)
+ break;
+ }
+ if (k == 4) {
+ s->macroblock_coding[current_macroblock] = MODE_INTER_NO_MV;
+ continue;
+ }
- /* mode 7 means get 3 bits for each coding mode */
- if (scheme == 7)
- coding_mode = get_bits(gb, 3);
- else
- coding_mode = alphabet
- [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];
+ /* mode 7 means get 3 bits for each coding mode */
+ if (scheme == 7)
+ coding_mode = get_bits(gb, 3);
+ else
+ coding_mode = alphabet[get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];
- s->macroblock_coding[current_macroblock] = coding_mode;
- for (k = 0; k < 4; k++) {
- frag = s->all_fragments + BLOCK_Y*s->fragment_width[0] + BLOCK_X;
- if (frag->coding_method != MODE_COPY)
- frag->coding_method = coding_mode;
- }
+ s->macroblock_coding[current_macroblock] = coding_mode;
+ for (k = 0; k < 4; k++) {
+ frag = s->all_fragments + BLOCK_Y * s->fragment_width[0] + BLOCK_X;
+ if (frag->coding_method != MODE_COPY)
+ frag->coding_method = coding_mode;
+ }
-#define SET_CHROMA_MODES \
- if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \
- frag[s->fragment_start[1]].coding_method = coding_mode;\
- if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \
+#define SET_CHROMA_MODES \
+ if (frag[s->fragment_start[1]].coding_method != MODE_COPY) \
+ frag[s->fragment_start[1]].coding_method = coding_mode; \
+ if (frag[s->fragment_start[2]].coding_method != MODE_COPY) \
frag[s->fragment_start[2]].coding_method = coding_mode;
- if (s->chroma_y_shift) {
- frag = s->all_fragments + mb_y*s->fragment_width[1] + mb_x;
- SET_CHROMA_MODES
- } else if (s->chroma_x_shift) {
- frag = s->all_fragments + 2*mb_y*s->fragment_width[1] + mb_x;
- for (k = 0; k < 2; k++) {
- SET_CHROMA_MODES
- frag += s->fragment_width[1];
- }
- } else {
- for (k = 0; k < 4; k++) {
- frag = s->all_fragments + BLOCK_Y*s->fragment_width[1] + BLOCK_X;
+ if (s->chroma_y_shift) {
+ frag = s->all_fragments + mb_y *
+ s->fragment_width[1] + mb_x;
SET_CHROMA_MODES
+ } else if (s->chroma_x_shift) {
+ frag = s->all_fragments +
+ 2 * mb_y * s->fragment_width[1] + mb_x;
+ for (k = 0; k < 2; k++) {
+ SET_CHROMA_MODES
+ frag += s->fragment_width[1];
+ }
+ } else {
+ for (k = 0; k < 4; k++) {
+ frag = s->all_fragments +
+ BLOCK_Y * s->fragment_width[1] + BLOCK_X;
+ SET_CHROMA_MODES
+ }
}
}
}
- }
}
}
@@ -712,151 +716,152 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
if (get_bits_left(gb) <= 0)
return -1;
- for (j = 0; j < 4; j++) {
- int mb_x = 2*sb_x + (j>>1);
- int mb_y = 2*sb_y + (((j>>1)+j)&1);
- current_macroblock = mb_y * s->macroblock_width + mb_x;
+ for (j = 0; j < 4; j++) {
+ int mb_x = 2 * sb_x + (j >> 1);
+ int mb_y = 2 * sb_y + (((j >> 1) + j) & 1);
+ current_macroblock = mb_y * s->macroblock_width + mb_x;
- if (mb_x >= s->macroblock_width || mb_y >= s->macroblock_height ||
- (s->macroblock_coding[current_macroblock] == MODE_COPY))
- continue;
+ if (mb_x >= s->macroblock_width ||
+ mb_y >= s->macroblock_height ||
+ s->macroblock_coding[current_macroblock] == MODE_COPY)
+ continue;
- switch (s->macroblock_coding[current_macroblock]) {
+ switch (s->macroblock_coding[current_macroblock]) {
+ case MODE_INTER_PLUS_MV:
+ case MODE_GOLDEN_MV:
+ /* all 6 fragments use the same motion vector */
+ if (coding_mode == 0) {
+ motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ } else {
+ motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)];
+ motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)];
+ }
- case MODE_INTER_PLUS_MV:
- case MODE_GOLDEN_MV:
- /* all 6 fragments use the same motion vector */
- if (coding_mode == 0) {
- motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
- motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
- } else {
- motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)];
- motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)];
- }
+ /* vector maintenance, only on MODE_INTER_PLUS_MV */
+ if (s->macroblock_coding[current_macroblock] == MODE_INTER_PLUS_MV) {
+ prior_last_motion_x = last_motion_x;
+ prior_last_motion_y = last_motion_y;
+ last_motion_x = motion_x[0];
+ last_motion_y = motion_y[0];
+ }
+ break;
- /* vector maintenance, only on MODE_INTER_PLUS_MV */
- if (s->macroblock_coding[current_macroblock] ==
- MODE_INTER_PLUS_MV) {
+ case MODE_INTER_FOURMV:
+ /* vector maintenance */
prior_last_motion_x = last_motion_x;
prior_last_motion_y = last_motion_y;
- last_motion_x = motion_x[0];
- last_motion_y = motion_y[0];
- }
- break;
-
- case MODE_INTER_FOURMV:
- /* vector maintenance */
- prior_last_motion_x = last_motion_x;
- prior_last_motion_y = last_motion_y;
- /* fetch 4 vectors from the bitstream, one for each
- * Y fragment, then average for the C fragment vectors */
- for (k = 0; k < 4; k++) {
- current_fragment = BLOCK_Y*s->fragment_width[0] + BLOCK_X;
- if (s->all_fragments[current_fragment].coding_method != MODE_COPY) {
- if (coding_mode == 0) {
- motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
- motion_y[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ /* fetch 4 vectors from the bitstream, one for each
+ * Y fragment, then average for the C fragment vectors */
+ for (k = 0; k < 4; k++) {
+ current_fragment = BLOCK_Y * s->fragment_width[0] + BLOCK_X;
+ if (s->all_fragments[current_fragment].coding_method != MODE_COPY) {
+ if (coding_mode == 0) {
+ motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ motion_y[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ } else {
+ motion_x[k] = fixed_motion_vector_table[get_bits(gb, 6)];
+ motion_y[k] = fixed_motion_vector_table[get_bits(gb, 6)];
+ }
+ last_motion_x = motion_x[k];
+ last_motion_y = motion_y[k];
} else {
- motion_x[k] = fixed_motion_vector_table[get_bits(gb, 6)];
- motion_y[k] = fixed_motion_vector_table[get_bits(gb, 6)];
+ motion_x[k] = 0;
+ motion_y[k] = 0;
}
- last_motion_x = motion_x[k];
- last_motion_y = motion_y[k];
- } else {
- motion_x[k] = 0;
- motion_y[k] = 0;
}
- }
- break;
-
- case MODE_INTER_LAST_MV:
- /* all 6 fragments use the last motion vector */
- motion_x[0] = last_motion_x;
- motion_y[0] = last_motion_y;
-
- /* no vector maintenance (last vector remains the
- * last vector) */
- break;
-
- case MODE_INTER_PRIOR_LAST:
- /* all 6 fragments use the motion vector prior to the
- * last motion vector */
- motion_x[0] = prior_last_motion_x;
- motion_y[0] = prior_last_motion_y;
-
- /* vector maintenance */
- prior_last_motion_x = last_motion_x;
- prior_last_motion_y = last_motion_y;
- last_motion_x = motion_x[0];
- last_motion_y = motion_y[0];
- break;
-
- default:
- /* covers intra, inter without MV, golden without MV */
- motion_x[0] = 0;
- motion_y[0] = 0;
-
- /* no vector maintenance */
- break;
- }
+ break;
- /* assign the motion vectors to the correct fragments */
- for (k = 0; k < 4; k++) {
- current_fragment =
- BLOCK_Y*s->fragment_width[0] + BLOCK_X;
- if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
- s->motion_val[0][current_fragment][0] = motion_x[k];
- s->motion_val[0][current_fragment][1] = motion_y[k];
- } else {
- s->motion_val[0][current_fragment][0] = motion_x[0];
- s->motion_val[0][current_fragment][1] = motion_y[0];
- }
- }
+ case MODE_INTER_LAST_MV:
+ /* all 6 fragments use the last motion vector */
+ motion_x[0] = last_motion_x;
+ motion_y[0] = last_motion_y;
- if (s->chroma_y_shift) {
- if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
- motion_x[0] = RSHIFT(motion_x[0] + motion_x[1] + motion_x[2] + motion_x[3], 2);
- motion_y[0] = RSHIFT(motion_y[0] + motion_y[1] + motion_y[2] + motion_y[3], 2);
- }
- motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
- motion_y[0] = (motion_y[0]>>1) | (motion_y[0]&1);
- frag = mb_y*s->fragment_width[1] + mb_x;
- s->motion_val[1][frag][0] = motion_x[0];
- s->motion_val[1][frag][1] = motion_y[0];
- } else if (s->chroma_x_shift) {
- if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
- motion_x[0] = RSHIFT(motion_x[0] + motion_x[1], 1);
- motion_y[0] = RSHIFT(motion_y[0] + motion_y[1], 1);
- motion_x[1] = RSHIFT(motion_x[2] + motion_x[3], 1);
- motion_y[1] = RSHIFT(motion_y[2] + motion_y[3], 1);
- } else {
- motion_x[1] = motion_x[0];
- motion_y[1] = motion_y[0];
- }
- motion_x[0] = (motion_x[0]>>1) | (motion_x[0]&1);
- motion_x[1] = (motion_x[1]>>1) | (motion_x[1]&1);
-
- frag = 2*mb_y*s->fragment_width[1] + mb_x;
- for (k = 0; k < 2; k++) {
- s->motion_val[1][frag][0] = motion_x[k];
- s->motion_val[1][frag][1] = motion_y[k];
- frag += s->fragment_width[1];
+ /* no vector maintenance (last vector remains the
+ * last vector) */
+ break;
+
+ case MODE_INTER_PRIOR_LAST:
+ /* all 6 fragments use the motion vector prior to the
+ * last motion vector */
+ motion_x[0] = prior_last_motion_x;
+ motion_y[0] = prior_last_motion_y;
+
+ /* vector maintenance */
+ prior_last_motion_x = last_motion_x;
+ prior_last_motion_y = last_motion_y;
+ last_motion_x = motion_x[0];
+ last_motion_y = motion_y[0];
+ break;
+
+ default:
+ /* covers intra, inter without MV, golden without MV */
+ motion_x[0] = 0;
+ motion_y[0] = 0;
+
+ /* no vector maintenance */
+ break;
}
- } else {
+
+ /* assign the motion vectors to the correct fragments */
for (k = 0; k < 4; k++) {
- frag = BLOCK_Y*s->fragment_width[1] + BLOCK_X;
+ current_fragment =
+ BLOCK_Y * s->fragment_width[0] + BLOCK_X;
+ if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
+ s->motion_val[0][current_fragment][0] = motion_x[k];
+ s->motion_val[0][current_fragment][1] = motion_y[k];
+ } else {
+ s->motion_val[0][current_fragment][0] = motion_x[0];
+ s->motion_val[0][current_fragment][1] = motion_y[0];
+ }
+ }
+
+ if (s->chroma_y_shift) {
if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
+ motion_x[0] = RSHIFT(motion_x[0] + motion_x[1] +
+ motion_x[2] + motion_x[3], 2);
+ motion_y[0] = RSHIFT(motion_y[0] + motion_y[1] +
+ motion_y[2] + motion_y[3], 2);
+ }
+ motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
+ motion_y[0] = (motion_y[0] >> 1) | (motion_y[0] & 1);
+ frag = mb_y * s->fragment_width[1] + mb_x;
+ s->motion_val[1][frag][0] = motion_x[0];
+ s->motion_val[1][frag][1] = motion_y[0];
+ } else if (s->chroma_x_shift) {
+ if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
+ motion_x[0] = RSHIFT(motion_x[0] + motion_x[1], 1);
+ motion_y[0] = RSHIFT(motion_y[0] + motion_y[1], 1);
+ motion_x[1] = RSHIFT(motion_x[2] + motion_x[3], 1);
+ motion_y[1] = RSHIFT(motion_y[2] + motion_y[3], 1);
+ } else {
+ motion_x[1] = motion_x[0];
+ motion_y[1] = motion_y[0];
+ }
+ motion_x[0] = (motion_x[0] >> 1) | (motion_x[0] & 1);
+ motion_x[1] = (motion_x[1] >> 1) | (motion_x[1] & 1);
+
+ frag = 2 * mb_y * s->fragment_width[1] + mb_x;
+ for (k = 0; k < 2; k++) {
s->motion_val[1][frag][0] = motion_x[k];
s->motion_val[1][frag][1] = motion_y[k];
- } else {
- s->motion_val[1][frag][0] = motion_x[0];
- s->motion_val[1][frag][1] = motion_y[0];
+ frag += s->fragment_width[1];
+ }
+ } else {
+ for (k = 0; k < 4; k++) {
+ frag = BLOCK_Y * s->fragment_width[1] + BLOCK_X;
+ if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
+ s->motion_val[1][frag][0] = motion_x[k];
+ s->motion_val[1][frag][1] = motion_y[k];
+ } else {
+ s->motion_val[1][frag][0] = motion_x[0];
+ s->motion_val[1][frag][1] = motion_y[0];
+ }
}
}
}
}
- }
}
return 0;
@@ -867,10 +872,10 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi;
int num_blocks = s->total_num_coded_frags;
- for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {
+ for (qpi = 0; qpi < s->nqps - 1 && num_blocks > 0; qpi++) {
i = blocks_decoded = num_blocks_at_qpi = 0;
- bit = get_bits1(gb) ^ 1;
+ bit = get_bits1(gb) ^ 1;
run_length = 0;
do {
@@ -917,34 +922,37 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
* be passed into the next call to this same function.
*/
static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
- VLC *table, int coeff_index,
- int plane,
- int eob_run)
+ VLC *table, int coeff_index,
+ int plane,
+ int eob_run)
{
int i, j = 0;
int token;
- int zero_run = 0;
+ int zero_run = 0;
int16_t coeff = 0;
int bits_to_get;
int blocks_ended;
int coeff_i = 0;
- int num_coeffs = s->num_coded_frags[plane][coeff_index];
+ int num_coeffs = s->num_coded_frags[plane][coeff_index];
int16_t *dct_tokens = s->dct_tokens[plane][coeff_index];
/* local references to structure members to avoid repeated deferences */
- int *coded_fragment_list = s->coded_fragment_list[plane];
+ int *coded_fragment_list = s->coded_fragment_list[plane];
Vp3Fragment *all_fragments = s->all_fragments;
- VLC_TYPE (*vlc_table)[2] = table->table;
+ VLC_TYPE(*vlc_table)[2] = table->table;
if (num_coeffs < 0)
- av_log(s->avctx, AV_LOG_ERROR, "Invalid number of coefficents at level %d\n", coeff_index);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid number of coefficents at level %d\n", coeff_index);
if (eob_run > num_coeffs) {
- coeff_i = blocks_ended = num_coeffs;
- eob_run -= num_coeffs;
+ coeff_i =
+ blocks_ended = num_coeffs;
+ eob_run -= num_coeffs;
} else {
- coeff_i = blocks_ended = eob_run;
- eob_run = 0;
+ coeff_i =
+ blocks_ended = eob_run;
+ eob_run = 0;
}
// insert fake EOB token to cover the split between planes or zzi
@@ -952,66 +960,66 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
dct_tokens[j++] = blocks_ended << 2;
while (coeff_i < num_coeffs && get_bits_left(gb) > 0) {
- /* decode a VLC into a token */
- token = get_vlc2(gb, vlc_table, 11, 3);
- /* use the token to get a zero run, a coefficient, and an eob run */
- if ((unsigned) token <= 6U) {
- eob_run = eob_run_base[token];
- if (eob_run_get_bits[token])
- eob_run += get_bits(gb, eob_run_get_bits[token]);
-
- // record only the number of blocks ended in this plane,
- // any spill will be recorded in the next plane.
- if (eob_run > num_coeffs - coeff_i) {
- dct_tokens[j++] = TOKEN_EOB(num_coeffs - coeff_i);
- blocks_ended += num_coeffs - coeff_i;
- eob_run -= num_coeffs - coeff_i;
- coeff_i = num_coeffs;
- } else {
- dct_tokens[j++] = TOKEN_EOB(eob_run);
- blocks_ended += eob_run;
- coeff_i += eob_run;
- eob_run = 0;
- }
- } else if (token >= 0) {
- bits_to_get = coeff_get_bits[token];
- if (bits_to_get)
- bits_to_get = get_bits(gb, bits_to_get);
- coeff = coeff_tables[token][bits_to_get];
-
- zero_run = zero_run_base[token];
- if (zero_run_get_bits[token])
- zero_run += get_bits(gb, zero_run_get_bits[token]);
-
- if (zero_run) {
- dct_tokens[j++] = TOKEN_ZERO_RUN(coeff, zero_run);
- } else {
- // Save DC into the fragment structure. DC prediction is
- // done in raster order, so the actual DC can't be in with
- // other tokens. We still need the token in dct_tokens[]
- // however, or else the structure collapses on itself.
- if (!coeff_index)
- all_fragments[coded_fragment_list[coeff_i]].dc = coeff;
-
- dct_tokens[j++] = TOKEN_COEFF(coeff);
- }
-
- if (coeff_index + zero_run > 64) {
- av_log(s->avctx, AV_LOG_DEBUG, "Invalid zero run of %d with"
- " %d coeffs left\n", zero_run, 64-coeff_index);
- zero_run = 64 - coeff_index;
- }
-
- // zero runs code multiple coefficients,
- // so don't try to decode coeffs for those higher levels
- for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
- s->num_coded_frags[plane][i]--;
- coeff_i++;
+ /* decode a VLC into a token */
+ token = get_vlc2(gb, vlc_table, 11, 3);
+ /* use the token to get a zero run, a coefficient, and an eob run */
+ if ((unsigned) token <= 6U) {
+ eob_run = eob_run_base[token];
+ if (eob_run_get_bits[token])
+ eob_run += get_bits(gb, eob_run_get_bits[token]);
+
+ // record only the number of blocks ended in this plane,
+ // any spill will be recorded in the next plane.
+ if (eob_run > num_coeffs - coeff_i) {
+ dct_tokens[j++] = TOKEN_EOB(num_coeffs - coeff_i);
+ blocks_ended += num_coeffs - coeff_i;
+ eob_run -= num_coeffs - coeff_i;
+ coeff_i = num_coeffs;
} else {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid token %d\n", token);
- return -1;
+ dct_tokens[j++] = TOKEN_EOB(eob_run);
+ blocks_ended += eob_run;
+ coeff_i += eob_run;
+ eob_run = 0;
}
+ } else if (token >= 0) {
+ bits_to_get = coeff_get_bits[token];
+ if (bits_to_get)
+ bits_to_get = get_bits(gb, bits_to_get);
+ coeff = coeff_tables[token][bits_to_get];
+
+ zero_run = zero_run_base[token];
+ if (zero_run_get_bits[token])
+ zero_run += get_bits(gb, zero_run_get_bits[token]);
+
+ if (zero_run) {
+ dct_tokens[j++] = TOKEN_ZERO_RUN(coeff, zero_run);
+ } else {
+ // Save DC into the fragment structure. DC prediction is
+ // done in raster order, so the actual DC can't be in with
+ // other tokens. We still need the token in dct_tokens[]
+ // however, or else the structure collapses on itself.
+ if (!coeff_index)
+ all_fragments[coded_fragment_list[coeff_i]].dc = coeff;
+
+ dct_tokens[j++] = TOKEN_COEFF(coeff);
+ }
+
+ if (coeff_index + zero_run > 64) {
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "Invalid zero run of %d with %d coeffs left\n",
+ zero_run, 64 - coeff_index);
+ zero_run = 64 - coeff_index;
+ }
+
+ // zero runs code multiple coefficients,
+ // so don't try to decode coeffs for those higher levels
+ for (i = coeff_index + 1; i <= coeff_index + zero_run; i++)
+ s->num_coded_frags[plane][i]--;
+ coeff_i++;
+ } else {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid token %d\n", token);
+ return -1;
+ }
}
if (blocks_ended > s->num_coded_frags[plane][coeff_index])
@@ -1020,14 +1028,14 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
// decrement the number of blocks that have higher coeffecients for each
// EOB run at this level
if (blocks_ended)
- for (i = coeff_index+1; i < 64; i++)
+ for (i = coeff_index + 1; i < 64; i++)
s->num_coded_frags[plane][i] -= blocks_ended;
// setup the next buffer
if (plane < 2)
- s->dct_tokens[plane+1][coeff_index] = dct_tokens + j;
+ s->dct_tokens[plane + 1][coeff_index] = dct_tokens + j;
else if (coeff_index < 63)
- s->dct_tokens[0][coeff_index+1] = dct_tokens + j;
+ s->dct_tokens[0][coeff_index + 1] = dct_tokens + j;
return eob_run;
}
@@ -1059,7 +1067,7 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
/* unpack the Y plane DC coefficients */
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
- 0, residual_eob_run);
+ 0, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
@@ -1068,21 +1076,20 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
/* unpack the C plane DC coefficients */
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
- 1, residual_eob_run);
+ 1, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
- 2, residual_eob_run);
+ 2, residual_eob_run);
if (residual_eob_run < 0)
return residual_eob_run;
/* reverse prediction of the C-plane DC coefficients */
- if (!(s->avctx->flags & CODEC_FLAG_GRAY))
- {
+ if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
reverse_dc_prediction(s, s->fragment_start[1],
- s->fragment_width[1], s->fragment_height[1]);
+ s->fragment_width[1], s->fragment_height[1]);
reverse_dc_prediction(s, s->fragment_start[2],
- s->fragment_width[1], s->fragment_height[1]);
+ s->fragment_width[1], s->fragment_height[1]);
}
/* fetch the AC table indexes */
@@ -1109,19 +1116,19 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
/* decode all AC coefficents */
for (i = 1; i <= 63; i++) {
- residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
- 0, residual_eob_run);
- if (residual_eob_run < 0)
- return residual_eob_run;
-
- residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
- 1, residual_eob_run);
- if (residual_eob_run < 0)
- return residual_eob_run;
- residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
- 2, residual_eob_run);
- if (residual_eob_run < 0)
- return residual_eob_run;
+ residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
+ 0, residual_eob_run);
+ if (residual_eob_run < 0)
+ return residual_eob_run;
+
+ residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+ 1, residual_eob_run);
+ if (residual_eob_run < 0)
+ return residual_eob_run;
+ residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+ 2, residual_eob_run);
+ if (residual_eob_run < 0)
+ return residual_eob_run;
}
return 0;
@@ -1132,8 +1139,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
* the frame. Much of this function is adapted directly from the original
* VP3 source code.
*/
-#define COMPATIBLE_FRAME(x) \
- (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
+#define COMPATIBLE_FRAME(x) \
+ (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
#define DC_COEFF(u) s->all_fragments[u].dc
static void reverse_dc_prediction(Vp3DecodeContext *s,
@@ -1141,7 +1148,6 @@ static void reverse_dc_prediction(Vp3DecodeContext *s,
int fragment_width,
int fragment_height)
{
-
#define PUL 8
#define PU 4
#define PUR 2
@@ -1166,22 +1172,22 @@ static void reverse_dc_prediction(Vp3DecodeContext *s,
* 3: left multiplier
*/
static const int predictor_transform[16][4] = {
- { 0, 0, 0, 0},
- { 0, 0, 0,128}, // PL
- { 0, 0,128, 0}, // PUR
- { 0, 0, 53, 75}, // PUR|PL
- { 0,128, 0, 0}, // PU
- { 0, 64, 0, 64}, // PU|PL
- { 0,128, 0, 0}, // PU|PUR
- { 0, 0, 53, 75}, // PU|PUR|PL
- {128, 0, 0, 0}, // PUL
- { 0, 0, 0,128}, // PUL|PL
- { 64, 0, 64, 0}, // PUL|PUR
- { 0, 0, 53, 75}, // PUL|PUR|PL
- { 0,128, 0, 0}, // PUL|PU
- {-104,116, 0,116}, // PUL|PU|PL
- { 24, 80, 24, 0}, // PUL|PU|PUR
- {-104,116, 0,116} // PUL|PU|PUR|PL
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 128 }, // PL
+ { 0, 0, 128, 0 }, // PUR
+ { 0, 0, 53, 75 }, // PUR|PL
+ { 0, 128, 0, 0 }, // PU
+ { 0, 64, 0, 64 }, // PU |PL
+ { 0, 128, 0, 0 }, // PU |PUR
+ { 0, 0, 53, 75 }, // PU |PUR|PL
+ { 128, 0, 0, 0 }, // PUL
+ { 0, 0, 0, 128 }, // PUL|PL
+ { 64, 0, 64, 0 }, // PUL|PUR
+ { 0, 0, 53, 75 }, // PUL|PUR|PL
+ { 0, 128, 0, 0 }, // PUL|PU
+ { -104, 116, 0, 116 }, // PUL|PU |PL
+ { 24, 80, 24, 0 }, // PUL|PU |PUR
+ { -104, 116, 0, 116 } // PUL|PU |PUR|PL
};
/* This table shows which types of blocks can use other blocks for
@@ -1208,54 +1214,55 @@ static void reverse_dc_prediction(Vp3DecodeContext *s,
int transform = 0;
- vul = vu = vur = vl = 0;
- last_dc[0] = last_dc[1] = last_dc[2] = 0;
+ vul =
+ vu =
+ vur =
+ vl = 0;
+ last_dc[0] =
+ last_dc[1] =
+ last_dc[2] = 0;
/* for each fragment row... */
for (y = 0; y < fragment_height; y++) {
-
/* for each fragment in a row... */
for (x = 0; x < fragment_width; x++, i++) {
/* reverse prediction if this block was coded */
if (s->all_fragments[i].coding_method != MODE_COPY) {
-
current_frame_type =
compatible_frame[s->all_fragments[i].coding_method];
- transform= 0;
- if(x){
- l= i-1;
+ transform = 0;
+ if (x) {
+ l = i - 1;
vl = DC_COEFF(l);
- if(COMPATIBLE_FRAME(l))
+ if (COMPATIBLE_FRAME(l))
transform |= PL;
}
- if(y){
- u= i-fragment_width;
+ if (y) {
+ u = i - fragment_width;
vu = DC_COEFF(u);
- if(COMPATIBLE_FRAME(u))
+ if (COMPATIBLE_FRAME(u))
transform |= PU;
- if(x){
- ul= i-fragment_width-1;
+ if (x) {
+ ul = i - fragment_width - 1;
vul = DC_COEFF(ul);
- if(COMPATIBLE_FRAME(ul))
+ if (COMPATIBLE_FRAME(ul))
transform |= PUL;
}
- if(x + 1 < fragment_width){
- ur= i-fragment_width+1;
+ if (x + 1 < fragment_width) {
+ ur = i - fragment_width + 1;
vur = DC_COEFF(ur);
- if(COMPATIBLE_FRAME(ur))
+ if (COMPATIBLE_FRAME(ur))
transform |= PUR;
}
}
if (transform == 0) {
-
/* if there were no fragments to predict from, use last
* DC saved */
predicted_dc = last_dc[current_frame_type];
} else {
-
/* apply the appropriate predictor transform */
predicted_dc =
(predictor_transform[transform][0] * vul) +
@@ -1286,39 +1293,39 @@ static void reverse_dc_prediction(Vp3DecodeContext *s,
}
}
-static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
+static void apply_loop_filter(Vp3DecodeContext *s, int plane,
+ int ystart, int yend)
{
int x, y;
- int *bounding_values= s->bounding_values_array+127;
+ int *bounding_values = s->bounding_values_array + 127;
int width = s->fragment_width[!!plane];
int height = s->fragment_height[!!plane];
- int fragment = s->fragment_start [plane] + ystart * width;
+ int fragment = s->fragment_start[plane] + ystart * width;
ptrdiff_t stride = s->current_frame.f->linesize[plane];
- uint8_t *plane_data = s->current_frame.f->data [plane];
- if (!s->flipped_image) stride = -stride;
- plane_data += s->data_offset[plane] + 8*ystart*stride;
+ uint8_t *plane_data = s->current_frame.f->data[plane];
+ if (!s->flipped_image)
+ stride = -stride;
+ plane_data += s->data_offset[plane] + 8 * ystart * stride;
for (y = ystart; y < yend; y++) {
-
for (x = 0; x < width; x++) {
/* This code basically just deblocks on the edges of coded blocks.
* However, it has to be much more complicated because of the
* braindamaged deblock ordering used in VP3/Theora. Order matters
* because some pixels get filtered twice. */
- if( s->all_fragments[fragment].coding_method != MODE_COPY )
- {
+ if (s->all_fragments[fragment].coding_method != MODE_COPY) {
/* do not perform left edge filter for left columns frags */
if (x > 0) {
s->vp3dsp.h_loop_filter(
- plane_data + 8*x,
+ plane_data + 8 * x,
stride, bounding_values);
}
/* do not perform top edge filter for top row fragments */
if (y > 0) {
s->vp3dsp.v_loop_filter(
- plane_data + 8*x,
+ plane_data + 8 * x,
stride, bounding_values);
}
@@ -1328,7 +1335,7 @@ static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int ye
if ((x < width - 1) &&
(s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {
s->vp3dsp.h_loop_filter(
- plane_data + 8*x + 8,
+ plane_data + 8 * x + 8,
stride, bounding_values);
}
@@ -1338,14 +1345,14 @@ static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int ye
if ((y < height - 1) &&
(s->all_fragments[fragment + width].coding_method == MODE_COPY)) {
s->vp3dsp.v_loop_filter(
- plane_data + 8*x + 8*stride,
+ plane_data + 8 * x + 8 * stride,
stride, bounding_values);
}
}
fragment++;
}
- plane_data += 8*stride;
+ plane_data += 8 * stride;
}
}
@@ -1364,7 +1371,7 @@ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag,
int token = *s->dct_tokens[plane][i];
switch (token & 3) {
case 0: // EOB
- if (--token < 4) // 0-3 are token types, so the EOB run must now be 0
+ if (--token < 4) // 0-3 are token types so the EOB run must now be 0
s->dct_tokens[plane][i]++;
else
*s->dct_tokens[plane][i] = token & ~3;
@@ -1403,30 +1410,32 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
int h, cy, i;
int offset[AV_NUM_DATA_POINTERS];
- if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
- int y_flipped = s->flipped_image ? s->avctx->height-y : y;
+ if (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_FRAME) {
+ int y_flipped = s->flipped_image ? s->avctx->height - y : y;
- // At the end of the frame, report INT_MAX instead of the height of the frame.
- // This makes the other threads' ff_thread_await_progress() calls cheaper, because
- // they don't have to clip their values.
- ff_thread_report_progress(&s->current_frame, y_flipped==s->avctx->height ? INT_MAX : y_flipped-1, 0);
+ /* At the end of the frame, report INT_MAX instead of the height of
+ * the frame. This makes the other threads' ff_thread_await_progress()
+ * calls cheaper, because they don't have to clip their values. */
+ ff_thread_report_progress(&s->current_frame,
+ y_flipped == s->avctx->height ? INT_MAX
+ : y_flipped - 1,
+ 0);
}
- if(s->avctx->draw_horiz_band==NULL)
+ if (s->avctx->draw_horiz_band == NULL)
return;
- h= y - s->last_slice_end;
- s->last_slice_end= y;
+ h = y - s->last_slice_end;
+ s->last_slice_end = y;
y -= h;
- if (!s->flipped_image) {
+ if (!s->flipped_image)
y = s->avctx->height - y - h;
- }
- cy = y >> s->chroma_y_shift;
- offset[0] = s->current_frame.f->linesize[0]*y;
- offset[1] = s->current_frame.f->linesize[1]*cy;
- offset[2] = s->current_frame.f->linesize[2]*cy;
+ cy = y >> s->chroma_y_shift;
+ offset[0] = s->current_frame.f->linesize[0] * y;
+ offset[1] = s->current_frame.f->linesize[1] * cy;
+ offset[2] = s->current_frame.f->linesize[2] * cy;
for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
offset[i] = 0;
@@ -1438,11 +1447,12 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
* Wait for the reference frame of the current fragment.
* The progress value is in luma pixel rows.
*/
-static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment, int motion_y, int y)
+static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment,
+ int motion_y, int y)
{
ThreadFrame *ref_frame;
int ref_row;
- int border = motion_y&1;
+ int border = motion_y & 1;
if (fragment->coding_method == MODE_USING_GOLDEN ||
fragment->coding_method == MODE_GOLDEN_MV)
@@ -1450,7 +1460,7 @@ static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment, int
else
ref_frame = &s->last_frame;
- ref_row = y + (motion_y>>1);
+ ref_row = y + (motion_y >> 1);
ref_row = FFMAX(FFABS(ref_row), ref_row + 8 + border);
ff_thread_await_progress(ref_frame, ref_row, 0);
@@ -1473,38 +1483,43 @@ static void render_slice(Vp3DecodeContext *s, int slice)
return;
for (plane = 0; plane < 3; plane++) {
- uint8_t *output_plane = s->current_frame.f->data [plane] + s->data_offset[plane];
- uint8_t * last_plane = s-> last_frame.f->data [plane] + s->data_offset[plane];
- uint8_t *golden_plane = s-> golden_frame.f->data [plane] + s->data_offset[plane];
- ptrdiff_t stride = s->current_frame.f->linesize[plane];
- int plane_width = s->width >> (plane && s->chroma_x_shift);
- int plane_height = s->height >> (plane && s->chroma_y_shift);
- int8_t (*motion_val)[2] = s->motion_val[!!plane];
-
- int sb_x, sb_y = slice << (!plane && s->chroma_y_shift);
- int slice_height = sb_y + 1 + (!plane && s->chroma_y_shift);
- int slice_width = plane ? s->c_superblock_width : s->y_superblock_width;
-
- int fragment_width = s->fragment_width[!!plane];
- int fragment_height = s->fragment_height[!!plane];
- int fragment_start = s->fragment_start[plane];
- int do_await = !plane && HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME);
-
- if (!s->flipped_image) stride = -stride;
+ uint8_t *output_plane = s->current_frame.f->data[plane] +
+ s->data_offset[plane];
+ uint8_t *last_plane = s->last_frame.f->data[plane] +
+ s->data_offset[plane];
+ uint8_t *golden_plane = s->golden_frame.f->data[plane] +
+ s->data_offset[plane];
+ ptrdiff_t stride = s->current_frame.f->linesize[plane];
+ int plane_width = s->width >> (plane && s->chroma_x_shift);
+ int plane_height = s->height >> (plane && s->chroma_y_shift);
+ int8_t(*motion_val)[2] = s->motion_val[!!plane];
+
+ int sb_x, sb_y = slice << (!plane && s->chroma_y_shift);
+ int slice_height = sb_y + 1 + (!plane && s->chroma_y_shift);
+ int slice_width = plane ? s->c_superblock_width
+ : s->y_superblock_width;
+
+ int fragment_width = s->fragment_width[!!plane];
+ int fragment_height = s->fragment_height[!!plane];
+ int fragment_start = s->fragment_start[plane];
+
+ int do_await = !plane && HAVE_THREADS &&
+ (s->avctx->active_thread_type & FF_THREAD_FRAME);
+
+ if (!s->flipped_image)
+ stride = -stride;
if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY))
continue;
/* for each superblock row in the slice (both of them)... */
for (; sb_y < slice_height; sb_y++) {
-
/* for each superblock in a row... */
for (sb_x = 0; sb_x < slice_width; sb_x++) {
-
/* for each block in a superblock... */
for (j = 0; j < 16; j++) {
- x = 4*sb_x + hilbert_offset[j][0];
- y = 4*sb_y + hilbert_offset[j][1];
- fragment = y*fragment_width + x;
+ x = 4 * sb_x + hilbert_offset[j][0];
+ y = 4 * sb_y + hilbert_offset[j][1];
+ fragment = y * fragment_width + x;
i = fragment_start + fragment;
@@ -1512,119 +1527,126 @@ static void render_slice(Vp3DecodeContext *s, int slice)
if (x >= fragment_width || y >= fragment_height)
continue;
- first_pixel = 8*y*stride + 8*x;
-
- if (do_await && s->all_fragments[i].coding_method != MODE_INTRA)
- await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift);
-
- /* transform if this block was coded */
- if (s->all_fragments[i].coding_method != MODE_COPY) {
- if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
- (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
- motion_source= golden_plane;
- else
- motion_source= last_plane;
-
- motion_source += first_pixel;
- motion_halfpel_index = 0;
-
- /* sort out the motion vector if this fragment is coded
- * using a motion vector method */
- if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
- (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
- int src_x, src_y;
- motion_x = motion_val[fragment][0];
- motion_y = motion_val[fragment][1];
-
- src_x= (motion_x>>1) + 8*x;
- src_y= (motion_y>>1) + 8*y;
-
- motion_halfpel_index = motion_x & 0x01;
- motion_source += (motion_x >> 1);
-
- motion_halfpel_index |= (motion_y & 0x01) << 1;
- motion_source += ((motion_y >> 1) * stride);
-
- if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){
- uint8_t *temp= s->edge_emu_buffer;
- if(stride<0) temp -= 8*stride;
-
- s->vdsp.emulated_edge_mc(temp, motion_source,
- stride, stride,
- 9, 9, src_x, src_y,
- plane_width,
- plane_height);
- motion_source= temp;
+ first_pixel = 8 * y * stride + 8 * x;
+
+ if (do_await &&
+ s->all_fragments[i].coding_method != MODE_INTRA)
+ await_reference_row(s, &s->all_fragments[i],
+ motion_val[fragment][1],
+ (16 * y) >> s->chroma_y_shift);
+
+ /* transform if this block was coded */
+ if (s->all_fragments[i].coding_method != MODE_COPY) {
+ if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
+ (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
+ motion_source = golden_plane;
+ else
+ motion_source = last_plane;
+
+ motion_source += first_pixel;
+ motion_halfpel_index = 0;
+
+ /* sort out the motion vector if this fragment is coded
+ * using a motion vector method */
+ if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
+ (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
+ int src_x, src_y;
+ motion_x = motion_val[fragment][0];
+ motion_y = motion_val[fragment][1];
+
+ src_x = (motion_x >> 1) + 8 * x;
+ src_y = (motion_y >> 1) + 8 * y;
+
+ motion_halfpel_index = motion_x & 0x01;
+ motion_source += (motion_x >> 1);
+
+ motion_halfpel_index |= (motion_y & 0x01) << 1;
+ motion_source += ((motion_y >> 1) * stride);
+
+ if (src_x < 0 || src_y < 0 ||
+ src_x + 9 >= plane_width ||
+ src_y + 9 >= plane_height) {
+ uint8_t *temp = s->edge_emu_buffer;
+ if (stride < 0)
+ temp -= 8 * stride;
+
+ s->vdsp.emulated_edge_mc(temp, motion_source,
+ stride, stride,
+ 9, 9, src_x, src_y,
+ plane_width,
+ plane_height);
+ motion_source = temp;
+ }
}
- }
-
- /* first, take care of copying a block from either the
- * previous or the golden frame */
- if (s->all_fragments[i].coding_method != MODE_INTRA) {
- /* Note, it is possible to implement all MC cases with
- put_no_rnd_pixels_l2 which would look more like the
- VP3 source but this would be slower as
- put_no_rnd_pixels_tab is better optimzed */
- if(motion_halfpel_index != 3){
- s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
- output_plane + first_pixel,
- motion_source, stride, 8);
- }else{
- int d= (motion_x ^ motion_y)>>31; // d is 0 if motion_x and _y have the same sign, else -1
- s->vp3dsp.put_no_rnd_pixels_l2(
- output_plane + first_pixel,
- motion_source - d,
- motion_source + stride + 1 + d,
- stride, 8);
+ /* first, take care of copying a block from either the
+ * previous or the golden frame */
+ if (s->all_fragments[i].coding_method != MODE_INTRA) {
+ /* Note, it is possible to implement all MC cases
+ * with put_no_rnd_pixels_l2 which would look more
+ * like the VP3 source but this would be slower as
+ * put_no_rnd_pixels_tab is better optimzed */
+ if (motion_halfpel_index != 3) {
+ s->hdsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
+ output_plane + first_pixel,
+ motion_source, stride, 8);
+ } else {
+ /* d is 0 if motion_x and _y have the same sign,
+ * else -1 */
+ int d = (motion_x ^ motion_y) >> 31;
+ s->vp3dsp.put_no_rnd_pixels_l2(output_plane + first_pixel,
+ motion_source - d,
+ motion_source + stride + 1 + d,
+ stride, 8);
+ }
}
- }
- /* invert DCT and place (or add) in final output */
+ /* invert DCT and place (or add) in final output */
- if (s->all_fragments[i].coding_method == MODE_INTRA) {
- vp3_dequant(s, s->all_fragments + i, plane, 0, block);
- s->vp3dsp.idct_put(
- output_plane + first_pixel,
- stride,
- block);
- } else {
- if (vp3_dequant(s, s->all_fragments + i, plane, 1, block)) {
- s->vp3dsp.idct_add(
- output_plane + first_pixel,
- stride,
- block);
+ if (s->all_fragments[i].coding_method == MODE_INTRA) {
+ vp3_dequant(s, s->all_fragments + i,
+ plane, 0, block);
+ s->vp3dsp.idct_put(output_plane + first_pixel,
+ stride,
+ block);
} else {
- s->vp3dsp.idct_dc_add(output_plane + first_pixel, stride, block);
+ if (vp3_dequant(s, s->all_fragments + i,
+ plane, 1, block)) {
+ s->vp3dsp.idct_add(output_plane + first_pixel,
+ stride,
+ block);
+ } else {
+ s->vp3dsp.idct_dc_add(output_plane + first_pixel,
+ stride, block);
+ }
}
+ } else {
+ /* copy directly from the previous frame */
+ s->hdsp.put_pixels_tab[1][0](
+ output_plane + first_pixel,
+ last_plane + first_pixel,
+ stride, 8);
}
- } else {
-
- /* copy directly from the previous frame */
- s->hdsp.put_pixels_tab[1][0](
- output_plane + first_pixel,
- last_plane + first_pixel,
- stride, 8);
-
- }
}
}
// Filter up to the last row in the superblock row
if (!s->skip_loop_filter)
- apply_loop_filter(s, plane, 4*sb_y - !!sb_y, FFMIN(4*sb_y+3, fragment_height-1));
+ apply_loop_filter(s, plane, 4 * sb_y - !!sb_y,
+ FFMIN(4 * sb_y + 3, fragment_height - 1));
}
}
- /* this looks like a good place for slice dispatch... */
- /* algorithm:
- * if (slice == s->macroblock_height - 1)
- * dispatch (both last slice & 2nd-to-last slice);
- * else if (slice > 0)
- * dispatch (slice - 1);
- */
+ /* this looks like a good place for slice dispatch... */
+ /* algorithm:
+ * if (slice == s->macroblock_height - 1)
+ * dispatch (both last slice & 2nd-to-last slice);
+ * else if (slice > 0)
+ * dispatch (slice - 1);
+ */
- vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
+ vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) - 16,
+ s->height - 16));
}
/// Allocate tables for per-frame data in Vp3DecodeContext
@@ -1637,19 +1659,23 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
s->superblock_coding = av_mallocz(s->superblock_count);
- s->all_fragments = av_mallocz(s->fragment_count * sizeof(Vp3Fragment));
+ s->all_fragments = av_mallocz(s->fragment_count * sizeof(Vp3Fragment));
+
s->coded_fragment_list[0] = av_mallocz(s->fragment_count * sizeof(int));
- s->dct_tokens_base = av_mallocz(64*s->fragment_count * sizeof(*s->dct_tokens_base));
+
+ s->dct_tokens_base = av_mallocz(64 * s->fragment_count *
+ sizeof(*s->dct_tokens_base));
s->motion_val[0] = av_mallocz(y_fragment_count * sizeof(*s->motion_val[0]));
s->motion_val[1] = av_mallocz(c_fragment_count * sizeof(*s->motion_val[1]));
/* work out the block mapping tables */
s->superblock_fragments = av_mallocz(s->superblock_count * 16 * sizeof(int));
- s->macroblock_coding = av_mallocz(s->macroblock_count + 1);
+ s->macroblock_coding = av_mallocz(s->macroblock_count + 1);
- if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
- !s->coded_fragment_list[0] || !s->superblock_fragments || !s->macroblock_coding ||
- !s->motion_val[0] || !s->motion_val[1]) {
+ if (!s->superblock_coding || !s->all_fragments ||
+ !s->dct_tokens_base || !s->coded_fragment_list[0] ||
+ !s->superblock_fragments || !s->macroblock_coding ||
+ !s->motion_val[0] || !s->motion_val[1]) {
vp3_decode_end(avctx);
return -1;
}
@@ -1689,13 +1715,13 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
avctx->internal->allocate_progress = 1;
- if (avctx->codec_tag == MKTAG('V','P','3','0'))
+ if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
s->version = 0;
else
s->version = 1;
- s->avctx = avctx;
- s->width = FFALIGN(avctx->width, 16);
+ s->avctx = avctx;
+ s->width = FFALIGN(avctx->width, 16);
s->height = FFALIGN(avctx->height, 16);
if (avctx->codec_id != AV_CODEC_ID_THEORA)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@ -1705,10 +1731,10 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
- s->idct_permutation[i] = T(i);
- s->idct_scantable[i] = T(ff_zigzag_direct[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+ s->idct_permutation[i] = TRANSPOSE(i);
+ s->idct_scantable[i] = TRANSPOSE(ff_zigzag_direct[i]);
+#undef TRANSPOSE
}
/* initialize to an impossible value which will force a recalculation
@@ -1718,135 +1744,132 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
- s->y_superblock_width = (s->width + 31) / 32;
+ s->y_superblock_width = (s->width + 31) / 32;
s->y_superblock_height = (s->height + 31) / 32;
- s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
+ s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
/* work out the dimensions for the C planes */
- c_width = s->width >> s->chroma_x_shift;
- c_height = s->height >> s->chroma_y_shift;
- s->c_superblock_width = (c_width + 31) / 32;
+ c_width = s->width >> s->chroma_x_shift;
+ c_height = s->height >> s->chroma_y_shift;
+ s->c_superblock_width = (c_width + 31) / 32;
s->c_superblock_height = (c_height + 31) / 32;
- s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
+ s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
- s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
+ s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
- s->macroblock_width = (s->width + 15) / 16;
+ s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
- s->macroblock_count = s->macroblock_width * s->macroblock_height;
+ s->macroblock_count = s->macroblock_width * s->macroblock_height;
- s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
+ s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
s->fragment_height[0] = s->height / FRAGMENT_PIXELS;
- s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
+ s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;
/* fragment count covers all 8x8 blocks for all 3 planes */
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
- s->fragment_count = y_fragment_count + 2*c_fragment_count;
+ s->fragment_count = y_fragment_count + 2 * c_fragment_count;
s->fragment_start[1] = y_fragment_count;
s->fragment_start[2] = y_fragment_count + c_fragment_count;
- if (!s->theora_tables)
- {
+ if (!s->theora_tables) {
for (i = 0; i < 64; i++) {
s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];
- s->base_matrix[0][i] = vp31_intra_y_dequant[i];
- s->base_matrix[1][i] = vp31_intra_c_dequant[i];
- s->base_matrix[2][i] = vp31_inter_dequant[i];
- s->filter_limit_values[i] = vp31_filter_limit_values[i];
+ s->base_matrix[0][i] = vp31_intra_y_dequant[i];
+ s->base_matrix[1][i] = vp31_intra_c_dequant[i];
+ s->base_matrix[2][i] = vp31_inter_dequant[i];
+ s->filter_limit_values[i] = vp31_filter_limit_values[i];
}
- for(inter=0; inter<2; inter++){
- for(plane=0; plane<3; plane++){
- s->qr_count[inter][plane]= 1;
- s->qr_size [inter][plane][0]= 63;
- s->qr_base [inter][plane][0]=
- s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
+ for (inter = 0; inter < 2; inter++) {
+ for (plane = 0; plane < 3; plane++) {
+ s->qr_count[inter][plane] = 1;
+ s->qr_size[inter][plane][0] = 63;
+ s->qr_base[inter][plane][0] =
+ s->qr_base[inter][plane][1] = 2 * inter + (!!plane) * !inter;
}
}
/* init VLC tables */
for (i = 0; i < 16; i++) {
-
/* DC histograms */
init_vlc(&s->dc_vlc[i], 11, 32,
- &dc_bias[i][0][1], 4, 2,
- &dc_bias[i][0][0], 4, 2, 0);
+ &dc_bias[i][0][1], 4, 2,
+ &dc_bias[i][0][0], 4, 2, 0);
/* group 1 AC histograms */
init_vlc(&s->ac_vlc_1[i], 11, 32,
- &ac_bias_0[i][0][1], 4, 2,
- &ac_bias_0[i][0][0], 4, 2, 0);
+ &ac_bias_0[i][0][1], 4, 2,
+ &ac_bias_0[i][0][0], 4, 2, 0);
/* group 2 AC histograms */
init_vlc(&s->ac_vlc_2[i], 11, 32,
- &ac_bias_1[i][0][1], 4, 2,
- &ac_bias_1[i][0][0], 4, 2, 0);
+ &ac_bias_1[i][0][1], 4, 2,
+ &ac_bias_1[i][0][0], 4, 2, 0);
/* group 3 AC histograms */
init_vlc(&s->ac_vlc_3[i], 11, 32,
- &ac_bias_2[i][0][1], 4, 2,
- &ac_bias_2[i][0][0], 4, 2, 0);
+ &ac_bias_2[i][0][1], 4, 2,
+ &ac_bias_2[i][0][0], 4, 2, 0);
/* group 4 AC histograms */
init_vlc(&s->ac_vlc_4[i], 11, 32,
- &ac_bias_3[i][0][1], 4, 2,
- &ac_bias_3[i][0][0], 4, 2, 0);
+ &ac_bias_3[i][0][1], 4, 2,
+ &ac_bias_3[i][0][0], 4, 2, 0);
}
} else {
-
for (i = 0; i < 16; i++) {
/* DC histograms */
if (init_vlc(&s->dc_vlc[i], 11, 32,
- &s->huffman_table[i][0][1], 8, 4,
- &s->huffman_table[i][0][0], 8, 4, 0) < 0)
+ &s->huffman_table[i][0][1], 8, 4,
+ &s->huffman_table[i][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 1 AC histograms */
if (init_vlc(&s->ac_vlc_1[i], 11, 32,
- &s->huffman_table[i+16][0][1], 8, 4,
- &s->huffman_table[i+16][0][0], 8, 4, 0) < 0)
+ &s->huffman_table[i + 16][0][1], 8, 4,
+ &s->huffman_table[i + 16][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 2 AC histograms */
if (init_vlc(&s->ac_vlc_2[i], 11, 32,
- &s->huffman_table[i+16*2][0][1], 8, 4,
- &s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0)
+ &s->huffman_table[i + 16 * 2][0][1], 8, 4,
+ &s->huffman_table[i + 16 * 2][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 3 AC histograms */
if (init_vlc(&s->ac_vlc_3[i], 11, 32,
- &s->huffman_table[i+16*3][0][1], 8, 4,
- &s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0)
+ &s->huffman_table[i + 16 * 3][0][1], 8, 4,
+ &s->huffman_table[i + 16 * 3][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 4 AC histograms */
if (init_vlc(&s->ac_vlc_4[i], 11, 32,
- &s->huffman_table[i+16*4][0][1], 8, 4,
- &s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0)
+ &s->huffman_table[i + 16 * 4][0][1], 8, 4,
+ &s->huffman_table[i + 16 * 4][0][0], 8, 4, 0) < 0)
goto vlc_fail;
}
}
init_vlc(&s->superblock_run_length_vlc, 6, 34,
- &superblock_run_length_vlc_table[0][1], 4, 2,
- &superblock_run_length_vlc_table[0][0], 4, 2, 0);
+ &superblock_run_length_vlc_table[0][1], 4, 2,
+ &superblock_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->fragment_run_length_vlc, 5, 30,
- &fragment_run_length_vlc_table[0][1], 4, 2,
- &fragment_run_length_vlc_table[0][0], 4, 2, 0);
+ &fragment_run_length_vlc_table[0][1], 4, 2,
+ &fragment_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->mode_code_vlc, 3, 8,
- &mode_code_vlc_table[0][1], 2, 1,
- &mode_code_vlc_table[0][0], 2, 1, 0);
+ &mode_code_vlc_table[0][1], 2, 1,
+ &mode_code_vlc_table[0][0], 2, 1, 0);
init_vlc(&s->motion_vector_vlc, 6, 63,
- &motion_vector_vlc_table[0][1], 2, 1,
- &motion_vector_vlc_table[0][0], 2, 1, 0);
+ &motion_vector_vlc_table[0][1], 2, 1,
+ &motion_vector_vlc_table[0][0], 2, 1, 0);
return allocate_tables(avctx);
@@ -1861,7 +1884,6 @@ static int update_frames(AVCodecContext *avctx)
Vp3DecodeContext *s = avctx->priv_data;
int ret = 0;
-
/* shuffle frames (last = current) */
ff_thread_release_buffer(avctx, &s->last_frame);
ret = ff_thread_ref_frame(&s->last_frame, &s->current_frame);
@@ -1901,11 +1923,12 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
int qps_changed = 0, i, err;
-#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
+#define copy_fields(to, from, start_field, end_field) \
+ memcpy(&to->start_field, &from->start_field, \
+ (char *) &to->end_field - (char *) &to->start_field)
- if (!s1->current_frame.f->data[0]
- ||s->width != s1->width
- ||s->height!= s1->height) {
+ if (!s1->current_frame.f->data[0] ||
+ s->width != s1->width || s->height != s1->height) {
if (s != s1)
ref_frames(s, s1);
return -1;
@@ -1921,8 +1944,10 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
return err;
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
- memcpy(s->motion_val[0], s1->motion_val[0], y_fragment_count * sizeof(*s->motion_val[0]));
- memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
+ memcpy(s->motion_val[0], s1->motion_val[0],
+ y_fragment_count * sizeof(*s->motion_val[0]));
+ memcpy(s->motion_val[1], s1->motion_val[1],
+ c_fragment_count * sizeof(*s->motion_val[1]));
}
// copy previous frame data
@@ -1940,7 +1965,8 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
}
if (s->qps[0] != s1->qps[0])
- memcpy(&s->bounding_values_array, &s1->bounding_values_array, sizeof(s->bounding_values_array));
+ memcpy(&s->bounding_values_array, &s1->bounding_values_array,
+ sizeof(s->bounding_values_array));
if (qps_changed)
copy_fields(s, s1, qps, superblock_count);
@@ -1954,8 +1980,8 @@ static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int i, ret;
@@ -1963,8 +1989,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
init_get_bits(&gb, buf, buf_size * 8);
#if CONFIG_THEORA_DECODER
- if (s->theora && get_bits1(&gb))
- {
+ if (s->theora && get_bits1(&gb)) {
int type = get_bits(&gb, 7);
skip_bits_long(&gb, 6*8); /* "theora" */
@@ -1990,7 +2015,8 @@ static int vp3_decode_frame(AVCodecContext *avctx,
return ret;
}
- av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Header packet passed to frame decoder, skipping\n");
return -1;
}
#endif
@@ -2005,19 +2031,20 @@ static int vp3_decode_frame(AVCodecContext *avctx,
for (i = 0; i < 3; i++)
s->last_qps[i] = s->qps[i];
- s->nqps=0;
- do{
- s->qps[s->nqps++]= get_bits(&gb, 6);
- } while(s->theora >= 0x030200 && s->nqps<3 && get_bits1(&gb));
+ s->nqps = 0;
+ do {
+ s->qps[s->nqps++] = get_bits(&gb, 6);
+ } while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));
for (i = s->nqps; i < 3; i++)
s->qps[i] = -1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
- s->keyframe?"key":"", avctx->frame_number+1, s->qps[0]);
+ s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
- avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL : AVDISCARD_NONKEY);
+ avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
+ : AVDISCARD_NONKEY);
if (s->qps[0] != s->last_qps[0])
init_loop_filter(s);
@@ -2031,41 +2058,44 @@ static int vp3_decode_frame(AVCodecContext *avctx,
if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
return buf_size;
- s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+ s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
+ : AV_PICTURE_TYPE_P;
s->current_frame.f->key_frame = s->keyframe;
if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
if (!s->edge_emu_buffer)
- s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.f->linesize[0]));
+ s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
if (s->keyframe) {
- if (!s->theora)
- {
+ if (!s->theora) {
skip_bits(&gb, 4); /* width code */
skip_bits(&gb, 4); /* height code */
- if (s->version)
- {
+ if (s->version) {
s->version = get_bits(&gb, 5);
if (avctx->frame_number == 0)
- av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "VP version: %d\n", s->version);
}
}
- if (s->version || s->theora)
- {
- if (get_bits1(&gb))
- av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
+ if (s->version || s->theora) {
+ if (get_bits1(&gb))
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2); /* reserved? */
}
} else {
if (!s->golden_frame.f->data[0]) {
- av_log(s->avctx, AV_LOG_WARNING, "vp3: first frame not a keyframe\n");
+ av_log(s->avctx, AV_LOG_WARNING,
+ "vp3: first frame not a keyframe\n");
s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
- if (ff_thread_get_buffer(avctx, &s->golden_frame, AV_GET_BUFFER_FLAG_REF) < 0)
+ if (ff_thread_get_buffer(avctx, &s->golden_frame,
+ AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
ff_thread_release_buffer(avctx, &s->last_frame);
- if ((ret = ff_thread_ref_frame(&s->last_frame, &s->golden_frame)) < 0)
+ if ((ret = ff_thread_ref_frame(&s->last_frame,
+ &s->golden_frame)) < 0)
goto error;
ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
@@ -2074,23 +2104,23 @@ static int vp3_decode_frame(AVCodecContext *avctx,
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
ff_thread_finish_setup(avctx);
- if (unpack_superblocks(s, &gb)){
+ if (unpack_superblocks(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
goto error;
}
- if (unpack_modes(s, &gb)){
+ if (unpack_modes(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
goto error;
}
- if (unpack_vectors(s, &gb)){
+ if (unpack_vectors(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
goto error;
}
- if (unpack_block_qpis(s, &gb)){
+ if (unpack_block_qpis(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n");
goto error;
}
- if (unpack_dct_coeffs(s, &gb)){
+ if (unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
goto error;
}
@@ -2100,7 +2130,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
if (s->flipped_image)
s->data_offset[i] = 0;
else
- s->data_offset[i] = (height-1) * s->current_frame.f->linesize[i];
+ s->data_offset[i] = (height - 1) * s->current_frame.f->linesize[i];
}
s->last_slice_end = 0;
@@ -2109,8 +2139,8 @@ static int vp3_decode_frame(AVCodecContext *avctx,
// filter the last row
for (i = 0; i < 3; i++) {
- int row = (s->height >> (3+(i && s->chroma_y_shift))) - 1;
- apply_loop_filter(s, i, row, row+1);
+ int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1;
+ apply_loop_filter(s, i, row, row + 1);
}
vp3_draw_horiz_band(s, s->avctx->height);
@@ -2118,7 +2148,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
return ret;
*got_frame = 1;
- if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) {
+ if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
ret = update_frames(avctx);
if (ret < 0)
return ret;
@@ -2129,7 +2159,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
error:
ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
- if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME))
+ if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME))
av_frame_unref(s->current_frame.f);
return -1;
@@ -2151,9 +2181,8 @@ static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb)
s->huffman_table[s->hti][token][0] = s->hbits;
s->huffman_table[s->hti][token][1] = s->huff_code_size;
s->entries++;
- }
- else {
- if (s->huff_code_size >= 32) {/* overflow */
+ } else {
+ if (s->huff_code_size >= 32) { /* overflow */
av_log(avctx, AV_LOG_ERROR, "huffman tree overflow\n");
return -1;
}
@@ -2203,16 +2232,18 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
s->theora = get_bits_long(gb, 24);
av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
- /* 3.2.0 aka alpha3 has the same frame orientation as original vp3 */
- /* but previous versions have the image flipped relative to vp3 */
- if (s->theora < 0x030200)
- {
+ /* 3.2.0 aka alpha3 has the same frame orientation as original vp3
+ * but previous versions have the image flipped relative to vp3 */
+ if (s->theora < 0x030200) {
s->flipped_image = 1;
- av_log(avctx, AV_LOG_DEBUG, "Old (<alpha3) Theora bitstream, flipped image\n");
+ av_log(avctx, AV_LOG_DEBUG,
+ "Old (<alpha3) Theora bitstream, flipped image\n");
}
- visible_width = s->width = get_bits(gb, 16) << 4;
- visible_height = s->height = get_bits(gb, 16) << 4;
+ visible_width =
+ s->width = get_bits(gb, 16) << 4;
+ visible_height =
+ s->height = get_bits(gb, 16) << 4;
if (s->theora >= 0x030200) {
visible_width = get_bits_long(gb, 24);
@@ -2230,7 +2261,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
return AVERROR_INVALIDDATA;
}
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
- fps.den, fps.num, 1<<30);
+ fps.den, fps.num, 1 << 30);
}
aspect.num = get_bits_long(gb, 24);
@@ -2238,7 +2269,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
if (aspect.num && aspect.den) {
av_reduce(&avctx->sample_aspect_ratio.num,
&avctx->sample_aspect_ratio.den,
- aspect.num, aspect.den, 1<<30);
+ aspect.num, aspect.den, 1 << 30);
}
if (s->theora < 0x030200)
@@ -2248,8 +2279,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
skip_bits(gb, 6); /* quality hint */
- if (s->theora >= 0x030200)
- {
+ if (s->theora >= 0x030200) {
skip_bits(gb, 5); /* keyframe frequency force */
avctx->pix_fmt = theora_pix_fmts[get_bits(gb, 2)];
if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
@@ -2261,20 +2291,20 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
// align_get_bits(gb);
- if ( visible_width <= s->width && visible_width > s->width-16
- && visible_height <= s->height && visible_height > s->height-16
- && !offset_x && (offset_y == s->height - visible_height))
+ if (visible_width <= s->width && visible_width > s->width - 16 &&
+ visible_height <= s->height && visible_height > s->height - 16 &&
+ !offset_x && (offset_y == s->height - visible_height))
ret = ff_set_dimensions(avctx, visible_width, visible_height);
else
ret = ff_set_dimensions(avctx, s->width, s->height);
if (ret < 0)
return ret;
- if (colorspace == 1) {
+ if (colorspace == 1)
avctx->color_primaries = AVCOL_PRI_BT470M;
- } else if (colorspace == 2) {
+ else if (colorspace == 2)
avctx->color_primaries = AVCOL_PRI_BT470BG;
- }
+
if (colorspace == 1 || colorspace == 2) {
avctx->colorspace = AVCOL_SPC_BT470BG;
avctx->color_trc = AVCOL_TRC_BT709;
@@ -2317,48 +2347,50 @@ static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
else
matrices = 3;
- if(matrices > 384){
+ if (matrices > 384) {
av_log(avctx, AV_LOG_ERROR, "invalid number of base matrixes\n");
return -1;
}
- for(n=0; n<matrices; n++){
+ for (n = 0; n < matrices; n++)
for (i = 0; i < 64; i++)
- s->base_matrix[n][i]= get_bits(gb, 8);
- }
+ s->base_matrix[n][i] = get_bits(gb, 8);
for (inter = 0; inter <= 1; inter++) {
for (plane = 0; plane <= 2; plane++) {
- int newqr= 1;
+ int newqr = 1;
if (inter || plane > 0)
newqr = get_bits1(gb);
if (!newqr) {
int qtj, plj;
- if(inter && get_bits1(gb)){
+ if (inter && get_bits1(gb)) {
qtj = 0;
plj = plane;
- }else{
- qtj= (3*inter + plane - 1) / 3;
- plj= (plane + 2) % 3;
+ } else {
+ qtj = (3 * inter + plane - 1) / 3;
+ plj = (plane + 2) % 3;
}
- s->qr_count[inter][plane]= s->qr_count[qtj][plj];
- memcpy(s->qr_size[inter][plane], s->qr_size[qtj][plj], sizeof(s->qr_size[0][0]));
- memcpy(s->qr_base[inter][plane], s->qr_base[qtj][plj], sizeof(s->qr_base[0][0]));
+ s->qr_count[inter][plane] = s->qr_count[qtj][plj];
+ memcpy(s->qr_size[inter][plane], s->qr_size[qtj][plj],
+ sizeof(s->qr_size[0][0]));
+ memcpy(s->qr_base[inter][plane], s->qr_base[qtj][plj],
+ sizeof(s->qr_base[0][0]));
} else {
- int qri= 0;
- int qi = 0;
-
- for(;;){
- i= get_bits(gb, av_log2(matrices-1)+1);
- if(i>= matrices){
- av_log(avctx, AV_LOG_ERROR, "invalid base matrix index\n");
+ int qri = 0;
+ int qi = 0;
+
+ for (;;) {
+ i = get_bits(gb, av_log2(matrices - 1) + 1);
+ if (i >= matrices) {
+ av_log(avctx, AV_LOG_ERROR,
+ "invalid base matrix index\n");
return -1;
}
- s->qr_base[inter][plane][qri]= i;
- if(qi >= 63)
+ s->qr_base[inter][plane][qri] = i;
+ if (qi >= 63)
break;
- i = get_bits(gb, av_log2(63-qi)+1) + 1;
- s->qr_size[inter][plane][qri++]= i;
+ i = get_bits(gb, av_log2(63 - qi) + 1) + 1;
+ s->qr_size[inter][plane][qri++] = i;
qi += i;
}
@@ -2366,21 +2398,21 @@ static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi);
return -1;
}
- s->qr_count[inter][plane]= qri;
+ s->qr_count[inter][plane] = qri;
}
}
}
/* Huffman tables */
for (s->hti = 0; s->hti < 80; s->hti++) {
- s->entries = 0;
+ s->entries = 0;
s->huff_code_size = 1;
if (!get_bits1(gb)) {
s->hbits = 0;
- if(read_huffman_tree(avctx, gb))
+ if (read_huffman_tree(avctx, gb))
return -1;
s->hbits = 1;
- if(read_huffman_tree(avctx, gb))
+ if (read_huffman_tree(avctx, gb))
return -1;
}
}
@@ -2403,40 +2435,37 @@ static av_cold int theora_decode_init(AVCodecContext *avctx)
s->theora = 1;
- if (!avctx->extradata_size)
- {
+ if (!avctx->extradata_size) {
av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n");
return -1;
}
if (avpriv_split_xiph_headers(avctx->extradata, avctx->extradata_size,
- 42, header_start, header_len) < 0) {
+ 42, header_start, header_len) < 0) {
av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n");
return -1;
}
- for(i=0;i<3;i++) {
- if (header_len[i] <= 0)
- continue;
- init_get_bits(&gb, header_start[i], header_len[i] * 8);
+ for (i = 0; i < 3; i++) {
+ if (header_len[i] <= 0)
+ continue;
+ init_get_bits(&gb, header_start[i], header_len[i] * 8);
- ptype = get_bits(&gb, 8);
+ ptype = get_bits(&gb, 8);
- if (!(ptype & 0x80))
- {
- av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n");
-// return -1;
- }
+ if (!(ptype & 0x80)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid extradata!\n");
+// return -1;
+ }
- // FIXME: Check for this as well.
- skip_bits_long(&gb, 6*8); /* "theora" */
+ // FIXME: Check for this as well.
+ skip_bits_long(&gb, 6 * 8); /* "theora" */
- switch(ptype)
- {
+ switch (ptype) {
case 0x80:
if (theora_decode_header(avctx, &gb) < 0)
return -1;
- break;
+ break;
case 0x81:
// FIXME: is this needed? it breaks sometimes
// theora_decode_comments(avctx, gb);
@@ -2446,14 +2475,17 @@ static av_cold int theora_decode_init(AVCodecContext *avctx)
return -1;
break;
default:
- av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80);
+ av_log(avctx, AV_LOG_ERROR,
+ "Unknown Theora config packet: %d\n", ptype & ~0x80);
+ break;
+ }
+ if (ptype != 0x81 && 8 * header_len[i] != get_bits_count(&gb))
+ av_log(avctx, AV_LOG_WARNING,
+ "%d bits left in packet %X\n",
+ 8 * header_len[i] - get_bits_count(&gb), ptype);
+ if (s->theora < 0x030200)
break;
}
- if(ptype != 0x81 && 8*header_len[i] != get_bits_count(&gb))
- av_log(avctx, AV_LOG_WARNING, "%d bits left in packet %X\n", 8*header_len[i] - get_bits_count(&gb), ptype);
- if (s->theora < 0x030200)
- break;
- }
return vp3_decode_init(avctx);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp3_parser.c b/chromium/third_party/ffmpeg/libavcodec/vp3_parser.c
index ce15309356c..7ee046c5437 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp3_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp3_parser.c
@@ -21,22 +21,24 @@
#include "parser.h"
static int parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
+ AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
{
- if(avctx->codec_id == AV_CODEC_ID_THEORA)
- s->pict_type= (buf[0]&0x40) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
+ if (avctx->codec_id == AV_CODEC_ID_THEORA)
+ s->pict_type = (buf[0] & 0x40) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
else
- s->pict_type= (buf[0]&0x80) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
+ s->pict_type = (buf[0] & 0x80) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
- *poutbuf = buf;
+ *poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
AVCodecParser ff_vp3_parser = {
- .codec_ids = { AV_CODEC_ID_THEORA, AV_CODEC_ID_VP3, AV_CODEC_ID_VP6,
- AV_CODEC_ID_VP6F, AV_CODEC_ID_VP6A },
- .parser_parse = parse,
+ .codec_ids = {
+ AV_CODEC_ID_THEORA, AV_CODEC_ID_VP3,
+ AV_CODEC_ID_VP6, AV_CODEC_ID_VP6F, AV_CODEC_ID_VP6A
+ },
+ .parser_parse = parse,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp3data.h b/chromium/third_party/ffmpeg/libavcodec/vp3data.h
index 904ec6abf58..bffc5bcc6bd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp3data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp3data.h
@@ -26,175 +26,175 @@
/* these coefficients dequantize intraframe Y plane coefficients
* (note: same as JPEG) */
-static const int16_t vp31_intra_y_dequant[64] =
-{ 16, 11, 10, 16, 24, 40, 51, 61,
- 12, 12, 14, 19, 26, 58, 60, 55,
- 14, 13, 16, 24, 40, 57, 69, 56,
- 14, 17, 22, 29, 51, 87, 80, 62,
- 18, 22, 37, 58, 68, 109, 103, 77,
- 24, 35, 55, 64, 81, 104, 113, 92,
- 49, 64, 78, 87, 103, 121, 120, 101,
- 72, 92, 95, 98, 112, 100, 103, 99
+static const int16_t vp31_intra_y_dequant[64] = {
+ 16, 11, 10, 16, 24, 40, 51, 61,
+ 12, 12, 14, 19, 26, 58, 60, 55,
+ 14, 13, 16, 24, 40, 57, 69, 56,
+ 14, 17, 22, 29, 51, 87, 80, 62,
+ 18, 22, 37, 58, 68, 109, 103, 77,
+ 24, 35, 55, 64, 81, 104, 113, 92,
+ 49, 64, 78, 87, 103, 121, 120, 101,
+ 72, 92, 95, 98, 112, 100, 103, 99
};
/* these coefficients dequantize intraframe C plane coefficients
* (note: same as JPEG) */
-static const int16_t vp31_intra_c_dequant[64] =
-{ 17, 18, 24, 47, 99, 99, 99, 99,
- 18, 21, 26, 66, 99, 99, 99, 99,
- 24, 26, 56, 99, 99, 99, 99, 99,
- 47, 66, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99
+static const int16_t vp31_intra_c_dequant[64] = {
+ 17, 18, 24, 47, 99, 99, 99, 99,
+ 18, 21, 26, 66, 99, 99, 99, 99,
+ 24, 26, 56, 99, 99, 99, 99, 99,
+ 47, 66, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99
};
/* these coefficients dequantize interframe coefficients (all planes) */
-static const int16_t vp31_inter_dequant[64] =
-{ 16, 16, 16, 20, 24, 28, 32, 40,
- 16, 16, 20, 24, 28, 32, 40, 48,
- 16, 20, 24, 28, 32, 40, 48, 64,
- 20, 24, 28, 32, 40, 48, 64, 64,
- 24, 28, 32, 40, 48, 64, 64, 64,
- 28, 32, 40, 48, 64, 64, 64, 96,
- 32, 40, 48, 64, 64, 64, 96, 128,
- 40, 48, 64, 64, 64, 96, 128, 128
+static const int16_t vp31_inter_dequant[64] = {
+ 16, 16, 16, 20, 24, 28, 32, 40,
+ 16, 16, 20, 24, 28, 32, 40, 48,
+ 16, 20, 24, 28, 32, 40, 48, 64,
+ 20, 24, 28, 32, 40, 48, 64, 64,
+ 24, 28, 32, 40, 48, 64, 64, 64,
+ 28, 32, 40, 48, 64, 64, 64, 96,
+ 32, 40, 48, 64, 64, 64, 96, 128,
+ 40, 48, 64, 64, 64, 96, 128, 128
};
-static const int16_t vp31_dc_scale_factor[64] =
-{ 220, 200, 190, 180, 170, 170, 160, 160,
- 150, 150, 140, 140, 130, 130, 120, 120,
- 110, 110, 100, 100, 90, 90, 90, 80,
- 80, 80, 70, 70, 70, 60, 60, 60,
- 60, 50, 50, 50, 50, 40, 40, 40,
- 40, 40, 30, 30, 30, 30, 30, 30,
- 30, 20, 20, 20, 20, 20, 20, 20,
- 20, 10, 10, 10, 10, 10, 10, 10
+static const int16_t vp31_dc_scale_factor[64] = {
+ 220, 200, 190, 180, 170, 170, 160, 160,
+ 150, 150, 140, 140, 130, 130, 120, 120,
+ 110, 110, 100, 100, 90, 90, 90, 80,
+ 80, 80, 70, 70, 70, 60, 60, 60,
+ 60, 50, 50, 50, 50, 40, 40, 40,
+ 40, 40, 30, 30, 30, 30, 30, 30,
+ 30, 20, 20, 20, 20, 20, 20, 20,
+ 20, 10, 10, 10, 10, 10, 10, 10
};
-static const uint32_t vp31_ac_scale_factor[64] =
-{ 500, 450, 400, 370, 340, 310, 285, 265,
- 245, 225, 210, 195, 185, 180, 170, 160,
- 150, 145, 135, 130, 125, 115, 110, 107,
- 100, 96, 93, 89, 85, 82, 75, 74,
- 70, 68, 64, 60, 57, 56, 52, 50,
- 49, 45, 44, 43, 40, 38, 37, 35,
- 33, 32, 30, 29, 28, 25, 24, 22,
- 21, 19, 18, 17, 15, 13, 12, 10
+static const uint32_t vp31_ac_scale_factor[64] = {
+ 500, 450, 400, 370, 340, 310, 285, 265,
+ 245, 225, 210, 195, 185, 180, 170, 160,
+ 150, 145, 135, 130, 125, 115, 110, 107,
+ 100, 96, 93, 89, 85, 82, 75, 74,
+ 70, 68, 64, 60, 57, 56, 52, 50,
+ 49, 45, 44, 43, 40, 38, 37, 35,
+ 33, 32, 30, 29, 28, 25, 24, 22,
+ 21, 19, 18, 17, 15, 13, 12, 10
};
-static const uint8_t vp31_filter_limit_values[64] =
-{ 30, 25, 20, 20, 15, 15, 14, 14,
- 13, 13, 12, 12, 11, 11, 10, 10,
- 9, 9, 8, 8, 7, 7, 7, 7,
- 6, 6, 6, 6, 5, 5, 5, 5,
- 4, 4, 4, 4, 3, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+static const uint8_t vp31_filter_limit_values[64] = {
+ 30, 25, 20, 20, 15, 15, 14, 14,
+ 13, 13, 12, 12, 11, 11, 10, 10,
+ 9, 9, 8, 8, 7, 7, 7, 7,
+ 6, 6, 6, 6, 5, 5, 5, 5,
+ 4, 4, 4, 4, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
};
static const uint16_t superblock_run_length_vlc_table[34][2] = {
- { 0, 1 },
+ { 0, 1 },
- { 4, 3 }, { 5, 3 },
+ { 4, 3 }, { 5, 3 },
- { 0xC, 4 }, { 0xD, 4 },
+ { 0xC, 4 }, { 0xD, 4 },
- { 0x38, 6 }, { 0x39, 6 }, { 0x3A, 6 }, { 0x3B, 6 },
+ { 0x38, 6 }, { 0x39, 6 }, { 0x3A, 6 }, { 0x3B, 6 },
- { 0xF0, 8 }, { 0xF1, 8 }, { 0xF2, 8 }, { 0xF3, 8 },
- { 0xF4, 8 }, { 0xF5, 8 }, { 0xF6, 8 }, { 0xF7, 8 },
+ { 0xF0, 8 }, { 0xF1, 8 }, { 0xF2, 8 }, { 0xF3, 8 },
+ { 0xF4, 8 }, { 0xF5, 8 }, { 0xF6, 8 }, { 0xF7, 8 },
- { 0x3E0, 10 }, { 0x3E1, 10 }, { 0x3E2, 10 }, { 0x3E3, 10 },
- { 0x3E4, 10 }, { 0x3E5, 10 }, { 0x3E6, 10 }, { 0x3E7, 10 },
- { 0x3E8, 10 }, { 0x3E9, 10 }, { 0x3EA, 10 }, { 0x3EB, 10 },
- { 0x3EC, 10 }, { 0x3ED, 10 }, { 0x3EE, 10 }, { 0x3EF, 10 },
+ { 0x3E0, 10 }, { 0x3E1, 10 }, { 0x3E2, 10 }, { 0x3E3, 10 },
+ { 0x3E4, 10 }, { 0x3E5, 10 }, { 0x3E6, 10 }, { 0x3E7, 10 },
+ { 0x3E8, 10 }, { 0x3E9, 10 }, { 0x3EA, 10 }, { 0x3EB, 10 },
+ { 0x3EC, 10 }, { 0x3ED, 10 }, { 0x3EE, 10 }, { 0x3EF, 10 },
- { 0x3F, 6 } /* this last VLC is a special case for reading 12 more
- bits from stream and adding the value 34 */
+ { 0x3F, 6 } /* this last VLC is a special case for reading 12 more
+ * bits from stream and adding the value 34 */
};
static const uint16_t fragment_run_length_vlc_table[30][2] = {
/* 1 -> 2 */
- { 0x0, 2 }, { 0x1, 2 },
+ { 0x0, 2 }, { 0x1, 2 },
/* 3 -> 4 */
- { 0x4, 3 }, { 0x5, 3 },
+ { 0x4, 3 }, { 0x5, 3 },
/* 5 -> 6 */
- { 0xC, 4 }, { 0xD, 4 },
+ { 0xC, 4 }, { 0xD, 4 },
/* 7 -> 10 */
- { 0x38, 6 }, { 0x39, 6 },
- { 0x3A, 6 }, { 0x3B, 6 },
+ { 0x38, 6 }, { 0x39, 6 },
+ { 0x3A, 6 }, { 0x3B, 6 },
/* 11 -> 14 */
- { 0x78, 7 }, { 0x79, 7 },
- { 0x7A, 7 }, { 0x7B, 7 },
+ { 0x78, 7 }, { 0x79, 7 },
+ { 0x7A, 7 }, { 0x7B, 7 },
/* 15 -> 30 */
- { 0x1F0, 9 }, { 0x1F1, 9 }, { 0x1F2, 9 }, { 0x1F3, 9 },
- { 0x1F4, 9 }, { 0x1F5, 9 }, { 0x1F6, 9 }, { 0x1F7, 9 },
- { 0x1F8, 9 }, { 0x1F9, 9 }, { 0x1FA, 9 }, { 0x1FB, 9 },
- { 0x1FC, 9 }, { 0x1FD, 9 }, { 0x1FE, 9 }, { 0x1FF, 9 }
+ { 0x1F0, 9 }, { 0x1F1, 9 }, { 0x1F2, 9 }, { 0x1F3, 9 },
+ { 0x1F4, 9 }, { 0x1F5, 9 }, { 0x1F6, 9 }, { 0x1F7, 9 },
+ { 0x1F8, 9 }, { 0x1F9, 9 }, { 0x1FA, 9 }, { 0x1FB, 9 },
+ { 0x1FC, 9 }, { 0x1FD, 9 }, { 0x1FE, 9 }, { 0x1FF, 9 }
};
static const uint8_t mode_code_vlc_table[8][2] = {
- { 0, 1 }, { 2, 2 },
- { 6, 3 }, { 14, 4 },
- { 30, 5 }, { 62, 6 },
- { 126, 7 }, { 127, 7 }
+ { 0, 1 }, { 2, 2 },
+ { 6, 3 }, { 14, 4 },
+ { 30, 5 }, { 62, 6 },
+ { 126, 7 }, { 127, 7 }
};
static const uint8_t motion_vector_vlc_table[63][2] = {
- { 0, 3 },
- { 1, 3 },
- { 2, 3 },
+ { 0, 3 },
+ { 1, 3 },
+ { 2, 3 },
- { 6, 4 }, { 7, 4 },
+ { 6, 4 }, { 7, 4 },
- { 8, 4 }, { 9, 4 },
+ { 8, 4 }, { 9, 4 },
- { 40, 6 }, { 41, 6 }, { 42, 6 }, { 43, 6 },
- { 44, 6 }, { 45, 6 }, { 46, 6 }, { 47, 6 },
+ { 40, 6 }, { 41, 6 }, { 42, 6 }, { 43, 6 },
+ { 44, 6 }, { 45, 6 }, { 46, 6 }, { 47, 6 },
- { 96, 7 }, { 97, 7 }, { 98, 7 }, { 99, 7 },
- { 100, 7 }, { 101, 7 }, { 102, 7 }, { 103, 7 },
- { 104, 7 }, { 105, 7 }, { 106, 7 }, { 107, 7 },
- { 108, 7 }, { 109, 7 }, { 110, 7 }, { 111, 7 },
+ { 96, 7 }, { 97, 7 }, { 98, 7 }, { 99, 7 },
+ { 100, 7 }, { 101, 7 }, { 102, 7 }, { 103, 7 },
+ { 104, 7 }, { 105, 7 }, { 106, 7 }, { 107, 7 },
+ { 108, 7 }, { 109, 7 }, { 110, 7 }, { 111, 7 },
- { 0xE0, 8 }, { 0xE1, 8 }, { 0xE2, 8 }, { 0xE3, 8 },
- { 0xE4, 8 }, { 0xE5, 8 }, { 0xE6, 8 }, { 0xE7, 8 },
- { 0xE8, 8 }, { 0xE9, 8 }, { 0xEA, 8 }, { 0xEB, 8 },
- { 0xEC, 8 }, { 0xED, 8 }, { 0xEE, 8 }, { 0xEF, 8 },
+ { 0xE0, 8 }, { 0xE1, 8 }, { 0xE2, 8 }, { 0xE3, 8 },
+ { 0xE4, 8 }, { 0xE5, 8 }, { 0xE6, 8 }, { 0xE7, 8 },
+ { 0xE8, 8 }, { 0xE9, 8 }, { 0xEA, 8 }, { 0xEB, 8 },
+ { 0xEC, 8 }, { 0xED, 8 }, { 0xEE, 8 }, { 0xEF, 8 },
- { 0xF0, 8 }, { 0xF1, 8 }, { 0xF2, 8 }, { 0xF3, 8 },
- { 0xF4, 8 }, { 0xF5, 8 }, { 0xF6, 8 }, { 0xF7, 8 },
- { 0xF8, 8 }, { 0xF9, 8 }, { 0xFA, 8 }, { 0xFB, 8 },
- { 0xFC, 8 }, { 0xFD, 8 }, { 0xFE, 8 }, { 0xFF, 8 }
+ { 0xF0, 8 }, { 0xF1, 8 }, { 0xF2, 8 }, { 0xF3, 8 },
+ { 0xF4, 8 }, { 0xF5, 8 }, { 0xF6, 8 }, { 0xF7, 8 },
+ { 0xF8, 8 }, { 0xF9, 8 }, { 0xFA, 8 }, { 0xFB, 8 },
+ { 0xFC, 8 }, { 0xFD, 8 }, { 0xFE, 8 }, { 0xFF, 8 }
};
static const int motion_vector_table[63] = {
- 0, 1, -1,
- 2, -2,
- 3, -3,
- 4, -4, 5, -5, 6, -6, 7, -7,
- 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15,
+ 0, 1, -1,
+ 2, -2,
+ 3, -3,
+ 4, -4, 5, -5, 6, -6, 7, -7,
+ 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15,
16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23,
24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31
};
static const int8_t fixed_motion_vector_table[64] = {
- 0, 0, 1, -1, 2, -2, 3, -3,
- 4, -4, 5, -5, 6, -6, 7, -7,
- 8, -8, 9, -9, 10, -10, 11, -11,
- 12, -12, 13, -13, 14, -14, 15, -15,
- 16, -16, 17, -17, 18, -18, 19, -19,
- 20, -20, 21, -21, 22, -22, 23, -23,
- 24, -24, 25, -25, 26, -26, 27, -27,
- 28, -28, 29, -29, 30, -30, 31, -31
+ 0, 0, 1, -1, 2, -2, 3, -3,
+ 4, -4, 5, -5, 6, -6, 7, -7,
+ 8, -8, 9, -9, 10, -10, 11, -11,
+ 12, -12, 13, -13, 14, -14, 15, -15,
+ 16, -16, 17, -17, 18, -18, 19, -19,
+ 20, -20, 21, -21, 22, -22, 23, -23,
+ 24, -24, 25, -25, 26, -26, 27, -27,
+ 28, -28, 29, -29, 30, -30, 31, -31
};
/* only tokens 0..6 indicate eob runs */
@@ -206,27 +206,27 @@ static const int eob_run_get_bits[7] = {
};
static const int zero_run_base[32] = {
- 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
- 0, 0, /* 7..8 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 9..22 */
- 1, 2, 3, 4, 5, /* 23..27 */
- 6, 10, 1, 2 /* 28..31 */
+ 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
+ 0, 0, /* 7..8 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 9..22 */
+ 1, 2, 3, 4, 5, /* 23..27 */
+ 6, 10, 1, 2 /* 28..31 */
};
static const int zero_run_get_bits[32] = {
- 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
- 3, 6, /* 7..8 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 9..22 */
- 0, 0, 0, 0, 0, /* 23..27 */
- 2, 3, 0, 1 /* 28..31 */
+ 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
+ 3, 6, /* 7..8 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 9..22 */
+ 0, 0, 0, 0, 0, /* 23..27 */
+ 2, 3, 0, 1 /* 28..31 */
};
static const int coeff_get_bits[32] = {
- 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
- 0, 0, 0, 0, 0, 0, /* 7..12 use constant coeffs */
- 1, 1, 1, 1, /* 13..16 are constants but still need sign bit */
- 2, 3, 4, 5, 6, 10, /* 17..22, for reading large coeffs */
- 1, 1, 1, 1, 1, 1, 1, /* 23..29 are constants but still need sign bit */
- 2, 2 /* 30..31 */
+ 0, 0, 0, 0, 0, 0, 0, /* 0..6 are never used */
+ 0, 0, 0, 0, 0, 0, /* 7..12 use constant coeffs */
+ 1, 1, 1, 1, /* 13..16 are constants but still need sign bit */
+ 2, 3, 4, 5, 6,10, /* 17..22, for reading large coeffs */
+ 1, 1, 1, 1, 1, 1, 1, /* 23..29 are constants but still need sign bit */
+ 2, 2 /* 30..31 */
};
static const int16_t coeff_table_token_7_8[1] = { 0 };
@@ -257,17 +257,17 @@ static const int16_t coeff_table_token_19[16] = {
};
static const int16_t coeff_table_token_20[32] = {
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
+ 21, 22, 23, 24, 25, 26, 27, 28,
+ 29, 30, 31, 32, 33, 34, 35, 36,
-21, -22, -23, -24, -25, -26, -27, -28,
-29, -30, -31, -32, -33, -34, -35, -36
};
static const int16_t coeff_table_token_21[64] = {
- 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68,
+ 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56, 57, 58, 59, 60,
+ 61, 62, 63, 64, 65, 66, 67, 68,
-37, -38, -39, -40, -41, -42, -43, -44,
-45, -46, -47, -48, -49, -50, -51, -52,
-53, -54, -55, -56, -57, -58, -59, -60,
@@ -275,74 +275,74 @@ static const int16_t coeff_table_token_21[64] = {
};
static const int16_t coeff_table_token_22[1024] = {
- 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 106, 107, 108,
- 109, 110, 111, 112, 113, 114, 115, 116,
- 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 129, 130, 131, 132,
- 133, 134, 135, 136, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, 147, 148,
- 149, 150, 151, 152, 153, 154, 155, 156,
- 157, 158, 159, 160, 161, 162, 163, 164,
- 165, 166, 167, 168, 169, 170, 171, 172,
- 173, 174, 175, 176, 177, 178, 179, 180,
- 181, 182, 183, 184, 185, 186, 187, 188,
- 189, 190, 191, 192, 193, 194, 195, 196,
- 197, 198, 199, 200, 201, 202, 203, 204,
- 205, 206, 207, 208, 209, 210, 211, 212,
- 213, 214, 215, 216, 217, 218, 219, 220,
- 221, 222, 223, 224, 225, 226, 227, 228,
- 229, 230, 231, 232, 233, 234, 235, 236,
- 237, 238, 239, 240, 241, 242, 243, 244,
- 245, 246, 247, 248, 249, 250, 251, 252,
- 253, 254, 255, 256, 257, 258, 259, 260,
- 261, 262, 263, 264, 265, 266, 267, 268,
- 269, 270, 271, 272, 273, 274, 275, 276,
- 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 298, 299, 300,
- 301, 302, 303, 304, 305, 306, 307, 308,
- 309, 310, 311, 312, 313, 314, 315, 316,
- 317, 318, 319, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332,
- 333, 334, 335, 336, 337, 338, 339, 340,
- 341, 342, 343, 344, 345, 346, 347, 348,
- 349, 350, 351, 352, 353, 354, 355, 356,
- 357, 358, 359, 360, 361, 362, 363, 364,
- 365, 366, 367, 368, 369, 370, 371, 372,
- 373, 374, 375, 376, 377, 378, 379, 380,
- 381, 382, 383, 384, 385, 386, 387, 388,
- 389, 390, 391, 392, 393, 394, 395, 396,
- 397, 398, 399, 400, 401, 402, 403, 404,
- 405, 406, 407, 408, 409, 410, 411, 412,
- 413, 414, 415, 416, 417, 418, 419, 420,
- 421, 422, 423, 424, 425, 426, 427, 428,
- 429, 430, 431, 432, 433, 434, 435, 436,
- 437, 438, 439, 440, 441, 442, 443, 444,
- 445, 446, 447, 448, 449, 450, 451, 452,
- 453, 454, 455, 456, 457, 458, 459, 460,
- 461, 462, 463, 464, 465, 466, 467, 468,
- 469, 470, 471, 472, 473, 474, 475, 476,
- 477, 478, 479, 480, 481, 482, 483, 484,
- 485, 486, 487, 488, 489, 490, 491, 492,
- 493, 494, 495, 496, 497, 498, 499, 500,
- 501, 502, 503, 504, 505, 506, 507, 508,
- 509, 510, 511, 512, 513, 514, 515, 516,
- 517, 518, 519, 520, 521, 522, 523, 524,
- 525, 526, 527, 528, 529, 530, 531, 532,
- 533, 534, 535, 536, 537, 538, 539, 540,
- 541, 542, 543, 544, 545, 546, 547, 548,
- 549, 550, 551, 552, 553, 554, 555, 556,
- 557, 558, 559, 560, 561, 562, 563, 564,
- 565, 566, 567, 568, 569, 570, 571, 572,
- 573, 574, 575, 576, 577, 578, 579, 580,
- -69, -70, -71, -72, -73, -74, -75, -76,
- -77, -78, -79, -80, -81, -82, -83, -84,
- -85, -86, -87, -88, -89, -90, -91, -92,
- -93, -94, -95, -96, -97, -98, -99, -100,
+ 69, 70, 71, 72, 73, 74, 75, 76,
+ 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89, 90, 91, 92,
+ 93, 94, 95, 96, 97, 98, 99, 100,
+ 101, 102, 103, 104, 105, 106, 107, 108,
+ 109, 110, 111, 112, 113, 114, 115, 116,
+ 117, 118, 119, 120, 121, 122, 123, 124,
+ 125, 126, 127, 128, 129, 130, 131, 132,
+ 133, 134, 135, 136, 137, 138, 139, 140,
+ 141, 142, 143, 144, 145, 146, 147, 148,
+ 149, 150, 151, 152, 153, 154, 155, 156,
+ 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 170, 171, 172,
+ 173, 174, 175, 176, 177, 178, 179, 180,
+ 181, 182, 183, 184, 185, 186, 187, 188,
+ 189, 190, 191, 192, 193, 194, 195, 196,
+ 197, 198, 199, 200, 201, 202, 203, 204,
+ 205, 206, 207, 208, 209, 210, 211, 212,
+ 213, 214, 215, 216, 217, 218, 219, 220,
+ 221, 222, 223, 224, 225, 226, 227, 228,
+ 229, 230, 231, 232, 233, 234, 235, 236,
+ 237, 238, 239, 240, 241, 242, 243, 244,
+ 245, 246, 247, 248, 249, 250, 251, 252,
+ 253, 254, 255, 256, 257, 258, 259, 260,
+ 261, 262, 263, 264, 265, 266, 267, 268,
+ 269, 270, 271, 272, 273, 274, 275, 276,
+ 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292,
+ 293, 294, 295, 296, 297, 298, 299, 300,
+ 301, 302, 303, 304, 305, 306, 307, 308,
+ 309, 310, 311, 312, 313, 314, 315, 316,
+ 317, 318, 319, 320, 321, 322, 323, 324,
+ 325, 326, 327, 328, 329, 330, 331, 332,
+ 333, 334, 335, 336, 337, 338, 339, 340,
+ 341, 342, 343, 344, 345, 346, 347, 348,
+ 349, 350, 351, 352, 353, 354, 355, 356,
+ 357, 358, 359, 360, 361, 362, 363, 364,
+ 365, 366, 367, 368, 369, 370, 371, 372,
+ 373, 374, 375, 376, 377, 378, 379, 380,
+ 381, 382, 383, 384, 385, 386, 387, 388,
+ 389, 390, 391, 392, 393, 394, 395, 396,
+ 397, 398, 399, 400, 401, 402, 403, 404,
+ 405, 406, 407, 408, 409, 410, 411, 412,
+ 413, 414, 415, 416, 417, 418, 419, 420,
+ 421, 422, 423, 424, 425, 426, 427, 428,
+ 429, 430, 431, 432, 433, 434, 435, 436,
+ 437, 438, 439, 440, 441, 442, 443, 444,
+ 445, 446, 447, 448, 449, 450, 451, 452,
+ 453, 454, 455, 456, 457, 458, 459, 460,
+ 461, 462, 463, 464, 465, 466, 467, 468,
+ 469, 470, 471, 472, 473, 474, 475, 476,
+ 477, 478, 479, 480, 481, 482, 483, 484,
+ 485, 486, 487, 488, 489, 490, 491, 492,
+ 493, 494, 495, 496, 497, 498, 499, 500,
+ 501, 502, 503, 504, 505, 506, 507, 508,
+ 509, 510, 511, 512, 513, 514, 515, 516,
+ 517, 518, 519, 520, 521, 522, 523, 524,
+ 525, 526, 527, 528, 529, 530, 531, 532,
+ 533, 534, 535, 536, 537, 538, 539, 540,
+ 541, 542, 543, 544, 545, 546, 547, 548,
+ 549, 550, 551, 552, 553, 554, 555, 556,
+ 557, 558, 559, 560, 561, 562, 563, 564,
+ 565, 566, 567, 568, 569, 570, 571, 572,
+ 573, 574, 575, 576, 577, 578, 579, 580,
+ -69, -70, -71, -72, -73, -74, -75, -76,
+ -77, -78, -79, -80, -81, -82, -83, -84,
+ -85, -86, -87, -88, -89, -90, -91, -92,
+ -93, -94, -95, -96, -97, -98, -99, -100,
-101, -102, -103, -104, -105, -106, -107, -108,
-109, -110, -111, -112, -113, -114, -115, -116,
-117, -118, -119, -120, -121, -122, -123, -124,
@@ -444,2738 +444,2738 @@ static const int16_t *const coeff_tables[32] = {
};
static const uint16_t dc_bias[16][32][2] = {
- { /* DC bias table 0 */
- { 0x2D, 6 },
- { 0x26, 7 },
- { 0x166, 9 },
- { 0x4E, 8 },
- { 0x2CE, 10 },
- { 0x59E, 11 },
- { 0x27D, 11 },
- { 0x8, 5 },
- { 0x4F9, 12 },
- { 0xF, 4 },
- { 0xE, 4 },
- { 0x1B, 5 },
- { 0x6, 4 },
- { 0x8, 4 },
- { 0x5, 4 },
- { 0x1A, 5 },
- { 0x15, 5 },
- { 0x7, 4 },
- { 0xC, 4 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0x9, 4 },
- { 0x17, 5 },
- { 0x29, 6 },
- { 0x28, 6 },
- { 0xB2, 8 },
- { 0x4F8, 12 },
- { 0x59F, 11 },
- { 0x9E, 9 },
- { 0x13F, 10 },
- { 0x12, 6 },
- { 0x58, 7 }
- },
- { /* DC bias table 1 */
- { 0x10, 5 },
- { 0x47, 7 },
- { 0x1FF, 9 },
- { 0x8C, 8 },
- { 0x3FC, 10 },
- { 0x46A, 11 },
- { 0x469, 11 },
- { 0x22, 6 },
- { 0x11A1, 13 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0x4, 4 },
- { 0x5, 4 },
- { 0x9, 4 },
- { 0x6, 4 },
- { 0x1E, 5 },
- { 0x16, 5 },
- { 0x7, 4 },
- { 0xC, 4 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xA, 4 },
- { 0x17, 5 },
- { 0x7D, 7 },
- { 0x7E, 7 },
- { 0x11B, 9 },
- { 0x8D1, 12 },
- { 0x3FD, 10 },
- { 0x46B, 11 },
- { 0x11A0, 13 },
- { 0x7C, 7 },
- { 0xFE, 8 }
- },
- { /* DC bias table 2 */
- { 0x16, 5 },
- { 0x20, 6 },
- { 0x86, 8 },
- { 0x87, 8 },
- { 0x367, 10 },
- { 0x6CC, 11 },
- { 0x6CB, 11 },
- { 0x6E, 7 },
- { 0x366D, 14 },
- { 0xF, 4 },
- { 0xE, 4 },
- { 0x4, 4 },
- { 0x5, 4 },
- { 0xA, 4 },
- { 0x6, 4 },
- { 0x1A, 5 },
- { 0x11, 5 },
- { 0x7, 4 },
- { 0xC, 4 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0x9, 4 },
- { 0x17, 5 },
- { 0x6F, 7 },
- { 0x6D, 7 },
- { 0x364, 10 },
- { 0xD9A, 12 },
- { 0x6CA, 11 },
- { 0x1B37, 13 },
- { 0x366C, 14 },
- { 0x42, 7 },
- { 0xD8, 8 }
- },
- { /* DC bias table 3 */
- { 0x0, 4 },
- { 0x2D, 6 },
- { 0xF7, 8 },
- { 0x58, 7 },
- { 0x167, 9 },
- { 0x2CB, 10 },
- { 0x2CA, 10 },
- { 0xE, 6 },
- { 0x1661, 13 },
- { 0x3, 3 },
- { 0x2, 3 },
- { 0x8, 4 },
- { 0x9, 4 },
- { 0xD, 4 },
- { 0x2, 4 },
- { 0x1F, 5 },
- { 0x17, 5 },
- { 0x1, 4 },
- { 0xC, 4 },
- { 0xE, 4 },
- { 0xA, 4 },
- { 0x6, 5 },
- { 0x78, 7 },
- { 0xF, 6 },
- { 0x7A, 7 },
- { 0x164, 9 },
- { 0x599, 11 },
- { 0x2CD, 10 },
- { 0xB31, 12 },
- { 0x1660, 13 },
- { 0x79, 7 },
- { 0xF6, 8 }
- },
- { /* DC bias table 4 */
- { 0x3, 4 },
- { 0x3C, 6 },
- { 0xF, 7 },
- { 0x7A, 7 },
- { 0x1D, 8 },
- { 0x20, 9 },
- { 0x72, 10 },
- { 0x6, 6 },
- { 0x399, 13 },
- { 0x4, 3 },
- { 0x5, 3 },
- { 0x5, 4 },
- { 0x6, 4 },
- { 0xE, 4 },
- { 0x4, 4 },
- { 0x0, 4 },
- { 0x19, 5 },
- { 0x2, 4 },
- { 0xD, 4 },
- { 0x7, 4 },
- { 0x1F, 5 },
- { 0x30, 6 },
- { 0x11, 8 },
- { 0x31, 6 },
- { 0x5, 6 },
- { 0x21, 9 },
- { 0xE7, 11 },
- { 0x38, 9 },
- { 0x1CD, 12 },
- { 0x398, 13 },
- { 0x7B, 7 },
- { 0x9, 7 }
- },
- { /* DC bias table 5 */
- { 0x9, 4 },
- { 0x2, 5 },
- { 0x74, 7 },
- { 0x7, 6 },
- { 0xEC, 8 },
- { 0xD1, 9 },
- { 0x1A6, 10 },
- { 0x6, 6 },
- { 0xD21, 13 },
- { 0x5, 3 },
- { 0x6, 3 },
- { 0x8, 4 },
- { 0x7, 4 },
- { 0xF, 4 },
- { 0x4, 4 },
- { 0x0, 4 },
- { 0x1C, 5 },
- { 0x2, 4 },
- { 0x5, 4 },
- { 0x3, 4 },
- { 0xC, 5 },
- { 0x35, 7 },
- { 0x1A7, 10 },
- { 0x1B, 6 },
- { 0x77, 7 },
- { 0x1A5, 10 },
- { 0x349, 11 },
- { 0xD0, 9 },
- { 0x691, 12 },
- { 0xD20, 13 },
- { 0x75, 7 },
- { 0xED, 8 }
- },
- { /* DC bias table 6 */
- { 0xA, 4 },
- { 0xC, 5 },
- { 0x12, 6 },
- { 0x1B, 6 },
- { 0xB7, 8 },
- { 0x16C, 9 },
- { 0x99, 9 },
- { 0x5A, 7 },
- { 0x16D8, 13 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x0, 3 },
- { 0x5, 4 },
- { 0x17, 5 },
- { 0xE, 5 },
- { 0x2, 4 },
- { 0x3, 4 },
- { 0xF, 5 },
- { 0x1A, 6 },
- { 0x4D, 8 },
- { 0x2DB3, 14 },
- { 0x2C, 6 },
- { 0x11, 6 },
- { 0x2DA, 10 },
- { 0x5B7, 11 },
- { 0x98, 9 },
- { 0xB6D, 12 },
- { 0x2DB2, 14 },
- { 0x10, 6 },
- { 0x27, 7 }
- },
- { /* DC bias table 7 */
- { 0xD, 4 },
- { 0xF, 5 },
- { 0x1D, 6 },
- { 0x8, 5 },
- { 0x51, 7 },
- { 0x56, 8 },
- { 0xAF, 9 },
- { 0x2A, 7 },
- { 0x148A, 13 },
- { 0x7, 3 },
- { 0x0, 2 },
- { 0x8, 4 },
- { 0x9, 4 },
- { 0xC, 4 },
- { 0x6, 4 },
- { 0x17, 5 },
- { 0xB, 5 },
- { 0x16, 5 },
- { 0x15, 5 },
- { 0x9, 5 },
- { 0x50, 7 },
- { 0xAE, 9 },
- { 0x2917, 14 },
- { 0x1C, 6 },
- { 0x14, 6 },
- { 0x290, 10 },
- { 0x523, 11 },
- { 0x149, 9 },
- { 0xA44, 12 },
- { 0x2916, 14 },
- { 0x53, 7 },
- { 0xA5, 8 }
- },
- { /* DC bias table 8 */
- { 0x1, 4 },
- { 0x1D, 6 },
- { 0xF5, 8 },
- { 0xF4, 8 },
- { 0x24D, 10 },
- { 0x499, 11 },
- { 0x498, 11 },
- { 0x1, 5 },
- { 0x21, 6 },
- { 0x6, 3 },
- { 0x5, 3 },
- { 0x6, 4 },
- { 0x5, 4 },
- { 0x2, 4 },
- { 0x7, 5 },
- { 0x25, 6 },
- { 0x7B, 7 },
- { 0x1C, 6 },
- { 0x20, 6 },
- { 0xD, 6 },
- { 0x48, 7 },
- { 0x92, 8 },
- { 0x127, 9 },
- { 0xE, 4 },
- { 0x4, 4 },
- { 0x11, 5 },
- { 0xC, 6 },
- { 0x3C, 6 },
- { 0xF, 5 },
- { 0x0, 5 },
- { 0x1F, 5 },
- { 0x13, 5 }
- },
- { /* DC bias table 9 */
- { 0x5, 4 },
- { 0x3C, 6 },
- { 0x40, 7 },
- { 0xD, 7 },
- { 0x31, 9 },
- { 0x61, 10 },
- { 0x60, 10 },
- { 0x2, 5 },
- { 0xF5, 8 },
- { 0x6, 3 },
- { 0x5, 3 },
- { 0x7, 4 },
- { 0x6, 4 },
- { 0x2, 4 },
- { 0x9, 5 },
- { 0x25, 6 },
- { 0x7, 6 },
- { 0x21, 6 },
- { 0x24, 6 },
- { 0x10, 6 },
- { 0x41, 7 },
- { 0xF4, 8 },
- { 0x19, 8 },
- { 0xE, 4 },
- { 0x3, 4 },
- { 0x11, 5 },
- { 0x11, 6 },
- { 0x3F, 6 },
- { 0x3E, 6 },
- { 0x7B, 7 },
- { 0x0, 4 },
- { 0x13, 5 }
- },
- { /* DC bias table 10 */
- { 0xA, 4 },
- { 0x7, 5 },
- { 0x1, 6 },
- { 0x9, 6 },
- { 0x131, 9 },
- { 0x261, 10 },
- { 0x260, 10 },
- { 0x15, 6 },
- { 0x1, 7 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x8, 4 },
- { 0x7, 4 },
- { 0x6, 4 },
- { 0x12, 5 },
- { 0x2F, 6 },
- { 0x14, 6 },
- { 0x27, 6 },
- { 0x2D, 6 },
- { 0x16, 6 },
- { 0x4D, 7 },
- { 0x99, 8 },
- { 0x0, 7 },
- { 0x4, 4 },
- { 0x1, 4 },
- { 0x5, 5 },
- { 0x17, 6 },
- { 0x2E, 6 },
- { 0x2C, 6 },
- { 0x8, 6 },
- { 0x6, 5 },
- { 0x1, 5 }
- },
- { /* DC bias table 11 */
- { 0x0, 3 },
- { 0xE, 5 },
- { 0x17, 6 },
- { 0x2A, 6 },
- { 0x10, 7 },
- { 0xF9, 10 },
- { 0xF8, 10 },
- { 0x1E, 7 },
- { 0x3F, 8 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x6, 4 },
- { 0xF, 5 },
- { 0x5, 5 },
- { 0x16, 6 },
- { 0x29, 6 },
- { 0x2B, 6 },
- { 0x15, 6 },
- { 0x50, 7 },
- { 0x11, 7 },
- { 0x7D, 9 },
- { 0x4, 4 },
- { 0x17, 5 },
- { 0x6, 5 },
- { 0x14, 6 },
- { 0x2C, 6 },
- { 0x2D, 6 },
- { 0xE, 6 },
- { 0x9, 6 },
- { 0x51, 7 }
- },
- { /* DC bias table 12 */
- { 0x2, 3 },
- { 0x18, 5 },
- { 0x2F, 6 },
- { 0xD, 5 },
- { 0x53, 7 },
- { 0x295, 10 },
- { 0x294, 10 },
- { 0xA4, 8 },
- { 0x7C, 8 },
- { 0x0, 2 },
- { 0x7, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x1B, 5 },
- { 0xC, 5 },
- { 0x28, 6 },
- { 0x6A, 7 },
- { 0x1E, 6 },
- { 0x1D, 6 },
- { 0x69, 7 },
- { 0xD7, 8 },
- { 0x7D, 8 },
- { 0x14B, 9 },
- { 0x19, 5 },
- { 0x16, 5 },
- { 0x2E, 6 },
- { 0x1C, 6 },
- { 0x2B, 6 },
- { 0x2A, 6 },
- { 0x68, 7 },
- { 0x3F, 7 },
- { 0xD6, 8 }
- },
- { /* DC bias table 13 */
- { 0x2, 3 },
- { 0x1B, 5 },
- { 0xC, 5 },
- { 0x18, 5 },
- { 0x29, 6 },
- { 0x7F, 8 },
- { 0x2F0, 10 },
- { 0x198, 9 },
- { 0x179, 9 },
- { 0x0, 2 },
- { 0x7, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x1A, 5 },
- { 0xD, 5 },
- { 0x2A, 6 },
- { 0x64, 7 },
- { 0x1E, 6 },
- { 0x67, 7 },
- { 0x5F, 7 },
- { 0xCD, 8 },
- { 0x7E, 8 },
- { 0x2F1, 10 },
- { 0x16, 5 },
- { 0xE, 5 },
- { 0x2E, 6 },
- { 0x65, 7 },
- { 0x2B, 6 },
- { 0x28, 6 },
- { 0x3E, 7 },
- { 0xBD, 8 },
- { 0x199, 9 }
- },
- { /* DC bias table 14 */
- { 0x2, 3 },
- { 0x7, 4 },
- { 0x16, 5 },
- { 0x6, 4 },
- { 0x36, 6 },
- { 0x5C, 7 },
- { 0x15D, 9 },
- { 0x15C, 9 },
- { 0x2BF, 10 },
- { 0x0, 2 },
- { 0x7, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x18, 5 },
- { 0x34, 6 },
- { 0x2A, 6 },
- { 0x5E, 7 },
- { 0x6A, 7 },
- { 0x64, 7 },
- { 0x5D, 7 },
- { 0xCB, 8 },
- { 0xAD, 8 },
- { 0x2BE, 10 },
- { 0x14, 5 },
- { 0x33, 6 },
- { 0x6E, 7 },
- { 0x5F, 7 },
- { 0x6F, 7 },
- { 0x6B, 7 },
- { 0xCA, 8 },
- { 0xAC, 8 },
- { 0x15E, 9 }
- },
- { /* DC bias table 15 */
- { 0xF, 4 },
- { 0x1D, 5 },
- { 0x18, 5 },
- { 0xB, 4 },
- { 0x19, 5 },
- { 0x29, 6 },
- { 0xD6, 8 },
- { 0x551, 11 },
- { 0xAA1, 12 },
- { 0x1, 2 },
- { 0x0, 2 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x1B, 5 },
- { 0x38, 6 },
- { 0x28, 6 },
- { 0x57, 7 },
- { 0x6A, 7 },
- { 0x68, 7 },
- { 0x56, 7 },
- { 0xE5, 8 },
- { 0x155, 9 },
- { 0xAA0, 12 },
- { 0x73, 7 },
- { 0x69, 7 },
- { 0xD7, 8 },
- { 0xAB, 8 },
- { 0xE4, 8 },
- { 0xA9, 8 },
- { 0x151, 9 },
- { 0x150, 9 },
- { 0x2A9, 10 }
- }
+ { /* DC bias table 0 */
+ { 0x2D, 6 },
+ { 0x26, 7 },
+ { 0x166, 9 },
+ { 0x4E, 8 },
+ { 0x2CE, 10 },
+ { 0x59E, 11 },
+ { 0x27D, 11 },
+ { 0x8, 5 },
+ { 0x4F9, 12 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x1B, 5 },
+ { 0x6, 4 },
+ { 0x8, 4 },
+ { 0x5, 4 },
+ { 0x1A, 5 },
+ { 0x15, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x17, 5 },
+ { 0x29, 6 },
+ { 0x28, 6 },
+ { 0xB2, 8 },
+ { 0x4F8, 12 },
+ { 0x59F, 11 },
+ { 0x9E, 9 },
+ { 0x13F, 10 },
+ { 0x12, 6 },
+ { 0x58, 7 }
+ },
+ { /* DC bias table 1 */
+ { 0x10, 5 },
+ { 0x47, 7 },
+ { 0x1FF, 9 },
+ { 0x8C, 8 },
+ { 0x3FC, 10 },
+ { 0x46A, 11 },
+ { 0x469, 11 },
+ { 0x22, 6 },
+ { 0x11A1, 13 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x6, 4 },
+ { 0x1E, 5 },
+ { 0x16, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x17, 5 },
+ { 0x7D, 7 },
+ { 0x7E, 7 },
+ { 0x11B, 9 },
+ { 0x8D1, 12 },
+ { 0x3FD, 10 },
+ { 0x46B, 11 },
+ { 0x11A0, 13 },
+ { 0x7C, 7 },
+ { 0xFE, 8 }
+ },
+ { /* DC bias table 2 */
+ { 0x16, 5 },
+ { 0x20, 6 },
+ { 0x86, 8 },
+ { 0x87, 8 },
+ { 0x367, 10 },
+ { 0x6CC, 11 },
+ { 0x6CB, 11 },
+ { 0x6E, 7 },
+ { 0x366D, 14 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0xA, 4 },
+ { 0x6, 4 },
+ { 0x1A, 5 },
+ { 0x11, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x17, 5 },
+ { 0x6F, 7 },
+ { 0x6D, 7 },
+ { 0x364, 10 },
+ { 0xD9A, 12 },
+ { 0x6CA, 11 },
+ { 0x1B37, 13 },
+ { 0x366C, 14 },
+ { 0x42, 7 },
+ { 0xD8, 8 }
+ },
+ { /* DC bias table 3 */
+ { 0x0, 4 },
+ { 0x2D, 6 },
+ { 0xF7, 8 },
+ { 0x58, 7 },
+ { 0x167, 9 },
+ { 0x2CB, 10 },
+ { 0x2CA, 10 },
+ { 0xE, 6 },
+ { 0x1661, 13 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0xD, 4 },
+ { 0x2, 4 },
+ { 0x1F, 5 },
+ { 0x17, 5 },
+ { 0x1, 4 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0xA, 4 },
+ { 0x6, 5 },
+ { 0x78, 7 },
+ { 0xF, 6 },
+ { 0x7A, 7 },
+ { 0x164, 9 },
+ { 0x599, 11 },
+ { 0x2CD, 10 },
+ { 0xB31, 12 },
+ { 0x1660, 13 },
+ { 0x79, 7 },
+ { 0xF6, 8 }
+ },
+ { /* DC bias table 4 */
+ { 0x3, 4 },
+ { 0x3C, 6 },
+ { 0xF, 7 },
+ { 0x7A, 7 },
+ { 0x1D, 8 },
+ { 0x20, 9 },
+ { 0x72, 10 },
+ { 0x6, 6 },
+ { 0x399, 13 },
+ { 0x4, 3 },
+ { 0x5, 3 },
+ { 0x5, 4 },
+ { 0x6, 4 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x0, 4 },
+ { 0x19, 5 },
+ { 0x2, 4 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x1F, 5 },
+ { 0x30, 6 },
+ { 0x11, 8 },
+ { 0x31, 6 },
+ { 0x5, 6 },
+ { 0x21, 9 },
+ { 0xE7, 11 },
+ { 0x38, 9 },
+ { 0x1CD, 12 },
+ { 0x398, 13 },
+ { 0x7B, 7 },
+ { 0x9, 7 }
+ },
+ { /* DC bias table 5 */
+ { 0x9, 4 },
+ { 0x2, 5 },
+ { 0x74, 7 },
+ { 0x7, 6 },
+ { 0xEC, 8 },
+ { 0xD1, 9 },
+ { 0x1A6, 10 },
+ { 0x6, 6 },
+ { 0xD21, 13 },
+ { 0x5, 3 },
+ { 0x6, 3 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0xF, 4 },
+ { 0x4, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x2, 4 },
+ { 0x5, 4 },
+ { 0x3, 4 },
+ { 0xC, 5 },
+ { 0x35, 7 },
+ { 0x1A7, 10 },
+ { 0x1B, 6 },
+ { 0x77, 7 },
+ { 0x1A5, 10 },
+ { 0x349, 11 },
+ { 0xD0, 9 },
+ { 0x691, 12 },
+ { 0xD20, 13 },
+ { 0x75, 7 },
+ { 0xED, 8 }
+ },
+ { /* DC bias table 6 */
+ { 0xA, 4 },
+ { 0xC, 5 },
+ { 0x12, 6 },
+ { 0x1B, 6 },
+ { 0xB7, 8 },
+ { 0x16C, 9 },
+ { 0x99, 9 },
+ { 0x5A, 7 },
+ { 0x16D8, 13 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x0, 3 },
+ { 0x5, 4 },
+ { 0x17, 5 },
+ { 0xE, 5 },
+ { 0x2, 4 },
+ { 0x3, 4 },
+ { 0xF, 5 },
+ { 0x1A, 6 },
+ { 0x4D, 8 },
+ { 0x2DB3, 14 },
+ { 0x2C, 6 },
+ { 0x11, 6 },
+ { 0x2DA, 10 },
+ { 0x5B7, 11 },
+ { 0x98, 9 },
+ { 0xB6D, 12 },
+ { 0x2DB2, 14 },
+ { 0x10, 6 },
+ { 0x27, 7 }
+ },
+ { /* DC bias table 7 */
+ { 0xD, 4 },
+ { 0xF, 5 },
+ { 0x1D, 6 },
+ { 0x8, 5 },
+ { 0x51, 7 },
+ { 0x56, 8 },
+ { 0xAF, 9 },
+ { 0x2A, 7 },
+ { 0x148A, 13 },
+ { 0x7, 3 },
+ { 0x0, 2 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x17, 5 },
+ { 0xB, 5 },
+ { 0x16, 5 },
+ { 0x15, 5 },
+ { 0x9, 5 },
+ { 0x50, 7 },
+ { 0xAE, 9 },
+ { 0x2917, 14 },
+ { 0x1C, 6 },
+ { 0x14, 6 },
+ { 0x290, 10 },
+ { 0x523, 11 },
+ { 0x149, 9 },
+ { 0xA44, 12 },
+ { 0x2916, 14 },
+ { 0x53, 7 },
+ { 0xA5, 8 }
+ },
+ { /* DC bias table 8 */
+ { 0x1, 4 },
+ { 0x1D, 6 },
+ { 0xF5, 8 },
+ { 0xF4, 8 },
+ { 0x24D, 10 },
+ { 0x499, 11 },
+ { 0x498, 11 },
+ { 0x1, 5 },
+ { 0x21, 6 },
+ { 0x6, 3 },
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x5, 4 },
+ { 0x2, 4 },
+ { 0x7, 5 },
+ { 0x25, 6 },
+ { 0x7B, 7 },
+ { 0x1C, 6 },
+ { 0x20, 6 },
+ { 0xD, 6 },
+ { 0x48, 7 },
+ { 0x92, 8 },
+ { 0x127, 9 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x11, 5 },
+ { 0xC, 6 },
+ { 0x3C, 6 },
+ { 0xF, 5 },
+ { 0x0, 5 },
+ { 0x1F, 5 },
+ { 0x13, 5 }
+ },
+ { /* DC bias table 9 */
+ { 0x5, 4 },
+ { 0x3C, 6 },
+ { 0x40, 7 },
+ { 0xD, 7 },
+ { 0x31, 9 },
+ { 0x61, 10 },
+ { 0x60, 10 },
+ { 0x2, 5 },
+ { 0xF5, 8 },
+ { 0x6, 3 },
+ { 0x5, 3 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x2, 4 },
+ { 0x9, 5 },
+ { 0x25, 6 },
+ { 0x7, 6 },
+ { 0x21, 6 },
+ { 0x24, 6 },
+ { 0x10, 6 },
+ { 0x41, 7 },
+ { 0xF4, 8 },
+ { 0x19, 8 },
+ { 0xE, 4 },
+ { 0x3, 4 },
+ { 0x11, 5 },
+ { 0x11, 6 },
+ { 0x3F, 6 },
+ { 0x3E, 6 },
+ { 0x7B, 7 },
+ { 0x0, 4 },
+ { 0x13, 5 }
+ },
+ { /* DC bias table 10 */
+ { 0xA, 4 },
+ { 0x7, 5 },
+ { 0x1, 6 },
+ { 0x9, 6 },
+ { 0x131, 9 },
+ { 0x261, 10 },
+ { 0x260, 10 },
+ { 0x15, 6 },
+ { 0x1, 7 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x12, 5 },
+ { 0x2F, 6 },
+ { 0x14, 6 },
+ { 0x27, 6 },
+ { 0x2D, 6 },
+ { 0x16, 6 },
+ { 0x4D, 7 },
+ { 0x99, 8 },
+ { 0x0, 7 },
+ { 0x4, 4 },
+ { 0x1, 4 },
+ { 0x5, 5 },
+ { 0x17, 6 },
+ { 0x2E, 6 },
+ { 0x2C, 6 },
+ { 0x8, 6 },
+ { 0x6, 5 },
+ { 0x1, 5 }
+ },
+ { /* DC bias table 11 */
+ { 0x0, 3 },
+ { 0xE, 5 },
+ { 0x17, 6 },
+ { 0x2A, 6 },
+ { 0x10, 7 },
+ { 0xF9, 10 },
+ { 0xF8, 10 },
+ { 0x1E, 7 },
+ { 0x3F, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x6, 4 },
+ { 0xF, 5 },
+ { 0x5, 5 },
+ { 0x16, 6 },
+ { 0x29, 6 },
+ { 0x2B, 6 },
+ { 0x15, 6 },
+ { 0x50, 7 },
+ { 0x11, 7 },
+ { 0x7D, 9 },
+ { 0x4, 4 },
+ { 0x17, 5 },
+ { 0x6, 5 },
+ { 0x14, 6 },
+ { 0x2C, 6 },
+ { 0x2D, 6 },
+ { 0xE, 6 },
+ { 0x9, 6 },
+ { 0x51, 7 }
+ },
+ { /* DC bias table 12 */
+ { 0x2, 3 },
+ { 0x18, 5 },
+ { 0x2F, 6 },
+ { 0xD, 5 },
+ { 0x53, 7 },
+ { 0x295, 10 },
+ { 0x294, 10 },
+ { 0xA4, 8 },
+ { 0x7C, 8 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0xC, 5 },
+ { 0x28, 6 },
+ { 0x6A, 7 },
+ { 0x1E, 6 },
+ { 0x1D, 6 },
+ { 0x69, 7 },
+ { 0xD7, 8 },
+ { 0x7D, 8 },
+ { 0x14B, 9 },
+ { 0x19, 5 },
+ { 0x16, 5 },
+ { 0x2E, 6 },
+ { 0x1C, 6 },
+ { 0x2B, 6 },
+ { 0x2A, 6 },
+ { 0x68, 7 },
+ { 0x3F, 7 },
+ { 0xD6, 8 }
+ },
+ { /* DC bias table 13 */
+ { 0x2, 3 },
+ { 0x1B, 5 },
+ { 0xC, 5 },
+ { 0x18, 5 },
+ { 0x29, 6 },
+ { 0x7F, 8 },
+ { 0x2F0, 10 },
+ { 0x198, 9 },
+ { 0x179, 9 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0xD, 5 },
+ { 0x2A, 6 },
+ { 0x64, 7 },
+ { 0x1E, 6 },
+ { 0x67, 7 },
+ { 0x5F, 7 },
+ { 0xCD, 8 },
+ { 0x7E, 8 },
+ { 0x2F1, 10 },
+ { 0x16, 5 },
+ { 0xE, 5 },
+ { 0x2E, 6 },
+ { 0x65, 7 },
+ { 0x2B, 6 },
+ { 0x28, 6 },
+ { 0x3E, 7 },
+ { 0xBD, 8 },
+ { 0x199, 9 }
+ },
+ { /* DC bias table 14 */
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x16, 5 },
+ { 0x6, 4 },
+ { 0x36, 6 },
+ { 0x5C, 7 },
+ { 0x15D, 9 },
+ { 0x15C, 9 },
+ { 0x2BF, 10 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x18, 5 },
+ { 0x34, 6 },
+ { 0x2A, 6 },
+ { 0x5E, 7 },
+ { 0x6A, 7 },
+ { 0x64, 7 },
+ { 0x5D, 7 },
+ { 0xCB, 8 },
+ { 0xAD, 8 },
+ { 0x2BE, 10 },
+ { 0x14, 5 },
+ { 0x33, 6 },
+ { 0x6E, 7 },
+ { 0x5F, 7 },
+ { 0x6F, 7 },
+ { 0x6B, 7 },
+ { 0xCA, 8 },
+ { 0xAC, 8 },
+ { 0x15E, 9 }
+ },
+ { /* DC bias table 15 */
+ { 0xF, 4 },
+ { 0x1D, 5 },
+ { 0x18, 5 },
+ { 0xB, 4 },
+ { 0x19, 5 },
+ { 0x29, 6 },
+ { 0xD6, 8 },
+ { 0x551, 11 },
+ { 0xAA1, 12 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0x38, 6 },
+ { 0x28, 6 },
+ { 0x57, 7 },
+ { 0x6A, 7 },
+ { 0x68, 7 },
+ { 0x56, 7 },
+ { 0xE5, 8 },
+ { 0x155, 9 },
+ { 0xAA0, 12 },
+ { 0x73, 7 },
+ { 0x69, 7 },
+ { 0xD7, 8 },
+ { 0xAB, 8 },
+ { 0xE4, 8 },
+ { 0xA9, 8 },
+ { 0x151, 9 },
+ { 0x150, 9 },
+ { 0x2A9, 10 }
+ }
};
static const uint16_t ac_bias_0[16][32][2] = {
- { /* AC bias group 1, table 0 */
- { 0x8, 5 },
- { 0x25, 7 },
- { 0x17A, 9 },
- { 0x2F7, 10 },
- { 0xBDB, 12 },
- { 0x17B4, 13 },
- { 0x2F6B, 14 },
- { 0x1D, 5 },
- { 0x2F6A, 14 },
- { 0x8, 4 },
- { 0x7, 4 },
- { 0x1, 4 },
- { 0x2, 4 },
- { 0xA, 4 },
- { 0x6, 4 },
- { 0x0, 4 },
- { 0x1C, 5 },
- { 0x9, 4 },
- { 0xD, 4 },
- { 0xF, 4 },
- { 0xC, 4 },
- { 0x3, 4 },
- { 0xA, 5 },
- { 0x16, 5 },
- { 0x13, 6 },
- { 0x5D, 7 },
- { 0x24, 7 },
- { 0xBC, 8 },
- { 0x5C, 7 },
- { 0x5EC, 11 },
- { 0xB, 5 },
- { 0x5F, 7 }
- },
- { /* AC bias group 1, table 1 */
- { 0xF, 5 },
- { 0x10, 6 },
- { 0x4B, 8 },
- { 0xC6, 8 },
- { 0x31D, 10 },
- { 0xC71, 12 },
- { 0xC70, 12 },
- { 0x1, 4 },
- { 0xC73, 12 },
- { 0x8, 4 },
- { 0x9, 4 },
- { 0x2, 4 },
- { 0x3, 4 },
- { 0xB, 4 },
- { 0x6, 4 },
- { 0x0, 4 },
- { 0x1C, 5 },
- { 0x5, 4 },
- { 0xD, 4 },
- { 0xF, 4 },
- { 0xA, 4 },
- { 0x19, 5 },
- { 0x13, 6 },
- { 0x1D, 5 },
- { 0x30, 6 },
- { 0x62, 7 },
- { 0x24, 7 },
- { 0x4A, 8 },
- { 0x18F, 9 },
- { 0xC72, 12 },
- { 0xE, 5 },
- { 0x11, 6 }
- },
- { /* AC bias group 1, table 2 */
- { 0x1B, 5 },
- { 0x3, 6 },
- { 0x8D, 8 },
- { 0x40, 7 },
- { 0x239, 10 },
- { 0x471, 11 },
- { 0x8E0, 12 },
- { 0x3, 4 },
- { 0x11C3, 13 },
- { 0xA, 4 },
- { 0x9, 4 },
- { 0x4, 4 },
- { 0x5, 4 },
- { 0xE, 4 },
- { 0x7, 4 },
- { 0x1, 4 },
- { 0x1E, 5 },
- { 0x6, 4 },
- { 0xC, 4 },
- { 0xB, 4 },
- { 0x2, 4 },
- { 0x0, 5 },
- { 0x41, 7 },
- { 0x1F, 5 },
- { 0x22, 6 },
- { 0x2, 6 },
- { 0x8F, 8 },
- { 0x8C, 8 },
- { 0x11D, 9 },
- { 0x11C2, 13 },
- { 0x1A, 5 },
- { 0x21, 6 }
- },
- { /* AC bias group 1, table 3 */
- { 0x1F, 5 },
- { 0x3, 6 },
- { 0x3, 7 },
- { 0x43, 7 },
- { 0xB, 9 },
- { 0x15, 10 },
- { 0x51, 12 },
- { 0x3, 4 },
- { 0x50, 12 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x4, 4 },
- { 0x6, 4 },
- { 0xE, 4 },
- { 0xA, 4 },
- { 0x1, 4 },
- { 0x1E, 5 },
- { 0x5, 4 },
- { 0x9, 4 },
- { 0x7, 4 },
- { 0x11, 5 },
- { 0x2, 6 },
- { 0x4, 8 },
- { 0x2, 4 },
- { 0x2D, 6 },
- { 0x20, 6 },
- { 0x42, 7 },
- { 0x1, 7 },
- { 0x0, 7 },
- { 0x29, 11 },
- { 0x17, 5 },
- { 0x2C, 6 }
- },
- { /* AC bias group 1, table 4 */
- { 0x3, 4 },
- { 0x1F, 6 },
- { 0x3A, 7 },
- { 0x5D, 7 },
- { 0x173, 9 },
- { 0x2E4, 10 },
- { 0x172D, 13 },
- { 0x4, 4 },
- { 0x172C, 13 },
- { 0xF, 4 },
- { 0xE, 4 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0xC, 4 },
- { 0xA, 4 },
- { 0x1, 4 },
- { 0x16, 5 },
- { 0x2, 4 },
- { 0x5, 4 },
- { 0x1A, 5 },
- { 0x2F, 6 },
- { 0x38, 7 },
- { 0x5CA, 11 },
- { 0x6, 4 },
- { 0x37, 6 },
- { 0x1E, 6 },
- { 0x3B, 7 },
- { 0x39, 7 },
- { 0xB8, 8 },
- { 0xB97, 12 },
- { 0x0, 4 },
- { 0x36, 6 }
- },
- { /* AC bias group 1, table 5 */
- { 0x6, 4 },
- { 0x37, 6 },
- { 0x5D, 7 },
- { 0xC, 6 },
- { 0xB9, 8 },
- { 0x2E3, 10 },
- { 0x5C4, 11 },
- { 0x4, 4 },
- { 0x1715, 13 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0x8, 4 },
- { 0x7, 4 },
- { 0xC, 4 },
- { 0x9, 4 },
- { 0x1D, 5 },
- { 0x16, 5 },
- { 0x1C, 5 },
- { 0x1A, 5 },
- { 0xB, 5 },
- { 0x5E, 7 },
- { 0x170, 9 },
- { 0x1714, 13 },
- { 0xA, 4 },
- { 0xA, 5 },
- { 0x36, 6 },
- { 0x5F, 7 },
- { 0x1B, 7 },
- { 0x1A, 7 },
- { 0xB8B, 12 },
- { 0x2, 4 },
- { 0x7, 5 }
- },
- { /* AC bias group 1, table 6 */
- { 0xC, 4 },
- { 0xB, 5 },
- { 0x79, 7 },
- { 0x22, 6 },
- { 0xF0, 8 },
- { 0x119, 9 },
- { 0x230, 10 },
- { 0x1D, 5 },
- { 0x8C4, 12 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xA, 4 },
- { 0x9, 4 },
- { 0xB, 4 },
- { 0x7, 4 },
- { 0x1C, 5 },
- { 0x3D, 6 },
- { 0xD, 5 },
- { 0x8, 5 },
- { 0x15, 6 },
- { 0x8D, 8 },
- { 0x118B, 13 },
- { 0x118A, 13 },
- { 0xD, 4 },
- { 0x10, 5 },
- { 0x9, 5 },
- { 0x14, 6 },
- { 0x47, 7 },
- { 0xF1, 8 },
- { 0x463, 11 },
- { 0x1F, 5 },
- { 0xC, 5 }
- },
- { /* AC bias group 1, table 7 */
- { 0x0, 3 },
- { 0x1A, 5 },
- { 0x33, 6 },
- { 0xC, 5 },
- { 0x46, 7 },
- { 0x1E3, 9 },
- { 0x3C5, 10 },
- { 0x17, 5 },
- { 0x1E21, 13 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x9, 4 },
- { 0xA, 4 },
- { 0x7, 4 },
- { 0x1B, 5 },
- { 0x3D, 6 },
- { 0x1B, 6 },
- { 0x22, 6 },
- { 0x79, 7 },
- { 0xF0, 8 },
- { 0x1E20, 13 },
- { 0x1E23, 13 },
- { 0x1E22, 13 },
- { 0xE, 4 },
- { 0x16, 5 },
- { 0x18, 5 },
- { 0x32, 6 },
- { 0x1A, 6 },
- { 0x47, 7 },
- { 0x789, 11 },
- { 0x1F, 5 },
- { 0x10, 5 }
- },
- { /* AC bias group 1, table 8 */
- { 0x1D, 5 },
- { 0x61, 7 },
- { 0x4E, 8 },
- { 0x9E, 9 },
- { 0x27C, 11 },
- { 0x9F5, 13 },
- { 0x9F4, 13 },
- { 0x3, 4 },
- { 0x60, 7 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0xB, 4 },
- { 0xA, 4 },
- { 0x9, 4 },
- { 0x5, 4 },
- { 0xD, 5 },
- { 0x31, 6 },
- { 0x8, 5 },
- { 0x38, 6 },
- { 0x12, 6 },
- { 0x26, 7 },
- { 0x13F, 10 },
- { 0x4FB, 12 },
- { 0xD, 4 },
- { 0x2, 4 },
- { 0xC, 5 },
- { 0x39, 6 },
- { 0x1C, 6 },
- { 0xF, 5 },
- { 0x1D, 6 },
- { 0x8, 4 },
- { 0x19, 5 }
- },
- { /* AC bias group 1, table 9 */
- { 0x7, 4 },
- { 0x19, 6 },
- { 0xAB, 8 },
- { 0xAA, 8 },
- { 0x119, 10 },
- { 0x461, 12 },
- { 0x460, 12 },
- { 0x1B, 5 },
- { 0x47, 8 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xC, 4 },
- { 0xB, 4 },
- { 0x9, 4 },
- { 0x5, 4 },
- { 0xD, 5 },
- { 0x35, 6 },
- { 0x3D, 6 },
- { 0x3C, 6 },
- { 0x18, 6 },
- { 0x22, 7 },
- { 0x8D, 9 },
- { 0x231, 11 },
- { 0xE, 4 },
- { 0x1F, 5 },
- { 0x9, 5 },
- { 0x2B, 6 },
- { 0x10, 6 },
- { 0x34, 6 },
- { 0x54, 7 },
- { 0x8, 4 },
- { 0x14, 5 }
- },
- { /* AC bias group 1, table 10 */
- { 0xC, 4 },
- { 0x5, 5 },
- { 0x8, 6 },
- { 0x5B, 7 },
- { 0x4D, 9 },
- { 0x131, 11 },
- { 0x261, 12 },
- { 0x1A, 5 },
- { 0x12, 7 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0xA, 4 },
- { 0x9, 4 },
- { 0x6, 4 },
- { 0x1B, 5 },
- { 0x6, 5 },
- { 0x1C, 6 },
- { 0x2C, 6 },
- { 0x15, 6 },
- { 0x5A, 7 },
- { 0x27, 8 },
- { 0x99, 10 },
- { 0x260, 12 },
- { 0xE, 4 },
- { 0x4, 4 },
- { 0xF, 5 },
- { 0x7, 5 },
- { 0x1D, 6 },
- { 0xB, 5 },
- { 0x14, 6 },
- { 0x8, 4 },
- { 0x17, 5 }
- },
- { /* AC bias group 1, table 11 */
- { 0xF, 4 },
- { 0x13, 5 },
- { 0x75, 7 },
- { 0x24, 6 },
- { 0x95, 8 },
- { 0x251, 10 },
- { 0x4A0, 11 },
- { 0x10, 5 },
- { 0xC8, 8 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x1, 4 },
- { 0x0, 4 },
- { 0x1A, 5 },
- { 0x11, 5 },
- { 0x2C, 6 },
- { 0x65, 7 },
- { 0x74, 7 },
- { 0x4B, 7 },
- { 0xC9, 8 },
- { 0x129, 9 },
- { 0x943, 12 },
- { 0x942, 12 },
- { 0x3, 3 },
- { 0xA, 4 },
- { 0x1C, 5 },
- { 0x18, 5 },
- { 0x33, 6 },
- { 0x17, 5 },
- { 0x2D, 6 },
- { 0x1B, 5 },
- { 0x3B, 6 }
- },
- { /* AC bias group 1, table 12 */
- { 0x3, 3 },
- { 0x1A, 5 },
- { 0x2D, 6 },
- { 0x38, 6 },
- { 0x28, 7 },
- { 0x395, 10 },
- { 0xE51, 12 },
- { 0x37, 6 },
- { 0xE4, 8 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0x1F, 5 },
- { 0x1E, 5 },
- { 0x17, 5 },
- { 0x3A, 6 },
- { 0x73, 7 },
- { 0x2A, 7 },
- { 0x2B, 7 },
- { 0x29, 7 },
- { 0x1CB, 9 },
- { 0x729, 11 },
- { 0x1CA1, 13 },
- { 0x1CA0, 13 },
- { 0x4, 3 },
- { 0xA, 4 },
- { 0x4, 4 },
- { 0x18, 5 },
- { 0x36, 6 },
- { 0xB, 5 },
- { 0x2C, 6 },
- { 0x19, 5 },
- { 0x3B, 6 }
- },
- { /* AC bias group 1, table 13 */
- { 0x4, 3 },
- { 0x4, 4 },
- { 0x3F, 6 },
- { 0x17, 5 },
- { 0x75, 7 },
- { 0x1F5, 9 },
- { 0x7D1, 11 },
- { 0x17, 6 },
- { 0x1F6, 9 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0x1B, 5 },
- { 0x1A, 5 },
- { 0xA, 5 },
- { 0x32, 6 },
- { 0x74, 7 },
- { 0xF8, 8 },
- { 0xF9, 8 },
- { 0x1F7, 9 },
- { 0x3E9, 10 },
- { 0xFA0, 12 },
- { 0x1F43, 13 },
- { 0x1F42, 13 },
- { 0x3, 3 },
- { 0xA, 4 },
- { 0x1E, 5 },
- { 0x1C, 5 },
- { 0x3B, 6 },
- { 0x18, 5 },
- { 0x16, 6 },
- { 0x16, 5 },
- { 0x33, 6 }
- },
- { /* AC bias group 1, table 14 */
- { 0x4, 3 },
- { 0x7, 4 },
- { 0x18, 5 },
- { 0x1E, 5 },
- { 0x36, 6 },
- { 0x31, 7 },
- { 0x177, 9 },
- { 0x77, 7 },
- { 0x176, 9 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0x1A, 5 },
- { 0x19, 5 },
- { 0x3A, 6 },
- { 0x19, 6 },
- { 0x5C, 7 },
- { 0xBA, 8 },
- { 0x61, 8 },
- { 0xC1, 9 },
- { 0x180, 10 },
- { 0x302, 11 },
- { 0x607, 12 },
- { 0x606, 12 },
- { 0x2, 3 },
- { 0xA, 4 },
- { 0x1F, 5 },
- { 0x1C, 5 },
- { 0x37, 6 },
- { 0x16, 5 },
- { 0x76, 7 },
- { 0xD, 5 },
- { 0x2F, 6 }
- },
- { /* AC bias group 1, table 15 */
- { 0x0, 3 },
- { 0xA, 4 },
- { 0x1A, 5 },
- { 0xC, 4 },
- { 0x1D, 5 },
- { 0x39, 6 },
- { 0x78, 7 },
- { 0x5E, 7 },
- { 0x393, 11 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x16, 5 },
- { 0xF, 5 },
- { 0x2E, 6 },
- { 0x5F, 7 },
- { 0x73, 8 },
- { 0xE5, 9 },
- { 0x1C8, 10 },
- { 0xE4A, 13 },
- { 0x1C97, 14 },
- { 0x1C96, 14 },
- { 0xE49, 13 },
- { 0xE48, 13 },
- { 0x4, 3 },
- { 0x6, 4 },
- { 0x1F, 5 },
- { 0x1B, 5 },
- { 0x1D, 6 },
- { 0x38, 6 },
- { 0x38, 7 },
- { 0x3D, 6 },
- { 0x79, 7 }
- }
+ { /* AC bias group 1, table 0 */
+ { 0x8, 5 },
+ { 0x25, 7 },
+ { 0x17A, 9 },
+ { 0x2F7, 10 },
+ { 0xBDB, 12 },
+ { 0x17B4, 13 },
+ { 0x2F6B, 14 },
+ { 0x1D, 5 },
+ { 0x2F6A, 14 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0x1, 4 },
+ { 0x2, 4 },
+ { 0xA, 4 },
+ { 0x6, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x9, 4 },
+ { 0xD, 4 },
+ { 0xF, 4 },
+ { 0xC, 4 },
+ { 0x3, 4 },
+ { 0xA, 5 },
+ { 0x16, 5 },
+ { 0x13, 6 },
+ { 0x5D, 7 },
+ { 0x24, 7 },
+ { 0xBC, 8 },
+ { 0x5C, 7 },
+ { 0x5EC, 11 },
+ { 0xB, 5 },
+ { 0x5F, 7 }
+ },
+ { /* AC bias group 1, table 1 */
+ { 0xF, 5 },
+ { 0x10, 6 },
+ { 0x4B, 8 },
+ { 0xC6, 8 },
+ { 0x31D, 10 },
+ { 0xC71, 12 },
+ { 0xC70, 12 },
+ { 0x1, 4 },
+ { 0xC73, 12 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0x2, 4 },
+ { 0x3, 4 },
+ { 0xB, 4 },
+ { 0x6, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x5, 4 },
+ { 0xD, 4 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x19, 5 },
+ { 0x13, 6 },
+ { 0x1D, 5 },
+ { 0x30, 6 },
+ { 0x62, 7 },
+ { 0x24, 7 },
+ { 0x4A, 8 },
+ { 0x18F, 9 },
+ { 0xC72, 12 },
+ { 0xE, 5 },
+ { 0x11, 6 }
+ },
+ { /* AC bias group 1, table 2 */
+ { 0x1B, 5 },
+ { 0x3, 6 },
+ { 0x8D, 8 },
+ { 0x40, 7 },
+ { 0x239, 10 },
+ { 0x471, 11 },
+ { 0x8E0, 12 },
+ { 0x3, 4 },
+ { 0x11C3, 13 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0xE, 4 },
+ { 0x7, 4 },
+ { 0x1, 4 },
+ { 0x1E, 5 },
+ { 0x6, 4 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x2, 4 },
+ { 0x0, 5 },
+ { 0x41, 7 },
+ { 0x1F, 5 },
+ { 0x22, 6 },
+ { 0x2, 6 },
+ { 0x8F, 8 },
+ { 0x8C, 8 },
+ { 0x11D, 9 },
+ { 0x11C2, 13 },
+ { 0x1A, 5 },
+ { 0x21, 6 }
+ },
+ { /* AC bias group 1, table 3 */
+ { 0x1F, 5 },
+ { 0x3, 6 },
+ { 0x3, 7 },
+ { 0x43, 7 },
+ { 0xB, 9 },
+ { 0x15, 10 },
+ { 0x51, 12 },
+ { 0x3, 4 },
+ { 0x50, 12 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x4, 4 },
+ { 0x6, 4 },
+ { 0xE, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0x1E, 5 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x7, 4 },
+ { 0x11, 5 },
+ { 0x2, 6 },
+ { 0x4, 8 },
+ { 0x2, 4 },
+ { 0x2D, 6 },
+ { 0x20, 6 },
+ { 0x42, 7 },
+ { 0x1, 7 },
+ { 0x0, 7 },
+ { 0x29, 11 },
+ { 0x17, 5 },
+ { 0x2C, 6 }
+ },
+ { /* AC bias group 1, table 4 */
+ { 0x3, 4 },
+ { 0x1F, 6 },
+ { 0x3A, 7 },
+ { 0x5D, 7 },
+ { 0x173, 9 },
+ { 0x2E4, 10 },
+ { 0x172D, 13 },
+ { 0x4, 4 },
+ { 0x172C, 13 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0xC, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0x16, 5 },
+ { 0x2, 4 },
+ { 0x5, 4 },
+ { 0x1A, 5 },
+ { 0x2F, 6 },
+ { 0x38, 7 },
+ { 0x5CA, 11 },
+ { 0x6, 4 },
+ { 0x37, 6 },
+ { 0x1E, 6 },
+ { 0x3B, 7 },
+ { 0x39, 7 },
+ { 0xB8, 8 },
+ { 0xB97, 12 },
+ { 0x0, 4 },
+ { 0x36, 6 }
+ },
+ { /* AC bias group 1, table 5 */
+ { 0x6, 4 },
+ { 0x37, 6 },
+ { 0x5D, 7 },
+ { 0xC, 6 },
+ { 0xB9, 8 },
+ { 0x2E3, 10 },
+ { 0x5C4, 11 },
+ { 0x4, 4 },
+ { 0x1715, 13 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x9, 4 },
+ { 0x1D, 5 },
+ { 0x16, 5 },
+ { 0x1C, 5 },
+ { 0x1A, 5 },
+ { 0xB, 5 },
+ { 0x5E, 7 },
+ { 0x170, 9 },
+ { 0x1714, 13 },
+ { 0xA, 4 },
+ { 0xA, 5 },
+ { 0x36, 6 },
+ { 0x5F, 7 },
+ { 0x1B, 7 },
+ { 0x1A, 7 },
+ { 0xB8B, 12 },
+ { 0x2, 4 },
+ { 0x7, 5 }
+ },
+ { /* AC bias group 1, table 6 */
+ { 0xC, 4 },
+ { 0xB, 5 },
+ { 0x79, 7 },
+ { 0x22, 6 },
+ { 0xF0, 8 },
+ { 0x119, 9 },
+ { 0x230, 10 },
+ { 0x1D, 5 },
+ { 0x8C4, 12 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0xB, 4 },
+ { 0x7, 4 },
+ { 0x1C, 5 },
+ { 0x3D, 6 },
+ { 0xD, 5 },
+ { 0x8, 5 },
+ { 0x15, 6 },
+ { 0x8D, 8 },
+ { 0x118B, 13 },
+ { 0x118A, 13 },
+ { 0xD, 4 },
+ { 0x10, 5 },
+ { 0x9, 5 },
+ { 0x14, 6 },
+ { 0x47, 7 },
+ { 0xF1, 8 },
+ { 0x463, 11 },
+ { 0x1F, 5 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 1, table 7 */
+ { 0x0, 3 },
+ { 0x1A, 5 },
+ { 0x33, 6 },
+ { 0xC, 5 },
+ { 0x46, 7 },
+ { 0x1E3, 9 },
+ { 0x3C5, 10 },
+ { 0x17, 5 },
+ { 0x1E21, 13 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x9, 4 },
+ { 0xA, 4 },
+ { 0x7, 4 },
+ { 0x1B, 5 },
+ { 0x3D, 6 },
+ { 0x1B, 6 },
+ { 0x22, 6 },
+ { 0x79, 7 },
+ { 0xF0, 8 },
+ { 0x1E20, 13 },
+ { 0x1E23, 13 },
+ { 0x1E22, 13 },
+ { 0xE, 4 },
+ { 0x16, 5 },
+ { 0x18, 5 },
+ { 0x32, 6 },
+ { 0x1A, 6 },
+ { 0x47, 7 },
+ { 0x789, 11 },
+ { 0x1F, 5 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 1, table 8 */
+ { 0x1D, 5 },
+ { 0x61, 7 },
+ { 0x4E, 8 },
+ { 0x9E, 9 },
+ { 0x27C, 11 },
+ { 0x9F5, 13 },
+ { 0x9F4, 13 },
+ { 0x3, 4 },
+ { 0x60, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x5, 4 },
+ { 0xD, 5 },
+ { 0x31, 6 },
+ { 0x8, 5 },
+ { 0x38, 6 },
+ { 0x12, 6 },
+ { 0x26, 7 },
+ { 0x13F, 10 },
+ { 0x4FB, 12 },
+ { 0xD, 4 },
+ { 0x2, 4 },
+ { 0xC, 5 },
+ { 0x39, 6 },
+ { 0x1C, 6 },
+ { 0xF, 5 },
+ { 0x1D, 6 },
+ { 0x8, 4 },
+ { 0x19, 5 }
+ },
+ { /* AC bias group 1, table 9 */
+ { 0x7, 4 },
+ { 0x19, 6 },
+ { 0xAB, 8 },
+ { 0xAA, 8 },
+ { 0x119, 10 },
+ { 0x461, 12 },
+ { 0x460, 12 },
+ { 0x1B, 5 },
+ { 0x47, 8 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x9, 4 },
+ { 0x5, 4 },
+ { 0xD, 5 },
+ { 0x35, 6 },
+ { 0x3D, 6 },
+ { 0x3C, 6 },
+ { 0x18, 6 },
+ { 0x22, 7 },
+ { 0x8D, 9 },
+ { 0x231, 11 },
+ { 0xE, 4 },
+ { 0x1F, 5 },
+ { 0x9, 5 },
+ { 0x2B, 6 },
+ { 0x10, 6 },
+ { 0x34, 6 },
+ { 0x54, 7 },
+ { 0x8, 4 },
+ { 0x14, 5 }
+ },
+ { /* AC bias group 1, table 10 */
+ { 0xC, 4 },
+ { 0x5, 5 },
+ { 0x8, 6 },
+ { 0x5B, 7 },
+ { 0x4D, 9 },
+ { 0x131, 11 },
+ { 0x261, 12 },
+ { 0x1A, 5 },
+ { 0x12, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x6, 4 },
+ { 0x1B, 5 },
+ { 0x6, 5 },
+ { 0x1C, 6 },
+ { 0x2C, 6 },
+ { 0x15, 6 },
+ { 0x5A, 7 },
+ { 0x27, 8 },
+ { 0x99, 10 },
+ { 0x260, 12 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0xF, 5 },
+ { 0x7, 5 },
+ { 0x1D, 6 },
+ { 0xB, 5 },
+ { 0x14, 6 },
+ { 0x8, 4 },
+ { 0x17, 5 }
+ },
+ { /* AC bias group 1, table 11 */
+ { 0xF, 4 },
+ { 0x13, 5 },
+ { 0x75, 7 },
+ { 0x24, 6 },
+ { 0x95, 8 },
+ { 0x251, 10 },
+ { 0x4A0, 11 },
+ { 0x10, 5 },
+ { 0xC8, 8 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0x1A, 5 },
+ { 0x11, 5 },
+ { 0x2C, 6 },
+ { 0x65, 7 },
+ { 0x74, 7 },
+ { 0x4B, 7 },
+ { 0xC9, 8 },
+ { 0x129, 9 },
+ { 0x943, 12 },
+ { 0x942, 12 },
+ { 0x3, 3 },
+ { 0xA, 4 },
+ { 0x1C, 5 },
+ { 0x18, 5 },
+ { 0x33, 6 },
+ { 0x17, 5 },
+ { 0x2D, 6 },
+ { 0x1B, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 1, table 12 */
+ { 0x3, 3 },
+ { 0x1A, 5 },
+ { 0x2D, 6 },
+ { 0x38, 6 },
+ { 0x28, 7 },
+ { 0x395, 10 },
+ { 0xE51, 12 },
+ { 0x37, 6 },
+ { 0xE4, 8 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0x1E, 5 },
+ { 0x17, 5 },
+ { 0x3A, 6 },
+ { 0x73, 7 },
+ { 0x2A, 7 },
+ { 0x2B, 7 },
+ { 0x29, 7 },
+ { 0x1CB, 9 },
+ { 0x729, 11 },
+ { 0x1CA1, 13 },
+ { 0x1CA0, 13 },
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x4, 4 },
+ { 0x18, 5 },
+ { 0x36, 6 },
+ { 0xB, 5 },
+ { 0x2C, 6 },
+ { 0x19, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 1, table 13 */
+ { 0x4, 3 },
+ { 0x4, 4 },
+ { 0x3F, 6 },
+ { 0x17, 5 },
+ { 0x75, 7 },
+ { 0x1F5, 9 },
+ { 0x7D1, 11 },
+ { 0x17, 6 },
+ { 0x1F6, 9 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0xA, 5 },
+ { 0x32, 6 },
+ { 0x74, 7 },
+ { 0xF8, 8 },
+ { 0xF9, 8 },
+ { 0x1F7, 9 },
+ { 0x3E9, 10 },
+ { 0xFA0, 12 },
+ { 0x1F43, 13 },
+ { 0x1F42, 13 },
+ { 0x3, 3 },
+ { 0xA, 4 },
+ { 0x1E, 5 },
+ { 0x1C, 5 },
+ { 0x3B, 6 },
+ { 0x18, 5 },
+ { 0x16, 6 },
+ { 0x16, 5 },
+ { 0x33, 6 }
+ },
+ { /* AC bias group 1, table 14 */
+ { 0x4, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x1E, 5 },
+ { 0x36, 6 },
+ { 0x31, 7 },
+ { 0x177, 9 },
+ { 0x77, 7 },
+ { 0x176, 9 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1A, 5 },
+ { 0x19, 5 },
+ { 0x3A, 6 },
+ { 0x19, 6 },
+ { 0x5C, 7 },
+ { 0xBA, 8 },
+ { 0x61, 8 },
+ { 0xC1, 9 },
+ { 0x180, 10 },
+ { 0x302, 11 },
+ { 0x607, 12 },
+ { 0x606, 12 },
+ { 0x2, 3 },
+ { 0xA, 4 },
+ { 0x1F, 5 },
+ { 0x1C, 5 },
+ { 0x37, 6 },
+ { 0x16, 5 },
+ { 0x76, 7 },
+ { 0xD, 5 },
+ { 0x2F, 6 }
+ },
+ { /* AC bias group 1, table 15 */
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x1A, 5 },
+ { 0xC, 4 },
+ { 0x1D, 5 },
+ { 0x39, 6 },
+ { 0x78, 7 },
+ { 0x5E, 7 },
+ { 0x393, 11 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x16, 5 },
+ { 0xF, 5 },
+ { 0x2E, 6 },
+ { 0x5F, 7 },
+ { 0x73, 8 },
+ { 0xE5, 9 },
+ { 0x1C8, 10 },
+ { 0xE4A, 13 },
+ { 0x1C97, 14 },
+ { 0x1C96, 14 },
+ { 0xE49, 13 },
+ { 0xE48, 13 },
+ { 0x4, 3 },
+ { 0x6, 4 },
+ { 0x1F, 5 },
+ { 0x1B, 5 },
+ { 0x1D, 6 },
+ { 0x38, 6 },
+ { 0x38, 7 },
+ { 0x3D, 6 },
+ { 0x79, 7 }
+ }
};
static const uint16_t ac_bias_1[16][32][2] = {
- { /* AC bias group 2, table 0 */
- { 0xB, 5 },
- { 0x2B, 7 },
- { 0x54, 8 },
- { 0x1B7, 9 },
- { 0x6D9, 11 },
- { 0xDB1, 12 },
- { 0xDB0, 12 },
- { 0x2, 4 },
- { 0xAB, 9 },
- { 0x9, 4 },
- { 0xA, 4 },
- { 0x7, 4 },
- { 0x8, 4 },
- { 0xF, 4 },
- { 0xC, 4 },
- { 0x3, 4 },
- { 0x1D, 5 },
- { 0x4, 4 },
- { 0xB, 4 },
- { 0x6, 4 },
- { 0x1A, 5 },
- { 0x3, 6 },
- { 0xAA, 9 },
- { 0x1, 4 },
- { 0x0, 5 },
- { 0x14, 6 },
- { 0x6C, 7 },
- { 0xDA, 8 },
- { 0x2, 6 },
- { 0x36D, 10 },
- { 0x1C, 5 },
- { 0x37, 6 }
- },
- { /* AC bias group 2, table 1 */
- { 0x1D, 5 },
- { 0x4, 6 },
- { 0xB6, 8 },
- { 0x6A, 8 },
- { 0x5B9, 11 },
- { 0x16E1, 13 },
- { 0x16E0, 13 },
- { 0x7, 4 },
- { 0x16F, 9 },
- { 0xC, 4 },
- { 0xD, 4 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0xF, 4 },
- { 0xA, 4 },
- { 0x3, 4 },
- { 0x17, 5 },
- { 0x2, 4 },
- { 0x4, 4 },
- { 0x1C, 5 },
- { 0x2C, 6 },
- { 0x6B, 8 },
- { 0xB71, 12 },
- { 0x5, 4 },
- { 0x3, 5 },
- { 0x1B, 6 },
- { 0x5A, 7 },
- { 0x34, 7 },
- { 0x5, 6 },
- { 0x2DD, 10 },
- { 0x0, 4 },
- { 0xC, 5 }
- },
- { /* AC bias group 2, table 2 */
- { 0x3, 4 },
- { 0x7F, 7 },
- { 0xA1, 8 },
- { 0xA0, 8 },
- { 0x20C, 10 },
- { 0x834, 12 },
- { 0x106B, 13 },
- { 0x7, 4 },
- { 0x82, 8 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0x0, 3 },
- { 0x9, 4 },
- { 0x2, 4 },
- { 0x11, 5 },
- { 0x1E, 5 },
- { 0x15, 5 },
- { 0x3E, 6 },
- { 0x40, 7 },
- { 0x41B, 11 },
- { 0x106A, 13 },
- { 0x6, 4 },
- { 0xA, 5 },
- { 0x29, 6 },
- { 0x7E, 7 },
- { 0x51, 7 },
- { 0x21, 6 },
- { 0x107, 9 },
- { 0x4, 4 },
- { 0xB, 5 }
- },
- { /* AC bias group 2, table 3 */
- { 0x7, 4 },
- { 0x1B, 6 },
- { 0xF6, 8 },
- { 0xE9, 8 },
- { 0x3A1, 10 },
- { 0x740, 11 },
- { 0xE82, 12 },
- { 0x1F, 5 },
- { 0x1EF, 9 },
- { 0x1, 3 },
- { 0x2, 3 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0xD, 4 },
- { 0x8, 4 },
- { 0x1C, 5 },
- { 0x3, 5 },
- { 0x12, 5 },
- { 0x2, 5 },
- { 0x75, 7 },
- { 0x1D1, 9 },
- { 0x1D07, 13 },
- { 0x1D06, 13 },
- { 0xA, 4 },
- { 0x13, 5 },
- { 0x3B, 6 },
- { 0x1A, 6 },
- { 0x7A, 7 },
- { 0x3C, 6 },
- { 0x1EE, 9 },
- { 0x0, 4 },
- { 0xC, 5 }
- },
- { /* AC bias group 2, table 4 */
- { 0xD, 4 },
- { 0x3D, 6 },
- { 0x42, 7 },
- { 0x37, 7 },
- { 0xD9, 9 },
- { 0x362, 11 },
- { 0x6C6, 12 },
- { 0x1F, 5 },
- { 0x86, 8 },
- { 0x1, 3 },
- { 0x2, 3 },
- { 0xC, 4 },
- { 0xB, 4 },
- { 0xA, 4 },
- { 0x1, 4 },
- { 0xF, 5 },
- { 0x25, 6 },
- { 0x3C, 6 },
- { 0x1A, 6 },
- { 0x87, 8 },
- { 0x1B0, 10 },
- { 0xD8F, 13 },
- { 0xD8E, 13 },
- { 0xE, 4 },
- { 0x13, 5 },
- { 0xC, 5 },
- { 0x24, 6 },
- { 0x20, 6 },
- { 0x11, 5 },
- { 0x6D, 8 },
- { 0x0, 4 },
- { 0xE, 5 }
- },
- { /* AC bias group 2, table 5 */
- { 0x0, 3 },
- { 0x12, 5 },
- { 0x76, 7 },
- { 0x77, 7 },
- { 0x14D, 9 },
- { 0x533, 11 },
- { 0x14C9, 13 },
- { 0x13, 5 },
- { 0xA5, 8 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0x8, 4 },
- { 0x1A, 5 },
- { 0x2B, 6 },
- { 0x75, 7 },
- { 0x74, 7 },
- { 0xA7, 8 },
- { 0x298, 10 },
- { 0x14C8, 13 },
- { 0x14CB, 13 },
- { 0x14CA, 13 },
- { 0xF, 4 },
- { 0x1C, 5 },
- { 0x7, 5 },
- { 0x2A, 6 },
- { 0x28, 6 },
- { 0x1B, 5 },
- { 0xA4, 8 },
- { 0x2, 4 },
- { 0x6, 5 }
- },
- { /* AC bias group 2, table 6 */
- { 0x2, 3 },
- { 0x1A, 5 },
- { 0x2B, 6 },
- { 0x3A, 6 },
- { 0xED, 8 },
- { 0x283, 10 },
- { 0xA0A, 12 },
- { 0x4, 5 },
- { 0xA1, 8 },
- { 0x4, 3 },
- { 0x3, 3 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0x1F, 5 },
- { 0x6, 5 },
- { 0x77, 7 },
- { 0xA3, 8 },
- { 0xA2, 8 },
- { 0x140, 9 },
- { 0x1417, 13 },
- { 0x1416, 13 },
- { 0xA09, 12 },
- { 0xA08, 12 },
- { 0x0, 3 },
- { 0x1E, 5 },
- { 0x7, 5 },
- { 0x2A, 6 },
- { 0x29, 6 },
- { 0x1C, 5 },
- { 0xEC, 8 },
- { 0x1B, 5 },
- { 0x5, 5 }
- },
- { /* AC bias group 2, table 7 */
- { 0x2, 3 },
- { 0x2, 4 },
- { 0x18, 5 },
- { 0x1D, 5 },
- { 0x35, 6 },
- { 0xE4, 8 },
- { 0x1CF, 11 },
- { 0x1D, 7 },
- { 0x72, 9 },
- { 0x4, 3 },
- { 0x5, 3 },
- { 0x6, 4 },
- { 0x7, 4 },
- { 0x6, 5 },
- { 0x73, 7 },
- { 0x38, 8 },
- { 0x1CE, 11 },
- { 0x39B, 12 },
- { 0x398, 12 },
- { 0x733, 13 },
- { 0x732, 13 },
- { 0x735, 13 },
- { 0x734, 13 },
- { 0x0, 3 },
- { 0x1F, 5 },
- { 0x1B, 5 },
- { 0x34, 6 },
- { 0xF, 6 },
- { 0x1E, 5 },
- { 0xE5, 8 },
- { 0x19, 5 },
- { 0x38, 6 }
- },
- { /* AC bias group 2, table 8 */
- { 0x16, 5 },
- { 0x50, 7 },
- { 0x172, 9 },
- { 0x2E7, 10 },
- { 0x1732, 13 },
- { 0x2E67, 14 },
- { 0x2E66, 14 },
- { 0x6, 4 },
- { 0x51, 7 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x9, 4 },
- { 0x1C, 5 },
- { 0x9, 5 },
- { 0x1C, 6 },
- { 0x1D, 6 },
- { 0x5D, 7 },
- { 0xB8, 8 },
- { 0x5CD, 11 },
- { 0x1731, 13 },
- { 0x1730, 13 },
- { 0xF, 4 },
- { 0x5, 4 },
- { 0xF, 5 },
- { 0x8, 5 },
- { 0x29, 6 },
- { 0x1D, 5 },
- { 0x2F, 6 },
- { 0x8, 4 },
- { 0x15, 5 }
- },
- { /* AC bias group 2, table 9 */
- { 0x9, 4 },
- { 0x21, 6 },
- { 0x40, 7 },
- { 0xAD, 8 },
- { 0x2B0, 10 },
- { 0x1589, 13 },
- { 0x1588, 13 },
- { 0x1C, 5 },
- { 0x5F, 7 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x6, 4 },
- { 0x11, 5 },
- { 0x2A, 6 },
- { 0x57, 7 },
- { 0x5E, 7 },
- { 0x41, 7 },
- { 0x159, 9 },
- { 0x563, 11 },
- { 0x158B, 13 },
- { 0x158A, 13 },
- { 0x1, 3 },
- { 0x5, 4 },
- { 0x14, 5 },
- { 0x3B, 6 },
- { 0x2E, 6 },
- { 0x4, 4 },
- { 0x3A, 6 },
- { 0x7, 4 },
- { 0x16, 5 }
- },
- { /* AC bias group 2, table 10 */
- { 0xE, 4 },
- { 0x7, 5 },
- { 0x46, 7 },
- { 0x45, 7 },
- { 0x64, 9 },
- { 0x32A, 12 },
- { 0x657, 13 },
- { 0x18, 5 },
- { 0xD, 6 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0xA, 4 },
- { 0xB, 4 },
- { 0x1A, 5 },
- { 0x36, 6 },
- { 0x47, 7 },
- { 0x44, 7 },
- { 0x18, 7 },
- { 0x33, 8 },
- { 0xCB, 10 },
- { 0x656, 13 },
- { 0x329, 12 },
- { 0x328, 12 },
- { 0x2, 3 },
- { 0x6, 4 },
- { 0x19, 5 },
- { 0xE, 5 },
- { 0x37, 6 },
- { 0x9, 4 },
- { 0xF, 5 },
- { 0x2, 4 },
- { 0x10, 5 }
- },
- { /* AC bias group 2, table 11 */
- { 0x3, 3 },
- { 0x18, 5 },
- { 0x23, 6 },
- { 0x77, 7 },
- { 0x194, 9 },
- { 0x1956, 13 },
- { 0x32AF, 14 },
- { 0x3A, 6 },
- { 0x76, 7 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x1F, 5 },
- { 0x1E, 5 },
- { 0x14, 5 },
- { 0x22, 6 },
- { 0x64, 7 },
- { 0x197, 9 },
- { 0x196, 9 },
- { 0x32B, 10 },
- { 0x654, 11 },
- { 0x32AE, 14 },
- { 0x1955, 13 },
- { 0x1954, 13 },
- { 0x0, 3 },
- { 0x9, 4 },
- { 0x1C, 5 },
- { 0x15, 5 },
- { 0x10, 5 },
- { 0xD, 4 },
- { 0x17, 5 },
- { 0x16, 5 },
- { 0x33, 6 }
- },
- { /* AC bias group 2, table 12 */
- { 0x5, 3 },
- { 0x6, 4 },
- { 0x3E, 6 },
- { 0x10, 5 },
- { 0x48, 7 },
- { 0x93F, 12 },
- { 0x24FA, 14 },
- { 0x32, 6 },
- { 0x67, 7 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x1B, 5 },
- { 0x1E, 5 },
- { 0x34, 6 },
- { 0x66, 7 },
- { 0x92, 8 },
- { 0x126, 9 },
- { 0x24E, 10 },
- { 0x49E, 11 },
- { 0x49F7, 15 },
- { 0x49F6, 15 },
- { 0x24F9, 14 },
- { 0x24F8, 14 },
- { 0x0, 3 },
- { 0x7, 4 },
- { 0x18, 5 },
- { 0x11, 5 },
- { 0x3F, 6 },
- { 0xE, 4 },
- { 0x13, 5 },
- { 0x35, 6 },
- { 0x25, 6 }
- },
- { /* AC bias group 2, table 13 */
- { 0x5, 3 },
- { 0x8, 4 },
- { 0x12, 5 },
- { 0x1C, 5 },
- { 0x1C, 6 },
- { 0xEA, 9 },
- { 0x1D75, 14 },
- { 0x1E, 6 },
- { 0x66, 7 },
- { 0x1, 3 },
- { 0x2, 3 },
- { 0x1B, 5 },
- { 0x1A, 5 },
- { 0x1F, 6 },
- { 0x3B, 7 },
- { 0x74, 8 },
- { 0x1D6, 10 },
- { 0x3AF, 11 },
- { 0x1D74, 14 },
- { 0x1D77, 14 },
- { 0x1D76, 14 },
- { 0xEB9, 13 },
- { 0xEB8, 13 },
- { 0xF, 4 },
- { 0x6, 4 },
- { 0x13, 5 },
- { 0x3B, 6 },
- { 0x3A, 6 },
- { 0x0, 3 },
- { 0x18, 5 },
- { 0x32, 6 },
- { 0x67, 7 }
- },
- { /* AC bias group 2, table 14 */
- { 0x4, 3 },
- { 0xA, 4 },
- { 0x1B, 5 },
- { 0xC, 4 },
- { 0xD, 5 },
- { 0xE6, 8 },
- { 0x684, 11 },
- { 0x72, 7 },
- { 0xE7, 8 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x17, 5 },
- { 0x16, 5 },
- { 0x18, 6 },
- { 0xD1, 8 },
- { 0x1A0, 9 },
- { 0x686, 11 },
- { 0xD0F, 12 },
- { 0xD0A, 12 },
- { 0x1A17, 13 },
- { 0x1A16, 13 },
- { 0x1A1D, 13 },
- { 0x1A1C, 13 },
- { 0xF, 4 },
- { 0x1D, 5 },
- { 0xE, 5 },
- { 0x35, 6 },
- { 0x38, 6 },
- { 0x0, 3 },
- { 0xF, 5 },
- { 0x19, 6 },
- { 0x69, 7 }
- },
- { /* AC bias group 2, table 15 */
- { 0x3, 3 },
- { 0xC, 4 },
- { 0x1B, 5 },
- { 0x0, 3 },
- { 0x3, 4 },
- { 0x2E, 6 },
- { 0x51, 9 },
- { 0xBC, 8 },
- { 0x53, 9 },
- { 0x4, 3 },
- { 0x2, 3 },
- { 0x16, 5 },
- { 0x15, 5 },
- { 0x15, 7 },
- { 0x50, 9 },
- { 0xA4, 10 },
- { 0x294, 12 },
- { 0x52B, 13 },
- { 0x52A, 13 },
- { 0x52D, 13 },
- { 0x52C, 13 },
- { 0x52F, 13 },
- { 0x52E, 13 },
- { 0xE, 4 },
- { 0x1A, 5 },
- { 0x4, 5 },
- { 0x28, 6 },
- { 0x29, 6 },
- { 0xF, 4 },
- { 0xB, 6 },
- { 0x5F, 7 },
- { 0xBD, 8 }
- }
+ { /* AC bias group 2, table 0 */
+ { 0xB, 5 },
+ { 0x2B, 7 },
+ { 0x54, 8 },
+ { 0x1B7, 9 },
+ { 0x6D9, 11 },
+ { 0xDB1, 12 },
+ { 0xDB0, 12 },
+ { 0x2, 4 },
+ { 0xAB, 9 },
+ { 0x9, 4 },
+ { 0xA, 4 },
+ { 0x7, 4 },
+ { 0x8, 4 },
+ { 0xF, 4 },
+ { 0xC, 4 },
+ { 0x3, 4 },
+ { 0x1D, 5 },
+ { 0x4, 4 },
+ { 0xB, 4 },
+ { 0x6, 4 },
+ { 0x1A, 5 },
+ { 0x3, 6 },
+ { 0xAA, 9 },
+ { 0x1, 4 },
+ { 0x0, 5 },
+ { 0x14, 6 },
+ { 0x6C, 7 },
+ { 0xDA, 8 },
+ { 0x2, 6 },
+ { 0x36D, 10 },
+ { 0x1C, 5 },
+ { 0x37, 6 }
+ },
+ { /* AC bias group 2, table 1 */
+ { 0x1D, 5 },
+ { 0x4, 6 },
+ { 0xB6, 8 },
+ { 0x6A, 8 },
+ { 0x5B9, 11 },
+ { 0x16E1, 13 },
+ { 0x16E0, 13 },
+ { 0x7, 4 },
+ { 0x16F, 9 },
+ { 0xC, 4 },
+ { 0xD, 4 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x3, 4 },
+ { 0x17, 5 },
+ { 0x2, 4 },
+ { 0x4, 4 },
+ { 0x1C, 5 },
+ { 0x2C, 6 },
+ { 0x6B, 8 },
+ { 0xB71, 12 },
+ { 0x5, 4 },
+ { 0x3, 5 },
+ { 0x1B, 6 },
+ { 0x5A, 7 },
+ { 0x34, 7 },
+ { 0x5, 6 },
+ { 0x2DD, 10 },
+ { 0x0, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 2, table 2 */
+ { 0x3, 4 },
+ { 0x7F, 7 },
+ { 0xA1, 8 },
+ { 0xA0, 8 },
+ { 0x20C, 10 },
+ { 0x834, 12 },
+ { 0x106B, 13 },
+ { 0x7, 4 },
+ { 0x82, 8 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x2, 4 },
+ { 0x11, 5 },
+ { 0x1E, 5 },
+ { 0x15, 5 },
+ { 0x3E, 6 },
+ { 0x40, 7 },
+ { 0x41B, 11 },
+ { 0x106A, 13 },
+ { 0x6, 4 },
+ { 0xA, 5 },
+ { 0x29, 6 },
+ { 0x7E, 7 },
+ { 0x51, 7 },
+ { 0x21, 6 },
+ { 0x107, 9 },
+ { 0x4, 4 },
+ { 0xB, 5 }
+ },
+ { /* AC bias group 2, table 3 */
+ { 0x7, 4 },
+ { 0x1B, 6 },
+ { 0xF6, 8 },
+ { 0xE9, 8 },
+ { 0x3A1, 10 },
+ { 0x740, 11 },
+ { 0xE82, 12 },
+ { 0x1F, 5 },
+ { 0x1EF, 9 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0xD, 4 },
+ { 0x8, 4 },
+ { 0x1C, 5 },
+ { 0x3, 5 },
+ { 0x12, 5 },
+ { 0x2, 5 },
+ { 0x75, 7 },
+ { 0x1D1, 9 },
+ { 0x1D07, 13 },
+ { 0x1D06, 13 },
+ { 0xA, 4 },
+ { 0x13, 5 },
+ { 0x3B, 6 },
+ { 0x1A, 6 },
+ { 0x7A, 7 },
+ { 0x3C, 6 },
+ { 0x1EE, 9 },
+ { 0x0, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 2, table 4 */
+ { 0xD, 4 },
+ { 0x3D, 6 },
+ { 0x42, 7 },
+ { 0x37, 7 },
+ { 0xD9, 9 },
+ { 0x362, 11 },
+ { 0x6C6, 12 },
+ { 0x1F, 5 },
+ { 0x86, 8 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0xF, 5 },
+ { 0x25, 6 },
+ { 0x3C, 6 },
+ { 0x1A, 6 },
+ { 0x87, 8 },
+ { 0x1B0, 10 },
+ { 0xD8F, 13 },
+ { 0xD8E, 13 },
+ { 0xE, 4 },
+ { 0x13, 5 },
+ { 0xC, 5 },
+ { 0x24, 6 },
+ { 0x20, 6 },
+ { 0x11, 5 },
+ { 0x6D, 8 },
+ { 0x0, 4 },
+ { 0xE, 5 }
+ },
+ { /* AC bias group 2, table 5 */
+ { 0x0, 3 },
+ { 0x12, 5 },
+ { 0x76, 7 },
+ { 0x77, 7 },
+ { 0x14D, 9 },
+ { 0x533, 11 },
+ { 0x14C9, 13 },
+ { 0x13, 5 },
+ { 0xA5, 8 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0x2B, 6 },
+ { 0x75, 7 },
+ { 0x74, 7 },
+ { 0xA7, 8 },
+ { 0x298, 10 },
+ { 0x14C8, 13 },
+ { 0x14CB, 13 },
+ { 0x14CA, 13 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0x7, 5 },
+ { 0x2A, 6 },
+ { 0x28, 6 },
+ { 0x1B, 5 },
+ { 0xA4, 8 },
+ { 0x2, 4 },
+ { 0x6, 5 }
+ },
+ { /* AC bias group 2, table 6 */
+ { 0x2, 3 },
+ { 0x1A, 5 },
+ { 0x2B, 6 },
+ { 0x3A, 6 },
+ { 0xED, 8 },
+ { 0x283, 10 },
+ { 0xA0A, 12 },
+ { 0x4, 5 },
+ { 0xA1, 8 },
+ { 0x4, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x1F, 5 },
+ { 0x6, 5 },
+ { 0x77, 7 },
+ { 0xA3, 8 },
+ { 0xA2, 8 },
+ { 0x140, 9 },
+ { 0x1417, 13 },
+ { 0x1416, 13 },
+ { 0xA09, 12 },
+ { 0xA08, 12 },
+ { 0x0, 3 },
+ { 0x1E, 5 },
+ { 0x7, 5 },
+ { 0x2A, 6 },
+ { 0x29, 6 },
+ { 0x1C, 5 },
+ { 0xEC, 8 },
+ { 0x1B, 5 },
+ { 0x5, 5 }
+ },
+ { /* AC bias group 2, table 7 */
+ { 0x2, 3 },
+ { 0x2, 4 },
+ { 0x18, 5 },
+ { 0x1D, 5 },
+ { 0x35, 6 },
+ { 0xE4, 8 },
+ { 0x1CF, 11 },
+ { 0x1D, 7 },
+ { 0x72, 9 },
+ { 0x4, 3 },
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x7, 4 },
+ { 0x6, 5 },
+ { 0x73, 7 },
+ { 0x38, 8 },
+ { 0x1CE, 11 },
+ { 0x39B, 12 },
+ { 0x398, 12 },
+ { 0x733, 13 },
+ { 0x732, 13 },
+ { 0x735, 13 },
+ { 0x734, 13 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0x1B, 5 },
+ { 0x34, 6 },
+ { 0xF, 6 },
+ { 0x1E, 5 },
+ { 0xE5, 8 },
+ { 0x19, 5 },
+ { 0x38, 6 }
+ },
+ { /* AC bias group 2, table 8 */
+ { 0x16, 5 },
+ { 0x50, 7 },
+ { 0x172, 9 },
+ { 0x2E7, 10 },
+ { 0x1732, 13 },
+ { 0x2E67, 14 },
+ { 0x2E66, 14 },
+ { 0x6, 4 },
+ { 0x51, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x9, 4 },
+ { 0x1C, 5 },
+ { 0x9, 5 },
+ { 0x1C, 6 },
+ { 0x1D, 6 },
+ { 0x5D, 7 },
+ { 0xB8, 8 },
+ { 0x5CD, 11 },
+ { 0x1731, 13 },
+ { 0x1730, 13 },
+ { 0xF, 4 },
+ { 0x5, 4 },
+ { 0xF, 5 },
+ { 0x8, 5 },
+ { 0x29, 6 },
+ { 0x1D, 5 },
+ { 0x2F, 6 },
+ { 0x8, 4 },
+ { 0x15, 5 }
+ },
+ { /* AC bias group 2, table 9 */
+ { 0x9, 4 },
+ { 0x21, 6 },
+ { 0x40, 7 },
+ { 0xAD, 8 },
+ { 0x2B0, 10 },
+ { 0x1589, 13 },
+ { 0x1588, 13 },
+ { 0x1C, 5 },
+ { 0x5F, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x11, 5 },
+ { 0x2A, 6 },
+ { 0x57, 7 },
+ { 0x5E, 7 },
+ { 0x41, 7 },
+ { 0x159, 9 },
+ { 0x563, 11 },
+ { 0x158B, 13 },
+ { 0x158A, 13 },
+ { 0x1, 3 },
+ { 0x5, 4 },
+ { 0x14, 5 },
+ { 0x3B, 6 },
+ { 0x2E, 6 },
+ { 0x4, 4 },
+ { 0x3A, 6 },
+ { 0x7, 4 },
+ { 0x16, 5 }
+ },
+ { /* AC bias group 2, table 10 */
+ { 0xE, 4 },
+ { 0x7, 5 },
+ { 0x46, 7 },
+ { 0x45, 7 },
+ { 0x64, 9 },
+ { 0x32A, 12 },
+ { 0x657, 13 },
+ { 0x18, 5 },
+ { 0xD, 6 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x36, 6 },
+ { 0x47, 7 },
+ { 0x44, 7 },
+ { 0x18, 7 },
+ { 0x33, 8 },
+ { 0xCB, 10 },
+ { 0x656, 13 },
+ { 0x329, 12 },
+ { 0x328, 12 },
+ { 0x2, 3 },
+ { 0x6, 4 },
+ { 0x19, 5 },
+ { 0xE, 5 },
+ { 0x37, 6 },
+ { 0x9, 4 },
+ { 0xF, 5 },
+ { 0x2, 4 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 2, table 11 */
+ { 0x3, 3 },
+ { 0x18, 5 },
+ { 0x23, 6 },
+ { 0x77, 7 },
+ { 0x194, 9 },
+ { 0x1956, 13 },
+ { 0x32AF, 14 },
+ { 0x3A, 6 },
+ { 0x76, 7 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1F, 5 },
+ { 0x1E, 5 },
+ { 0x14, 5 },
+ { 0x22, 6 },
+ { 0x64, 7 },
+ { 0x197, 9 },
+ { 0x196, 9 },
+ { 0x32B, 10 },
+ { 0x654, 11 },
+ { 0x32AE, 14 },
+ { 0x1955, 13 },
+ { 0x1954, 13 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x1C, 5 },
+ { 0x15, 5 },
+ { 0x10, 5 },
+ { 0xD, 4 },
+ { 0x17, 5 },
+ { 0x16, 5 },
+ { 0x33, 6 }
+ },
+ { /* AC bias group 2, table 12 */
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x3E, 6 },
+ { 0x10, 5 },
+ { 0x48, 7 },
+ { 0x93F, 12 },
+ { 0x24FA, 14 },
+ { 0x32, 6 },
+ { 0x67, 7 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1B, 5 },
+ { 0x1E, 5 },
+ { 0x34, 6 },
+ { 0x66, 7 },
+ { 0x92, 8 },
+ { 0x126, 9 },
+ { 0x24E, 10 },
+ { 0x49E, 11 },
+ { 0x49F7, 15 },
+ { 0x49F6, 15 },
+ { 0x24F9, 14 },
+ { 0x24F8, 14 },
+ { 0x0, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x11, 5 },
+ { 0x3F, 6 },
+ { 0xE, 4 },
+ { 0x13, 5 },
+ { 0x35, 6 },
+ { 0x25, 6 }
+ },
+ { /* AC bias group 2, table 13 */
+ { 0x5, 3 },
+ { 0x8, 4 },
+ { 0x12, 5 },
+ { 0x1C, 5 },
+ { 0x1C, 6 },
+ { 0xEA, 9 },
+ { 0x1D75, 14 },
+ { 0x1E, 6 },
+ { 0x66, 7 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0x1F, 6 },
+ { 0x3B, 7 },
+ { 0x74, 8 },
+ { 0x1D6, 10 },
+ { 0x3AF, 11 },
+ { 0x1D74, 14 },
+ { 0x1D77, 14 },
+ { 0x1D76, 14 },
+ { 0xEB9, 13 },
+ { 0xEB8, 13 },
+ { 0xF, 4 },
+ { 0x6, 4 },
+ { 0x13, 5 },
+ { 0x3B, 6 },
+ { 0x3A, 6 },
+ { 0x0, 3 },
+ { 0x18, 5 },
+ { 0x32, 6 },
+ { 0x67, 7 }
+ },
+ { /* AC bias group 2, table 14 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x1B, 5 },
+ { 0xC, 4 },
+ { 0xD, 5 },
+ { 0xE6, 8 },
+ { 0x684, 11 },
+ { 0x72, 7 },
+ { 0xE7, 8 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x17, 5 },
+ { 0x16, 5 },
+ { 0x18, 6 },
+ { 0xD1, 8 },
+ { 0x1A0, 9 },
+ { 0x686, 11 },
+ { 0xD0F, 12 },
+ { 0xD0A, 12 },
+ { 0x1A17, 13 },
+ { 0x1A16, 13 },
+ { 0x1A1D, 13 },
+ { 0x1A1C, 13 },
+ { 0xF, 4 },
+ { 0x1D, 5 },
+ { 0xE, 5 },
+ { 0x35, 6 },
+ { 0x38, 6 },
+ { 0x0, 3 },
+ { 0xF, 5 },
+ { 0x19, 6 },
+ { 0x69, 7 }
+ },
+ { /* AC bias group 2, table 15 */
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0x1B, 5 },
+ { 0x0, 3 },
+ { 0x3, 4 },
+ { 0x2E, 6 },
+ { 0x51, 9 },
+ { 0xBC, 8 },
+ { 0x53, 9 },
+ { 0x4, 3 },
+ { 0x2, 3 },
+ { 0x16, 5 },
+ { 0x15, 5 },
+ { 0x15, 7 },
+ { 0x50, 9 },
+ { 0xA4, 10 },
+ { 0x294, 12 },
+ { 0x52B, 13 },
+ { 0x52A, 13 },
+ { 0x52D, 13 },
+ { 0x52C, 13 },
+ { 0x52F, 13 },
+ { 0x52E, 13 },
+ { 0xE, 4 },
+ { 0x1A, 5 },
+ { 0x4, 5 },
+ { 0x28, 6 },
+ { 0x29, 6 },
+ { 0xF, 4 },
+ { 0xB, 6 },
+ { 0x5F, 7 },
+ { 0xBD, 8 }
+ }
};
static const uint16_t ac_bias_2[16][32][2] = {
- { /* AC bias group 3, table 0 */
- { 0x3, 4 },
- { 0x9, 6 },
- { 0xD0, 8 },
- { 0x1A3, 9 },
- { 0x344, 10 },
- { 0xD14, 12 },
- { 0x1A2B, 13 },
- { 0x4, 4 },
- { 0x15, 7 },
- { 0x0, 3 },
- { 0xF, 4 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0xE, 4 },
- { 0x9, 4 },
- { 0x1B, 5 },
- { 0xA, 5 },
- { 0x14, 5 },
- { 0xD, 5 },
- { 0x2A, 6 },
- { 0x14, 7 },
- { 0x68B, 11 },
- { 0x1A2A, 13 },
- { 0x8, 4 },
- { 0xB, 5 },
- { 0x2B, 6 },
- { 0xB, 6 },
- { 0x69, 7 },
- { 0x35, 6 },
- { 0x8, 6 },
- { 0x7, 4 },
- { 0xC, 5 }
- },
- { /* AC bias group 3, table 1 */
- { 0xA, 4 },
- { 0x3C, 6 },
- { 0x32, 7 },
- { 0x30, 7 },
- { 0xC5, 9 },
- { 0x621, 12 },
- { 0x620, 12 },
- { 0x1F, 5 },
- { 0x33, 7 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x4, 4 },
- { 0xD, 5 },
- { 0x26, 6 },
- { 0x27, 6 },
- { 0x14, 6 },
- { 0x63, 8 },
- { 0x189, 10 },
- { 0x623, 12 },
- { 0x622, 12 },
- { 0xB, 4 },
- { 0x12, 5 },
- { 0x3D, 6 },
- { 0x22, 6 },
- { 0x15, 6 },
- { 0xB, 5 },
- { 0x23, 6 },
- { 0x7, 4 },
- { 0x10, 5 }
- },
- { /* AC bias group 3, table 2 */
- { 0xF, 4 },
- { 0xC, 5 },
- { 0x43, 7 },
- { 0x10, 6 },
- { 0x44, 8 },
- { 0x114, 10 },
- { 0x455, 12 },
- { 0x18, 5 },
- { 0x23, 7 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0x9, 4 },
- { 0x19, 5 },
- { 0x9, 5 },
- { 0x17, 6 },
- { 0x16, 6 },
- { 0x42, 7 },
- { 0x8B, 9 },
- { 0x454, 12 },
- { 0x457, 12 },
- { 0x456, 12 },
- { 0xB, 4 },
- { 0x15, 5 },
- { 0xA, 5 },
- { 0x29, 6 },
- { 0x20, 6 },
- { 0xD, 5 },
- { 0x28, 6 },
- { 0x7, 4 },
- { 0x11, 5 }
- },
- { /* AC bias group 3, table 3 */
- { 0x1, 3 },
- { 0x1A, 5 },
- { 0x29, 6 },
- { 0x2A, 6 },
- { 0xA0, 8 },
- { 0x285, 10 },
- { 0x1425, 13 },
- { 0x2, 5 },
- { 0x0, 7 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0xC, 4 },
- { 0xB, 4 },
- { 0x8, 4 },
- { 0x12, 5 },
- { 0x1, 6 },
- { 0x51, 7 },
- { 0x1, 7 },
- { 0x143, 9 },
- { 0x508, 11 },
- { 0x1424, 13 },
- { 0x1427, 13 },
- { 0x1426, 13 },
- { 0xF, 4 },
- { 0x1C, 5 },
- { 0x3, 5 },
- { 0x37, 6 },
- { 0x2B, 6 },
- { 0x13, 5 },
- { 0x36, 6 },
- { 0x1D, 5 },
- { 0x1, 5 }
- },
- { /* AC bias group 3, table 4 */
- { 0x4, 3 },
- { 0x1F, 5 },
- { 0x3D, 6 },
- { 0x6, 5 },
- { 0x16, 7 },
- { 0x53, 9 },
- { 0x14A, 11 },
- { 0x34, 6 },
- { 0x2A, 8 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0xB, 4 },
- { 0xC, 4 },
- { 0x1C, 5 },
- { 0x37, 6 },
- { 0x17, 7 },
- { 0x2B, 8 },
- { 0x28, 8 },
- { 0xA4, 10 },
- { 0x52D, 13 },
- { 0x52C, 13 },
- { 0x52F, 13 },
- { 0x52E, 13 },
- { 0x0, 3 },
- { 0x1D, 5 },
- { 0x7, 5 },
- { 0x4, 5 },
- { 0x35, 6 },
- { 0x14, 5 },
- { 0x36, 6 },
- { 0x15, 5 },
- { 0x3C, 6 }
- },
- { /* AC bias group 3, table 5 */
- { 0x4, 3 },
- { 0xA, 4 },
- { 0x7, 5 },
- { 0x1D, 5 },
- { 0x9, 6 },
- { 0x1F3, 9 },
- { 0x7C7, 11 },
- { 0x8, 6 },
- { 0x1F0, 9 },
- { 0x3, 3 },
- { 0x2, 3 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x17, 5 },
- { 0x7D, 7 },
- { 0x1F2, 9 },
- { 0x7C6, 11 },
- { 0x7C5, 11 },
- { 0x1F12, 13 },
- { 0x3E27, 14 },
- { 0x3E26, 14 },
- { 0x1F11, 13 },
- { 0x1F10, 13 },
- { 0x0, 3 },
- { 0x1E, 5 },
- { 0x6, 5 },
- { 0x39, 6 },
- { 0x38, 6 },
- { 0x3F, 6 },
- { 0x2C, 6 },
- { 0x5, 5 },
- { 0x2D, 6 }
- },
- { /* AC bias group 3, table 6 */
- { 0x2, 3 },
- { 0x7, 4 },
- { 0x18, 5 },
- { 0x3, 4 },
- { 0x5, 5 },
- { 0x35, 7 },
- { 0x4F, 9 },
- { 0x12, 7 },
- { 0x4E5, 13 },
- { 0x5, 3 },
- { 0x4, 3 },
- { 0xD, 4 },
- { 0xE, 4 },
- { 0x33, 6 },
- { 0x26, 8 },
- { 0x9D, 10 },
- { 0x4E4, 13 },
- { 0x4E7, 13 },
- { 0x4E6, 13 },
- { 0x4E1, 13 },
- { 0x4E0, 13 },
- { 0x4E3, 13 },
- { 0x4E2, 13 },
- { 0x0, 3 },
- { 0x1F, 5 },
- { 0xC, 5 },
- { 0x3D, 6 },
- { 0x3C, 6 },
- { 0x32, 6 },
- { 0x34, 7 },
- { 0x1B, 6 },
- { 0x8, 6 }
- },
- { /* AC bias group 3, table 7 */
- { 0x0, 3 },
- { 0x4, 4 },
- { 0x1C, 5 },
- { 0xF, 4 },
- { 0x2, 4 },
- { 0x7, 5 },
- { 0x75, 7 },
- { 0xE8, 8 },
- { 0x1D2A, 13 },
- { 0x5, 3 },
- { 0x4, 3 },
- { 0xD, 4 },
- { 0xC, 4 },
- { 0x77, 7 },
- { 0xE96, 12 },
- { 0x3A57, 14 },
- { 0x3A56, 14 },
- { 0x3A5D, 14 },
- { 0x3A5C, 14 },
- { 0x3A5F, 14 },
- { 0x3A5E, 14 },
- { 0x1D29, 13 },
- { 0x1D28, 13 },
- { 0x3, 3 },
- { 0x6, 5 },
- { 0xA, 5 },
- { 0x2C, 7 },
- { 0x17, 6 },
- { 0x76, 7 },
- { 0x1D3, 9 },
- { 0x3A4, 10 },
- { 0x2D, 7 }
- },
- { /* AC bias group 3, table 8 */
- { 0xA, 4 },
- { 0x24, 6 },
- { 0xBF, 8 },
- { 0x85, 8 },
- { 0x211, 10 },
- { 0x842, 12 },
- { 0x1087, 13 },
- { 0x18, 5 },
- { 0x20, 6 },
- { 0x1, 3 },
- { 0x2, 3 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0x7, 4 },
- { 0x13, 5 },
- { 0x25, 6 },
- { 0x5E, 7 },
- { 0x43, 7 },
- { 0xBE, 8 },
- { 0x109, 9 },
- { 0x1086, 13 },
- { 0x841, 12 },
- { 0x840, 12 },
- { 0xF, 4 },
- { 0x1, 4 },
- { 0x11, 5 },
- { 0x0, 5 },
- { 0x2E, 6 },
- { 0x19, 5 },
- { 0x1, 5 },
- { 0x6, 4 },
- { 0x16, 5 }
- },
- { /* AC bias group 3, table 9 */
- { 0x2, 3 },
- { 0xF, 5 },
- { 0x6F, 7 },
- { 0x61, 7 },
- { 0x374, 10 },
- { 0x1BA8, 13 },
- { 0x3753, 14 },
- { 0x12, 5 },
- { 0x36, 6 },
- { 0x0, 3 },
- { 0x1, 3 },
- { 0xA, 4 },
- { 0xB, 4 },
- { 0x1A, 5 },
- { 0x31, 6 },
- { 0x60, 7 },
- { 0xDC, 8 },
- { 0x1BB, 9 },
- { 0x6EB, 11 },
- { 0x1BAB, 13 },
- { 0x3752, 14 },
- { 0x3755, 14 },
- { 0x3754, 14 },
- { 0xE, 4 },
- { 0x6, 4 },
- { 0x13, 5 },
- { 0xE, 5 },
- { 0x3E, 6 },
- { 0x8, 4 },
- { 0x1E, 5 },
- { 0x19, 5 },
- { 0x3F, 6 }
- },
- { /* AC bias group 3, table 10 */
- { 0x3, 3 },
- { 0x1C, 5 },
- { 0x25, 6 },
- { 0x24, 6 },
- { 0x1DA, 9 },
- { 0x1DBD, 13 },
- { 0x3B7C, 14 },
- { 0x3C, 6 },
- { 0x3D, 6 },
- { 0x0, 3 },
- { 0x1, 3 },
- { 0xB, 4 },
- { 0xA, 4 },
- { 0xB, 5 },
- { 0x77, 7 },
- { 0xEC, 8 },
- { 0x3B6, 10 },
- { 0x76E, 11 },
- { 0x1DBF, 13 },
- { 0x76FB, 15 },
- { 0x76FA, 15 },
- { 0x3B79, 14 },
- { 0x3B78, 14 },
- { 0xD, 4 },
- { 0x1F, 5 },
- { 0x13, 5 },
- { 0xA, 5 },
- { 0x8, 5 },
- { 0xC, 4 },
- { 0x8, 4 },
- { 0x9, 5 },
- { 0x3A, 6 }
- },
- { /* AC bias group 3, table 11 */
- { 0x5, 3 },
- { 0x3, 4 },
- { 0x4, 5 },
- { 0x10, 5 },
- { 0x8F, 8 },
- { 0x475, 11 },
- { 0x11D1, 13 },
- { 0x79, 7 },
- { 0x27, 6 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0x1, 4 },
- { 0x0, 4 },
- { 0x26, 6 },
- { 0x46, 7 },
- { 0x11C, 9 },
- { 0x477, 11 },
- { 0x8ED, 12 },
- { 0x11D0, 13 },
- { 0x11D3, 13 },
- { 0x11D2, 13 },
- { 0x11D9, 13 },
- { 0x11D8, 13 },
- { 0xD, 4 },
- { 0x1F, 5 },
- { 0x12, 5 },
- { 0x5, 5 },
- { 0x3D, 6 },
- { 0xC, 4 },
- { 0xE, 4 },
- { 0x22, 6 },
- { 0x78, 7 }
- },
- { /* AC bias group 3, table 12 */
- { 0x5, 3 },
- { 0xC, 4 },
- { 0x1B, 5 },
- { 0x0, 4 },
- { 0x6, 6 },
- { 0x3E2, 10 },
- { 0x3E3D, 14 },
- { 0xF, 7 },
- { 0x34, 6 },
- { 0x3, 3 },
- { 0x2, 3 },
- { 0x1E, 5 },
- { 0x1D, 5 },
- { 0x7D, 7 },
- { 0x1F0, 9 },
- { 0x7C6, 11 },
- { 0x3E3C, 14 },
- { 0x3E3F, 14 },
- { 0x3E3E, 14 },
- { 0x3E39, 14 },
- { 0x3E38, 14 },
- { 0x3E3B, 14 },
- { 0x3E3A, 14 },
- { 0x8, 4 },
- { 0x1C, 5 },
- { 0x2, 5 },
- { 0x3F, 6 },
- { 0x35, 6 },
- { 0x9, 4 },
- { 0x1, 3 },
- { 0xE, 7 },
- { 0xF9, 8 }
- },
- { /* AC bias group 3, table 13 */
- { 0x4, 3 },
- { 0xB, 4 },
- { 0x1, 4 },
- { 0xA, 4 },
- { 0x1E, 6 },
- { 0xE0, 9 },
- { 0xE1E, 13 },
- { 0x71, 8 },
- { 0x39, 7 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0xD, 5 },
- { 0xC, 5 },
- { 0x20, 7 },
- { 0x1C2, 10 },
- { 0x1C3F, 14 },
- { 0x1C3E, 14 },
- { 0xE19, 13 },
- { 0xE18, 13 },
- { 0xE1B, 13 },
- { 0xE1A, 13 },
- { 0xE1D, 13 },
- { 0xE1C, 13 },
- { 0x0, 4 },
- { 0x9, 5 },
- { 0x1D, 6 },
- { 0x1F, 6 },
- { 0x11, 6 },
- { 0x5, 4 },
- { 0x1, 3 },
- { 0x43, 8 },
- { 0x42, 8 }
- },
- { /* AC bias group 3, table 14 */
- { 0x4, 3 },
- { 0xD, 4 },
- { 0x7, 4 },
- { 0x2, 3 },
- { 0x14, 5 },
- { 0x16C, 9 },
- { 0x16D1, 13 },
- { 0x2DF, 10 },
- { 0x16E, 9 },
- { 0x0, 2 },
- { 0x7, 3 },
- { 0x2C, 6 },
- { 0x2B, 6 },
- { 0x2DE, 10 },
- { 0x16D0, 13 },
- { 0x16D3, 13 },
- { 0x16D2, 13 },
- { 0x2DB5, 14 },
- { 0x2DB4, 14 },
- { 0x2DB7, 14 },
- { 0x2DB6, 14 },
- { 0x16D9, 13 },
- { 0x16D8, 13 },
- { 0xC, 5 },
- { 0x2A, 6 },
- { 0x5A, 7 },
- { 0x1B, 6 },
- { 0x1A, 6 },
- { 0x17, 5 },
- { 0xC, 4 },
- { 0x5B7, 11 },
- { 0x5B5, 11 }
- },
- { /* AC bias group 3, table 15 */
- { 0x2, 2 },
- { 0xF, 4 },
- { 0x1C, 5 },
- { 0xC, 4 },
- { 0x3B, 6 },
- { 0x1AC, 9 },
- { 0x1AD8, 13 },
- { 0x35B3, 14 },
- { 0x35B2, 14 },
- { 0x1, 2 },
- { 0x0, 2 },
- { 0x69, 7 },
- { 0x68, 7 },
- { 0x35BD, 14 },
- { 0x35BC, 14 },
- { 0x35BF, 14 },
- { 0x35BE, 14 },
- { 0x35B9, 14 },
- { 0x35B8, 14 },
- { 0x35BB, 14 },
- { 0x35BA, 14 },
- { 0x35B5, 14 },
- { 0x35B4, 14 },
- { 0x1A9, 9 },
- { 0x1A8, 9 },
- { 0x35A, 10 },
- { 0xD7, 8 },
- { 0xD5, 8 },
- { 0x3A, 6 },
- { 0x1B, 5 },
- { 0x35B7, 14 },
- { 0x35B6, 14 }
- }
+ { /* AC bias group 3, table 0 */
+ { 0x3, 4 },
+ { 0x9, 6 },
+ { 0xD0, 8 },
+ { 0x1A3, 9 },
+ { 0x344, 10 },
+ { 0xD14, 12 },
+ { 0x1A2B, 13 },
+ { 0x4, 4 },
+ { 0x15, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0x9, 4 },
+ { 0x1B, 5 },
+ { 0xA, 5 },
+ { 0x14, 5 },
+ { 0xD, 5 },
+ { 0x2A, 6 },
+ { 0x14, 7 },
+ { 0x68B, 11 },
+ { 0x1A2A, 13 },
+ { 0x8, 4 },
+ { 0xB, 5 },
+ { 0x2B, 6 },
+ { 0xB, 6 },
+ { 0x69, 7 },
+ { 0x35, 6 },
+ { 0x8, 6 },
+ { 0x7, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 3, table 1 */
+ { 0xA, 4 },
+ { 0x3C, 6 },
+ { 0x32, 7 },
+ { 0x30, 7 },
+ { 0xC5, 9 },
+ { 0x621, 12 },
+ { 0x620, 12 },
+ { 0x1F, 5 },
+ { 0x33, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x4, 4 },
+ { 0xD, 5 },
+ { 0x26, 6 },
+ { 0x27, 6 },
+ { 0x14, 6 },
+ { 0x63, 8 },
+ { 0x189, 10 },
+ { 0x623, 12 },
+ { 0x622, 12 },
+ { 0xB, 4 },
+ { 0x12, 5 },
+ { 0x3D, 6 },
+ { 0x22, 6 },
+ { 0x15, 6 },
+ { 0xB, 5 },
+ { 0x23, 6 },
+ { 0x7, 4 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 3, table 2 */
+ { 0xF, 4 },
+ { 0xC, 5 },
+ { 0x43, 7 },
+ { 0x10, 6 },
+ { 0x44, 8 },
+ { 0x114, 10 },
+ { 0x455, 12 },
+ { 0x18, 5 },
+ { 0x23, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x9, 4 },
+ { 0x19, 5 },
+ { 0x9, 5 },
+ { 0x17, 6 },
+ { 0x16, 6 },
+ { 0x42, 7 },
+ { 0x8B, 9 },
+ { 0x454, 12 },
+ { 0x457, 12 },
+ { 0x456, 12 },
+ { 0xB, 4 },
+ { 0x15, 5 },
+ { 0xA, 5 },
+ { 0x29, 6 },
+ { 0x20, 6 },
+ { 0xD, 5 },
+ { 0x28, 6 },
+ { 0x7, 4 },
+ { 0x11, 5 }
+ },
+ { /* AC bias group 3, table 3 */
+ { 0x1, 3 },
+ { 0x1A, 5 },
+ { 0x29, 6 },
+ { 0x2A, 6 },
+ { 0xA0, 8 },
+ { 0x285, 10 },
+ { 0x1425, 13 },
+ { 0x2, 5 },
+ { 0x0, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x8, 4 },
+ { 0x12, 5 },
+ { 0x1, 6 },
+ { 0x51, 7 },
+ { 0x1, 7 },
+ { 0x143, 9 },
+ { 0x508, 11 },
+ { 0x1424, 13 },
+ { 0x1427, 13 },
+ { 0x1426, 13 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0x3, 5 },
+ { 0x37, 6 },
+ { 0x2B, 6 },
+ { 0x13, 5 },
+ { 0x36, 6 },
+ { 0x1D, 5 },
+ { 0x1, 5 }
+ },
+ { /* AC bias group 3, table 4 */
+ { 0x4, 3 },
+ { 0x1F, 5 },
+ { 0x3D, 6 },
+ { 0x6, 5 },
+ { 0x16, 7 },
+ { 0x53, 9 },
+ { 0x14A, 11 },
+ { 0x34, 6 },
+ { 0x2A, 8 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x1C, 5 },
+ { 0x37, 6 },
+ { 0x17, 7 },
+ { 0x2B, 8 },
+ { 0x28, 8 },
+ { 0xA4, 10 },
+ { 0x52D, 13 },
+ { 0x52C, 13 },
+ { 0x52F, 13 },
+ { 0x52E, 13 },
+ { 0x0, 3 },
+ { 0x1D, 5 },
+ { 0x7, 5 },
+ { 0x4, 5 },
+ { 0x35, 6 },
+ { 0x14, 5 },
+ { 0x36, 6 },
+ { 0x15, 5 },
+ { 0x3C, 6 }
+ },
+ { /* AC bias group 3, table 5 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x7, 5 },
+ { 0x1D, 5 },
+ { 0x9, 6 },
+ { 0x1F3, 9 },
+ { 0x7C7, 11 },
+ { 0x8, 6 },
+ { 0x1F0, 9 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x17, 5 },
+ { 0x7D, 7 },
+ { 0x1F2, 9 },
+ { 0x7C6, 11 },
+ { 0x7C5, 11 },
+ { 0x1F12, 13 },
+ { 0x3E27, 14 },
+ { 0x3E26, 14 },
+ { 0x1F11, 13 },
+ { 0x1F10, 13 },
+ { 0x0, 3 },
+ { 0x1E, 5 },
+ { 0x6, 5 },
+ { 0x39, 6 },
+ { 0x38, 6 },
+ { 0x3F, 6 },
+ { 0x2C, 6 },
+ { 0x5, 5 },
+ { 0x2D, 6 }
+ },
+ { /* AC bias group 3, table 6 */
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x3, 4 },
+ { 0x5, 5 },
+ { 0x35, 7 },
+ { 0x4F, 9 },
+ { 0x12, 7 },
+ { 0x4E5, 13 },
+ { 0x5, 3 },
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0xE, 4 },
+ { 0x33, 6 },
+ { 0x26, 8 },
+ { 0x9D, 10 },
+ { 0x4E4, 13 },
+ { 0x4E7, 13 },
+ { 0x4E6, 13 },
+ { 0x4E1, 13 },
+ { 0x4E0, 13 },
+ { 0x4E3, 13 },
+ { 0x4E2, 13 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0xC, 5 },
+ { 0x3D, 6 },
+ { 0x3C, 6 },
+ { 0x32, 6 },
+ { 0x34, 7 },
+ { 0x1B, 6 },
+ { 0x8, 6 }
+ },
+ { /* AC bias group 3, table 7 */
+ { 0x0, 3 },
+ { 0x4, 4 },
+ { 0x1C, 5 },
+ { 0xF, 4 },
+ { 0x2, 4 },
+ { 0x7, 5 },
+ { 0x75, 7 },
+ { 0xE8, 8 },
+ { 0x1D2A, 13 },
+ { 0x5, 3 },
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x77, 7 },
+ { 0xE96, 12 },
+ { 0x3A57, 14 },
+ { 0x3A56, 14 },
+ { 0x3A5D, 14 },
+ { 0x3A5C, 14 },
+ { 0x3A5F, 14 },
+ { 0x3A5E, 14 },
+ { 0x1D29, 13 },
+ { 0x1D28, 13 },
+ { 0x3, 3 },
+ { 0x6, 5 },
+ { 0xA, 5 },
+ { 0x2C, 7 },
+ { 0x17, 6 },
+ { 0x76, 7 },
+ { 0x1D3, 9 },
+ { 0x3A4, 10 },
+ { 0x2D, 7 }
+ },
+ { /* AC bias group 3, table 8 */
+ { 0xA, 4 },
+ { 0x24, 6 },
+ { 0xBF, 8 },
+ { 0x85, 8 },
+ { 0x211, 10 },
+ { 0x842, 12 },
+ { 0x1087, 13 },
+ { 0x18, 5 },
+ { 0x20, 6 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x13, 5 },
+ { 0x25, 6 },
+ { 0x5E, 7 },
+ { 0x43, 7 },
+ { 0xBE, 8 },
+ { 0x109, 9 },
+ { 0x1086, 13 },
+ { 0x841, 12 },
+ { 0x840, 12 },
+ { 0xF, 4 },
+ { 0x1, 4 },
+ { 0x11, 5 },
+ { 0x0, 5 },
+ { 0x2E, 6 },
+ { 0x19, 5 },
+ { 0x1, 5 },
+ { 0x6, 4 },
+ { 0x16, 5 }
+ },
+ { /* AC bias group 3, table 9 */
+ { 0x2, 3 },
+ { 0xF, 5 },
+ { 0x6F, 7 },
+ { 0x61, 7 },
+ { 0x374, 10 },
+ { 0x1BA8, 13 },
+ { 0x3753, 14 },
+ { 0x12, 5 },
+ { 0x36, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xA, 4 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x31, 6 },
+ { 0x60, 7 },
+ { 0xDC, 8 },
+ { 0x1BB, 9 },
+ { 0x6EB, 11 },
+ { 0x1BAB, 13 },
+ { 0x3752, 14 },
+ { 0x3755, 14 },
+ { 0x3754, 14 },
+ { 0xE, 4 },
+ { 0x6, 4 },
+ { 0x13, 5 },
+ { 0xE, 5 },
+ { 0x3E, 6 },
+ { 0x8, 4 },
+ { 0x1E, 5 },
+ { 0x19, 5 },
+ { 0x3F, 6 }
+ },
+ { /* AC bias group 3, table 10 */
+ { 0x3, 3 },
+ { 0x1C, 5 },
+ { 0x25, 6 },
+ { 0x24, 6 },
+ { 0x1DA, 9 },
+ { 0x1DBD, 13 },
+ { 0x3B7C, 14 },
+ { 0x3C, 6 },
+ { 0x3D, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0xB, 5 },
+ { 0x77, 7 },
+ { 0xEC, 8 },
+ { 0x3B6, 10 },
+ { 0x76E, 11 },
+ { 0x1DBF, 13 },
+ { 0x76FB, 15 },
+ { 0x76FA, 15 },
+ { 0x3B79, 14 },
+ { 0x3B78, 14 },
+ { 0xD, 4 },
+ { 0x1F, 5 },
+ { 0x13, 5 },
+ { 0xA, 5 },
+ { 0x8, 5 },
+ { 0xC, 4 },
+ { 0x8, 4 },
+ { 0x9, 5 },
+ { 0x3A, 6 }
+ },
+ { /* AC bias group 3, table 11 */
+ { 0x5, 3 },
+ { 0x3, 4 },
+ { 0x4, 5 },
+ { 0x10, 5 },
+ { 0x8F, 8 },
+ { 0x475, 11 },
+ { 0x11D1, 13 },
+ { 0x79, 7 },
+ { 0x27, 6 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0x26, 6 },
+ { 0x46, 7 },
+ { 0x11C, 9 },
+ { 0x477, 11 },
+ { 0x8ED, 12 },
+ { 0x11D0, 13 },
+ { 0x11D3, 13 },
+ { 0x11D2, 13 },
+ { 0x11D9, 13 },
+ { 0x11D8, 13 },
+ { 0xD, 4 },
+ { 0x1F, 5 },
+ { 0x12, 5 },
+ { 0x5, 5 },
+ { 0x3D, 6 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0x22, 6 },
+ { 0x78, 7 }
+ },
+ { /* AC bias group 3, table 12 */
+ { 0x5, 3 },
+ { 0xC, 4 },
+ { 0x1B, 5 },
+ { 0x0, 4 },
+ { 0x6, 6 },
+ { 0x3E2, 10 },
+ { 0x3E3D, 14 },
+ { 0xF, 7 },
+ { 0x34, 6 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0x1E, 5 },
+ { 0x1D, 5 },
+ { 0x7D, 7 },
+ { 0x1F0, 9 },
+ { 0x7C6, 11 },
+ { 0x3E3C, 14 },
+ { 0x3E3F, 14 },
+ { 0x3E3E, 14 },
+ { 0x3E39, 14 },
+ { 0x3E38, 14 },
+ { 0x3E3B, 14 },
+ { 0x3E3A, 14 },
+ { 0x8, 4 },
+ { 0x1C, 5 },
+ { 0x2, 5 },
+ { 0x3F, 6 },
+ { 0x35, 6 },
+ { 0x9, 4 },
+ { 0x1, 3 },
+ { 0xE, 7 },
+ { 0xF9, 8 }
+ },
+ { /* AC bias group 3, table 13 */
+ { 0x4, 3 },
+ { 0xB, 4 },
+ { 0x1, 4 },
+ { 0xA, 4 },
+ { 0x1E, 6 },
+ { 0xE0, 9 },
+ { 0xE1E, 13 },
+ { 0x71, 8 },
+ { 0x39, 7 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0xD, 5 },
+ { 0xC, 5 },
+ { 0x20, 7 },
+ { 0x1C2, 10 },
+ { 0x1C3F, 14 },
+ { 0x1C3E, 14 },
+ { 0xE19, 13 },
+ { 0xE18, 13 },
+ { 0xE1B, 13 },
+ { 0xE1A, 13 },
+ { 0xE1D, 13 },
+ { 0xE1C, 13 },
+ { 0x0, 4 },
+ { 0x9, 5 },
+ { 0x1D, 6 },
+ { 0x1F, 6 },
+ { 0x11, 6 },
+ { 0x5, 4 },
+ { 0x1, 3 },
+ { 0x43, 8 },
+ { 0x42, 8 }
+ },
+ { /* AC bias group 3, table 14 */
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x2, 3 },
+ { 0x14, 5 },
+ { 0x16C, 9 },
+ { 0x16D1, 13 },
+ { 0x2DF, 10 },
+ { 0x16E, 9 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x2C, 6 },
+ { 0x2B, 6 },
+ { 0x2DE, 10 },
+ { 0x16D0, 13 },
+ { 0x16D3, 13 },
+ { 0x16D2, 13 },
+ { 0x2DB5, 14 },
+ { 0x2DB4, 14 },
+ { 0x2DB7, 14 },
+ { 0x2DB6, 14 },
+ { 0x16D9, 13 },
+ { 0x16D8, 13 },
+ { 0xC, 5 },
+ { 0x2A, 6 },
+ { 0x5A, 7 },
+ { 0x1B, 6 },
+ { 0x1A, 6 },
+ { 0x17, 5 },
+ { 0xC, 4 },
+ { 0x5B7, 11 },
+ { 0x5B5, 11 }
+ },
+ { /* AC bias group 3, table 15 */
+ { 0x2, 2 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0xC, 4 },
+ { 0x3B, 6 },
+ { 0x1AC, 9 },
+ { 0x1AD8, 13 },
+ { 0x35B3, 14 },
+ { 0x35B2, 14 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x69, 7 },
+ { 0x68, 7 },
+ { 0x35BD, 14 },
+ { 0x35BC, 14 },
+ { 0x35BF, 14 },
+ { 0x35BE, 14 },
+ { 0x35B9, 14 },
+ { 0x35B8, 14 },
+ { 0x35BB, 14 },
+ { 0x35BA, 14 },
+ { 0x35B5, 14 },
+ { 0x35B4, 14 },
+ { 0x1A9, 9 },
+ { 0x1A8, 9 },
+ { 0x35A, 10 },
+ { 0xD7, 8 },
+ { 0xD5, 8 },
+ { 0x3A, 6 },
+ { 0x1B, 5 },
+ { 0x35B7, 14 },
+ { 0x35B6, 14 }
+ }
};
static const uint16_t ac_bias_3[16][32][2] = {
- { /* AC bias group 4, table 0 */
- { 0x0, 3 },
- { 0x10, 5 },
- { 0x72, 7 },
- { 0x71, 7 },
- { 0x154, 9 },
- { 0xAAB, 12 },
- { 0xAA8, 12 },
- { 0x14, 5 },
- { 0x70, 7 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0xC, 4 },
- { 0xB, 4 },
- { 0x3, 4 },
- { 0x11, 5 },
- { 0x73, 7 },
- { 0x54, 7 },
- { 0xAB, 8 },
- { 0x2AB, 10 },
- { 0x1553, 13 },
- { 0x1552, 13 },
- { 0x1555, 13 },
- { 0x1554, 13 },
- { 0xD, 4 },
- { 0x1E, 5 },
- { 0x12, 5 },
- { 0x3E, 6 },
- { 0x2B, 6 },
- { 0x2, 4 },
- { 0x3F, 6 },
- { 0x1D, 5 },
- { 0x13, 5 }
- },
- { /* AC bias group 4, table 1 */
- { 0x3, 3 },
- { 0x1F, 5 },
- { 0x29, 6 },
- { 0x3D, 6 },
- { 0xC, 7 },
- { 0x69, 10 },
- { 0x345, 13 },
- { 0x2, 5 },
- { 0x28, 6 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0xE, 4 },
- { 0xC, 4 },
- { 0x15, 5 },
- { 0x7, 6 },
- { 0x1B, 8 },
- { 0x6B, 10 },
- { 0x6A, 10 },
- { 0x344, 13 },
- { 0x347, 13 },
- { 0x346, 13 },
- { 0x1A1, 12 },
- { 0x1A0, 12 },
- { 0xB, 4 },
- { 0x1A, 5 },
- { 0x12, 5 },
- { 0x0, 5 },
- { 0x3C, 6 },
- { 0x8, 4 },
- { 0x1B, 5 },
- { 0x13, 5 },
- { 0x1, 5 }
- },
- { /* AC bias group 4, table 2 */
- { 0x4, 3 },
- { 0x4, 4 },
- { 0x3F, 6 },
- { 0x14, 5 },
- { 0x56, 7 },
- { 0x15C, 9 },
- { 0x15D5, 13 },
- { 0x3C, 6 },
- { 0x2A, 6 },
- { 0x0, 3 },
- { 0x1, 3 },
- { 0xE, 4 },
- { 0xD, 4 },
- { 0xC, 5 },
- { 0xAF, 8 },
- { 0x2BB, 10 },
- { 0x15D4, 13 },
- { 0x15D7, 13 },
- { 0x15D6, 13 },
- { 0x15D1, 13 },
- { 0x15D0, 13 },
- { 0x15D3, 13 },
- { 0x15D2, 13 },
- { 0xB, 4 },
- { 0x19, 5 },
- { 0xD, 5 },
- { 0x3E, 6 },
- { 0x31, 6 },
- { 0x7, 4 },
- { 0x5, 4 },
- { 0x3D, 6 },
- { 0x30, 6 }
- },
- { /* AC bias group 4, table 3 */
- { 0x5, 3 },
- { 0x8, 4 },
- { 0x1A, 5 },
- { 0x0, 4 },
- { 0x36, 6 },
- { 0x11, 8 },
- { 0x106, 12 },
- { 0xA, 7 },
- { 0x6E, 7 },
- { 0x2, 3 },
- { 0x3, 3 },
- { 0x3, 4 },
- { 0x2, 4 },
- { 0x6F, 7 },
- { 0x21, 9 },
- { 0x20F, 13 },
- { 0x20E, 13 },
- { 0x101, 12 },
- { 0x100, 12 },
- { 0x103, 12 },
- { 0x102, 12 },
- { 0x105, 12 },
- { 0x104, 12 },
- { 0xC, 4 },
- { 0x1E, 5 },
- { 0x3, 5 },
- { 0x3E, 6 },
- { 0x3F, 6 },
- { 0x9, 4 },
- { 0xE, 4 },
- { 0xB, 7 },
- { 0x9, 7 }
- },
- { /* AC bias group 4, table 4 */
- { 0x2, 3 },
- { 0xE, 4 },
- { 0x1E, 5 },
- { 0xC, 4 },
- { 0x1F, 5 },
- { 0x6E, 7 },
- { 0xAD, 10 },
- { 0xAF, 10 },
- { 0x14, 7 },
- { 0x4, 3 },
- { 0x3, 3 },
- { 0x1A, 5 },
- { 0x17, 5 },
- { 0x2A, 8 },
- { 0x576, 13 },
- { 0xAEF, 14 },
- { 0xAEE, 14 },
- { 0x571, 13 },
- { 0x570, 13 },
- { 0x573, 13 },
- { 0x572, 13 },
- { 0x575, 13 },
- { 0x574, 13 },
- { 0x3, 4 },
- { 0x16, 5 },
- { 0x4, 5 },
- { 0x36, 6 },
- { 0xB, 6 },
- { 0xA, 4 },
- { 0x0, 3 },
- { 0x6F, 7 },
- { 0xAC, 10 }
- },
- { /* AC bias group 4, table 5 */
- { 0x4, 3 },
- { 0x5, 4 },
- { 0x3, 3 },
- { 0x1, 3 },
- { 0x4, 4 },
- { 0x2F, 6 },
- { 0x526, 11 },
- { 0x1495, 13 },
- { 0xA6, 8 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x2D, 6 },
- { 0x2C, 6 },
- { 0x1494, 13 },
- { 0x1497, 13 },
- { 0x1496, 13 },
- { 0x1491, 13 },
- { 0x1490, 13 },
- { 0x1493, 13 },
- { 0x1492, 13 },
- { 0x293D, 14 },
- { 0x293C, 14 },
- { 0x293F, 14 },
- { 0x0, 3 },
- { 0x28, 6 },
- { 0xA5, 8 },
- { 0x148, 9 },
- { 0xA7, 8 },
- { 0x2E, 6 },
- { 0x15, 5 },
- { 0xA4E, 12 },
- { 0x293E, 14 }
- },
- { /* AC bias group 4, table 6 */
- { 0x4, 3 },
- { 0x5, 4 },
- { 0x3, 3 },
- { 0x1, 3 },
- { 0x4, 4 },
- { 0x2F, 6 },
- { 0x526, 11 },
- { 0x1495, 13 },
- { 0xA6, 8 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x2D, 6 },
- { 0x2C, 6 },
- { 0x1494, 13 },
- { 0x1497, 13 },
- { 0x1496, 13 },
- { 0x1491, 13 },
- { 0x1490, 13 },
- { 0x1493, 13 },
- { 0x1492, 13 },
- { 0x293D, 14 },
- { 0x293C, 14 },
- { 0x293F, 14 },
- { 0x0, 3 },
- { 0x28, 6 },
- { 0xA5, 8 },
- { 0x148, 9 },
- { 0xA7, 8 },
- { 0x2E, 6 },
- { 0x15, 5 },
- { 0xA4E, 12 },
- { 0x293E, 14 }
- },
- { /* AC bias group 4, table 7 */
- { 0x4, 3 },
- { 0x5, 4 },
- { 0x3, 3 },
- { 0x1, 3 },
- { 0x4, 4 },
- { 0x2F, 6 },
- { 0x526, 11 },
- { 0x1495, 13 },
- { 0xA6, 8 },
- { 0x7, 3 },
- { 0x6, 3 },
- { 0x2D, 6 },
- { 0x2C, 6 },
- { 0x1494, 13 },
- { 0x1497, 13 },
- { 0x1496, 13 },
- { 0x1491, 13 },
- { 0x1490, 13 },
- { 0x1493, 13 },
- { 0x1492, 13 },
- { 0x293D, 14 },
- { 0x293C, 14 },
- { 0x293F, 14 },
- { 0x0, 3 },
- { 0x28, 6 },
- { 0xA5, 8 },
- { 0x148, 9 },
- { 0xA7, 8 },
- { 0x2E, 6 },
- { 0x15, 5 },
- { 0xA4E, 12 },
- { 0x293E, 14 }
- },
- { /* AC bias group 4, table 8 */
- { 0x3, 3 },
- { 0x11, 5 },
- { 0x20, 6 },
- { 0x74, 7 },
- { 0x10D, 9 },
- { 0x863, 12 },
- { 0x860, 12 },
- { 0xA, 5 },
- { 0x75, 7 },
- { 0x1, 3 },
- { 0x0, 3 },
- { 0xB, 4 },
- { 0xA, 4 },
- { 0x18, 5 },
- { 0x38, 6 },
- { 0x42, 7 },
- { 0x10F, 9 },
- { 0x10E, 9 },
- { 0x219, 10 },
- { 0x10C3, 13 },
- { 0x10C2, 13 },
- { 0x10C5, 13 },
- { 0x10C4, 13 },
- { 0xF, 4 },
- { 0x4, 4 },
- { 0x19, 5 },
- { 0xB, 5 },
- { 0x39, 6 },
- { 0x9, 4 },
- { 0x1B, 5 },
- { 0x1A, 5 },
- { 0x3B, 6 }
- },
- { /* AC bias group 4, table 9 */
- { 0x5, 3 },
- { 0x1, 4 },
- { 0x3E, 6 },
- { 0x1, 5 },
- { 0xE2, 8 },
- { 0x1C6F, 13 },
- { 0x38D9, 14 },
- { 0x39, 6 },
- { 0x1F, 6 },
- { 0x2, 3 },
- { 0x1, 3 },
- { 0x9, 4 },
- { 0x8, 4 },
- { 0x0, 5 },
- { 0x70, 7 },
- { 0x1C7, 9 },
- { 0x38C, 10 },
- { 0x71A, 11 },
- { 0x38D8, 14 },
- { 0x38DB, 14 },
- { 0x38DA, 14 },
- { 0x38DD, 14 },
- { 0x38DC, 14 },
- { 0xD, 4 },
- { 0x1D, 5 },
- { 0xE, 5 },
- { 0x3F, 6 },
- { 0x3C, 6 },
- { 0xC, 4 },
- { 0x6, 4 },
- { 0x3D, 6 },
- { 0x1E, 6 }
- },
- { /* AC bias group 4, table 10 */
- { 0x6, 3 },
- { 0xB, 4 },
- { 0x11, 5 },
- { 0x1E, 5 },
- { 0x74, 7 },
- { 0x3AA, 10 },
- { 0x1D5C, 13 },
- { 0x1, 6 },
- { 0x21, 6 },
- { 0x1, 3 },
- { 0x2, 3 },
- { 0x7, 4 },
- { 0x6, 4 },
- { 0x3E, 6 },
- { 0xEB, 8 },
- { 0x1D4, 9 },
- { 0xEAF, 12 },
- { 0x3ABB, 14 },
- { 0x3ABA, 14 },
- { 0x1D59, 13 },
- { 0x1D58, 13 },
- { 0x1D5B, 13 },
- { 0x1D5A, 13 },
- { 0xA, 4 },
- { 0x1C, 5 },
- { 0x1, 5 },
- { 0x3F, 6 },
- { 0x3B, 6 },
- { 0x1, 4 },
- { 0x9, 4 },
- { 0x20, 6 },
- { 0x0, 6 }
- },
- { /* AC bias group 4, table 11 */
- { 0x4, 3 },
- { 0xA, 4 },
- { 0x17, 5 },
- { 0x4, 4 },
- { 0x16, 6 },
- { 0x16A, 9 },
- { 0x16B1, 13 },
- { 0x17, 7 },
- { 0x5B, 7 },
- { 0x6, 3 },
- { 0x7, 3 },
- { 0x1, 4 },
- { 0x0, 4 },
- { 0xA, 6 },
- { 0x2D7, 10 },
- { 0xB5A, 12 },
- { 0x16B0, 13 },
- { 0x16B3, 13 },
- { 0x16B2, 13 },
- { 0x2D6D, 14 },
- { 0x2D6C, 14 },
- { 0x2D6F, 14 },
- { 0x2D6E, 14 },
- { 0x6, 4 },
- { 0xA, 5 },
- { 0x4, 5 },
- { 0x2C, 6 },
- { 0x17, 6 },
- { 0x3, 4 },
- { 0x7, 4 },
- { 0x16, 7 },
- { 0xB4, 8 }
- },
- { /* AC bias group 4, table 12 */
- { 0x5, 3 },
- { 0xD, 4 },
- { 0x5, 4 },
- { 0x9, 4 },
- { 0x33, 6 },
- { 0x193, 9 },
- { 0x192C, 13 },
- { 0x61, 8 },
- { 0x31, 7 },
- { 0x0, 2 },
- { 0x7, 3 },
- { 0x10, 5 },
- { 0x11, 5 },
- { 0xC8, 8 },
- { 0x192F, 13 },
- { 0x325B, 14 },
- { 0x325A, 14 },
- { 0x1929, 13 },
- { 0x1928, 13 },
- { 0x192B, 13 },
- { 0x192A, 13 },
- { 0x325D, 14 },
- { 0x325C, 14 },
- { 0x18, 5 },
- { 0x1A, 6 },
- { 0x1B, 6 },
- { 0x65, 7 },
- { 0x19, 6 },
- { 0x4, 4 },
- { 0x7, 4 },
- { 0x60, 8 },
- { 0x324, 10 }
- },
- { /* AC bias group 4, table 13 */
- { 0x6, 3 },
- { 0x0, 3 },
- { 0x2, 4 },
- { 0xF, 4 },
- { 0x39, 6 },
- { 0x1D9, 9 },
- { 0x1D82, 13 },
- { 0x761, 11 },
- { 0x3BE, 10 },
- { 0x1, 2 },
- { 0x2, 2 },
- { 0xF, 6 },
- { 0xE, 6 },
- { 0x762, 11 },
- { 0x3B07, 14 },
- { 0x3B06, 14 },
- { 0x3B1D, 14 },
- { 0x3B1C, 14 },
- { 0x3B1F, 14 },
- { 0x3B1E, 14 },
- { 0x3B19, 14 },
- { 0x3B18, 14 },
- { 0x3B1B, 14 },
- { 0x38, 6 },
- { 0x1DE, 9 },
- { 0xED, 8 },
- { 0x3BF, 10 },
- { 0xEE, 8 },
- { 0x3A, 6 },
- { 0x6, 5 },
- { 0xEC0, 12 },
- { 0x3B1A, 14 }
- },
- { /* AC bias group 4, table 14 */
- { 0x0, 2 },
- { 0x2, 3 },
- { 0xF, 5 },
- { 0x6, 4 },
- { 0x1C, 6 },
- { 0x1D0, 10 },
- { 0xE8C, 13 },
- { 0x1D1B, 14 },
- { 0x1D1A, 14 },
- { 0x3, 2 },
- { 0x2, 2 },
- { 0xEA, 9 },
- { 0xE9, 9 },
- { 0xE89, 13 },
- { 0xE88, 13 },
- { 0xE8B, 13 },
- { 0xE8A, 13 },
- { 0x1D65, 14 },
- { 0x1D64, 14 },
- { 0x1D67, 14 },
- { 0x1D66, 14 },
- { 0x1D61, 14 },
- { 0x1D60, 14 },
- { 0x3AD, 11 },
- { 0x1D63, 14 },
- { 0x1D62, 14 },
- { 0x1D1D, 14 },
- { 0x1D1C, 14 },
- { 0x3B, 7 },
- { 0x1D7, 10 },
- { 0x1D1F, 14 },
- { 0x1D1E, 14 }
- },
- { /* AC bias group 4, table 15 */
- { 0x2, 2 },
- { 0xF, 4 },
- { 0x1C, 5 },
- { 0xC, 4 },
- { 0x3B, 6 },
- { 0x1AC, 9 },
- { 0x1AD8, 13 },
- { 0x35B3, 14 },
- { 0x35B2, 14 },
- { 0x1, 2 },
- { 0x0, 2 },
- { 0x69, 7 },
- { 0x68, 7 },
- { 0x35BD, 14 },
- { 0x35BC, 14 },
- { 0x35BF, 14 },
- { 0x35BE, 14 },
- { 0x35B9, 14 },
- { 0x35B8, 14 },
- { 0x35BB, 14 },
- { 0x35BA, 14 },
- { 0x35B5, 14 },
- { 0x35B4, 14 },
- { 0x1A9, 9 },
- { 0x1A8, 9 },
- { 0x35A, 10 },
- { 0xD7, 8 },
- { 0xD5, 8 },
- { 0x3A, 6 },
- { 0x1B, 5 },
- { 0x35B7, 14 },
- { 0x35B6, 14 }
- }
+ { /* AC bias group 4, table 0 */
+ { 0x0, 3 },
+ { 0x10, 5 },
+ { 0x72, 7 },
+ { 0x71, 7 },
+ { 0x154, 9 },
+ { 0xAAB, 12 },
+ { 0xAA8, 12 },
+ { 0x14, 5 },
+ { 0x70, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x3, 4 },
+ { 0x11, 5 },
+ { 0x73, 7 },
+ { 0x54, 7 },
+ { 0xAB, 8 },
+ { 0x2AB, 10 },
+ { 0x1553, 13 },
+ { 0x1552, 13 },
+ { 0x1555, 13 },
+ { 0x1554, 13 },
+ { 0xD, 4 },
+ { 0x1E, 5 },
+ { 0x12, 5 },
+ { 0x3E, 6 },
+ { 0x2B, 6 },
+ { 0x2, 4 },
+ { 0x3F, 6 },
+ { 0x1D, 5 },
+ { 0x13, 5 }
+ },
+ { /* AC bias group 4, table 1 */
+ { 0x3, 3 },
+ { 0x1F, 5 },
+ { 0x29, 6 },
+ { 0x3D, 6 },
+ { 0xC, 7 },
+ { 0x69, 10 },
+ { 0x345, 13 },
+ { 0x2, 5 },
+ { 0x28, 6 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0xE, 4 },
+ { 0xC, 4 },
+ { 0x15, 5 },
+ { 0x7, 6 },
+ { 0x1B, 8 },
+ { 0x6B, 10 },
+ { 0x6A, 10 },
+ { 0x344, 13 },
+ { 0x347, 13 },
+ { 0x346, 13 },
+ { 0x1A1, 12 },
+ { 0x1A0, 12 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x12, 5 },
+ { 0x0, 5 },
+ { 0x3C, 6 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0x13, 5 },
+ { 0x1, 5 }
+ },
+ { /* AC bias group 4, table 2 */
+ { 0x4, 3 },
+ { 0x4, 4 },
+ { 0x3F, 6 },
+ { 0x14, 5 },
+ { 0x56, 7 },
+ { 0x15C, 9 },
+ { 0x15D5, 13 },
+ { 0x3C, 6 },
+ { 0x2A, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xC, 5 },
+ { 0xAF, 8 },
+ { 0x2BB, 10 },
+ { 0x15D4, 13 },
+ { 0x15D7, 13 },
+ { 0x15D6, 13 },
+ { 0x15D1, 13 },
+ { 0x15D0, 13 },
+ { 0x15D3, 13 },
+ { 0x15D2, 13 },
+ { 0xB, 4 },
+ { 0x19, 5 },
+ { 0xD, 5 },
+ { 0x3E, 6 },
+ { 0x31, 6 },
+ { 0x7, 4 },
+ { 0x5, 4 },
+ { 0x3D, 6 },
+ { 0x30, 6 }
+ },
+ { /* AC bias group 4, table 3 */
+ { 0x5, 3 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0x0, 4 },
+ { 0x36, 6 },
+ { 0x11, 8 },
+ { 0x106, 12 },
+ { 0xA, 7 },
+ { 0x6E, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0x3, 4 },
+ { 0x2, 4 },
+ { 0x6F, 7 },
+ { 0x21, 9 },
+ { 0x20F, 13 },
+ { 0x20E, 13 },
+ { 0x101, 12 },
+ { 0x100, 12 },
+ { 0x103, 12 },
+ { 0x102, 12 },
+ { 0x105, 12 },
+ { 0x104, 12 },
+ { 0xC, 4 },
+ { 0x1E, 5 },
+ { 0x3, 5 },
+ { 0x3E, 6 },
+ { 0x3F, 6 },
+ { 0x9, 4 },
+ { 0xE, 4 },
+ { 0xB, 7 },
+ { 0x9, 7 }
+ },
+ { /* AC bias group 4, table 4 */
+ { 0x2, 3 },
+ { 0xE, 4 },
+ { 0x1E, 5 },
+ { 0xC, 4 },
+ { 0x1F, 5 },
+ { 0x6E, 7 },
+ { 0xAD, 10 },
+ { 0xAF, 10 },
+ { 0x14, 7 },
+ { 0x4, 3 },
+ { 0x3, 3 },
+ { 0x1A, 5 },
+ { 0x17, 5 },
+ { 0x2A, 8 },
+ { 0x576, 13 },
+ { 0xAEF, 14 },
+ { 0xAEE, 14 },
+ { 0x571, 13 },
+ { 0x570, 13 },
+ { 0x573, 13 },
+ { 0x572, 13 },
+ { 0x575, 13 },
+ { 0x574, 13 },
+ { 0x3, 4 },
+ { 0x16, 5 },
+ { 0x4, 5 },
+ { 0x36, 6 },
+ { 0xB, 6 },
+ { 0xA, 4 },
+ { 0x0, 3 },
+ { 0x6F, 7 },
+ { 0xAC, 10 }
+ },
+ { /* AC bias group 4, table 5 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 6 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 7 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 8 */
+ { 0x3, 3 },
+ { 0x11, 5 },
+ { 0x20, 6 },
+ { 0x74, 7 },
+ { 0x10D, 9 },
+ { 0x863, 12 },
+ { 0x860, 12 },
+ { 0xA, 5 },
+ { 0x75, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x18, 5 },
+ { 0x38, 6 },
+ { 0x42, 7 },
+ { 0x10F, 9 },
+ { 0x10E, 9 },
+ { 0x219, 10 },
+ { 0x10C3, 13 },
+ { 0x10C2, 13 },
+ { 0x10C5, 13 },
+ { 0x10C4, 13 },
+ { 0xF, 4 },
+ { 0x4, 4 },
+ { 0x19, 5 },
+ { 0xB, 5 },
+ { 0x39, 6 },
+ { 0x9, 4 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 4, table 9 */
+ { 0x5, 3 },
+ { 0x1, 4 },
+ { 0x3E, 6 },
+ { 0x1, 5 },
+ { 0xE2, 8 },
+ { 0x1C6F, 13 },
+ { 0x38D9, 14 },
+ { 0x39, 6 },
+ { 0x1F, 6 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x0, 5 },
+ { 0x70, 7 },
+ { 0x1C7, 9 },
+ { 0x38C, 10 },
+ { 0x71A, 11 },
+ { 0x38D8, 14 },
+ { 0x38DB, 14 },
+ { 0x38DA, 14 },
+ { 0x38DD, 14 },
+ { 0x38DC, 14 },
+ { 0xD, 4 },
+ { 0x1D, 5 },
+ { 0xE, 5 },
+ { 0x3F, 6 },
+ { 0x3C, 6 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x3D, 6 },
+ { 0x1E, 6 }
+ },
+ { /* AC bias group 4, table 10 */
+ { 0x6, 3 },
+ { 0xB, 4 },
+ { 0x11, 5 },
+ { 0x1E, 5 },
+ { 0x74, 7 },
+ { 0x3AA, 10 },
+ { 0x1D5C, 13 },
+ { 0x1, 6 },
+ { 0x21, 6 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x3E, 6 },
+ { 0xEB, 8 },
+ { 0x1D4, 9 },
+ { 0xEAF, 12 },
+ { 0x3ABB, 14 },
+ { 0x3ABA, 14 },
+ { 0x1D59, 13 },
+ { 0x1D58, 13 },
+ { 0x1D5B, 13 },
+ { 0x1D5A, 13 },
+ { 0xA, 4 },
+ { 0x1C, 5 },
+ { 0x1, 5 },
+ { 0x3F, 6 },
+ { 0x3B, 6 },
+ { 0x1, 4 },
+ { 0x9, 4 },
+ { 0x20, 6 },
+ { 0x0, 6 }
+ },
+ { /* AC bias group 4, table 11 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x17, 5 },
+ { 0x4, 4 },
+ { 0x16, 6 },
+ { 0x16A, 9 },
+ { 0x16B1, 13 },
+ { 0x17, 7 },
+ { 0x5B, 7 },
+ { 0x6, 3 },
+ { 0x7, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0xA, 6 },
+ { 0x2D7, 10 },
+ { 0xB5A, 12 },
+ { 0x16B0, 13 },
+ { 0x16B3, 13 },
+ { 0x16B2, 13 },
+ { 0x2D6D, 14 },
+ { 0x2D6C, 14 },
+ { 0x2D6F, 14 },
+ { 0x2D6E, 14 },
+ { 0x6, 4 },
+ { 0xA, 5 },
+ { 0x4, 5 },
+ { 0x2C, 6 },
+ { 0x17, 6 },
+ { 0x3, 4 },
+ { 0x7, 4 },
+ { 0x16, 7 },
+ { 0xB4, 8 }
+ },
+ { /* AC bias group 4, table 12 */
+ { 0x5, 3 },
+ { 0xD, 4 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x33, 6 },
+ { 0x193, 9 },
+ { 0x192C, 13 },
+ { 0x61, 8 },
+ { 0x31, 7 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x10, 5 },
+ { 0x11, 5 },
+ { 0xC8, 8 },
+ { 0x192F, 13 },
+ { 0x325B, 14 },
+ { 0x325A, 14 },
+ { 0x1929, 13 },
+ { 0x1928, 13 },
+ { 0x192B, 13 },
+ { 0x192A, 13 },
+ { 0x325D, 14 },
+ { 0x325C, 14 },
+ { 0x18, 5 },
+ { 0x1A, 6 },
+ { 0x1B, 6 },
+ { 0x65, 7 },
+ { 0x19, 6 },
+ { 0x4, 4 },
+ { 0x7, 4 },
+ { 0x60, 8 },
+ { 0x324, 10 }
+ },
+ { /* AC bias group 4, table 13 */
+ { 0x6, 3 },
+ { 0x0, 3 },
+ { 0x2, 4 },
+ { 0xF, 4 },
+ { 0x39, 6 },
+ { 0x1D9, 9 },
+ { 0x1D82, 13 },
+ { 0x761, 11 },
+ { 0x3BE, 10 },
+ { 0x1, 2 },
+ { 0x2, 2 },
+ { 0xF, 6 },
+ { 0xE, 6 },
+ { 0x762, 11 },
+ { 0x3B07, 14 },
+ { 0x3B06, 14 },
+ { 0x3B1D, 14 },
+ { 0x3B1C, 14 },
+ { 0x3B1F, 14 },
+ { 0x3B1E, 14 },
+ { 0x3B19, 14 },
+ { 0x3B18, 14 },
+ { 0x3B1B, 14 },
+ { 0x38, 6 },
+ { 0x1DE, 9 },
+ { 0xED, 8 },
+ { 0x3BF, 10 },
+ { 0xEE, 8 },
+ { 0x3A, 6 },
+ { 0x6, 5 },
+ { 0xEC0, 12 },
+ { 0x3B1A, 14 }
+ },
+ { /* AC bias group 4, table 14 */
+ { 0x0, 2 },
+ { 0x2, 3 },
+ { 0xF, 5 },
+ { 0x6, 4 },
+ { 0x1C, 6 },
+ { 0x1D0, 10 },
+ { 0xE8C, 13 },
+ { 0x1D1B, 14 },
+ { 0x1D1A, 14 },
+ { 0x3, 2 },
+ { 0x2, 2 },
+ { 0xEA, 9 },
+ { 0xE9, 9 },
+ { 0xE89, 13 },
+ { 0xE88, 13 },
+ { 0xE8B, 13 },
+ { 0xE8A, 13 },
+ { 0x1D65, 14 },
+ { 0x1D64, 14 },
+ { 0x1D67, 14 },
+ { 0x1D66, 14 },
+ { 0x1D61, 14 },
+ { 0x1D60, 14 },
+ { 0x3AD, 11 },
+ { 0x1D63, 14 },
+ { 0x1D62, 14 },
+ { 0x1D1D, 14 },
+ { 0x1D1C, 14 },
+ { 0x3B, 7 },
+ { 0x1D7, 10 },
+ { 0x1D1F, 14 },
+ { 0x1D1E, 14 }
+ },
+ { /* AC bias group 4, table 15 */
+ { 0x2, 2 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0xC, 4 },
+ { 0x3B, 6 },
+ { 0x1AC, 9 },
+ { 0x1AD8, 13 },
+ { 0x35B3, 14 },
+ { 0x35B2, 14 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x69, 7 },
+ { 0x68, 7 },
+ { 0x35BD, 14 },
+ { 0x35BC, 14 },
+ { 0x35BF, 14 },
+ { 0x35BE, 14 },
+ { 0x35B9, 14 },
+ { 0x35B8, 14 },
+ { 0x35BB, 14 },
+ { 0x35BA, 14 },
+ { 0x35B5, 14 },
+ { 0x35B4, 14 },
+ { 0x1A9, 9 },
+ { 0x1A8, 9 },
+ { 0x35A, 10 },
+ { 0xD7, 8 },
+ { 0xD5, 8 },
+ { 0x3A, 6 },
+ { 0x1B, 5 },
+ { 0x35B7, 14 },
+ { 0x35B6, 14 }
+ }
};
#endif /* AVCODEC_VP3DATA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp3dsp.c b/chromium/third_party/ffmpeg/libavcodec/vp3dsp.c
index 56566293d7a..b72952d2302 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp3dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp3dsp.c
@@ -26,8 +26,9 @@
#include "libavutil/attributes.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+
#include "avcodec.h"
-#include "dsputil.h"
#include "rnd_avg.h"
#include "vp3dsp.h"
@@ -40,9 +41,10 @@
#define xC6S2 25080
#define xC7S1 12785
-#define M(a,b) (((a) * (b))>>16)
+#define M(a, b) (((a) * (b)) >> 16)
-static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
+static av_always_inline void idct(uint8_t *dst, int stride,
+ int16_t *input, int type)
{
int16_t *ip = input;
@@ -54,8 +56,8 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
/* Inverse DCT on the rows now */
for (i = 0; i < 8; i++) {
/* Check for non-zero values */
- if ( ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
- ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
+ if (ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
+ ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8]) {
A = M(xC1S7, ip[1 * 8]) + M(xC7S1, ip[7 * 8]);
B = M(xC7S1, ip[1 * 8]) - M(xC1S7, ip[7 * 8]);
C = M(xC3S5, ip[3 * 8]) + M(xC5S3, ip[5 * 8]);
@@ -83,14 +85,14 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
Hd = Bd + H;
/* Final sequence of operations over-write original inputs. */
- ip[0 * 8] = Gd + Cd ;
- ip[7 * 8] = Gd - Cd ;
+ ip[0 * 8] = Gd + Cd;
+ ip[7 * 8] = Gd - Cd;
ip[1 * 8] = Add + Hd;
ip[2 * 8] = Add - Hd;
- ip[3 * 8] = Ed + Dd ;
- ip[4 * 8] = Ed - Dd ;
+ ip[3 * 8] = Ed + Dd;
+ ip[4 * 8] = Ed - Dd;
ip[5 * 8] = Fd + Bdd;
ip[6 * 8] = Fd - Bdd;
@@ -101,11 +103,10 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
ip = input;
- for ( i = 0; i < 8; i++) {
+ for (i = 0; i < 8; i++) {
/* Check for non-zero values (bitwise or faster than ||) */
- if ( ip[1] | ip[2] | ip[3] |
- ip[4] | ip[5] | ip[6] | ip[7] ) {
-
+ if (ip[1] | ip[2] | ip[3] |
+ ip[4] | ip[5] | ip[6] | ip[7]) {
A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]);
B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]);
C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]);
@@ -120,9 +121,9 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
E = M(xC4S4, (ip[0] + ip[4])) + 8;
F = M(xC4S4, (ip[0] - ip[4])) + 8;
- if(type==1){ //HACK
- E += 16*128;
- F += 16*128;
+ if (type == 1) { // HACK
+ E += 16 * 128;
+ F += 16 * 128;
}
G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
@@ -139,52 +140,51 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
/* Final sequence of operations over-write original inputs. */
if (type == 1) {
- dst[0*stride] = av_clip_uint8((Gd + Cd ) >> 4);
- dst[7*stride] = av_clip_uint8((Gd - Cd ) >> 4);
+ dst[0 * stride] = av_clip_uint8((Gd + Cd) >> 4);
+ dst[7 * stride] = av_clip_uint8((Gd - Cd) >> 4);
- dst[1*stride] = av_clip_uint8((Add + Hd ) >> 4);
- dst[2*stride] = av_clip_uint8((Add - Hd ) >> 4);
+ dst[1 * stride] = av_clip_uint8((Add + Hd) >> 4);
+ dst[2 * stride] = av_clip_uint8((Add - Hd) >> 4);
- dst[3*stride] = av_clip_uint8((Ed + Dd ) >> 4);
- dst[4*stride] = av_clip_uint8((Ed - Dd ) >> 4);
+ dst[3 * stride] = av_clip_uint8((Ed + Dd) >> 4);
+ dst[4 * stride] = av_clip_uint8((Ed - Dd) >> 4);
- dst[5*stride] = av_clip_uint8((Fd + Bdd ) >> 4);
- dst[6*stride] = av_clip_uint8((Fd - Bdd ) >> 4);
- }else{
- dst[0*stride] = av_clip_uint8(dst[0*stride] + ((Gd + Cd ) >> 4));
- dst[7*stride] = av_clip_uint8(dst[7*stride] + ((Gd - Cd ) >> 4));
+ dst[5 * stride] = av_clip_uint8((Fd + Bdd) >> 4);
+ dst[6 * stride] = av_clip_uint8((Fd - Bdd) >> 4);
+ } else {
+ dst[0 * stride] = av_clip_uint8(dst[0 * stride] + ((Gd + Cd) >> 4));
+ dst[7 * stride] = av_clip_uint8(dst[7 * stride] + ((Gd - Cd) >> 4));
- dst[1*stride] = av_clip_uint8(dst[1*stride] + ((Add + Hd ) >> 4));
- dst[2*stride] = av_clip_uint8(dst[2*stride] + ((Add - Hd ) >> 4));
+ dst[1 * stride] = av_clip_uint8(dst[1 * stride] + ((Add + Hd) >> 4));
+ dst[2 * stride] = av_clip_uint8(dst[2 * stride] + ((Add - Hd) >> 4));
- dst[3*stride] = av_clip_uint8(dst[3*stride] + ((Ed + Dd ) >> 4));
- dst[4*stride] = av_clip_uint8(dst[4*stride] + ((Ed - Dd ) >> 4));
+ dst[3 * stride] = av_clip_uint8(dst[3 * stride] + ((Ed + Dd) >> 4));
+ dst[4 * stride] = av_clip_uint8(dst[4 * stride] + ((Ed - Dd) >> 4));
- dst[5*stride] = av_clip_uint8(dst[5*stride] + ((Fd + Bdd ) >> 4));
- dst[6*stride] = av_clip_uint8(dst[6*stride] + ((Fd - Bdd ) >> 4));
+ dst[5 * stride] = av_clip_uint8(dst[5 * stride] + ((Fd + Bdd) >> 4));
+ dst[6 * stride] = av_clip_uint8(dst[6 * stride] + ((Fd - Bdd) >> 4));
}
-
} else {
if (type == 1) {
- dst[0*stride]=
- dst[1*stride]=
- dst[2*stride]=
- dst[3*stride]=
- dst[4*stride]=
- dst[5*stride]=
- dst[6*stride]=
- dst[7*stride]= av_clip_uint8(128 + ((xC4S4 * ip[0] + (IdctAdjustBeforeShift<<16))>>20));
- }else{
- if(ip[0]){
- int v= ((xC4S4 * ip[0] + (IdctAdjustBeforeShift<<16))>>20);
- dst[0*stride] = av_clip_uint8(dst[0*stride] + v);
- dst[1*stride] = av_clip_uint8(dst[1*stride] + v);
- dst[2*stride] = av_clip_uint8(dst[2*stride] + v);
- dst[3*stride] = av_clip_uint8(dst[3*stride] + v);
- dst[4*stride] = av_clip_uint8(dst[4*stride] + v);
- dst[5*stride] = av_clip_uint8(dst[5*stride] + v);
- dst[6*stride] = av_clip_uint8(dst[6*stride] + v);
- dst[7*stride] = av_clip_uint8(dst[7*stride] + v);
+ dst[0*stride] =
+ dst[1*stride] =
+ dst[2*stride] =
+ dst[3*stride] =
+ dst[4*stride] =
+ dst[5*stride] =
+ dst[6*stride] =
+ dst[7*stride] = av_clip_uint8(128 + ((xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20));
+ } else {
+ if (ip[0]) {
+ int v = (xC4S4 * ip[0] + (IdctAdjustBeforeShift << 16)) >> 20;
+ dst[0 * stride] = av_clip_uint8(dst[0 * stride] + v);
+ dst[1 * stride] = av_clip_uint8(dst[1 * stride] + v);
+ dst[2 * stride] = av_clip_uint8(dst[2 * stride] + v);
+ dst[3 * stride] = av_clip_uint8(dst[3 * stride] + v);
+ dst[4 * stride] = av_clip_uint8(dst[4 * stride] + v);
+ dst[5 * stride] = av_clip_uint8(dst[5 * stride] + v);
+ dst[6 * stride] = av_clip_uint8(dst[6 * stride] + v);
+ dst[7 * stride] = av_clip_uint8(dst[7 * stride] + v);
}
}
}
@@ -194,26 +194,26 @@ static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int
}
}
-static void vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size,
- int16_t *block/*align 16*/)
+static void vp3_idct_put_c(uint8_t *dest /* align 8 */, int line_size,
+ int16_t *block /* align 16 */)
{
idct(dest, line_size, block, 1);
memset(block, 0, sizeof(*block) * 64);
}
-static void vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size,
- int16_t *block/*align 16*/)
+static void vp3_idct_add_c(uint8_t *dest /* align 8 */, int line_size,
+ int16_t *block /* align 16 */)
{
idct(dest, line_size, block, 2);
memset(block, 0, sizeof(*block) * 64);
}
-static void vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size,
- int16_t *block/*align 16*/)
+static void vp3_idct_dc_add_c(uint8_t *dest /* align 8 */, int line_size,
+ int16_t *block /* align 16 */)
{
int i, dc = (block[0] + 15) >> 5;
- for(i = 0; i < 8; i++){
+ for (i = 0; i < 8; i++) {
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
@@ -222,7 +222,7 @@ static void vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size,
dest[5] = av_clip_uint8(dest[5] + dc);
dest[6] = av_clip_uint8(dest[6] + dc);
dest[7] = av_clip_uint8(dest[7] + dc);
- dest += line_size;
+ dest += line_size;
}
block[0] = 0;
}
@@ -232,15 +232,15 @@ static void vp3_v_loop_filter_c(uint8_t *first_pixel, int stride,
{
unsigned char *end;
int filter_value;
- const int nstride= -stride;
+ const int nstride = -stride;
- for (end= first_pixel + 8; first_pixel < end; first_pixel++) {
- filter_value =
- (first_pixel[2 * nstride] - first_pixel[ stride])
- +3*(first_pixel[0 ] - first_pixel[nstride]);
+ for (end = first_pixel + 8; first_pixel < end; first_pixel++) {
+ filter_value = (first_pixel[2 * nstride] - first_pixel[stride]) +
+ (first_pixel[0] - first_pixel[nstride]) * 3;
filter_value = bounding_values[(filter_value + 4) >> 3];
+
first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
- first_pixel[0] = av_clip_uint8(first_pixel[0] - filter_value);
+ first_pixel[0] = av_clip_uint8(first_pixel[0] - filter_value);
}
}
@@ -250,11 +250,11 @@ static void vp3_h_loop_filter_c(uint8_t *first_pixel, int stride,
unsigned char *end;
int filter_value;
- for (end= first_pixel + 8*stride; first_pixel != end; first_pixel += stride) {
- filter_value =
- (first_pixel[-2] - first_pixel[ 1])
- +3*(first_pixel[ 0] - first_pixel[-1]);
+ for (end = first_pixel + 8 * stride; first_pixel != end; first_pixel += stride) {
+ filter_value = (first_pixel[-2] - first_pixel[1]) +
+ (first_pixel[ 0] - first_pixel[-1]) * 3;
filter_value = bounding_values[(filter_value + 4) >> 3];
+
first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp5.c b/chromium/third_party/ffmpeg/libavcodec/vp5.c
index 756dc9270c6..1923d6335c8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp5.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp5.c
@@ -85,7 +85,7 @@ static void vp5_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
for (comp=0; comp<2; comp++) {
int delta = 0;
- if (vp56_rac_get_prob(c, model->vector_dct[comp])) {
+ if (vp56_rac_get_prob_branchy(c, model->vector_dct[comp])) {
int sign = vp56_rac_get_prob(c, model->vector_sig[comp]);
di = vp56_rac_get_prob(c, model->vector_pdi[comp][0]);
di |= vp56_rac_get_prob(c, model->vector_pdi[comp][1]) << 1;
@@ -108,19 +108,19 @@ static void vp5_parse_vector_models(VP56Context *s)
int comp, node;
for (comp=0; comp<2; comp++) {
- if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][0]))
+ if (vp56_rac_get_prob_branchy(c, vp5_vmc_pct[comp][0]))
model->vector_dct[comp] = vp56_rac_gets_nn(c, 7);
- if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][1]))
+ if (vp56_rac_get_prob_branchy(c, vp5_vmc_pct[comp][1]))
model->vector_sig[comp] = vp56_rac_gets_nn(c, 7);
- if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][2]))
+ if (vp56_rac_get_prob_branchy(c, vp5_vmc_pct[comp][2]))
model->vector_pdi[comp][0] = vp56_rac_gets_nn(c, 7);
- if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][3]))
+ if (vp56_rac_get_prob_branchy(c, vp5_vmc_pct[comp][3]))
model->vector_pdi[comp][1] = vp56_rac_gets_nn(c, 7);
}
for (comp=0; comp<2; comp++)
for (node=0; node<7; node++)
- if (vp56_rac_get_prob(c, vp5_vmc_pct[comp][4 + node]))
+ if (vp56_rac_get_prob_branchy(c, vp5_vmc_pct[comp][4 + node]))
model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
}
@@ -137,7 +137,7 @@ static int vp5_parse_coeff_models(VP56Context *s)
for (pt=0; pt<2; pt++)
for (node=0; node<11; node++)
- if (vp56_rac_get_prob(c, vp5_dccv_pct[pt][node])) {
+ if (vp56_rac_get_prob_branchy(c, vp5_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_dccv[pt][node] = def_prob[node];
} else if (s->frames[VP56_FRAME_CURRENT]->key_frame) {
@@ -148,7 +148,7 @@ static int vp5_parse_coeff_models(VP56Context *s)
for (pt=0; pt<2; pt++)
for (cg=0; cg<6; cg++)
for (node=0; node<11; node++)
- if (vp56_rac_get_prob(c, vp5_ract_pct[ct][pt][cg][node])) {
+ if (vp56_rac_get_prob_branchy(c, vp5_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_ract[pt][ct][cg][node] = def_prob[node];
} else if (s->frames[VP56_FRAME_CURRENT]->key_frame) {
@@ -193,9 +193,9 @@ static void vp5_parse_coeff(VP56Context *s)
coeff_idx = 0;
for (;;) {
- if (vp56_rac_get_prob(c, model2[0])) {
- if (vp56_rac_get_prob(c, model2[2])) {
- if (vp56_rac_get_prob(c, model2[3])) {
+ if (vp56_rac_get_prob_branchy(c, model2[0])) {
+ if (vp56_rac_get_prob_branchy(c, model2[2])) {
+ if (vp56_rac_get_prob_branchy(c, model2[3])) {
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 4;
idx = vp56_rac_get_tree(c, ff_vp56_pc_tree, model1);
sign = vp56_rac_get(c);
@@ -203,7 +203,7 @@ static void vp5_parse_coeff(VP56Context *s)
for (i=ff_vp56_coeff_bit_length[idx]; i>=0; i--)
coeff += vp56_rac_get_prob(c, ff_vp56_coeff_parse_table[idx][i]) << i;
} else {
- if (vp56_rac_get_prob(c, model2[4])) {
+ if (vp56_rac_get_prob_branchy(c, model2[4])) {
coeff = 3 + vp56_rac_get_prob(c, model1[5]);
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 3;
} else {
@@ -224,7 +224,7 @@ static void vp5_parse_coeff(VP56Context *s)
coeff *= s->dequant_ac;
s->block_coeff[b][permute[coeff_idx]] = coeff;
} else {
- if (ct && !vp56_rac_get_prob(c, model2[1]))
+ if (ct && !vp56_rac_get_prob_branchy(c, model2[1]))
break;
ct = 0;
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp56.c b/chromium/third_party/ffmpeg/libavcodec/vp56.c
index a0cb060d68a..ba39b56436a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp56.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp56.c
@@ -83,16 +83,16 @@ static void vp56_parse_mb_type_models(VP56Context *s)
int i, ctx, type;
for (ctx=0; ctx<3; ctx++) {
- if (vp56_rac_get_prob(c, 174)) {
+ if (vp56_rac_get_prob_branchy(c, 174)) {
int idx = vp56_rac_gets(c, 4);
memcpy(model->mb_types_stats[ctx],
ff_vp56_pre_def_mb_type_stats[idx][ctx],
sizeof(model->mb_types_stats[ctx]));
}
- if (vp56_rac_get_prob(c, 254)) {
+ if (vp56_rac_get_prob_branchy(c, 254)) {
for (type=0; type<10; type++) {
for(i=0; i<2; i++) {
- if (vp56_rac_get_prob(c, 205)) {
+ if (vp56_rac_get_prob_branchy(c, 205)) {
int delta, sign = vp56_rac_get(c);
delta = vp56_rac_get_tree(c, ff_vp56_pmbtm_tree,
@@ -153,7 +153,7 @@ static VP56mb vp56_parse_mb_type(VP56Context *s,
uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type];
VP56RangeCoder *c = &s->c;
- if (vp56_rac_get_prob(c, mb_type_model[0]))
+ if (vp56_rac_get_prob_branchy(c, mb_type_model[0]))
return prev_type;
else
return vp56_rac_get_tree(c, ff_vp56_pmbt_tree, mb_type_model);
@@ -700,9 +700,9 @@ av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id);
for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
- s->idct_scantable[i] = T(ff_zigzag_direct[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+ s->idct_scantable[i] = TRANSPOSE(ff_zigzag_direct[i]);
+#undef TRANSPOSE
}
for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp56.h b/chromium/third_party/ffmpeg/libavcodec/vp56.h
index 9a952969203..1af5eaf5026 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp56.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp56.h
@@ -26,7 +26,6 @@
#ifndef AVCODEC_VP56_H
#define AVCODEC_VP56_H
-#include "dsputil.h"
#include "get_bits.h"
#include "hpeldsp.h"
#include "bytestream.h"
@@ -364,7 +363,7 @@ int vp56_rac_get_tree(VP56RangeCoder *c,
const uint8_t *probs)
{
while (tree->val > 0) {
- if (vp56_rac_get_prob(c, probs[tree->prob_idx]))
+ if (vp56_rac_get_prob_branchy(c, probs[tree->prob_idx]))
tree += tree->val;
else
tree++;
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp6.c b/chromium/third_party/ffmpeg/libavcodec/vp6.c
index f552524db67..a18b8ff5234 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp6.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp6.c
@@ -211,20 +211,20 @@ static void vp6_parse_vector_models(VP56Context *s)
int comp, node;
for (comp=0; comp<2; comp++) {
- if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][0]))
+ if (vp56_rac_get_prob_branchy(c, vp6_sig_dct_pct[comp][0]))
model->vector_dct[comp] = vp56_rac_gets_nn(c, 7);
- if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][1]))
+ if (vp56_rac_get_prob_branchy(c, vp6_sig_dct_pct[comp][1]))
model->vector_sig[comp] = vp56_rac_gets_nn(c, 7);
}
for (comp=0; comp<2; comp++)
for (node=0; node<7; node++)
- if (vp56_rac_get_prob(c, vp6_pdv_pct[comp][node]))
+ if (vp56_rac_get_prob_branchy(c, vp6_pdv_pct[comp][node]))
model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
for (comp=0; comp<2; comp++)
for (node=0; node<8; node++)
- if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node]))
+ if (vp56_rac_get_prob_branchy(c, vp6_fdv_pct[comp][node]))
model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7);
}
@@ -270,7 +270,7 @@ static int vp6_parse_coeff_models(VP56Context *s)
for (pt=0; pt<2; pt++)
for (node=0; node<11; node++)
- if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) {
+ if (vp56_rac_get_prob_branchy(c, vp6_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_dccv[pt][node] = def_prob[node];
} else if (s->frames[VP56_FRAME_CURRENT]->key_frame) {
@@ -279,21 +279,21 @@ static int vp6_parse_coeff_models(VP56Context *s)
if (vp56_rac_get(c)) {
for (pos=1; pos<64; pos++)
- if (vp56_rac_get_prob(c, vp6_coeff_reorder_pct[pos]))
+ if (vp56_rac_get_prob_branchy(c, vp6_coeff_reorder_pct[pos]))
model->coeff_reorder[pos] = vp56_rac_gets(c, 4);
vp6_coeff_order_table_init(s);
}
for (cg=0; cg<2; cg++)
for (node=0; node<14; node++)
- if (vp56_rac_get_prob(c, vp6_runv_pct[cg][node]))
+ if (vp56_rac_get_prob_branchy(c, vp6_runv_pct[cg][node]))
model->coeff_runv[cg][node] = vp56_rac_gets_nn(c, 7);
for (ct=0; ct<3; ct++)
for (pt=0; pt<2; pt++)
for (cg=0; cg<6; cg++)
for (node=0; node<11; node++)
- if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) {
+ if (vp56_rac_get_prob_branchy(c, vp6_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_ract[pt][ct][cg][node] = def_prob[node];
} else if (s->frames[VP56_FRAME_CURRENT]->key_frame) {
@@ -339,7 +339,7 @@ static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
for (comp=0; comp<2; comp++) {
int i, delta = 0;
- if (vp56_rac_get_prob(c, model->vector_dct[comp])) {
+ if (vp56_rac_get_prob_branchy(c, model->vector_dct[comp])) {
static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4};
for (i=0; i<sizeof(prob_order); i++) {
int j = prob_order[i];
@@ -354,7 +354,7 @@ static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
model->vector_pdv[comp]);
}
- if (delta && vp56_rac_get_prob(c, model->vector_sig[comp]))
+ if (delta && vp56_rac_get_prob_branchy(c, model->vector_sig[comp]))
delta = -delta;
if (!comp)
@@ -462,16 +462,16 @@ static void vp6_parse_coeff(VP56Context *s)
coeff_idx = 0;
for (;;) {
- if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) {
+ if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob_branchy(c, model2[0])) {
/* parse a coeff */
- if (vp56_rac_get_prob(c, model2[2])) {
- if (vp56_rac_get_prob(c, model2[3])) {
+ if (vp56_rac_get_prob_branchy(c, model2[2])) {
+ if (vp56_rac_get_prob_branchy(c, model2[3])) {
idx = vp56_rac_get_tree(c, ff_vp56_pc_tree, model1);
coeff = ff_vp56_coeff_bias[idx+5];
for (i=ff_vp56_coeff_bit_length[idx]; i>=0; i--)
coeff += vp56_rac_get_prob(c, ff_vp56_coeff_parse_table[idx][i]) << i;
} else {
- if (vp56_rac_get_prob(c, model2[4]))
+ if (vp56_rac_get_prob_branchy(c, model2[4]))
coeff = 3 + vp56_rac_get_prob(c, model1[5]);
else
coeff = 2;
@@ -492,7 +492,7 @@ static void vp6_parse_coeff(VP56Context *s)
/* parse a run */
ct = 0;
if (coeff_idx > 0) {
- if (!vp56_rac_get_prob(c, model2[1]))
+ if (!vp56_rac_get_prob_branchy(c, model2[1]))
break;
model3 = model->coeff_runv[coeff_idx >= 6];
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8.c b/chromium/third_party/ffmpeg/libavcodec/vp8.c
index 4aaef888a42..8421be8a7cb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8.c
@@ -1,10 +1,11 @@
/*
- * VP8 compatible video decoder
+ * VP7/VP8 compatible video decoder
*
* Copyright (C) 2010 David Conrad
* Copyright (C) 2010 Ronald S. Bultje
* Copyright (C) 2010 Jason Garrett-Glaser
* Copyright (C) 2012 Daniel Kang
+ * Copyright (C) 2014 Peter Ross
*
* This file is part of FFmpeg.
*
@@ -24,17 +25,26 @@
*/
#include "libavutil/imgutils.h"
+
#include "avcodec.h"
#include "internal.h"
-#include "vp8.h"
-#include "vp8data.h"
#include "rectangle.h"
#include "thread.h"
+#include "vp8.h"
+#include "vp8data.h"
#if ARCH_ARM
# include "arm/vp8.h"
#endif
+#if CONFIG_VP7_DECODER && CONFIG_VP8_DECODER
+#define VPX(vp7, f) (vp7 ? vp7_ ## f : vp8_ ## f)
+#elif CONFIG_VP7_DECODER
+#define VPX(vp7, f) vp7_ ## f
+#else // CONFIG_VP8_DECODER
+#define VPX(vp7, f) vp8_ ## f
+#endif
+
static void free_buffers(VP8Context *s)
{
int i;
@@ -74,6 +84,7 @@ static void vp8_release_frame(VP8Context *s, VP8Frame *f)
ff_thread_release_buffer(s->avctx, &f->tf);
}
+#if CONFIG_VP8_DECODER
static int vp8_ref_frame(VP8Context *s, VP8Frame *dst, VP8Frame *src)
{
int ret;
@@ -90,7 +101,7 @@ static int vp8_ref_frame(VP8Context *s, VP8Frame *dst, VP8Frame *src)
return 0;
}
-
+#endif /* CONFIG_VP8_DECODER */
static void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem)
{
@@ -110,7 +121,32 @@ static void vp8_decode_flush(AVCodecContext *avctx)
vp8_decode_flush_impl(avctx, 0);
}
-static int update_dimensions(VP8Context *s, int width, int height)
+static VP8Frame *vp8_find_free_buffer(VP8Context *s)
+{
+ VP8Frame *frame = NULL;
+ int i;
+
+ // find a free buffer
+ for (i = 0; i < 5; i++)
+ if (&s->frames[i] != s->framep[VP56_FRAME_CURRENT] &&
+ &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
+ &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
+ &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) {
+ frame = &s->frames[i];
+ break;
+ }
+ if (i == 5) {
+ av_log(s->avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
+ abort();
+ }
+ if (frame->tf.f->data[0])
+ vp8_release_frame(s, frame);
+
+ return frame;
+}
+
+static av_always_inline
+int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
{
AVCodecContext *avctx = s->avctx;
int i, ret;
@@ -124,22 +160,25 @@ static int update_dimensions(VP8Context *s, int width, int height)
return ret;
}
- s->mb_width = (s->avctx->coded_width +15) / 16;
- s->mb_height = (s->avctx->coded_height+15) / 16;
+ s->mb_width = (s->avctx->coded_width + 15) / 16;
+ s->mb_height = (s->avctx->coded_height + 15) / 16;
- s->mb_layout = (avctx->active_thread_type == FF_THREAD_SLICE) && (FFMIN(s->num_coeff_partitions, avctx->thread_count) > 1);
+ s->mb_layout = is_vp7 || avctx->active_thread_type == FF_THREAD_SLICE &&
+ FFMIN(s->num_coeff_partitions, avctx->thread_count) > 1;
if (!s->mb_layout) { // Frame threading and one thread
- s->macroblocks_base = av_mallocz((s->mb_width+s->mb_height*2+1)*sizeof(*s->macroblocks));
- s->intra4x4_pred_mode_top = av_mallocz(s->mb_width*4);
- }
- else // Sliced threading
- s->macroblocks_base = av_mallocz((s->mb_width+2)*(s->mb_height+2)*sizeof(*s->macroblocks));
- s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz));
- s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border));
- s->thread_data = av_mallocz(MAX_THREADS*sizeof(VP8ThreadData));
+ s->macroblocks_base = av_mallocz((s->mb_width + s->mb_height * 2 + 1) *
+ sizeof(*s->macroblocks));
+ s->intra4x4_pred_mode_top = av_mallocz(s->mb_width * 4);
+ } else // Sliced threading
+ s->macroblocks_base = av_mallocz((s->mb_width + 2) * (s->mb_height + 2) *
+ sizeof(*s->macroblocks));
+ s->top_nnz = av_mallocz(s->mb_width * sizeof(*s->top_nnz));
+ s->top_border = av_mallocz((s->mb_width + 1) * sizeof(*s->top_border));
+ s->thread_data = av_mallocz(MAX_THREADS * sizeof(VP8ThreadData));
for (i = 0; i < MAX_THREADS; i++) {
- s->thread_data[i].filter_strength = av_mallocz(s->mb_width*sizeof(*s->thread_data[0].filter_strength));
+ s->thread_data[i].filter_strength =
+ av_mallocz(s->mb_width * sizeof(*s->thread_data[0].filter_strength));
#if HAVE_THREADS
pthread_mutex_init(&s->thread_data[i].lock, NULL);
pthread_cond_init(&s->thread_data[i].cond, NULL);
@@ -150,11 +189,22 @@ static int update_dimensions(VP8Context *s, int width, int height)
(!s->intra4x4_pred_mode_top && !s->mb_layout))
return AVERROR(ENOMEM);
- s->macroblocks = s->macroblocks_base + 1;
+ s->macroblocks = s->macroblocks_base + 1;
return 0;
}
+static int vp7_update_dimensions(VP8Context *s, int width, int height)
+{
+ return update_dimensions(s, width, height, IS_VP7);
+}
+
+static int vp8_update_dimensions(VP8Context *s, int width, int height)
+{
+ return update_dimensions(s, width, height, IS_VP8);
+}
+
+
static void parse_segment_info(VP8Context *s)
{
VP56RangeCoder *c = &s->c;
@@ -207,13 +257,13 @@ static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
s->num_coeff_partitions = 1 << vp8_rac_get_uint(&s->c, 2);
- buf += 3*(s->num_coeff_partitions-1);
- buf_size -= 3*(s->num_coeff_partitions-1);
+ buf += 3 * (s->num_coeff_partitions - 1);
+ buf_size -= 3 * (s->num_coeff_partitions - 1);
if (buf_size < 0)
return -1;
- for (i = 0; i < s->num_coeff_partitions-1; i++) {
- int size = AV_RL24(sizes + 3*i);
+ for (i = 0; i < s->num_coeff_partitions - 1; i++) {
+ int size = AV_RL24(sizes + 3 * i);
if (buf_size - size < 0)
return -1;
@@ -226,7 +276,26 @@ static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
return 0;
}
-static void get_quants(VP8Context *s)
+static void vp7_get_quants(VP8Context *s)
+{
+ VP56RangeCoder *c = &s->c;
+
+ int yac_qi = vp8_rac_get_uint(c, 7);
+ int ydc_qi = vp8_rac_get(c) ? vp8_rac_get_uint(c, 7) : yac_qi;
+ int y2dc_qi = vp8_rac_get(c) ? vp8_rac_get_uint(c, 7) : yac_qi;
+ int y2ac_qi = vp8_rac_get(c) ? vp8_rac_get_uint(c, 7) : yac_qi;
+ int uvdc_qi = vp8_rac_get(c) ? vp8_rac_get_uint(c, 7) : yac_qi;
+ int uvac_qi = vp8_rac_get(c) ? vp8_rac_get_uint(c, 7) : yac_qi;
+
+ s->qmat[0].luma_qmul[0] = vp7_ydc_qlookup[ydc_qi];
+ s->qmat[0].luma_qmul[1] = vp7_yac_qlookup[yac_qi];
+ s->qmat[0].luma_dc_qmul[0] = vp7_y2dc_qlookup[y2dc_qi];
+ s->qmat[0].luma_dc_qmul[1] = vp7_y2ac_qlookup[y2ac_qi];
+ s->qmat[0].chroma_qmul[0] = FFMIN(vp7_ydc_qlookup[uvdc_qi], 132);
+ s->qmat[0].chroma_qmul[1] = vp7_yac_qlookup[uvac_qi];
+}
+
+static void vp8_get_quants(VP8Context *s)
{
VP56RangeCoder *c = &s->c;
int i, base_qi;
@@ -246,13 +315,13 @@ static void get_quants(VP8Context *s)
} else
base_qi = yac_qi;
- s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + ydc_delta , 7)];
- s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi , 7)];
- s->qmat[i].luma_dc_qmul[0] = 2 * vp8_dc_qlookup[av_clip_uintp2(base_qi + y2dc_delta, 7)];
+ s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + ydc_delta, 7)];
+ s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi, 7)];
+ s->qmat[i].luma_dc_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + y2dc_delta, 7)] * 2;
/* 101581>>16 is equivalent to 155/100 */
- s->qmat[i].luma_dc_qmul[1] = (101581 * vp8_ac_qlookup[av_clip_uintp2(base_qi + y2ac_delta, 7)]) >> 16;
- s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + uvdc_delta, 7)];
- s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + uvac_delta, 7)];
+ s->qmat[i].luma_dc_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + y2ac_delta, 7)] * 101581 >> 16;
+ s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + uvdc_delta, 7)];
+ s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + uvac_delta, 7)];
s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8);
s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132);
@@ -288,6 +357,54 @@ static VP56Frame ref_to_update(VP8Context *s, int update, VP56Frame ref)
return VP56_FRAME_NONE;
}
+static void vp78_reset_probability_tables(VP8Context *s)
+{
+ int i, j;
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 16; j++)
+ memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]],
+ sizeof(s->prob->token[i][j]));
+}
+
+static void vp78_update_probability_tables(VP8Context *s)
+{
+ VP56RangeCoder *c = &s->c;
+ int i, j, k, l, m;
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 8; j++)
+ for (k = 0; k < 3; k++)
+ for (l = 0; l < NUM_DCT_TOKENS-1; l++)
+ if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) {
+ int prob = vp8_rac_get_uint(c, 8);
+ for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++)
+ s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob;
+ }
+}
+
+#define VP7_MVC_SIZE 17
+#define VP8_MVC_SIZE 19
+
+static void vp78_update_pred16x16_pred8x8_mvc_probabilities(VP8Context *s,
+ int mvc_size)
+{
+ VP56RangeCoder *c = &s->c;
+ int i, j;
+
+ if (vp8_rac_get(c))
+ for (i = 0; i < 4; i++)
+ s->prob->pred16x16[i] = vp8_rac_get_uint(c, 8);
+ if (vp8_rac_get(c))
+ for (i = 0; i < 3; i++)
+ s->prob->pred8x8c[i] = vp8_rac_get_uint(c, 8);
+
+ // 17.2 MV probability update
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < mvc_size; j++)
+ if (vp56_rac_get_prob_branchy(c, vp8_mv_update_prob[i][j]))
+ s->prob->mvc[i][j] = vp8_rac_get_nn(c);
+}
+
static void update_refs(VP8Context *s)
{
VP56RangeCoder *c = &s->c;
@@ -299,10 +416,220 @@ static void update_refs(VP8Context *s)
s->update_altref = ref_to_update(s, update_altref, VP56_FRAME_GOLDEN2);
}
-static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
+static void copy_chroma(AVFrame *dst, AVFrame *src, int width, int height)
+{
+ int i, j;
+
+ for (j = 1; j < 3; j++) {
+ for (i = 0; i < height / 2; i++)
+ memcpy(dst->data[j] + i * dst->linesize[j],
+ src->data[j] + i * src->linesize[j], width / 2);
+ }
+}
+
+static void fade(uint8_t *dst, int dst_linesize,
+ const uint8_t *src, int src_linesize,
+ int width, int height,
+ int alpha, int beta)
+{
+ int i, j;
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ uint8_t y = src[j * src_linesize + i];
+ dst[j * dst_linesize + i] = av_clip_uint8(y + ((y * beta) >> 8) + alpha);
+ }
+ }
+}
+
+static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
+{
+ int alpha = (int8_t) vp8_rac_get_uint(c, 8);
+ int beta = (int8_t) vp8_rac_get_uint(c, 8);
+ int ret;
+
+ if (!s->keyframe && (alpha || beta)) {
+ int width = s->mb_width * 16;
+ int height = s->mb_height * 16;
+ AVFrame *src, *dst;
+
+ if (!s->framep[VP56_FRAME_PREVIOUS] ||
+ !s->framep[VP56_FRAME_GOLDEN]) {
+ av_log(s->avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ dst =
+ src = s->framep[VP56_FRAME_PREVIOUS]->tf.f;
+
+ /* preserve the golden frame, write a new previous frame */
+ if (s->framep[VP56_FRAME_GOLDEN] == s->framep[VP56_FRAME_PREVIOUS]) {
+ s->framep[VP56_FRAME_PREVIOUS] = vp8_find_free_buffer(s);
+ if ((ret = vp8_alloc_frame(s, s->framep[VP56_FRAME_PREVIOUS], 1)) < 0)
+ return ret;
+
+ dst = s->framep[VP56_FRAME_PREVIOUS]->tf.f;
+
+ copy_chroma(dst, src, width, height);
+ }
+
+ fade(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ width, height, alpha, beta);
+ }
+
+ return 0;
+}
+
+static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
+{
+ VP56RangeCoder *c = &s->c;
+ int part1_size, hscale, vscale, i, j, ret;
+ int width = s->avctx->width;
+ int height = s->avctx->height;
+
+ s->profile = (buf[0] >> 1) & 7;
+ if (s->profile > 1) {
+ avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile);
+ return AVERROR_INVALIDDATA;
+ }
+
+ s->keyframe = !(buf[0] & 1);
+ s->invisible = 0;
+ part1_size = AV_RL24(buf) >> 4;
+
+ if (buf_size < 4 - s->profile + part1_size) {
+ av_log(s->avctx, AV_LOG_ERROR, "Buffer size %d is too small, needed : %d\n", buf_size, 4 - s->profile + part1_size);
+ return AVERROR_INVALIDDATA;
+ }
+
+ buf += 4 - s->profile;
+ buf_size -= 4 - s->profile;
+
+ memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
+
+ ff_vp56_init_range_decoder(c, buf, part1_size);
+ buf += part1_size;
+ buf_size -= part1_size;
+
+ /* A. Dimension information (keyframes only) */
+ if (s->keyframe) {
+ width = vp8_rac_get_uint(c, 12);
+ height = vp8_rac_get_uint(c, 12);
+ hscale = vp8_rac_get_uint(c, 2);
+ vscale = vp8_rac_get_uint(c, 2);
+ if (hscale || vscale)
+ avpriv_request_sample(s->avctx, "Upscaling");
+
+ s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
+ vp78_reset_probability_tables(s);
+ memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
+ sizeof(s->prob->pred16x16));
+ memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
+ sizeof(s->prob->pred8x8c));
+ for (i = 0; i < 2; i++)
+ memcpy(s->prob->mvc[i], vp7_mv_default_prob[i],
+ sizeof(vp7_mv_default_prob[i]));
+ memset(&s->segmentation, 0, sizeof(s->segmentation));
+ memset(&s->lf_delta, 0, sizeof(s->lf_delta));
+ memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan));
+ }
+
+ if (s->keyframe || s->profile > 0)
+ memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred));
+
+ /* B. Decoding information for all four macroblock-level features */
+ for (i = 0; i < 4; i++) {
+ s->feature_enabled[i] = vp8_rac_get(c);
+ if (s->feature_enabled[i]) {
+ s->feature_present_prob[i] = vp8_rac_get_uint(c, 8);
+
+ for (j = 0; j < 3; j++)
+ s->feature_index_prob[i][j] =
+ vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255;
+
+ if (vp7_feature_value_size[s->profile][i])
+ for (j = 0; j < 4; j++)
+ s->feature_value[i][j] =
+ vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0;
+ }
+ }
+
+ s->segmentation.enabled = 0;
+ s->segmentation.update_map = 0;
+ s->lf_delta.enabled = 0;
+
+ s->num_coeff_partitions = 1;
+ ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size);
+
+ if (!s->macroblocks_base || /* first frame */
+ width != s->avctx->width || height != s->avctx->height ||
+ (width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) {
+ if ((ret = vp7_update_dimensions(s, width, height)) < 0)
+ return ret;
+ }
+
+ /* C. Dequantization indices */
+ vp7_get_quants(s);
+
+ /* D. Golden frame update flag (a Flag) for interframes only */
+ if (!s->keyframe) {
+ s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE;
+ s->sign_bias[VP56_FRAME_GOLDEN] = 0;
+ }
+
+ s->update_last = 1;
+ s->update_probabilities = 1;
+ s->fade_present = 1;
+
+ if (s->profile > 0) {
+ s->update_probabilities = vp8_rac_get(c);
+ if (!s->update_probabilities)
+ s->prob[1] = s->prob[0];
+
+ if (!s->keyframe)
+ s->fade_present = vp8_rac_get(c);
+ }
+
+ /* E. Fading information for previous frame */
+ if (s->fade_present && vp8_rac_get(c)) {
+ if ((ret = vp7_fade_frame(s ,c)) < 0)
+ return ret;
+ }
+
+ /* F. Loop filter type */
+ if (!s->profile)
+ s->filter.simple = vp8_rac_get(c);
+
+ /* G. DCT coefficient ordering specification */
+ if (vp8_rac_get(c))
+ for (i = 1; i < 16; i++)
+ s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)];
+
+ /* H. Loop filter levels */
+ if (s->profile > 0)
+ s->filter.simple = vp8_rac_get(c);
+ s->filter.level = vp8_rac_get_uint(c, 6);
+ s->filter.sharpness = vp8_rac_get_uint(c, 3);
+
+ /* I. DCT coefficient probability update; 13.3 Token Probability Updates */
+ vp78_update_probability_tables(s);
+
+ s->mbskip_enabled = 0;
+
+ /* J. The remaining frame header data occurs ONLY FOR INTERFRAMES */
+ if (!s->keyframe) {
+ s->prob->intra = vp8_rac_get_uint(c, 8);
+ s->prob->last = vp8_rac_get_uint(c, 8);
+ vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
+ }
+
+ return 0;
+}
+
+static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
{
VP56RangeCoder *c = &s->c;
- int header_size, hscale, vscale, i, j, k, l, m, ret;
+ int header_size, hscale, vscale, ret;
int width = s->avctx->width;
int height = s->avctx->height;
@@ -317,24 +644,27 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
if (!s->profile)
- memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
+ memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab,
+ sizeof(s->put_pixels_tab));
else // profile 1-3 use bilinear, 4+ aren't defined so whatever
- memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, sizeof(s->put_pixels_tab));
+ memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab,
+ sizeof(s->put_pixels_tab));
- if (header_size > buf_size - 7*s->keyframe) {
+ if (header_size > buf_size - 7 * s->keyframe) {
av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
return AVERROR_INVALIDDATA;
}
if (s->keyframe) {
if (AV_RL24(buf) != 0x2a019d) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid start code 0x%x\n", AV_RL24(buf));
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid start code 0x%x\n", AV_RL24(buf));
return AVERROR_INVALIDDATA;
}
- width = AV_RL16(buf+3) & 0x3fff;
- height = AV_RL16(buf+5) & 0x3fff;
- hscale = buf[4] >> 6;
- vscale = buf[6] >> 6;
+ width = AV_RL16(buf + 3) & 0x3fff;
+ height = AV_RL16(buf + 5) & 0x3fff;
+ hscale = buf[4] >> 6;
+ vscale = buf[6] >> 6;
buf += 7;
buf_size -= 7;
@@ -342,13 +672,13 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
avpriv_request_sample(s->avctx, "Upscaling");
s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 16; j++)
- memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]],
- sizeof(s->prob->token[i][j]));
- memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16));
- memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c));
- memcpy(s->prob->mvc , vp8_mv_default_prob , sizeof(s->prob->mvc));
+ vp78_reset_probability_tables(s);
+ memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
+ sizeof(s->prob->pred16x16));
+ memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
+ sizeof(s->prob->pred8x8c));
+ memcpy(s->prob->mvc, vp8_mv_default_prob,
+ sizeof(s->prob->mvc));
memset(&s->segmentation, 0, sizeof(s->segmentation));
memset(&s->lf_delta, 0, sizeof(s->lf_delta));
}
@@ -382,12 +712,12 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
}
if (!s->macroblocks_base || /* first frame */
- width != s->avctx->width || height != s->avctx->height || (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) {
- if ((ret = update_dimensions(s, width, height)) < 0)
+ width != s->avctx->width || height != s->avctx->height ||
+ (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height)
+ if ((ret = vp8_update_dimensions(s, width, height)) < 0)
return ret;
- }
- get_quants(s);
+ vp8_get_quants(s);
if (!s->keyframe) {
update_refs(s);
@@ -402,15 +732,7 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
s->update_last = s->keyframe || vp8_rac_get(c);
- for (i = 0; i < 4; i++)
- for (j = 0; j < 8; j++)
- for (k = 0; k < 3; k++)
- for (l = 0; l < NUM_DCT_TOKENS-1; l++)
- if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) {
- int prob = vp8_rac_get_uint(c, 8);
- for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++)
- s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob;
- }
+ vp78_update_probability_tables(s);
if ((s->mbskip_enabled = vp8_rac_get(c)))
s->prob->mbskip = vp8_rac_get_uint(c, 8);
@@ -419,25 +741,14 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
s->prob->intra = vp8_rac_get_uint(c, 8);
s->prob->last = vp8_rac_get_uint(c, 8);
s->prob->golden = vp8_rac_get_uint(c, 8);
-
- if (vp8_rac_get(c))
- for (i = 0; i < 4; i++)
- s->prob->pred16x16[i] = vp8_rac_get_uint(c, 8);
- if (vp8_rac_get(c))
- for (i = 0; i < 3; i++)
- s->prob->pred8x8c[i] = vp8_rac_get_uint(c, 8);
-
- // 17.2 MV probability update
- for (i = 0; i < 2; i++)
- for (j = 0; j < 19; j++)
- if (vp56_rac_get_prob_branchy(c, vp8_mv_update_prob[i][j]))
- s->prob->mvc[i][j] = vp8_rac_get_nn(c);
+ vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE);
}
return 0;
}
-static av_always_inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
+static av_always_inline
+void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
{
dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);
dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);
@@ -446,7 +757,7 @@ static av_always_inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *
/**
* Motion vector coding, 17.1.
*/
-static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
+static av_always_inline int read_mv_component(VP56RangeCoder *c, const uint8_t *p, int vp7)
{
int bit, x = 0;
@@ -455,33 +766,46 @@ static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
for (i = 0; i < 3; i++)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
- for (i = 9; i > 3; i--)
+ for (i = (vp7 ? 7 : 9); i > 3; i--)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
- if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))
+ if (!(x & (vp7 ? 0xF0 : 0xFFF0)) || vp56_rac_get_prob(c, p[12]))
x += 8;
} else {
// small_mvtree
- const uint8_t *ps = p+2;
+ const uint8_t *ps = p + 2;
bit = vp56_rac_get_prob(c, *ps);
- ps += 1 + 3*bit;
- x += 4*bit;
+ ps += 1 + 3 * bit;
+ x += 4 * bit;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + bit;
- x += 2*bit;
+ x += 2 * bit;
x += vp56_rac_get_prob(c, *ps);
}
return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
}
+static int vp7_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
+{
+ return read_mv_component(c, p, 1);
+}
+
+static int vp8_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
+{
+ return read_mv_component(c, p, 0);
+}
+
static av_always_inline
-const uint8_t *get_submv_prob(uint32_t left, uint32_t top)
+const uint8_t *get_submv_prob(uint32_t left, uint32_t top, int is_vp7)
{
+ if (is_vp7)
+ return vp7_submv_prob;
+
if (left == top)
- return vp8_submv_prob[4-!!left];
+ return vp8_submv_prob[4 - !!left];
if (!top)
return vp8_submv_prob[2];
- return vp8_submv_prob[1-!!left];
+ return vp8_submv_prob[1 - !!left];
}
/**
@@ -489,15 +813,15 @@ const uint8_t *get_submv_prob(uint32_t left, uint32_t top)
* @returns the number of motion vectors parsed (2, 4 or 16)
*/
static av_always_inline
-int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int layout)
+int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
+ int layout, int is_vp7)
{
int part_idx;
int n, num;
VP8Macroblock *top_mb;
VP8Macroblock *left_mb = &mb[-1];
- const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning],
- *mbsplits_top,
- *mbsplits_cur, *firstidx;
+ const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning];
+ const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
VP56mv *top_mv;
VP56mv *left_mv = left_mb->bmv;
VP56mv *cur_mv = mb->bmv;
@@ -505,23 +829,22 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int lay
if (!layout) // layout is inlined, s->mb_layout is not
top_mb = &mb[2];
else
- top_mb = &mb[-s->mb_width-1];
+ top_mb = &mb[-s->mb_width - 1];
mbsplits_top = vp8_mbsplits[top_mb->partitioning];
- top_mv = top_mb->bmv;
+ top_mv = top_mb->bmv;
if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
- if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1]))
part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
- } else {
+ else
part_idx = VP8_SPLITMVMODE_8x8;
- }
} else {
part_idx = VP8_SPLITMVMODE_4x4;
}
- num = vp8_mbsplit_count[part_idx];
- mbsplits_cur = vp8_mbsplits[part_idx],
- firstidx = vp8_mbfirstidx[part_idx];
+ num = vp8_mbsplit_count[part_idx];
+ mbsplits_cur = vp8_mbsplits[part_idx],
+ firstidx = vp8_mbfirstidx[part_idx];
mb->partitioning = part_idx;
for (n = 0; n < num; n++) {
@@ -532,19 +855,21 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int lay
if (!(k & 3))
left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
else
- left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
+ left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
if (k <= 3)
above = AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
else
above = AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
- submv_prob = get_submv_prob(left, above);
+ submv_prob = get_submv_prob(left, above, is_vp7);
if (vp56_rac_get_prob_branchy(c, submv_prob[0])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[1])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[2])) {
- mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]);
- mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]);
+ mb->bmv[n].y = mb->mv.y +
+ read_mv_component(c, s->prob->mvc[0], is_vp7);
+ mb->bmv[n].x = mb->mv.x +
+ read_mv_component(c, s->prob->mvc[1], is_vp7);
} else {
AV_ZERO32(&mb->bmv[n]);
}
@@ -559,12 +884,133 @@ int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int lay
return num;
}
+/**
+ * The vp7 reference decoder uses a padding macroblock column (added to right
+ * edge of the frame) to guard against illegal macroblock offsets. The
+ * algorithm has bugs that permit offsets to straddle the padding column.
+ * This function replicates those bugs.
+ *
+ * @param[out] edge_x macroblock x address
+ * @param[out] edge_y macroblock y address
+ *
+ * @return macroblock offset legal (boolean)
+ */
+static int vp7_calculate_mb_offset(int mb_x, int mb_y, int mb_width,
+ int xoffset, int yoffset, int boundary,
+ int *edge_x, int *edge_y)
+{
+ int vwidth = mb_width + 1;
+ int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
+ if (new < boundary || new % vwidth == vwidth - 1)
+ return 0;
+ *edge_y = new / vwidth;
+ *edge_x = new % vwidth;
+ return 1;
+}
+
+static const VP56mv *get_bmv_ptr(const VP8Macroblock *mb, int subblock)
+{
+ return &mb->bmv[mb->mode == VP8_MVMODE_SPLIT ? vp8_mbsplits[mb->partitioning][subblock] : 0];
+}
+
static av_always_inline
-void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
+void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
+ int mb_x, int mb_y, int layout)
{
- VP8Macroblock *mb_edge[3] = { 0 /* top */,
+ VP8Macroblock *mb_edge[12];
+ enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
+ enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
+ int idx = CNT_ZERO;
+ VP56mv near_mv[3];
+ uint8_t cnt[3] = { 0 };
+ VP56RangeCoder *c = &s->c;
+ int i;
+
+ AV_ZERO32(&near_mv[0]);
+ AV_ZERO32(&near_mv[1]);
+ AV_ZERO32(&near_mv[2]);
+
+ for (i = 0; i < VP7_MV_PRED_COUNT; i++) {
+ const VP7MVPred * pred = &vp7_mv_pred[i];
+ int edge_x, edge_y;
+
+ if (vp7_calculate_mb_offset(mb_x, mb_y, s->mb_width, pred->xoffset,
+ pred->yoffset, !s->profile, &edge_x, &edge_y)) {
+ VP8Macroblock *edge = mb_edge[i] = (s->mb_layout == 1)
+ ? s->macroblocks_base + 1 + edge_x +
+ (s->mb_width + 1) * (edge_y + 1)
+ : s->macroblocks + edge_x +
+ (s->mb_height - edge_y - 1) * 2;
+ uint32_t mv = AV_RN32A(get_bmv_ptr(edge, vp7_mv_pred[i].subblock));
+ if (mv) {
+ if (AV_RN32A(&near_mv[CNT_NEAREST])) {
+ if (mv == AV_RN32A(&near_mv[CNT_NEAREST])) {
+ idx = CNT_NEAREST;
+ } else if (AV_RN32A(&near_mv[CNT_NEAR])) {
+ if (mv != AV_RN32A(&near_mv[CNT_NEAR]))
+ continue;
+ idx = CNT_NEAR;
+ } else {
+ AV_WN32A(&near_mv[CNT_NEAR], mv);
+ idx = CNT_NEAR;
+ }
+ } else {
+ AV_WN32A(&near_mv[CNT_NEAREST], mv);
+ idx = CNT_NEAREST;
+ }
+ } else {
+ idx = CNT_ZERO;
+ }
+ } else {
+ idx = CNT_ZERO;
+ }
+ cnt[idx] += vp7_mv_pred[i].score;
+ }
+
+ mb->partitioning = VP8_SPLITMVMODE_NONE;
+
+ if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_ZERO]][0])) {
+ mb->mode = VP8_MVMODE_MV;
+
+ if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAREST]][1])) {
+
+ if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][2])) {
+
+ if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
+ AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 : AV_RN32A(&near_mv[CNT_NEAREST]));
+ else
+ AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAR] ? 0 : AV_RN32A(&near_mv[CNT_NEAR]));
+
+ if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][3])) {
+ mb->mode = VP8_MVMODE_SPLIT;
+ mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP7) - 1];
+ } else {
+ mb->mv.y += vp7_read_mv_component(c, s->prob->mvc[0]);
+ mb->mv.x += vp7_read_mv_component(c, s->prob->mvc[1]);
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ mb->mv = near_mv[CNT_NEAR];
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ mb->mv = near_mv[CNT_NEAREST];
+ mb->bmv[0] = mb->mv;
+ }
+ } else {
+ mb->mode = VP8_MVMODE_ZERO;
+ AV_ZERO32(&mb->mv);
+ mb->bmv[0] = mb->mv;
+ }
+}
+
+static av_always_inline
+void vp8_decode_mvs(VP8Context *s, VP8Macroblock *mb,
+ int mb_x, int mb_y, int layout)
+{
+ VP8Macroblock *mb_edge[3] = { 0 /* top */,
mb - 1 /* left */,
- 0 /* top-left */ };
+ 0 /* top-left */ };
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
int idx = CNT_ZERO;
@@ -577,10 +1023,9 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout
if (!layout) { // layout is inlined (s->mb_layout is not)
mb_edge[0] = mb + 2;
mb_edge[2] = mb + 1;
- }
- else {
- mb_edge[0] = mb - s->mb_width-1;
- mb_edge[2] = mb - s->mb_width-2;
+ } else {
+ mb_edge[0] = mb - s->mb_width - 1;
+ mb_edge[2] = mb - s->mb_width - 2;
}
AV_ZERO32(&near_mv[0]);
@@ -588,24 +1033,25 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout
AV_ZERO32(&near_mv[2]);
/* Process MB on top, left and top-left */
- #define MV_EDGE_CHECK(n)\
- {\
- VP8Macroblock *edge = mb_edge[n];\
- int edge_ref = edge->ref_frame;\
- if (edge_ref != VP56_FRAME_CURRENT) {\
- uint32_t mv = AV_RN32A(&edge->mv);\
- if (mv) {\
- if (cur_sign_bias != sign_bias[edge_ref]) {\
- /* SWAR negate of the values in mv. */\
- mv = ~mv;\
- mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
- }\
- if (!n || mv != AV_RN32A(&near_mv[idx]))\
- AV_WN32A(&near_mv[++idx], mv);\
- cnt[idx] += 1 + (n != 2);\
- } else\
- cnt[CNT_ZERO] += 1 + (n != 2);\
- }\
+#define MV_EDGE_CHECK(n) \
+ { \
+ VP8Macroblock *edge = mb_edge[n]; \
+ int edge_ref = edge->ref_frame; \
+ if (edge_ref != VP56_FRAME_CURRENT) { \
+ uint32_t mv = AV_RN32A(&edge->mv); \
+ if (mv) { \
+ if (cur_sign_bias != sign_bias[edge_ref]) { \
+ /* SWAR negate of the values in mv. */ \
+ mv = ~mv; \
+ mv = ((mv & 0x7fff7fff) + \
+ 0x00010001) ^ (mv & 0x80008000); \
+ } \
+ if (!n || mv != AV_RN32A(&near_mv[idx])) \
+ AV_WN32A(&near_mv[++idx], mv); \
+ cnt[idx] += 1 + (n != 2); \
+ } else \
+ cnt[CNT_ZERO] += 1 + (n != 2); \
+ } \
}
MV_EDGE_CHECK(0)
@@ -617,7 +1063,8 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout
mb->mode = VP8_MVMODE_MV;
/* If we have three distinct MVs, merge first and last if they're the same */
- if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
+ if (cnt[CNT_SPLITMV] &&
+ AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
/* Swap near and nearest if necessary */
@@ -628,7 +1075,6 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
-
/* Choose the best mv out of 0,0 and the nearest mv */
clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
@@ -637,10 +1083,10 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
mb->mode = VP8_MVMODE_SPLIT;
- mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout) - 1];
+ mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP8) - 1];
} else {
- mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
- mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
+ mb->mv.y += vp8_read_mv_component(c, s->prob->mvc[0]);
+ mb->mv.x += vp8_read_mv_component(c, s->prob->mvc[1]);
mb->bmv[0] = mb->mv;
}
} else {
@@ -664,41 +1110,59 @@ void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
{
uint8_t *intra4x4 = mb->intra4x4_pred_mode_mb;
- if (layout == 1) {
+ if (layout) {
VP8Macroblock *mb_top = mb - s->mb_width - 1;
memcpy(mb->intra4x4_pred_mode_top, mb_top->intra4x4_pred_mode_top, 4);
}
if (keyframe) {
int x, y;
- uint8_t* top;
- uint8_t* const left = s->intra4x4_pred_mode_left;
- if (layout == 1)
+ uint8_t *top;
+ uint8_t *const left = s->intra4x4_pred_mode_left;
+ if (layout)
top = mb->intra4x4_pred_mode_top;
else
top = s->intra4x4_pred_mode_top + 4 * mb_x;
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
const uint8_t *ctx;
- ctx = vp8_pred4x4_prob_intra[top[x]][left[y]];
+ ctx = vp8_pred4x4_prob_intra[top[x]][left[y]];
*intra4x4 = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
- left[y] = top[x] = *intra4x4;
+ left[y] = top[x] = *intra4x4;
intra4x4++;
}
}
} else {
int i;
for (i = 0; i < 16; i++)
- intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree, vp8_pred4x4_prob_inter);
+ intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree,
+ vp8_pred4x4_prob_inter);
}
}
static av_always_inline
void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
- uint8_t *segment, uint8_t *ref, int layout)
+ uint8_t *segment, uint8_t *ref, int layout, int is_vp7)
{
VP56RangeCoder *c = &s->c;
-
- if (s->segmentation.update_map) {
+ const char *vp7_feature_name[] = { "q-index",
+ "lf-delta",
+ "partial-golden-update",
+ "blit-pitch" };
+ if (is_vp7) {
+ int i;
+ *segment = 0;
+ for (i = 0; i < 4; i++) {
+ if (s->feature_enabled[i]) {
+ if (vp56_rac_get_prob_branchy(c, s->feature_present_prob[i])) {
+ int index = vp8_rac_get_tree(c, vp7_feature_index_tree,
+ s->feature_index_prob[i]);
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Feature %s present in macroblock (value 0x%x)\n",
+ vp7_feature_name[i], s->feature_value[i][index]);
+ }
+ }
+ }
+ } else if (s->segmentation.update_map) {
int bit = vp56_rac_get_prob(c, s->prob->segmentid[0]);
*segment = vp56_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit;
} else if (s->segmentation.enabled)
@@ -708,32 +1172,39 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0;
if (s->keyframe) {
- mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra, vp8_pred16x16_prob_intra);
+ mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra,
+ vp8_pred16x16_prob_intra);
if (mb->mode == MODE_I4x4) {
decode_intra4x4_modes(s, c, mb, mb_x, 1, layout);
} else {
- const uint32_t modes = vp8_pred4x4_mode[mb->mode] * 0x01010101u;
- if (s->mb_layout == 1)
+ const uint32_t modes = (is_vp7 ? vp7_pred4x4_mode
+ : vp8_pred4x4_mode)[mb->mode] * 0x01010101u;
+ if (s->mb_layout)
AV_WN32A(mb->intra4x4_pred_mode_top, modes);
else
AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);
- AV_WN32A( s->intra4x4_pred_mode_left, modes);
+ AV_WN32A(s->intra4x4_pred_mode_left, modes);
}
- mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, vp8_pred8x8c_prob_intra);
- mb->ref_frame = VP56_FRAME_CURRENT;
+ mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
+ vp8_pred8x8c_prob_intra);
+ mb->ref_frame = VP56_FRAME_CURRENT;
} else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {
// inter MB, 16.2
if (vp56_rac_get_prob_branchy(c, s->prob->last))
- mb->ref_frame = vp56_rac_get_prob(c, s->prob->golden) ?
- VP56_FRAME_GOLDEN2 /* altref */ : VP56_FRAME_GOLDEN;
+ mb->ref_frame =
+ (!is_vp7 && vp56_rac_get_prob(c, s->prob->golden)) ? VP56_FRAME_GOLDEN2 /* altref */
+ : VP56_FRAME_GOLDEN;
else
mb->ref_frame = VP56_FRAME_PREVIOUS;
- s->ref_count[mb->ref_frame-1]++;
+ s->ref_count[mb->ref_frame - 1]++;
// motion vectors, 16.3
- decode_mvs(s, mb, mb_x, mb_y, layout);
+ if (is_vp7)
+ vp7_decode_mvs(s, mb, mb_x, mb_y, layout);
+ else
+ vp8_decode_mvs(s, mb, mb_x, mb_y, layout);
} else {
// intra MB, 16.1
mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);
@@ -741,31 +1212,35 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
if (mb->mode == MODE_I4x4)
decode_intra4x4_modes(s, c, mb, mb_x, 0, layout);
- mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c);
- mb->ref_frame = VP56_FRAME_CURRENT;
- mb->partitioning = VP8_SPLITMVMODE_NONE;
+ mb->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree,
+ s->prob->pred8x8c);
+ mb->ref_frame = VP56_FRAME_CURRENT;
+ mb->partitioning = VP8_SPLITMVMODE_NONE;
AV_ZERO32(&mb->bmv[0]);
}
}
-#ifndef decode_block_coeffs_internal
/**
- * @param r arithmetic bitstream reader context
+ * @param r arithmetic bitstream reader context
* @param block destination for block coefficients
* @param probs probabilities to use when reading trees from the bitstream
- * @param i initial coeff index, 0 unless a separate DC block is coded
- * @param qmul array holding the dc/ac dequant factor at position 0/1
+ * @param i initial coeff index, 0 unless a separate DC block is coded
+ * @param qmul array holding the dc/ac dequant factor at position 0/1
+ *
* @return 0 if no coeffs were decoded
* otherwise, the index of the last coeff decoded plus one
*/
-static int decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16],
- uint8_t probs[16][3][NUM_DCT_TOKENS-1],
- int i, uint8_t *token_prob, int16_t qmul[2])
+static av_always_inline
+int decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16],
+ uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
+ int i, uint8_t *token_prob, int16_t qmul[2],
+ const uint8_t scan[16], int vp7)
{
VP56RangeCoder c = *r;
goto skip_eob;
do {
int coeff;
+restart:
if (!vp56_rac_get_prob_branchy(&c, token_prob[0])) // DCT_EOB
break;
@@ -774,12 +1249,14 @@ skip_eob:
if (++i == 16)
break; // invalid input; blocks should end with EOB
token_prob = probs[i][0];
+ if (vp7)
+ goto restart;
goto skip_eob;
}
if (!vp56_rac_get_prob_branchy(&c, token_prob[2])) { // DCT_1
coeff = 1;
- token_prob = probs[i+1][1];
+ token_prob = probs[i + 1][1];
} else {
if (!vp56_rac_get_prob_branchy(&c, token_prob[3])) { // DCT 2,3,4
coeff = vp56_rac_get_prob_branchy(&c, token_prob[4]);
@@ -790,87 +1267,150 @@ skip_eob:
// DCT_CAT*
if (!vp56_rac_get_prob_branchy(&c, token_prob[6])) {
if (!vp56_rac_get_prob_branchy(&c, token_prob[7])) { // DCT_CAT1
- coeff = 5 + vp56_rac_get_prob(&c, vp8_dct_cat1_prob[0]);
+ coeff = 5 + vp56_rac_get_prob(&c, vp8_dct_cat1_prob[0]);
} else { // DCT_CAT2
coeff = 7;
coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[0]) << 1;
coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[1]);
}
} else { // DCT_CAT3 and up
- int a = vp56_rac_get_prob(&c, token_prob[8]);
- int b = vp56_rac_get_prob(&c, token_prob[9+a]);
- int cat = (a<<1) + b;
- coeff = 3 + (8<<cat);
+ int a = vp56_rac_get_prob(&c, token_prob[8]);
+ int b = vp56_rac_get_prob(&c, token_prob[9 + a]);
+ int cat = (a << 1) + b;
+ coeff = 3 + (8 << cat);
coeff += vp8_rac_get_coeff(&c, ff_vp8_dct_cat_prob[cat]);
}
}
- token_prob = probs[i+1][2];
+ token_prob = probs[i + 1][2];
}
- block[zigzag_scan[i]] = (vp8_rac_get(&c) ? -coeff : coeff) * qmul[!!i];
+ block[scan[i]] = (vp8_rac_get(&c) ? -coeff : coeff) * qmul[!!i];
} while (++i < 16);
*r = c;
return i;
}
+
+static av_always_inline
+int inter_predict_dc(int16_t block[16], int16_t pred[2])
+{
+ int16_t dc = block[0];
+ int ret = 0;
+
+ if (pred[1] > 3) {
+ dc += pred[0];
+ ret = 1;
+ }
+
+ if (!pred[0] | !dc | ((int32_t)pred[0] ^ (int32_t)dc) >> 31) {
+ block[0] = pred[0] = dc;
+ pred[1] = 0;
+ } else {
+ if (pred[0] == dc)
+ pred[1]++;
+ block[0] = pred[0] = dc;
+ }
+
+ return ret;
+}
+
+static int vp7_decode_block_coeffs_internal(VP56RangeCoder *r,
+ int16_t block[16],
+ uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
+ int i, uint8_t *token_prob,
+ int16_t qmul[2],
+ const uint8_t scan[16])
+{
+ return decode_block_coeffs_internal(r, block, probs, i,
+ token_prob, qmul, scan, IS_VP7);
+}
+
+#ifndef vp8_decode_block_coeffs_internal
+static int vp8_decode_block_coeffs_internal(VP56RangeCoder *r,
+ int16_t block[16],
+ uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
+ int i, uint8_t *token_prob,
+ int16_t qmul[2])
+{
+ return decode_block_coeffs_internal(r, block, probs, i,
+ token_prob, qmul, zigzag_scan, IS_VP8);
+}
#endif
/**
- * @param c arithmetic bitstream reader context
- * @param block destination for block coefficients
- * @param probs probabilities to use when reading trees from the bitstream
- * @param i initial coeff index, 0 unless a separate DC block is coded
+ * @param c arithmetic bitstream reader context
+ * @param block destination for block coefficients
+ * @param probs probabilities to use when reading trees from the bitstream
+ * @param i initial coeff index, 0 unless a separate DC block is coded
* @param zero_nhood the initial prediction context for number of surrounding
* all-zero blocks (only left/top, so 0-2)
- * @param qmul array holding the dc/ac dequant factor at position 0/1
+ * @param qmul array holding the dc/ac dequant factor at position 0/1
+ * @param scan scan pattern (VP7 only)
+ *
* @return 0 if no coeffs were decoded
* otherwise, the index of the last coeff decoded plus one
*/
static av_always_inline
int decode_block_coeffs(VP56RangeCoder *c, int16_t block[16],
- uint8_t probs[16][3][NUM_DCT_TOKENS-1],
- int i, int zero_nhood, int16_t qmul[2])
+ uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
+ int i, int zero_nhood, int16_t qmul[2],
+ const uint8_t scan[16], int vp7)
{
uint8_t *token_prob = probs[i][zero_nhood];
if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
return 0;
- return decode_block_coeffs_internal(c, block, probs, i, token_prob, qmul);
+ return vp7 ? vp7_decode_block_coeffs_internal(c, block, probs, i,
+ token_prob, qmul, scan)
+ : vp8_decode_block_coeffs_internal(c, block, probs, i,
+ token_prob, qmul);
}
static av_always_inline
-void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Macroblock *mb,
- uint8_t t_nnz[9], uint8_t l_nnz[9])
+void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c,
+ VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9],
+ int is_vp7)
{
int i, x, y, luma_start = 0, luma_ctx = 3;
int nnz_pred, nnz, nnz_total = 0;
int segment = mb->segment;
int block_dc = 0;
- if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
+ if (mb->mode != MODE_I4x4 && (is_vp7 || mb->mode != VP8_MVMODE_SPLIT)) {
nnz_pred = t_nnz[8] + l_nnz[8];
// decode DC values and do hadamard
- nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0, nnz_pred,
- s->qmat[segment].luma_dc_qmul);
+ nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0,
+ nnz_pred, s->qmat[segment].luma_dc_qmul,
+ zigzag_scan, is_vp7);
l_nnz[8] = t_nnz[8] = !!nnz;
+
+ if (is_vp7 && mb->mode > MODE_I4x4) {
+ nnz |= inter_predict_dc(td->block_dc,
+ s->inter_dc_pred[mb->ref_frame - 1]);
+ }
+
if (nnz) {
nnz_total += nnz;
- block_dc = 1;
+ block_dc = 1;
if (nnz == 1)
s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc);
else
s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc);
}
luma_start = 1;
- luma_ctx = 0;
+ luma_ctx = 0;
}
// luma blocks
for (y = 0; y < 4; y++)
for (x = 0; x < 4; x++) {
nnz_pred = l_nnz[y] + t_nnz[x];
- nnz = decode_block_coeffs(c, td->block[y][x], s->prob->token[luma_ctx], luma_start,
- nnz_pred, s->qmat[segment].luma_qmul);
- // nnz+block_dc may be one more than the actual last index, but we don't care
+ nnz = decode_block_coeffs(c, td->block[y][x],
+ s->prob->token[luma_ctx],
+ luma_start, nnz_pred,
+ s->qmat[segment].luma_qmul,
+ s->prob[0].scan, is_vp7);
+ /* nnz+block_dc may be one more than the actual last index,
+ * but we don't care */
td->non_zero_count_cache[y][x] = nnz + block_dc;
t_nnz[x] = l_nnz[y] = !!nnz;
nnz_total += nnz;
@@ -882,11 +1422,13 @@ void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Ma
for (i = 4; i < 6; i++)
for (y = 0; y < 2; y++)
for (x = 0; x < 2; x++) {
- nnz_pred = l_nnz[i+2*y] + t_nnz[i+2*x];
- nnz = decode_block_coeffs(c, td->block[i][(y<<1)+x], s->prob->token[2], 0,
- nnz_pred, s->qmat[segment].chroma_qmul);
- td->non_zero_count_cache[i][(y<<1)+x] = nnz;
- t_nnz[i+2*x] = l_nnz[i+2*y] = !!nnz;
+ nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];
+ nnz = decode_block_coeffs(c, td->block[i][(y << 1) + x],
+ s->prob->token[2], 0, nnz_pred,
+ s->qmat[segment].chroma_qmul,
+ s->prob[0].scan, is_vp7);
+ td->non_zero_count_cache[i][(y << 1) + x] = nnz;
+ t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;
nnz_total += nnz;
}
@@ -898,105 +1440,98 @@ void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Ma
}
static av_always_inline
-void backup_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr,
+void backup_mb_border(uint8_t *top_border, uint8_t *src_y,
+ uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize, int simple)
{
- AV_COPY128(top_border, src_y + 15*linesize);
+ AV_COPY128(top_border, src_y + 15 * linesize);
if (!simple) {
- AV_COPY64(top_border+16, src_cb + 7*uvlinesize);
- AV_COPY64(top_border+24, src_cr + 7*uvlinesize);
+ AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
+ AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
}
}
static av_always_inline
-void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr,
- int linesize, int uvlinesize, int mb_x, int mb_y, int mb_width,
- int simple, int xchg)
+void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb,
+ uint8_t *src_cr, int linesize, int uvlinesize, int mb_x,
+ int mb_y, int mb_width, int simple, int xchg)
{
- uint8_t *top_border_m1 = top_border-32; // for TL prediction
- src_y -= linesize;
+ uint8_t *top_border_m1 = top_border - 32; // for TL prediction
+ src_y -= linesize;
src_cb -= uvlinesize;
src_cr -= uvlinesize;
-#define XCHG(a,b,xchg) do { \
- if (xchg) AV_SWAP64(b,a); \
- else AV_COPY64(b,a); \
+#define XCHG(a, b, xchg) \
+ do { \
+ if (xchg) \
+ AV_SWAP64(b, a); \
+ else \
+ AV_COPY64(b, a); \
} while (0)
- XCHG(top_border_m1+8, src_y-8, xchg);
- XCHG(top_border, src_y, xchg);
- XCHG(top_border+8, src_y+8, 1);
- if (mb_x < mb_width-1)
- XCHG(top_border+32, src_y+16, 1);
+ XCHG(top_border_m1 + 8, src_y - 8, xchg);
+ XCHG(top_border, src_y, xchg);
+ XCHG(top_border + 8, src_y + 8, 1);
+ if (mb_x < mb_width - 1)
+ XCHG(top_border + 32, src_y + 16, 1);
// only copy chroma for normal loop filter
// or to initialize the top row to 127
if (!simple || !mb_y) {
- XCHG(top_border_m1+16, src_cb-8, xchg);
- XCHG(top_border_m1+24, src_cr-8, xchg);
- XCHG(top_border+16, src_cb, 1);
- XCHG(top_border+24, src_cr, 1);
+ XCHG(top_border_m1 + 16, src_cb - 8, xchg);
+ XCHG(top_border_m1 + 24, src_cr - 8, xchg);
+ XCHG(top_border + 16, src_cb, 1);
+ XCHG(top_border + 24, src_cr, 1);
}
}
static av_always_inline
int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
{
- if (!mb_x) {
+ if (!mb_x)
return mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
- } else {
+ else
return mb_y ? mode : LEFT_DC_PRED8x8;
- }
}
static av_always_inline
-int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)
+int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y, int vp7)
{
- if (!mb_x) {
- return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;
- } else {
+ if (!mb_x)
+ return mb_y ? VERT_PRED8x8 : (vp7 ? DC_128_PRED8x8 : DC_129_PRED8x8);
+ else
return mb_y ? mode : HOR_PRED8x8;
- }
}
static av_always_inline
-int check_intra_pred8x8_mode(int mode, int mb_x, int mb_y)
-{
- if (mode == DC_PRED8x8) {
- return check_dc_pred8x8_mode(mode, mb_x, mb_y);
- } else {
- return mode;
- }
-}
-
-static av_always_inline
-int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y)
+int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y, int vp7)
{
switch (mode) {
case DC_PRED8x8:
return check_dc_pred8x8_mode(mode, mb_x, mb_y);
case VERT_PRED8x8:
- return !mb_y ? DC_127_PRED8x8 : mode;
+ return !mb_y ? (vp7 ? DC_128_PRED8x8 : DC_127_PRED8x8) : mode;
case HOR_PRED8x8:
- return !mb_x ? DC_129_PRED8x8 : mode;
- case PLANE_PRED8x8 /*TM*/:
- return check_tm_pred8x8_mode(mode, mb_x, mb_y);
+ return !mb_x ? (vp7 ? DC_128_PRED8x8 : DC_129_PRED8x8) : mode;
+ case PLANE_PRED8x8: /* TM */
+ return check_tm_pred8x8_mode(mode, mb_x, mb_y, vp7);
}
return mode;
}
static av_always_inline
-int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y)
+int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y, int vp7)
{
if (!mb_x) {
- return mb_y ? VERT_VP8_PRED : DC_129_PRED;
+ return mb_y ? VERT_VP8_PRED : (vp7 ? DC_128_PRED : DC_129_PRED);
} else {
return mb_y ? mode : HOR_VP8_PRED;
}
}
static av_always_inline
-int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf)
+int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y,
+ int *copy_buf, int vp7)
{
switch (mode) {
case VERT_PRED:
@@ -1007,7 +1542,7 @@ int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf
/* fall-through */
case DIAG_DOWN_LEFT_PRED:
case VERT_LEFT_PRED:
- return !mb_y ? DC_127_PRED : mode;
+ return !mb_y ? (vp7 ? DC_128_PRED : DC_127_PRED) : mode;
case HOR_PRED:
if (!mb_y) {
*copy_buf = 1;
@@ -1015,10 +1550,11 @@ int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf
}
/* fall-through */
case HOR_UP_PRED:
- return !mb_x ? DC_129_PRED : mode;
+ return !mb_x ? (vp7 ? DC_128_PRED : DC_129_PRED) : mode;
case TM_VP8_PRED:
- return check_tm_pred4x4_mode(mode, mb_x, mb_y);
- case DC_PRED: // 4x4 DC doesn't use the same "H.264-style" exceptions as 16x16/8x8 DC
+ return check_tm_pred4x4_mode(mode, mb_x, mb_y, vp7);
+ case DC_PRED: /* 4x4 DC doesn't use the same "H.264-style" exceptions
+ * as 16x16/8x8 DC */
case DIAG_DOWN_RIGHT_PRED:
case VERT_RIGHT_PRED:
case HOR_DOWN_PRED:
@@ -1031,30 +1567,27 @@ int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf
static av_always_inline
void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
- VP8Macroblock *mb, int mb_x, int mb_y)
+ VP8Macroblock *mb, int mb_x, int mb_y, int is_vp7)
{
- AVCodecContext *avctx = s->avctx;
int x, y, mode, nnz;
uint32_t tr;
- // for the first row, we need to run xchg_mb_border to init the top edge to 127
- // otherwise, skip it if we aren't going to deblock
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
- xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
+ /* for the first row, we need to run xchg_mb_border to init the top edge
+ * to 127 otherwise, skip it if we aren't going to deblock */
+ if (mb_y && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
+ xchg_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 1);
if (mb->mode < MODE_I4x4) {
- if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // tested
- mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y);
- } else {
- mode = check_intra_pred8x8_mode(mb->mode, mb_x, mb_y);
- }
+ mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y, is_vp7);
s->hpc.pred16x16[mode](dst[0], s->linesize);
} else {
uint8_t *ptr = dst[0];
uint8_t *intra4x4 = mb->intra4x4_pred_mode_mb;
- uint8_t tr_top[4] = { 127, 127, 127, 127 };
+ const uint8_t lo = is_vp7 ? 128 : 127;
+ const uint8_t hi = is_vp7 ? 128 : 129;
+ uint8_t tr_top[4] = { lo, lo, lo, lo };
// all blocks on the right edge of the macroblock use bottom edge
// the top macroblock for their topright edge
@@ -1062,10 +1595,9 @@ void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
// if we're on the right edge of the frame, said edge is extended
// from the top macroblock
- if (!(!mb_y && avctx->flags & CODEC_FLAG_EMU_EDGE) &&
- mb_x == s->mb_width-1) {
- tr = tr_right[-1]*0x01010101u;
- tr_right = (uint8_t *)&tr;
+ if (mb_y && mb_x == s->mb_width - 1) {
+ tr = tr_right[-1] * 0x01010101u;
+ tr_right = (uint8_t *) &tr;
}
if (mb->skip)
@@ -1075,78 +1607,74 @@ void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
uint8_t *topright = ptr + 4 - s->linesize;
for (x = 0; x < 4; x++) {
int copy = 0, linesize = s->linesize;
- uint8_t *dst = ptr+4*x;
- DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
+ uint8_t *dst = ptr + 4 * x;
+ DECLARE_ALIGNED(4, uint8_t, copy_dst)[5 * 8];
- if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ if ((y == 0 || x == 3) && mb_y == 0) {
topright = tr_top;
} else if (x == 3)
topright = tr_right;
- if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // mb_x+x or mb_y+y is a hack but works
- mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x, mb_y + y, &copy);
- if (copy) {
- dst = copy_dst + 12;
- linesize = 8;
- if (!(mb_y + y)) {
- copy_dst[3] = 127U;
- AV_WN32A(copy_dst+4, 127U * 0x01010101U);
- } else {
- AV_COPY32(copy_dst+4, ptr+4*x-s->linesize);
- if (!(mb_x + x)) {
- copy_dst[3] = 129U;
- } else {
- copy_dst[3] = ptr[4*x-s->linesize-1];
- }
- }
+ mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x,
+ mb_y + y, &copy, is_vp7);
+ if (copy) {
+ dst = copy_dst + 12;
+ linesize = 8;
+ if (!(mb_y + y)) {
+ copy_dst[3] = lo;
+ AV_WN32A(copy_dst + 4, lo * 0x01010101U);
+ } else {
+ AV_COPY32(copy_dst + 4, ptr + 4 * x - s->linesize);
if (!(mb_x + x)) {
- copy_dst[11] =
- copy_dst[19] =
- copy_dst[27] =
- copy_dst[35] = 129U;
+ copy_dst[3] = hi;
} else {
- copy_dst[11] = ptr[4*x -1];
- copy_dst[19] = ptr[4*x+s->linesize -1];
- copy_dst[27] = ptr[4*x+s->linesize*2-1];
- copy_dst[35] = ptr[4*x+s->linesize*3-1];
+ copy_dst[3] = ptr[4 * x - s->linesize - 1];
}
}
- } else {
- mode = intra4x4[x];
+ if (!(mb_x + x)) {
+ copy_dst[11] =
+ copy_dst[19] =
+ copy_dst[27] =
+ copy_dst[35] = hi;
+ } else {
+ copy_dst[11] = ptr[4 * x - 1];
+ copy_dst[19] = ptr[4 * x + s->linesize - 1];
+ copy_dst[27] = ptr[4 * x + s->linesize * 2 - 1];
+ copy_dst[35] = ptr[4 * x + s->linesize * 3 - 1];
+ }
}
s->hpc.pred4x4[mode](dst, topright, linesize);
if (copy) {
- AV_COPY32(ptr+4*x , copy_dst+12);
- AV_COPY32(ptr+4*x+s->linesize , copy_dst+20);
- AV_COPY32(ptr+4*x+s->linesize*2, copy_dst+28);
- AV_COPY32(ptr+4*x+s->linesize*3, copy_dst+36);
+ AV_COPY32(ptr + 4 * x, copy_dst + 12);
+ AV_COPY32(ptr + 4 * x + s->linesize, copy_dst + 20);
+ AV_COPY32(ptr + 4 * x + s->linesize * 2, copy_dst + 28);
+ AV_COPY32(ptr + 4 * x + s->linesize * 3, copy_dst + 36);
}
nnz = td->non_zero_count_cache[y][x];
if (nnz) {
if (nnz == 1)
- s->vp8dsp.vp8_idct_dc_add(ptr+4*x, td->block[y][x], s->linesize);
+ s->vp8dsp.vp8_idct_dc_add(ptr + 4 * x,
+ td->block[y][x], s->linesize);
else
- s->vp8dsp.vp8_idct_add(ptr+4*x, td->block[y][x], s->linesize);
+ s->vp8dsp.vp8_idct_add(ptr + 4 * x,
+ td->block[y][x], s->linesize);
}
topright += 4;
}
- ptr += 4*s->linesize;
+ ptr += 4 * s->linesize;
intra4x4 += 4;
}
}
- if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
- mode = check_intra_pred8x8_mode_emuedge(mb->chroma_pred_mode, mb_x, mb_y);
- } else {
- mode = check_intra_pred8x8_mode(mb->chroma_pred_mode, mb_x, mb_y);
- }
+ mode = check_intra_pred8x8_mode_emuedge(mb->chroma_pred_mode,
+ mb_x, mb_y, is_vp7);
s->hpc.pred8x8[mode](dst[1], s->uvlinesize);
s->hpc.pred8x8[mode](dst[2], s->uvlinesize);
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
- xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
+ if (mb_y && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
+ xchg_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 0);
}
@@ -1161,18 +1689,18 @@ static const uint8_t subpel_idx[3][8] = {
/**
* luma MC function
*
- * @param s VP8 decoding context
- * @param dst target buffer for block data at block position
- * @param ref reference picture buffer at origin (0, 0)
- * @param mv motion vector (relative to block position) to get pixel data from
- * @param x_off horizontal position of block from origin (0, 0)
- * @param y_off vertical position of block from origin (0, 0)
- * @param block_w width of block (16, 8 or 4)
- * @param block_h height of block (always same as block_w)
- * @param width width of src/dst plane data
- * @param height height of src/dst plane data
+ * @param s VP8 decoding context
+ * @param dst target buffer for block data at block position
+ * @param ref reference picture buffer at origin (0, 0)
+ * @param mv motion vector (relative to block position) to get pixel data from
+ * @param x_off horizontal position of block from origin (0, 0)
+ * @param y_off vertical position of block from origin (0, 0)
+ * @param block_w width of block (16, 8 or 4)
+ * @param block_h height of block (always same as block_w)
+ * @param width width of src/dst plane data
+ * @param height height of src/dst plane data
* @param linesize size of a single line of plane data, including padding
- * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
+ * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
*/
static av_always_inline
void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
@@ -1185,8 +1713,9 @@ void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
if (AV_RN32A(mv)) {
int src_linesize = linesize;
- int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx];
- int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my];
+
+ int mx = (mv->x << 1) & 7, mx_idx = subpel_idx[0][mx];
+ int my = (mv->y << 1) & 7, my_idx = subpel_idx[0][my];
x_off += mv->x >> 2;
y_off += mv->y >> 2;
@@ -1198,48 +1727,51 @@ void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
src - my_idx * linesize - mx_idx,
- 32, linesize,
+ EDGE_EMU_LINESIZE, linesize,
block_w + subpel_idx[1][mx],
block_h + subpel_idx[1][my],
- x_off - mx_idx, y_off - my_idx, width, height);
- src = td->edge_emu_buffer + mx_idx + 32 * my_idx;
- src_linesize = 32;
+ x_off - mx_idx, y_off - my_idx,
+ width, height);
+ src = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
+ src_linesize = EDGE_EMU_LINESIZE;
}
mc_func[my_idx][mx_idx](dst, linesize, src, src_linesize, block_h, mx, my);
} else {
ff_thread_await_progress(ref, (3 + y_off + block_h) >> 4, 0);
- mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0);
+ mc_func[0][0](dst, linesize, src + y_off * linesize + x_off,
+ linesize, block_h, 0, 0);
}
}
/**
* chroma MC function
*
- * @param s VP8 decoding context
- * @param dst1 target buffer for block data at block position (U plane)
- * @param dst2 target buffer for block data at block position (V plane)
- * @param ref reference picture buffer at origin (0, 0)
- * @param mv motion vector (relative to block position) to get pixel data from
- * @param x_off horizontal position of block from origin (0, 0)
- * @param y_off vertical position of block from origin (0, 0)
- * @param block_w width of block (16, 8 or 4)
- * @param block_h height of block (always same as block_w)
- * @param width width of src/dst plane data
- * @param height height of src/dst plane data
+ * @param s VP8 decoding context
+ * @param dst1 target buffer for block data at block position (U plane)
+ * @param dst2 target buffer for block data at block position (V plane)
+ * @param ref reference picture buffer at origin (0, 0)
+ * @param mv motion vector (relative to block position) to get pixel data from
+ * @param x_off horizontal position of block from origin (0, 0)
+ * @param y_off vertical position of block from origin (0, 0)
+ * @param block_w width of block (16, 8 or 4)
+ * @param block_h height of block (always same as block_w)
+ * @param width width of src/dst plane data
+ * @param height height of src/dst plane data
* @param linesize size of a single line of plane data, including padding
- * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
+ * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
*/
static av_always_inline
-void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst2,
- ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off,
- int block_w, int block_h, int width, int height, ptrdiff_t linesize,
+void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1,
+ uint8_t *dst2, ThreadFrame *ref, const VP56mv *mv,
+ int x_off, int y_off, int block_w, int block_h,
+ int width, int height, ptrdiff_t linesize,
vp8_mc_func mc_func[3][3])
{
uint8_t *src1 = ref->f->data[1], *src2 = ref->f->data[2];
if (AV_RN32A(mv)) {
- int mx = mv->x&7, mx_idx = subpel_idx[0][mx];
- int my = mv->y&7, my_idx = subpel_idx[0][my];
+ int mx = mv->x & 7, mx_idx = subpel_idx[0][mx];
+ int my = mv->y & 7, my_idx = subpel_idx[0][my];
x_off += mv->x >> 3;
y_off += mv->y >> 3;
@@ -1252,21 +1784,21 @@ void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst
y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
src1 - my_idx * linesize - mx_idx,
- 32, linesize,
+ EDGE_EMU_LINESIZE, linesize,
block_w + subpel_idx[1][mx],
block_h + subpel_idx[1][my],
x_off - mx_idx, y_off - my_idx, width, height);
- src1 = td->edge_emu_buffer + mx_idx + 32 * my_idx;
- mc_func[my_idx][mx_idx](dst1, linesize, src1, 32, block_h, mx, my);
+ src1 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
+ mc_func[my_idx][mx_idx](dst1, linesize, src1, EDGE_EMU_LINESIZE, block_h, mx, my);
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
src2 - my_idx * linesize - mx_idx,
- 32, linesize,
+ EDGE_EMU_LINESIZE, linesize,
block_w + subpel_idx[1][mx],
block_h + subpel_idx[1][my],
x_off - mx_idx, y_off - my_idx, width, height);
- src2 = td->edge_emu_buffer + mx_idx + 32 * my_idx;
- mc_func[my_idx][mx_idx](dst2, linesize, src2, 32, block_h, mx, my);
+ src2 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
+ mc_func[my_idx][mx_idx](dst2, linesize, src2, EDGE_EMU_LINESIZE, block_h, mx, my);
} else {
mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
@@ -1281,8 +1813,7 @@ void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst
static av_always_inline
void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
ThreadFrame *ref_frame, int x_off, int y_off,
- int bx_off, int by_off,
- int block_w, int block_h,
+ int bx_off, int by_off, int block_w, int block_h,
int width, int height, VP56mv *mv)
{
VP56mv uvmv = *mv;
@@ -1295,13 +1826,19 @@ void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
/* U/V */
if (s->profile == 3) {
+ /* this block only applies VP8; it is safe to check
+ * only the profile, as VP7 profile <= 1 */
uvmv.x &= ~7;
uvmv.y &= ~7;
}
- x_off >>= 1; y_off >>= 1;
- bx_off >>= 1; by_off >>= 1;
- width >>= 1; height >>= 1;
- block_w >>= 1; block_h >>= 1;
+ x_off >>= 1;
+ y_off >>= 1;
+ bx_off >>= 1;
+ by_off >>= 1;
+ width >>= 1;
+ height >>= 1;
+ block_w >>= 1;
+ block_h >>= 1;
vp8_mc_chroma(s, td, dst[1] + by_off * s->uvlinesize + bx_off,
dst[2] + by_off * s->uvlinesize + bx_off, ref_frame,
&uvmv, x_off + bx_off, y_off + by_off,
@@ -1310,22 +1847,24 @@ void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
}
/* Fetch pixels for estimated mv 4 macroblocks ahead.
- * Optimized for 64-byte cache lines. Inspired by ffh264 prefetch_motion. */
-static av_always_inline void prefetch_motion(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int mb_xy, int ref)
+ * Optimized for 64-byte cache lines. Inspired by ffh264 prefetch_motion. */
+static av_always_inline
+void prefetch_motion(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
+ int mb_xy, int ref)
{
/* Don't prefetch refs that haven't been used very often this frame. */
- if (s->ref_count[ref-1] > (mb_xy >> 5)) {
+ if (s->ref_count[ref - 1] > (mb_xy >> 5)) {
int x_off = mb_x << 4, y_off = mb_y << 4;
- int mx = (mb->mv.x>>2) + x_off + 8;
- int my = (mb->mv.y>>2) + y_off;
- uint8_t **src= s->framep[ref]->tf.f->data;
- int off= mx + (my + (mb_x&3)*4)*s->linesize + 64;
+ int mx = (mb->mv.x >> 2) + x_off + 8;
+ int my = (mb->mv.y >> 2) + y_off;
+ uint8_t **src = s->framep[ref]->tf.f->data;
+ int off = mx + (my + (mb_x & 3) * 4) * s->linesize + 64;
/* For threading, a ff_thread_await_progress here might be useful, but
* it actually slows down the decoder. Since a bad prefetch doesn't
* generate bad decoder output, we don't run it here. */
- s->vdsp.prefetch(src[0]+off, s->linesize, 4);
- off= (mx>>1) + ((my>>1) + (mb_x&7))*s->uvlinesize + 64;
- s->vdsp.prefetch(src[1]+off, src[2]-src[1], 2);
+ s->vdsp.prefetch(src[0] + off, s->linesize, 4);
+ off = (mx >> 1) + ((my >> 1) + (mb_x & 7)) * s->uvlinesize + 64;
+ s->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
}
}
@@ -1337,7 +1876,7 @@ void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
VP8Macroblock *mb, int mb_x, int mb_y)
{
int x_off = mb_x << 4, y_off = mb_y << 4;
- int width = 16*s->mb_width, height = 16*s->mb_height;
+ int width = 16 * s->mb_width, height = 16 * s->mb_height;
ThreadFrame *ref = &s->framep[mb->ref_frame]->tf;
VP56mv *bmv = mb->bmv;
@@ -1353,35 +1892,38 @@ void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
/* Y */
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
- vp8_mc_luma(s, td, dst[0] + 4*y*s->linesize + x*4,
- ref, &bmv[4*y + x],
- 4*x + x_off, 4*y + y_off, 4, 4,
+ vp8_mc_luma(s, td, dst[0] + 4 * y * s->linesize + x * 4,
+ ref, &bmv[4 * y + x],
+ 4 * x + x_off, 4 * y + y_off, 4, 4,
width, height, s->linesize,
s->put_pixels_tab[2]);
}
}
/* U/V */
- x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1;
+ x_off >>= 1;
+ y_off >>= 1;
+ width >>= 1;
+ height >>= 1;
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
- uvmv.x = mb->bmv[ 2*y * 4 + 2*x ].x +
- mb->bmv[ 2*y * 4 + 2*x+1].x +
- mb->bmv[(2*y+1) * 4 + 2*x ].x +
- mb->bmv[(2*y+1) * 4 + 2*x+1].x;
- uvmv.y = mb->bmv[ 2*y * 4 + 2*x ].y +
- mb->bmv[ 2*y * 4 + 2*x+1].y +
- mb->bmv[(2*y+1) * 4 + 2*x ].y +
- mb->bmv[(2*y+1) * 4 + 2*x+1].y;
- uvmv.x = (uvmv.x + 2 + (uvmv.x >> (INT_BIT-1))) >> 2;
- uvmv.y = (uvmv.y + 2 + (uvmv.y >> (INT_BIT-1))) >> 2;
+ uvmv.x = mb->bmv[2 * y * 4 + 2 * x ].x +
+ mb->bmv[2 * y * 4 + 2 * x + 1].x +
+ mb->bmv[(2 * y + 1) * 4 + 2 * x ].x +
+ mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].x;
+ uvmv.y = mb->bmv[2 * y * 4 + 2 * x ].y +
+ mb->bmv[2 * y * 4 + 2 * x + 1].y +
+ mb->bmv[(2 * y + 1) * 4 + 2 * x ].y +
+ mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].y;
+ uvmv.x = (uvmv.x + 2 + (uvmv.x >> (INT_BIT - 1))) >> 2;
+ uvmv.y = (uvmv.y + 2 + (uvmv.y >> (INT_BIT - 1))) >> 2;
if (s->profile == 3) {
uvmv.x &= ~7;
uvmv.y &= ~7;
}
- vp8_mc_chroma(s, td, dst[1] + 4*y*s->uvlinesize + x*4,
- dst[2] + 4*y*s->uvlinesize + x*4, ref, &uvmv,
- 4*x + x_off, 4*y + y_off, 4, 4,
+ vp8_mc_chroma(s, td, dst[1] + 4 * y * s->uvlinesize + x * 4,
+ dst[2] + 4 * y * s->uvlinesize + x * 4, ref,
+ &uvmv, 4 * x + x_off, 4 * y + y_off, 4, 4,
width, height, s->uvlinesize,
s->put_pixels_tab[2]);
}
@@ -1413,8 +1955,8 @@ void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
}
}
-static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td,
- uint8_t *dst[3], VP8Macroblock *mb)
+static av_always_inline
+void idct_mb(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb)
{
int x, y, ch;
@@ -1423,12 +1965,16 @@ static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td,
for (y = 0; y < 4; y++) {
uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[y]);
if (nnz4) {
- if (nnz4&~0x01010101) {
+ if (nnz4 & ~0x01010101) {
for (x = 0; x < 4; x++) {
- if ((uint8_t)nnz4 == 1)
- s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, td->block[y][x], s->linesize);
- else if((uint8_t)nnz4 > 1)
- s->vp8dsp.vp8_idct_add(y_dst+4*x, td->block[y][x], s->linesize);
+ if ((uint8_t) nnz4 == 1)
+ s->vp8dsp.vp8_idct_dc_add(y_dst + 4 * x,
+ td->block[y][x],
+ s->linesize);
+ else if ((uint8_t) nnz4 > 1)
+ s->vp8dsp.vp8_idct_add(y_dst + 4 * x,
+ td->block[y][x],
+ s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
@@ -1437,36 +1983,43 @@ static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td,
s->vp8dsp.vp8_idct_dc_add4y(y_dst, td->block[y], s->linesize);
}
}
- y_dst += 4*s->linesize;
+ y_dst += 4 * s->linesize;
}
}
for (ch = 0; ch < 2; ch++) {
- uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[4+ch]);
+ uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[4 + ch]);
if (nnz4) {
- uint8_t *ch_dst = dst[1+ch];
- if (nnz4&~0x01010101) {
+ uint8_t *ch_dst = dst[1 + ch];
+ if (nnz4 & ~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
- if ((uint8_t)nnz4 == 1)
- s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, td->block[4+ch][(y<<1)+x], s->uvlinesize);
- else if((uint8_t)nnz4 > 1)
- s->vp8dsp.vp8_idct_add(ch_dst+4*x, td->block[4+ch][(y<<1)+x], s->uvlinesize);
+ if ((uint8_t) nnz4 == 1)
+ s->vp8dsp.vp8_idct_dc_add(ch_dst + 4 * x,
+ td->block[4 + ch][(y << 1) + x],
+ s->uvlinesize);
+ else if ((uint8_t) nnz4 > 1)
+ s->vp8dsp.vp8_idct_add(ch_dst + 4 * x,
+ td->block[4 + ch][(y << 1) + x],
+ s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
goto chroma_idct_end;
}
- ch_dst += 4*s->uvlinesize;
+ ch_dst += 4 * s->uvlinesize;
}
} else {
- s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, td->block[4+ch], s->uvlinesize);
+ s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, td->block[4 + ch], s->uvlinesize);
}
}
-chroma_idct_end: ;
+chroma_idct_end:
+ ;
}
}
-static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
+static av_always_inline
+void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb,
+ VP8FilterStrength *f, int is_vp7)
{
int interior_limit, filter_level;
@@ -1493,12 +2046,15 @@ static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *m
f->filter_level = filter_level;
f->inner_limit = interior_limit;
- f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
+ f->inner_filter = is_vp7 || !mb->skip || mb->mode == MODE_I4x4 ||
+ mb->mode == VP8_MVMODE_SPLIT;
}
-static av_always_inline void filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f, int mb_x, int mb_y)
+static av_always_inline
+void filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f,
+ int mb_x, int mb_y, int is_vp7)
{
- int mbedge_lim, bedge_lim, hev_thresh;
+ int mbedge_lim, bedge_lim_y, bedge_lim_uv, hev_thresh;
int filter_level = f->filter_level;
int inner_limit = f->inner_limit;
int inner_filter = f->inner_filter;
@@ -1518,88 +2074,106 @@ static av_always_inline void filter_mb(VP8Context *s, uint8_t *dst[3], VP8Filter
if (!filter_level)
return;
- bedge_lim = 2*filter_level + inner_limit;
- mbedge_lim = bedge_lim + 4;
+ if (is_vp7) {
+ bedge_lim_y = filter_level;
+ bedge_lim_uv = filter_level * 2;
+ mbedge_lim = filter_level + 2;
+ } else {
+ bedge_lim_y =
+ bedge_lim_uv = filter_level * 2 + inner_limit;
+ mbedge_lim = bedge_lim_y + 4;
+ }
hev_thresh = hev_thresh_lut[s->keyframe][filter_level];
if (mb_x) {
- s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
+ s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
mbedge_lim, inner_limit, hev_thresh);
- s->vp8dsp.vp8_h_loop_filter8uv(dst[1], dst[2], uvlinesize,
+ s->vp8dsp.vp8_h_loop_filter8uv(dst[1], dst[2], uvlinesize,
mbedge_lim, inner_limit, hev_thresh);
}
- if (inner_filter) {
- s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+ 4, linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+ 8, linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+12, linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4,
- uvlinesize, bedge_lim,
- inner_limit, hev_thresh);
+#define H_LOOP_FILTER_16Y_INNER(cond) \
+ if (cond && inner_filter) { \
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, \
+ bedge_lim_y, inner_limit, \
+ hev_thresh); \
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, \
+ bedge_lim_y, inner_limit, \
+ hev_thresh); \
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, \
+ bedge_lim_y, inner_limit, \
+ hev_thresh); \
+ s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4, \
+ uvlinesize, bedge_lim_uv, \
+ inner_limit, hev_thresh); \
}
+ H_LOOP_FILTER_16Y_INNER(!is_vp7)
+
if (mb_y) {
- s->vp8dsp.vp8_v_loop_filter16y(dst[0], linesize,
+ s->vp8dsp.vp8_v_loop_filter16y(dst[0], linesize,
mbedge_lim, inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter8uv(dst[1], dst[2], uvlinesize,
+ s->vp8dsp.vp8_v_loop_filter8uv(dst[1], dst[2], uvlinesize,
mbedge_lim, inner_limit, hev_thresh);
}
if (inner_filter) {
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 4*linesize,
- linesize, bedge_lim,
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 4 * linesize,
+ linesize, bedge_lim_y,
inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 8*linesize,
- linesize, bedge_lim,
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 8 * linesize,
+ linesize, bedge_lim_y,
inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+12*linesize,
- linesize, bedge_lim,
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 12 * linesize,
+ linesize, bedge_lim_y,
inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
- dst[2] + 4 * uvlinesize,
- uvlinesize, bedge_lim,
+ s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
+ dst[2] + 4 * uvlinesize,
+ uvlinesize, bedge_lim_uv,
inner_limit, hev_thresh);
}
+
+ H_LOOP_FILTER_16Y_INNER(is_vp7)
}
-static av_always_inline void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f, int mb_x, int mb_y)
+static av_always_inline
+void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f,
+ int mb_x, int mb_y)
{
int mbedge_lim, bedge_lim;
int filter_level = f->filter_level;
- int inner_limit = f->inner_limit;
+ int inner_limit = f->inner_limit;
int inner_filter = f->inner_filter;
- int linesize = s->linesize;
+ int linesize = s->linesize;
if (!filter_level)
return;
- bedge_lim = 2*filter_level + inner_limit;
+ bedge_lim = 2 * filter_level + inner_limit;
mbedge_lim = bedge_lim + 4;
if (mb_x)
s->vp8dsp.vp8_h_loop_filter_simple(dst, linesize, mbedge_lim);
if (inner_filter) {
- s->vp8dsp.vp8_h_loop_filter_simple(dst+ 4, linesize, bedge_lim);
- s->vp8dsp.vp8_h_loop_filter_simple(dst+ 8, linesize, bedge_lim);
- s->vp8dsp.vp8_h_loop_filter_simple(dst+12, linesize, bedge_lim);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst + 4, linesize, bedge_lim);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst + 8, linesize, bedge_lim);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst + 12, linesize, bedge_lim);
}
if (mb_y)
s->vp8dsp.vp8_v_loop_filter_simple(dst, linesize, mbedge_lim);
if (inner_filter) {
- s->vp8dsp.vp8_v_loop_filter_simple(dst+ 4*linesize, linesize, bedge_lim);
- s->vp8dsp.vp8_v_loop_filter_simple(dst+ 8*linesize, linesize, bedge_lim);
- s->vp8dsp.vp8_v_loop_filter_simple(dst+12*linesize, linesize, bedge_lim);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst + 4 * linesize, linesize, bedge_lim);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst + 8 * linesize, linesize, bedge_lim);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst + 12 * linesize, linesize, bedge_lim);
}
}
#define MARGIN (16 << 2)
-static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
- VP8Frame *prev_frame)
+static av_always_inline
+void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
+ VP8Frame *prev_frame, int is_vp7)
{
VP8Context *s = avctx->priv_data;
int mb_x, mb_y;
@@ -1607,19 +2181,21 @@ static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- VP8Macroblock *mb = s->macroblocks_base + ((s->mb_width+1)*(mb_y + 1) + 1);
- int mb_xy = mb_y*s->mb_width;
+ VP8Macroblock *mb = s->macroblocks_base +
+ ((s->mb_width + 1) * (mb_y + 1) + 1);
+ int mb_xy = mb_y * s->mb_width;
- AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101);
+ AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
if (mb_y == 0)
- AV_WN32A((mb-s->mb_width-1)->intra4x4_pred_mode_top, DC_PRED*0x01010101);
+ AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
+ DC_PRED * 0x01010101);
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
- prev_frame->seg_map->data + mb_xy : NULL, 1);
+ prev_frame->seg_map->data + mb_xy : NULL, 1, is_vp7);
s->mv_min.x -= 64;
s->mv_max.x -= 64;
}
@@ -1628,115 +2204,132 @@ static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
}
}
+static void vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
+ VP8Frame *prev_frame)
+{
+ vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP7);
+}
+
+static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
+ VP8Frame *prev_frame)
+{
+ vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP8);
+}
+
#if HAVE_THREADS
-#define check_thread_pos(td, otd, mb_x_check, mb_y_check)\
- do {\
- int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF);\
- if (otd->thread_mb_pos < tmp) {\
- pthread_mutex_lock(&otd->lock);\
- td->wait_mb_pos = tmp;\
- do {\
- if (otd->thread_mb_pos >= tmp)\
- break;\
- pthread_cond_wait(&otd->cond, &otd->lock);\
- } while (1);\
- td->wait_mb_pos = INT_MAX;\
- pthread_mutex_unlock(&otd->lock);\
- }\
- } while(0);
-
-#define update_pos(td, mb_y, mb_x)\
- do {\
- int pos = (mb_y << 16) | (mb_x & 0xFFFF);\
- int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && (num_jobs > 1);\
- int is_null = (next_td == NULL) || (prev_td == NULL);\
- int pos_check = (is_null) ? 1 :\
- (next_td != td && pos >= next_td->wait_mb_pos) ||\
- (prev_td != td && pos >= prev_td->wait_mb_pos);\
- td->thread_mb_pos = pos;\
- if (sliced_threading && pos_check) {\
- pthread_mutex_lock(&td->lock);\
- pthread_cond_broadcast(&td->cond);\
- pthread_mutex_unlock(&td->lock);\
- }\
- } while(0);
+#define check_thread_pos(td, otd, mb_x_check, mb_y_check) \
+ do { \
+ int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF); \
+ if (otd->thread_mb_pos < tmp) { \
+ pthread_mutex_lock(&otd->lock); \
+ td->wait_mb_pos = tmp; \
+ do { \
+ if (otd->thread_mb_pos >= tmp) \
+ break; \
+ pthread_cond_wait(&otd->cond, &otd->lock); \
+ } while (1); \
+ td->wait_mb_pos = INT_MAX; \
+ pthread_mutex_unlock(&otd->lock); \
+ } \
+ } while (0);
+
+#define update_pos(td, mb_y, mb_x) \
+ do { \
+ int pos = (mb_y << 16) | (mb_x & 0xFFFF); \
+ int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && \
+ (num_jobs > 1); \
+ int is_null = (next_td == NULL) || (prev_td == NULL); \
+ int pos_check = (is_null) ? 1 \
+ : (next_td != td && \
+ pos >= next_td->wait_mb_pos) || \
+ (prev_td != td && \
+ pos >= prev_td->wait_mb_pos); \
+ td->thread_mb_pos = pos; \
+ if (sliced_threading && pos_check) { \
+ pthread_mutex_lock(&td->lock); \
+ pthread_cond_broadcast(&td->cond); \
+ pthread_mutex_unlock(&td->lock); \
+ } \
+ } while (0);
#else
#define check_thread_pos(td, otd, mb_x_check, mb_y_check)
#define update_pos(td, mb_y, mb_x)
#endif
-static void vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
- int jobnr, int threadnr)
+static av_always_inline void decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr];
- int mb_y = td->thread_mb_pos>>16;
- int i, y, mb_x, mb_xy = mb_y*s->mb_width;
+ int mb_y = td->thread_mb_pos >> 16;
+ int mb_x, mb_xy = mb_y * s->mb_width;
int num_jobs = s->num_jobs;
VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame;
- VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)];
+ VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)];
VP8Macroblock *mb;
uint8_t *dst[3] = {
- curframe->tf.f->data[0] + 16*mb_y*s->linesize,
- curframe->tf.f->data[1] + 8*mb_y*s->uvlinesize,
- curframe->tf.f->data[2] + 8*mb_y*s->uvlinesize
+ curframe->tf.f->data[0] + 16 * mb_y * s->linesize,
+ curframe->tf.f->data[1] + 8 * mb_y * s->uvlinesize,
+ curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize
};
- if (mb_y == 0) prev_td = td;
- else prev_td = &s->thread_data[(jobnr + num_jobs - 1)%num_jobs];
- if (mb_y == s->mb_height-1) next_td = td;
- else next_td = &s->thread_data[(jobnr + 1)%num_jobs];
+ if (mb_y == 0)
+ prev_td = td;
+ else
+ prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
+ if (mb_y == s->mb_height - 1)
+ next_td = td;
+ else
+ next_td = &s->thread_data[(jobnr + 1) % num_jobs];
if (s->mb_layout == 1)
- mb = s->macroblocks_base + ((s->mb_width+1)*(mb_y + 1) + 1);
+ mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else {
// Make sure the previous frame has read its segmentation map,
// if we re-use the same map.
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, mb_y, 0);
- mb = s->macroblocks + (s->mb_height - mb_y - 1)*2;
+ mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
memset(mb - 1, 0, sizeof(*mb)); // zero left macroblock
- AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101);
+ AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
}
- memset(td->left_nnz, 0, sizeof(td->left_nnz));
- // left edge of 129 for intra prediction
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
- for (i = 0; i < 3; i++)
- for (y = 0; y < 16>>!!i; y++)
- dst[i][y*curframe->tf.f->linesize[i]-1] = 129;
- if (mb_y == 1) {
- s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
- }
- }
+ if (!is_vp7 || mb_y == 0)
+ memset(td->left_nnz, 0, sizeof(td->left_nnz));
s->mv_min.x = -MARGIN;
- s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
+ s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
// Wait for previous thread to read mb_x+2, and reach mb_y-1.
if (prev_td != td) {
if (threadnr != 0) {
- check_thread_pos(td, prev_td, mb_x+1, mb_y-1);
+ check_thread_pos(td, prev_td,
+ mb_x + (is_vp7 ? 2 : 1),
+ mb_y - (is_vp7 ? 2 : 1));
} else {
- check_thread_pos(td, prev_td, (s->mb_width+3) + (mb_x+1), mb_y-1);
+ check_thread_pos(td, prev_td,
+ mb_x + (is_vp7 ? 2 : 1) + s->mb_width + 3,
+ mb_y - (is_vp7 ? 2 : 1));
}
}
- s->vdsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
- s->vdsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2);
+ s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 * s->linesize + 64,
+ s->linesize, 4);
+ s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64,
+ dst[2] - dst[1], 2);
if (!s->mb_layout)
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
- prev_frame->seg_map->data + mb_xy : NULL, 0);
+ prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS);
if (!mb->skip)
- decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz);
+ decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz, is_vp7);
if (mb->mode <= MODE_I4x4)
- intra_predict(s, td, dst, mb, mb_x, mb_y);
+ intra_predict(s, td, dst, mb, mb_x, mb_y, is_vp7);
else
inter_predict(s, td, dst, mb, mb_x, mb_y);
@@ -1748,7 +2341,8 @@ static void vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
AV_ZERO64(td->left_nnz);
AV_WN64(s->top_nnz[mb_x], 0); // array of 9, so unaligned
- // Reset DC block predictors if they would exist if the mb had coefficients
+ /* Reset DC block predictors if they would exist
+ * if the mb had coefficients */
if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
td->left_nnz[8] = 0;
s->top_nnz[mb_x][8] = 0;
@@ -1756,100 +2350,134 @@ static void vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
}
if (s->deblock_filter)
- filter_level_for_mb(s, mb, &td->filter_strength[mb_x]);
+ filter_level_for_mb(s, mb, &td->filter_strength[mb_x], is_vp7);
- if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs-1) {
+ if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
if (s->filter.simple)
- backup_mb_border(s->top_border[mb_x+1], dst[0], NULL, NULL, s->linesize, 0, 1);
+ backup_mb_border(s->top_border[mb_x + 1], dst[0],
+ NULL, NULL, s->linesize, 0, 1);
else
- backup_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2], s->linesize, s->uvlinesize, 0);
+ backup_mb_border(s->top_border[mb_x + 1], dst[0],
+ dst[1], dst[2], s->linesize, s->uvlinesize, 0);
}
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2);
- dst[0] += 16;
- dst[1] += 8;
- dst[2] += 8;
+ dst[0] += 16;
+ dst[1] += 8;
+ dst[2] += 8;
s->mv_min.x -= 64;
s->mv_max.x -= 64;
- if (mb_x == s->mb_width+1) {
- update_pos(td, mb_y, s->mb_width+3);
+ if (mb_x == s->mb_width + 1) {
+ update_pos(td, mb_y, s->mb_width + 3);
} else {
update_pos(td, mb_y, mb_x);
}
}
}
-static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata,
- int jobnr, int threadnr)
+static void vp7_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 1);
+}
+
+static void vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 0);
+}
+
+static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *td = &s->thread_data[threadnr];
- int mb_x, mb_y = td->thread_mb_pos>>16, num_jobs = s->num_jobs;
+ int mb_x, mb_y = td->thread_mb_pos >> 16, num_jobs = s->num_jobs;
AVFrame *curframe = s->curframe->tf.f;
VP8Macroblock *mb;
VP8ThreadData *prev_td, *next_td;
uint8_t *dst[3] = {
- curframe->data[0] + 16*mb_y*s->linesize,
- curframe->data[1] + 8*mb_y*s->uvlinesize,
- curframe->data[2] + 8*mb_y*s->uvlinesize
+ curframe->data[0] + 16 * mb_y * s->linesize,
+ curframe->data[1] + 8 * mb_y * s->uvlinesize,
+ curframe->data[2] + 8 * mb_y * s->uvlinesize
};
if (s->mb_layout == 1)
- mb = s->macroblocks_base + ((s->mb_width+1)*(mb_y + 1) + 1);
+ mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else
- mb = s->macroblocks + (s->mb_height - mb_y - 1)*2;
+ mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
- if (mb_y == 0) prev_td = td;
- else prev_td = &s->thread_data[(jobnr + num_jobs - 1)%num_jobs];
- if (mb_y == s->mb_height-1) next_td = td;
- else next_td = &s->thread_data[(jobnr + 1)%num_jobs];
+ if (mb_y == 0)
+ prev_td = td;
+ else
+ prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
+ if (mb_y == s->mb_height - 1)
+ next_td = td;
+ else
+ next_td = &s->thread_data[(jobnr + 1) % num_jobs];
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb++) {
VP8FilterStrength *f = &td->filter_strength[mb_x];
- if (prev_td != td) {
- check_thread_pos(td, prev_td, (mb_x+1) + (s->mb_width+3), mb_y-1);
- }
+ if (prev_td != td)
+ check_thread_pos(td, prev_td,
+ (mb_x + 1) + (s->mb_width + 3), mb_y - 1);
if (next_td != td)
- if (next_td != &s->thread_data[0]) {
- check_thread_pos(td, next_td, mb_x+1, mb_y+1);
- }
+ if (next_td != &s->thread_data[0])
+ check_thread_pos(td, next_td, mb_x + 1, mb_y + 1);
if (num_jobs == 1) {
if (s->filter.simple)
- backup_mb_border(s->top_border[mb_x+1], dst[0], NULL, NULL, s->linesize, 0, 1);
+ backup_mb_border(s->top_border[mb_x + 1], dst[0],
+ NULL, NULL, s->linesize, 0, 1);
else
- backup_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2], s->linesize, s->uvlinesize, 0);
+ backup_mb_border(s->top_border[mb_x + 1], dst[0],
+ dst[1], dst[2], s->linesize, s->uvlinesize, 0);
}
if (s->filter.simple)
filter_mb_simple(s, dst[0], f, mb_x, mb_y);
else
- filter_mb(s, dst, f, mb_x, mb_y);
+ filter_mb(s, dst, f, mb_x, mb_y, is_vp7);
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
- update_pos(td, mb_y, (s->mb_width+3) + mb_x);
+ update_pos(td, mb_y, (s->mb_width + 3) + mb_x);
}
}
-static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata,
- int jobnr, int threadnr)
+static void vp7_filter_mb_row(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ filter_mb_row(avctx, tdata, jobnr, threadnr, 1);
+}
+
+static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ filter_mb_row(avctx, tdata, jobnr, threadnr, 0);
+}
+
+static av_always_inline
+int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr,
+ int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *td = &s->thread_data[jobnr];
VP8ThreadData *next_td = NULL, *prev_td = NULL;
VP8Frame *curframe = s->curframe;
int mb_y, num_jobs = s->num_jobs;
+
td->thread_nr = threadnr;
for (mb_y = jobnr; mb_y < s->mb_height; mb_y += num_jobs) {
- if (mb_y >= s->mb_height) break;
- td->thread_mb_pos = mb_y<<16;
- vp8_decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr);
+ if (mb_y >= s->mb_height)
+ break;
+ td->thread_mb_pos = mb_y << 16;
+ s->decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr);
if (s->deblock_filter)
- vp8_filter_mb_row(avctx, tdata, jobnr, threadnr);
+ s->filter_mb_row(avctx, tdata, jobnr, threadnr);
update_pos(td, mb_y, INT_MAX & 0xFFFF);
s->mv_min.y -= 64;
@@ -1862,24 +2490,44 @@ static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata,
return 0;
}
-int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
+static int vp7_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ return vp78_decode_mb_row_sliced(avctx, tdata, jobnr, threadnr, IS_VP7);
+}
+
+static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata,
+ int jobnr, int threadnr)
+{
+ return vp78_decode_mb_row_sliced(avctx, tdata, jobnr, threadnr, IS_VP8);
+}
+
+
+static av_always_inline
+int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+ AVPacket *avpkt, int is_vp7)
{
VP8Context *s = avctx->priv_data;
int ret, i, referenced, num_jobs;
enum AVDiscard skip_thresh;
VP8Frame *av_uninit(curframe), *prev_frame;
- if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)
+ if (is_vp7)
+ ret = vp7_decode_frame_header(s, avpkt->data, avpkt->size);
+ else
+ ret = vp8_decode_frame_header(s, avpkt->data, avpkt->size);
+
+ if (ret < 0)
goto err;
prev_frame = s->framep[VP56_FRAME_CURRENT];
- referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT
- || s->update_altref == VP56_FRAME_CURRENT;
+ referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT ||
+ s->update_altref == VP56_FRAME_CURRENT;
- skip_thresh = !referenced ? AVDISCARD_NONREF :
- !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL;
+ skip_thresh = !referenced ? AVDISCARD_NONREF
+ : !s->keyframe ? AVDISCARD_NONKEY
+ : AVDISCARD_ALL;
if (avctx->skip_frame >= skip_thresh) {
s->invisible = 1;
@@ -1893,88 +2541,75 @@ int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (s->frames[i].tf.f->data[0] &&
&s->frames[i] != prev_frame &&
&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
- &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
+ &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN2])
vp8_release_frame(s, &s->frames[i]);
- // find a free buffer
- for (i = 0; i < 5; i++)
- if (&s->frames[i] != prev_frame &&
- &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
- &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
- &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) {
- curframe = s->framep[VP56_FRAME_CURRENT] = &s->frames[i];
- break;
- }
- if (i == 5) {
- av_log(avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
- abort();
- }
- if (curframe->tf.f->data[0])
- vp8_release_frame(s, curframe);
+ curframe = s->framep[VP56_FRAME_CURRENT] = vp8_find_free_buffer(s);
- // Given that arithmetic probabilities are updated every frame, it's quite likely
- // that the values we have on a random interframe are complete junk if we didn't
- // start decode on a keyframe. So just don't display anything rather than junk.
+ /* Given that arithmetic probabilities are updated every frame, it's quite
+ * likely that the values we have on a random interframe are complete
+ * junk if we didn't start decode on a keyframe. So just don't display
+ * anything rather than junk. */
if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] ||
- !s->framep[VP56_FRAME_GOLDEN] ||
+ !s->framep[VP56_FRAME_GOLDEN] ||
!s->framep[VP56_FRAME_GOLDEN2])) {
- av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n");
+ av_log(avctx, AV_LOG_WARNING,
+ "Discarding interframe without a prior keyframe!\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
curframe->tf.f->key_frame = s->keyframe;
- curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+ curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
+ : AV_PICTURE_TYPE_P;
if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0)
goto err;
// check if golden and altref are swapped
- if (s->update_altref != VP56_FRAME_NONE) {
- s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref];
- } else {
- s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2];
- }
- if (s->update_golden != VP56_FRAME_NONE) {
- s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden];
- } else {
- s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN];
- }
- if (s->update_last) {
+ if (s->update_altref != VP56_FRAME_NONE)
+ s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref];
+ else
+ s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2];
+
+ if (s->update_golden != VP56_FRAME_NONE)
+ s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden];
+ else
+ s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN];
+
+ if (s->update_last)
s->next_framep[VP56_FRAME_PREVIOUS] = curframe;
- } else {
+ else
s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS];
- }
- s->next_framep[VP56_FRAME_CURRENT] = curframe;
+
+ s->next_framep[VP56_FRAME_CURRENT] = curframe;
ff_thread_finish_setup(avctx);
s->linesize = curframe->tf.f->linesize[0];
s->uvlinesize = curframe->tf.f->linesize[1];
- memset(s->top_nnz, 0, s->mb_width*sizeof(*s->top_nnz));
- /* Zero macroblock structures for top/top-left prediction from outside the frame. */
+ memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz));
+ /* Zero macroblock structures for top/top-left prediction
+ * from outside the frame. */
if (!s->mb_layout)
- memset(s->macroblocks + s->mb_height*2 - 1, 0, (s->mb_width+1)*sizeof(*s->macroblocks));
+ memset(s->macroblocks + s->mb_height * 2 - 1, 0,
+ (s->mb_width + 1) * sizeof(*s->macroblocks));
if (!s->mb_layout && s->keyframe)
- memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4);
+ memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);
- // top edge of 127 for intra prediction
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
- s->top_border[0][15] = s->top_border[0][23] = 127;
- s->top_border[0][31] = 127;
- memset(s->top_border[1], 127, s->mb_width*sizeof(*s->top_border));
- }
memset(s->ref_count, 0, sizeof(s->ref_count));
-
if (s->mb_layout == 1) {
// Make sure the previous frame has read its segmentation map,
// if we re-use the same map.
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, 1, 0);
- vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
+ if (is_vp7)
+ vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
+ else
+ vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
}
if (avctx->active_thread_type == FF_THREAD_FRAME)
@@ -1988,9 +2623,14 @@ int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (i = 0; i < MAX_THREADS; i++) {
s->thread_data[i].thread_mb_pos = 0;
- s->thread_data[i].wait_mb_pos = INT_MAX;
+ s->thread_data[i].wait_mb_pos = INT_MAX;
}
- avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL, num_jobs);
+ if (is_vp7)
+ avctx->execute2(avctx, vp7_decode_mb_row_sliced, s->thread_data, NULL,
+ num_jobs);
+ else
+ avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL,
+ num_jobs);
ff_thread_report_progress(&curframe->tf, INT_MAX, 0);
memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4);
@@ -2004,7 +2644,7 @@ skip_decode:
if (!s->invisible) {
if ((ret = av_frame_ref(data, curframe->tf.f)) < 0)
return ret;
- *got_frame = 1;
+ *got_frame = 1;
}
return avpkt->size;
@@ -2013,6 +2653,20 @@ err:
return ret;
}
+int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+ AVPacket *avpkt)
+{
+ return vp78_decode_frame(avctx, data, got_frame, avpkt, IS_VP8);
+}
+
+#if CONFIG_VP7_DECODER
+static int vp7_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+ AVPacket *avpkt)
+{
+ return vp78_decode_frame(avctx, data, got_frame, avpkt, IS_VP7);
+}
+#endif /* CONFIG_VP7_DECODER */
+
av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
{
VP8Context *s = avctx->priv_data;
@@ -2036,12 +2690,14 @@ static av_cold int vp8_init_frames(VP8Context *s)
return 0;
}
-av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
+static av_always_inline
+int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
{
VP8Context *s = avctx->priv_data;
int ret;
s->avctx = avctx;
+ s->vp7 = avctx->codec->id == AV_CODEC_ID_VP7;
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
avctx->internal->allocate_progress = 1;
@@ -2053,8 +2709,22 @@ av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
#endif
ff_videodsp_init(&s->vdsp, 8);
- ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP8, 8, 1);
- ff_vp8dsp_init(&s->vp8dsp);
+
+ ff_vp78dsp_init(&s->vp8dsp);
+ if (CONFIG_VP7_DECODER && is_vp7) {
+ ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP7, 8, 1);
+ ff_vp7dsp_init(&s->vp8dsp);
+ s->decode_mb_row_no_filter = vp7_decode_mb_row_no_filter;
+ s->filter_mb_row = vp7_filter_mb_row;
+ } else if (CONFIG_VP8_DECODER && !is_vp7) {
+ ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP8, 8, 1);
+ ff_vp8dsp_init(&s->vp8dsp);
+ s->decode_mb_row_no_filter = vp8_decode_mb_row_no_filter;
+ s->filter_mb_row = vp8_filter_mb_row;
+ }
+
+ /* does not change for VP8 */
+ memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan));
if ((ret = vp8_init_frames(s)) < 0) {
ff_vp8_decode_free(avctx);
@@ -2064,6 +2734,19 @@ av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
return 0;
}
+#if CONFIG_VP7_DECODER
+static int vp7_decode_init(AVCodecContext *avctx)
+{
+ return vp78_decode_init(avctx, IS_VP7);
+}
+#endif /* CONFIG_VP7_DECODER */
+
+av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
+{
+ return vp78_decode_init(avctx, IS_VP8);
+}
+
+#if CONFIG_VP8_DECODER
static av_cold int vp8_decode_init_thread_copy(AVCodecContext *avctx)
{
VP8Context *s = avctx->priv_data;
@@ -2079,10 +2762,10 @@ static av_cold int vp8_decode_init_thread_copy(AVCodecContext *avctx)
return 0;
}
-#define REBASE(pic) \
- pic ? pic - &s_src->frames[0] + &s->frames[0] : NULL
+#define REBASE(pic) pic ? pic - &s_src->frames[0] + &s->frames[0] : NULL
-static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
+static int vp8_decode_update_thread_context(AVCodecContext *dst,
+ const AVCodecContext *src)
{
VP8Context *s = dst->priv_data, *s_src = src->priv_data;
int i;
@@ -2094,9 +2777,9 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
s->mb_height = s_src->mb_height;
}
- s->prob[0] = s_src->prob[!s_src->update_probabilities];
+ s->prob[0] = s_src->prob[!s_src->update_probabilities];
s->segmentation = s_src->segmentation;
- s->lf_delta = s_src->lf_delta;
+ s->lf_delta = s_src->lf_delta;
memcpy(s->sign_bias, s_src->sign_bias, sizeof(s->sign_bias));
for (i = 0; i < FF_ARRAY_ELEMS(s_src->frames); i++) {
@@ -2114,7 +2797,24 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
return 0;
}
+#endif /* CONFIG_VP8_DECODER */
+#if CONFIG_VP7_DECODER
+AVCodec ff_vp7_decoder = {
+ .name = "vp7",
+ .long_name = NULL_IF_CONFIG_SMALL("On2 VP7"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_VP7,
+ .priv_data_size = sizeof(VP8Context),
+ .init = vp7_decode_init,
+ .close = ff_vp8_decode_free,
+ .decode = vp7_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .flush = vp8_decode_flush,
+};
+#endif /* CONFIG_VP7_DECODER */
+
+#if CONFIG_VP8_DECODER
AVCodec ff_vp8_decoder = {
.name = "vp8",
.long_name = NULL_IF_CONFIG_SMALL("On2 VP8"),
@@ -2129,4 +2829,4 @@ AVCodec ff_vp8_decoder = {
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),
};
-
+#endif /* CONFIG_VP7_DECODER */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8.h b/chromium/third_party/ffmpeg/libavcodec/vp8.h
index c9a7906df03..534c08160b9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8.h
@@ -28,16 +28,17 @@
#include "libavutil/buffer.h"
-#include "vp56.h"
-#include "vp8dsp.h"
#include "h264pred.h"
#include "thread.h"
+#include "vp56.h"
+#include "vp8dsp.h"
+
#if HAVE_PTHREADS
-#include <pthread.h>
+# include <pthread.h>
#elif HAVE_OS2THREADS
-#include "compat/os2threads.h"
+# include "compat/os2threads.h"
#elif HAVE_W32THREADS
-#include "compat/w32pthreads.h"
+# include "compat/w32pthreads.h"
#endif
#define VP8_MAX_QUANT 127
@@ -84,7 +85,7 @@ typedef struct VP8FilterStrength {
typedef struct VP8Macroblock {
uint8_t skip;
- // todo: make it possible to check for at least (i4x4 or split_mv)
+ // TODO: make it possible to check for at least (i4x4 or split_mv)
// in one op. are others needed?
uint8_t mode;
uint8_t ref_frame;
@@ -92,7 +93,7 @@ typedef struct VP8Macroblock {
uint8_t chroma_pred_mode;
uint8_t segment;
uint8_t intra4x4_pred_mode_mb[16];
- uint8_t intra4x4_pred_mode_top[4];
+ DECLARE_ALIGNED(4, uint8_t, intra4x4_pred_mode_top)[4];
VP56mv mv;
VP56mv bmv[16];
} VP8Macroblock;
@@ -118,11 +119,13 @@ typedef struct VP8ThreadData {
int thread_nr;
#if HAVE_THREADS
pthread_mutex_t lock;
- pthread_cond_t cond;
+ pthread_cond_t cond;
#endif
int thread_mb_pos; // (mb_y << 16) | (mb_x & 0xFFFF)
int wait_mb_pos; // What the current thread is waiting on.
- DECLARE_ALIGNED(16, uint8_t, edge_emu_buffer)[21*32];
+
+#define EDGE_EMU_LINESIZE 32
+ DECLARE_ALIGNED(16, uint8_t, edge_emu_buffer)[21 * EDGE_EMU_LINESIZE];
VP8FilterStrength *filter_strength;
} VP8ThreadData;
@@ -203,7 +206,7 @@ typedef struct VP8Context {
* [7] - split mv
* i16x16 modes never have any adjustment
*/
- int8_t mode[VP8_MVMODE_SPLIT+1];
+ int8_t mode[VP8_MVMODE_SPLIT + 1];
/**
* filter strength adjustment for macroblocks that reference:
@@ -215,7 +218,7 @@ typedef struct VP8Context {
int8_t ref[4];
} lf_delta;
- uint8_t (*top_border)[16+8+8];
+ uint8_t (*top_border)[16 + 8 + 8];
uint8_t (*top_nnz)[9];
VP56RangeCoder c; ///< header context, includes mb modes and motion vectors
@@ -234,8 +237,9 @@ typedef struct VP8Context {
uint8_t golden;
uint8_t pred16x16[4];
uint8_t pred8x8c[3];
- uint8_t token[4][16][3][NUM_DCT_TOKENS-1];
+ uint8_t token[4][16][3][NUM_DCT_TOKENS - 1];
uint8_t mvc[2][19];
+ uint8_t scan[16];
} prob[2];
VP8Macroblock *macroblocks_base;
@@ -269,6 +273,31 @@ typedef struct VP8Context {
* 1 -> Macroblocks for entire frame alloced (sliced thread).
*/
int mb_layout;
+
+ void (*decode_mb_row_no_filter)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr);
+ void (*filter_mb_row)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr);
+
+ int vp7;
+
+ /**
+ * Fade bit present in bitstream (VP7)
+ */
+ int fade_present;
+
+ /**
+ * Interframe DC prediction (VP7)
+ * [0] VP56_FRAME_PREVIOUS
+ * [1] VP56_FRAME_GOLDEN
+ */
+ uint16_t inter_dc_pred[2][2];
+
+ /**
+ * Macroblock features (VP7)
+ */
+ uint8_t feature_enabled[4];
+ uint8_t feature_present_prob[4];
+ uint8_t feature_index_prob[4][3];
+ uint8_t feature_value[4][4];
} VP8Context;
int ff_vp8_decode_init(AVCodecContext *avctx);
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8_parser.c b/chromium/third_party/ffmpeg/libavcodec/vp8_parser.c
index 096961fec1a..afc7f991e64 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8_parser.c
@@ -21,18 +21,19 @@
#include "parser.h"
static int parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
+ AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
{
- s->pict_type= (buf[0]&0x01) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
+ s->pict_type = (buf[0] & 0x01) ? AV_PICTURE_TYPE_P
+ : AV_PICTURE_TYPE_I;
- *poutbuf = buf;
+ *poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
AVCodecParser ff_vp8_parser = {
- .codec_ids = { AV_CODEC_ID_VP8 },
- .parser_parse = parse,
+ .codec_ids = { AV_CODEC_ID_VP8 },
+ .parser_parse = parse,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8data.h b/chromium/third_party/ffmpeg/libavcodec/vp8data.h
index 0ea24d7ed87..f9dbf56feb9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8data.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8data.h
@@ -30,28 +30,89 @@
#include "vp8.h"
#include "h264pred.h"
-static const uint8_t vp8_pred4x4_mode[] =
-{
+static const uint8_t vp7_pred4x4_mode[] = {
+ [DC_PRED8x8] = DC_PRED,
+ [VERT_PRED8x8] = TM_VP8_PRED,
+ [HOR_PRED8x8] = TM_VP8_PRED,
+ [PLANE_PRED8x8] = TM_VP8_PRED,
+};
+
+static const uint8_t vp8_pred4x4_mode[] = {
[DC_PRED8x8] = DC_PRED,
[VERT_PRED8x8] = VERT_PRED,
[HOR_PRED8x8] = HOR_PRED,
[PLANE_PRED8x8] = TM_VP8_PRED,
};
-static const int8_t vp8_pred16x16_tree_intra[4][2] =
-{
- { -MODE_I4x4, 1 }, // '0'
- { 2, 3 },
- { -DC_PRED8x8, -VERT_PRED8x8 }, // '100', '101'
- { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111'
+static const int8_t vp8_pred16x16_tree_intra[4][2] = {
+ { -MODE_I4x4, 1 }, // '0'
+ { 2, 3 },
+ { -DC_PRED8x8, -VERT_PRED8x8 }, // '100', '101'
+ { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111'
};
-static const int8_t vp8_pred16x16_tree_inter[4][2] =
-{
- { -DC_PRED8x8, 1 }, // '0'
- { 2, 3 },
- { -VERT_PRED8x8, -HOR_PRED8x8 }, // '100', '101'
- { -PLANE_PRED8x8, -MODE_I4x4 }, // '110', '111'
+static const int8_t vp8_pred16x16_tree_inter[4][2] = {
+ { -DC_PRED8x8, 1 }, // '0'
+ { 2, 3 },
+ { -VERT_PRED8x8, -HOR_PRED8x8 }, // '100', '101'
+ { -PLANE_PRED8x8, -MODE_I4x4 }, // '110', '111'
+};
+
+typedef struct VP7MVPred {
+ int8_t yoffset;
+ int8_t xoffset;
+ uint8_t subblock;
+ uint8_t score;
+} VP7MVPred;
+
+#define VP7_MV_PRED_COUNT 12
+static const VP7MVPred vp7_mv_pred[VP7_MV_PRED_COUNT] = {
+ { -1, 0, 12, 8 },
+ { 0, -1, 3, 8 },
+ { -1, -1, 15, 2 },
+ { -1, 1, 12, 2 },
+ { -2, 0, 12, 2 },
+ { 0, -2, 3, 2 },
+ { -1, -2, 15, 1 },
+ { -2, -1, 15, 1 },
+ { -2, 1, 12, 1 },
+ { -1, 2, 12, 1 },
+ { -2, -2, 15, 1 },
+ { -2, 2, 12, 1 },
+};
+
+static const int vp7_mode_contexts[31][4] = {
+ { 3, 3, 1, 246 },
+ { 7, 89, 66, 239 },
+ { 10, 90, 78, 238 },
+ { 14, 118, 95, 241 },
+ { 14, 123, 106, 238 },
+ { 20, 140, 109, 240 },
+ { 13, 155, 103, 238 },
+ { 21, 158, 99, 240 },
+ { 27, 82, 108, 232 },
+ { 19, 99, 123, 217 },
+ { 45, 139, 148, 236 },
+ { 50, 117, 144, 235 },
+ { 57, 128, 164, 238 },
+ { 69, 139, 171, 239 },
+ { 74, 154, 179, 238 },
+ { 112, 165, 186, 242 },
+ { 98, 143, 185, 245 },
+ { 105, 153, 190, 250 },
+ { 124, 167, 192, 245 },
+ { 131, 186, 203, 246 },
+ { 59, 184, 222, 224 },
+ { 148, 215, 214, 213 },
+ { 137, 211, 210, 219 },
+ { 190, 227, 128, 228 },
+ { 183, 228, 128, 228 },
+ { 194, 234, 128, 228 },
+ { 202, 236, 128, 228 },
+ { 205, 240, 128, 228 },
+ { 205, 244, 128, 228 },
+ { 225, 246, 128, 228 },
+ { 233, 251, 128, 228 },
};
static const int vp8_mode_contexts[6][4] = {
@@ -64,26 +125,30 @@ static const int vp8_mode_contexts[6][4] = {
};
static const uint8_t vp8_mbsplits[5][16] = {
- { 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1 },
- { 0, 0, 1, 1, 0, 0, 1, 1,
- 0, 0, 1, 1, 0, 0, 1, 1 },
- { 0, 0, 1, 1, 0, 0, 1, 1,
- 2, 2, 3, 3, 2, 2, 3, 3 },
- { 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15 },
- { 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
static const uint8_t vp8_mbfirstidx[4][16] = {
- { 0, 8 }, { 0, 2 }, { 0, 2, 8, 10 },
- { 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15 }
+ { 0, 8 },
+ { 0, 2 },
+ { 0, 2, 8, 10 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
};
-static const uint8_t vp8_mbsplit_count[4] = { 2, 2, 4, 16 };
-static const uint8_t vp8_mbsplit_prob[3] = { 110, 111, 150 };
+static const uint8_t vp8_mbsplit_count[4] = {
+ 2, 2, 4, 16
+};
+static const uint8_t vp8_mbsplit_prob[3] = {
+ 110, 111, 150
+};
+
+static const uint8_t vp7_submv_prob[3] = {
+ 180, 162, 25
+};
static const uint8_t vp8_submv_prob[5][3] = {
{ 147, 136, 18 },
@@ -93,39 +158,42 @@ static const uint8_t vp8_submv_prob[5][3] = {
{ 208, 1, 1 }
};
-static const uint8_t vp8_pred16x16_prob_intra[4] = { 145, 156, 163, 128 };
-static const uint8_t vp8_pred16x16_prob_inter[4] = { 112, 86, 140, 37 };
+static const uint8_t vp8_pred16x16_prob_intra[4] = {
+ 145, 156, 163, 128
+};
+static const uint8_t vp8_pred16x16_prob_inter[4] = {
+ 112, 86, 140, 37
+};
-static const int8_t vp8_pred4x4_tree[9][2] =
-{
- { -DC_PRED, 1 }, // '0'
- { -TM_VP8_PRED, 2 }, // '10'
- { -VERT_PRED, 3 }, // '110'
- { 4, 6 },
- { -HOR_PRED, 5 }, // '11100'
- { -DIAG_DOWN_RIGHT_PRED, -VERT_RIGHT_PRED }, // '111010', '111011'
- { -DIAG_DOWN_LEFT_PRED, 7 }, // '11110'
- { -VERT_LEFT_PRED, 8 }, // '111110'
- { -HOR_DOWN_PRED, -HOR_UP_PRED }, // '1111110', '1111111'
-};
-
-static const int8_t vp8_pred8x8c_tree[3][2] =
-{
- { -DC_PRED8x8, 1 }, // '0'
- { -VERT_PRED8x8, 2 }, // '10
- { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111'
+static const int8_t vp8_pred4x4_tree[9][2] = {
+ { -DC_PRED, 1 }, // '0'
+ { -TM_VP8_PRED, 2 }, // '10'
+ { -VERT_PRED, 3 }, // '110'
+ { 4, 6 },
+ { -HOR_PRED, 5 }, // '11100'
+ { -DIAG_DOWN_RIGHT_PRED, -VERT_RIGHT_PRED }, // '111010', '111011'
+ { -DIAG_DOWN_LEFT_PRED, 7 }, // '11110'
+ { -VERT_LEFT_PRED, 8 }, // '111110'
+ { -HOR_DOWN_PRED, -HOR_UP_PRED }, // '1111110', '1111111'
};
-static const uint8_t vp8_pred8x8c_prob_intra[3] = { 142, 114, 183 };
-static const uint8_t vp8_pred8x8c_prob_inter[3] = { 162, 101, 204 };
+static const int8_t vp8_pred8x8c_tree[3][2] = {
+ { -DC_PRED8x8, 1 }, // '0'
+ { -VERT_PRED8x8, 2 }, // '10
+ { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111'
+};
-static const uint8_t vp8_pred4x4_prob_inter[9] =
-{
+static const uint8_t vp8_pred8x8c_prob_intra[3] = {
+ 142, 114, 183
+};
+static const uint8_t vp8_pred8x8c_prob_inter[3] = {
+ 162, 101, 204
+};
+static const uint8_t vp8_pred4x4_prob_inter[9] = {
120, 90, 79, 133, 87, 85, 80, 111, 151
};
-static const uint8_t vp8_pred4x4_prob_intra[10][10][9] =
-{
+static const uint8_t vp8_pred4x4_prob_intra[10][10][9] = {
{
{ 39, 53, 200, 87, 26, 21, 43, 232, 171 },
{ 56, 34, 51, 104, 114, 102, 29, 93, 77 },
@@ -248,50 +316,57 @@ static const uint8_t vp8_pred4x4_prob_intra[10][10][9] =
},
};
-static const int8_t vp8_segmentid_tree[][2] =
-{
- { 1, 2 },
- { -0, -1 }, // '00', '01'
- { -2, -3 }, // '10', '11'
+static const int8_t vp8_segmentid_tree[][2] = {
+ { 1, 2 },
+ { -0, -1 }, // '00', '01'
+ { -2, -3 }, // '10', '11'
};
-static const uint8_t vp8_coeff_band[16] =
-{
+static const uint8_t vp8_coeff_band[16] = {
0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7
};
/* Inverse of vp8_coeff_band: mappings of bands to coefficient indexes.
* Each list is -1-terminated. */
-static const int8_t vp8_coeff_band_indexes[8][10] =
-{
- {0, -1},
- {1, -1},
- {2, -1},
- {3, -1},
- {5, -1},
- {6, -1},
- {4, 7, 8, 9, 10, 11, 12, 13, 14, -1},
- {15, -1}
-};
-
-static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 };
-static const uint8_t vp8_dct_cat2_prob[] = { 165, 145, 0 };
-static const uint8_t vp8_dct_cat3_prob[] = { 173, 148, 140, 0 };
-static const uint8_t vp8_dct_cat4_prob[] = { 176, 155, 140, 135, 0 };
-static const uint8_t vp8_dct_cat5_prob[] = { 180, 157, 141, 134, 130, 0 };
-static const uint8_t vp8_dct_cat6_prob[] = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
+static const int8_t vp8_coeff_band_indexes[8][10] = {
+ { 0, -1 },
+ { 1, -1 },
+ { 2, -1 },
+ { 3, -1 },
+ { 5, -1 },
+ { 6, -1 },
+ { 4, 7, 8, 9, 10, 11, 12, 13, 14, -1 },
+ { 15, -1 }
+};
+
+static const uint8_t vp8_dct_cat1_prob[] = {
+ 159, 0
+};
+static const uint8_t vp8_dct_cat2_prob[] = {
+ 165, 145, 0
+};
+static const uint8_t vp8_dct_cat3_prob[] = {
+ 173, 148, 140, 0
+};
+static const uint8_t vp8_dct_cat4_prob[] = {
+ 176, 155, 140, 135, 0
+};
+static const uint8_t vp8_dct_cat5_prob[] = {
+ 180, 157, 141, 134, 130, 0
+};
+static const uint8_t vp8_dct_cat6_prob[] = {
+ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0
+};
// only used for cat3 and above; cat 1 and 2 are referenced directly
-const uint8_t * const ff_vp8_dct_cat_prob[] =
-{
+const uint8_t *const ff_vp8_dct_cat_prob[] = {
vp8_dct_cat3_prob,
vp8_dct_cat4_prob,
vp8_dct_cat5_prob,
vp8_dct_cat6_prob,
};
-static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS-1] =
-{
+static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS - 1] = {
{
{
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
@@ -462,8 +537,7 @@ static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS-1] =
},
};
-static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS-1] =
-{
+static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS - 1] = {
{
{
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
@@ -636,14 +710,13 @@ static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS-1] =
// fixme: copied from h264data.h
static const uint8_t zigzag_scan[16]={
- 0+0*4, 1+0*4, 0+1*4, 0+2*4,
- 1+1*4, 2+0*4, 3+0*4, 2+1*4,
- 1+2*4, 0+3*4, 1+3*4, 2+2*4,
- 3+1*4, 3+2*4, 2+3*4, 3+3*4,
+ 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4,
+ 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4,
+ 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4,
+ 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4,
};
-static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT+1] =
-{
+static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT + 1] = {
4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17,
18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43,
@@ -654,8 +727,7 @@ static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT+1] =
122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157,
};
-static const uint16_t vp8_ac_qlookup[VP8_MAX_QUANT+1] =
-{
+static const uint16_t vp8_ac_qlookup[VP8_MAX_QUANT + 1] = {
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
@@ -670,11 +742,22 @@ static const uint8_t vp8_mv_update_prob[2][19] = {
{ 237,
246,
253, 253, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 250, 250, 252, 254, 254 },
+ 254, 254, 254, 254, 254, 250, 250, 252, /* VP8 only: */ 254, 254 },
{ 231,
243,
245, 253, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 251, 251, 254, 254, 254 }
+ 254, 254, 254, 254, 254, 251, 251, 254, /* VP8 only: */ 254, 254 }
+};
+
+static const uint8_t vp7_mv_default_prob[2][17] = {
+ { 162,
+ 128,
+ 225, 146, 172, 147, 214, 39, 156,
+ 247, 210, 135, 68, 138, 220, 239, 246 },
+ { 164,
+ 128,
+ 204, 170, 119, 235, 140, 230, 228,
+ 244, 184, 201, 44, 173, 221, 239, 253 }
};
static const uint8_t vp8_mv_default_prob[2][19] = {
@@ -688,4 +771,68 @@ static const uint8_t vp8_mv_default_prob[2][19] = {
128, 130, 130, 74, 148, 180, 203, 236, 254, 254 }
};
+static const uint8_t vp7_feature_value_size[2][4] = {
+ { 7, 6, 0, 8 },
+ { 7, 6, 0, 5 },
+};
+
+static const int8_t vp7_feature_index_tree[4][2] =
+{
+ { 1, 2 },
+ { -0, -1 }, // '00', '01'
+ { -2, -3 }, // '10', '11'
+};
+
+static const uint16_t vp7_ydc_qlookup[] = {
+ 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 39, 39, 40, 41,
+ 41, 42, 43, 43, 44, 45, 45, 46, 47, 48, 48, 49, 50, 51, 52,
+ 53, 53, 54, 56, 57, 58, 59, 60, 62, 63, 65, 66, 68, 70, 72,
+ 74, 76, 79, 81, 84, 87, 90, 93, 96, 100, 104, 108, 112, 116, 121,
+ 126, 131, 136, 142, 148, 154, 160, 167, 174, 182, 189, 198, 206, 215, 224,
+ 234, 244, 254, 265, 277, 288, 301, 313, 327, 340, 355, 370, 385, 401, 417,
+ 434, 452, 470, 489, 509, 529, 550, 572,
+};
+
+static const uint16_t vp7_yac_qlookup[] = {
+ 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 15,
+ 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35,
+ 37, 38, 40, 41, 42, 44, 45, 46, 48, 49, 50, 51, 53, 54,
+ 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 67, 68, 69, 70,
+ 72, 73, 75, 76, 78, 80, 82, 84, 86, 88, 91, 93, 96, 99,
+ 102, 105, 109, 112, 116, 121, 125, 130, 135, 140, 146, 152, 158, 165,
+ 172, 180, 188, 196, 205, 214, 224, 234, 245, 256, 268, 281, 294, 308,
+ 322, 337, 353, 369, 386, 404, 423, 443, 463, 484, 506, 529, 553, 578,
+ 604, 631, 659, 688, 718, 749, 781, 814, 849, 885, 922, 960, 1000, 1041,
+ 1083, 1127,
+};
+
+static const uint16_t vp7_y2dc_qlookup[] = {
+ 7, 9, 11, 13, 15, 17, 19, 21, 23, 26, 28, 30, 33, 35,
+ 37, 39, 42, 44, 46, 48, 51, 53, 55, 57, 59, 61, 63, 65,
+ 67, 69, 70, 72, 74, 75, 77, 78, 80, 81, 83, 84, 85, 87,
+ 88, 89, 90, 92, 93, 94, 95, 96, 97, 99, 100, 101, 102, 104,
+ 105, 106, 108, 109, 111, 113, 114, 116, 118, 120, 123, 125, 128, 131,
+ 134, 137, 140, 144, 148, 152, 156, 161, 166, 171, 176, 182, 188, 195,
+ 202, 209, 217, 225, 234, 243, 253, 263, 274, 285, 297, 309, 322, 336,
+ 350, 365, 381, 397, 414, 432, 450, 470, 490, 511, 533, 556, 579, 604,
+ 630, 656, 684, 713, 742, 773, 805, 838, 873, 908, 945, 983, 1022, 1063,
+ 1105, 1148,
+};
+
+static const uint16_t vp7_y2ac_qlookup[] = {
+ 7, 9, 11, 13, 16, 18, 21, 24, 26, 29, 32, 35,
+ 38, 41, 43, 46, 49, 52, 55, 58, 61, 64, 66, 69,
+ 72, 74, 77, 79, 82, 84, 86, 88, 91, 93, 95, 97,
+ 98, 100, 102, 104, 105, 107, 109, 110, 112, 113, 115, 116,
+ 117, 119, 120, 122, 123, 125, 127, 128, 130, 132, 134, 136,
+ 138, 141, 143, 146, 149, 152, 155, 158, 162, 166, 171, 175,
+ 180, 185, 191, 197, 204, 210, 218, 226, 234, 243, 252, 262,
+ 273, 284, 295, 308, 321, 335, 350, 365, 381, 398, 416, 435,
+ 455, 476, 497, 520, 544, 569, 595, 622, 650, 680, 711, 743,
+ 776, 811, 848, 885, 925, 965, 1008, 1052, 1097, 1144, 1193, 1244,
+ 1297, 1351, 1407, 1466, 1526, 1588, 1652, 1719,
+};
+
#endif /* AVCODEC_VP8DATA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8dsp.c b/chromium/third_party/ffmpeg/libavcodec/vp8dsp.c
index ba267fdcd20..f2a7f320797 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8dsp.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 David Conrad
* Copyright (C) 2010 Ronald S. Bultje
+ * Copyright (C) 2014 Peter Ross
*
* This file is part of FFmpeg.
*
@@ -24,36 +25,148 @@
* VP8 compatible video decoder
*/
-#include "dsputil.h"
-#include "vp8dsp.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+
+#include "mathops.h"
+#include "vp8dsp.h"
+
+#define MK_IDCT_DC_ADD4_C(name) \
+static void name ## _idct_dc_add4uv_c(uint8_t *dst, int16_t block[4][16], \
+ ptrdiff_t stride) \
+{ \
+ name ## _idct_dc_add_c(dst + stride * 0 + 0, block[0], stride); \
+ name ## _idct_dc_add_c(dst + stride * 0 + 4, block[1], stride); \
+ name ## _idct_dc_add_c(dst + stride * 4 + 0, block[2], stride); \
+ name ## _idct_dc_add_c(dst + stride * 4 + 4, block[3], stride); \
+} \
+ \
+static void name ## _idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16], \
+ ptrdiff_t stride) \
+{ \
+ name ## _idct_dc_add_c(dst + 0, block[0], stride); \
+ name ## _idct_dc_add_c(dst + 4, block[1], stride); \
+ name ## _idct_dc_add_c(dst + 8, block[2], stride); \
+ name ## _idct_dc_add_c(dst + 12, block[3], stride); \
+}
+
+#if CONFIG_VP7_DECODER
+static void vp7_luma_dc_wht_c(int16_t block[4][4][16], int16_t dc[16])
+{
+ int i, a1, b1, c1, d1;
+ int16_t tmp[16];
+
+ for (i = 0; i < 4; i++) {
+ a1 = (dc[i * 4 + 0] + dc[i * 4 + 2]) * 23170;
+ b1 = (dc[i * 4 + 0] - dc[i * 4 + 2]) * 23170;
+ c1 = dc[i * 4 + 1] * 12540 - dc[i * 4 + 3] * 30274;
+ d1 = dc[i * 4 + 1] * 30274 + dc[i * 4 + 3] * 12540;
+ tmp[i * 4 + 0] = (a1 + d1) >> 14;
+ tmp[i * 4 + 3] = (a1 - d1) >> 14;
+ tmp[i * 4 + 1] = (b1 + c1) >> 14;
+ tmp[i * 4 + 2] = (b1 - c1) >> 14;
+ }
+
+ for (i = 0; i < 4; i++) {
+ a1 = (tmp[i + 0] + tmp[i + 8]) * 23170;
+ b1 = (tmp[i + 0] - tmp[i + 8]) * 23170;
+ c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274;
+ d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540;
+ AV_ZERO64(dc + i * 4);
+ block[0][i][0] = (a1 + d1 + 0x20000) >> 18;
+ block[3][i][0] = (a1 - d1 + 0x20000) >> 18;
+ block[1][i][0] = (b1 + c1 + 0x20000) >> 18;
+ block[2][i][0] = (b1 - c1 + 0x20000) >> 18;
+ }
+}
+
+static void vp7_luma_dc_wht_dc_c(int16_t block[4][4][16], int16_t dc[16])
+{
+ int i, val = (23170 * (23170 * dc[0] >> 14) + 0x20000) >> 18;
+ dc[0] = 0;
+
+ for (i = 0; i < 4; i++) {
+ block[i][0][0] = val;
+ block[i][1][0] = val;
+ block[i][2][0] = val;
+ block[i][3][0] = val;
+ }
+}
+
+static void vp7_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
+{
+ int i, a1, b1, c1, d1;
+ int16_t tmp[16];
+
+ for (i = 0; i < 4; i++) {
+ a1 = (block[i * 4 + 0] + block[i * 4 + 2]) * 23170;
+ b1 = (block[i * 4 + 0] - block[i * 4 + 2]) * 23170;
+ c1 = block[i * 4 + 1] * 12540 - block[i * 4 + 3] * 30274;
+ d1 = block[i * 4 + 1] * 30274 + block[i * 4 + 3] * 12540;
+ AV_ZERO64(block + i * 4);
+ tmp[i * 4 + 0] = (a1 + d1) >> 14;
+ tmp[i * 4 + 3] = (a1 - d1) >> 14;
+ tmp[i * 4 + 1] = (b1 + c1) >> 14;
+ tmp[i * 4 + 2] = (b1 - c1) >> 14;
+ }
+
+ for (i = 0; i < 4; i++) {
+ a1 = (tmp[i + 0] + tmp[i + 8]) * 23170;
+ b1 = (tmp[i + 0] - tmp[i + 8]) * 23170;
+ c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274;
+ d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540;
+ dst[0 * stride + i] = av_clip_uint8(dst[0 * stride + i] +
+ ((a1 + d1 + 0x20000) >> 18));
+ dst[3 * stride + i] = av_clip_uint8(dst[3 * stride + i] +
+ ((a1 - d1 + 0x20000) >> 18));
+ dst[1 * stride + i] = av_clip_uint8(dst[1 * stride + i] +
+ ((b1 + c1 + 0x20000) >> 18));
+ dst[2 * stride + i] = av_clip_uint8(dst[2 * stride + i] +
+ ((b1 - c1 + 0x20000) >> 18));
+ }
+}
+
+static void vp7_idct_dc_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
+{
+ int i, dc = (23170 * (23170 * block[0] >> 14) + 0x20000) >> 18;
+ block[0] = 0;
+
+ for (i = 0; i < 4; i++) {
+ dst[0] = av_clip_uint8(dst[0] + dc);
+ dst[1] = av_clip_uint8(dst[1] + dc);
+ dst[2] = av_clip_uint8(dst[2] + dc);
+ dst[3] = av_clip_uint8(dst[3] + dc);
+ dst += stride;
+ }
+}
+
+MK_IDCT_DC_ADD4_C(vp7)
+#endif /* CONFIG_VP7_DECODER */
// TODO: Maybe add dequant
+#if CONFIG_VP8_DECODER
static void vp8_luma_dc_wht_c(int16_t block[4][4][16], int16_t dc[16])
{
int i, t0, t1, t2, t3;
for (i = 0; i < 4; i++) {
- t0 = dc[0*4+i] + dc[3*4+i];
- t1 = dc[1*4+i] + dc[2*4+i];
- t2 = dc[1*4+i] - dc[2*4+i];
- t3 = dc[0*4+i] - dc[3*4+i];
-
- dc[0*4+i] = t0 + t1;
- dc[1*4+i] = t3 + t2;
- dc[2*4+i] = t0 - t1;
- dc[3*4+i] = t3 - t2;
+ t0 = dc[0 * 4 + i] + dc[3 * 4 + i];
+ t1 = dc[1 * 4 + i] + dc[2 * 4 + i];
+ t2 = dc[1 * 4 + i] - dc[2 * 4 + i];
+ t3 = dc[0 * 4 + i] - dc[3 * 4 + i];
+
+ dc[0 * 4 + i] = t0 + t1;
+ dc[1 * 4 + i] = t3 + t2;
+ dc[2 * 4 + i] = t0 - t1;
+ dc[3 * 4 + i] = t3 - t2;
}
for (i = 0; i < 4; i++) {
- t0 = dc[i*4+0] + dc[i*4+3] + 3; // rounding
- t1 = dc[i*4+1] + dc[i*4+2];
- t2 = dc[i*4+1] - dc[i*4+2];
- t3 = dc[i*4+0] - dc[i*4+3] + 3; // rounding
- dc[i*4+0] = 0;
- dc[i*4+1] = 0;
- dc[i*4+2] = 0;
- dc[i*4+3] = 0;
+ t0 = dc[i * 4 + 0] + dc[i * 4 + 3] + 3; // rounding
+ t1 = dc[i * 4 + 1] + dc[i * 4 + 2];
+ t2 = dc[i * 4 + 1] - dc[i * 4 + 2];
+ t3 = dc[i * 4 + 0] - dc[i * 4 + 3] + 3; // rounding
+ AV_ZERO64(dc + i * 4);
block[i][0][0] = (t0 + t1) >> 3;
block[i][1][0] = (t3 + t2) >> 3;
@@ -75,8 +188,8 @@ static void vp8_luma_dc_wht_dc_c(int16_t block[4][4][16], int16_t dc[16])
}
}
-#define MUL_20091(a) ((((a)*20091) >> 16) + (a))
-#define MUL_35468(a) (((a)*35468) >> 16)
+#define MUL_20091(a) ((((a) * 20091) >> 16) + (a))
+#define MUL_35468(a) (((a) * 35468) >> 16)
static void vp8_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
{
@@ -84,32 +197,32 @@ static void vp8_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
int16_t tmp[16];
for (i = 0; i < 4; i++) {
- t0 = block[0*4+i] + block[2*4+i];
- t1 = block[0*4+i] - block[2*4+i];
- t2 = MUL_35468(block[1*4+i]) - MUL_20091(block[3*4+i]);
- t3 = MUL_20091(block[1*4+i]) + MUL_35468(block[3*4+i]);
- block[0*4+i] = 0;
- block[1*4+i] = 0;
- block[2*4+i] = 0;
- block[3*4+i] = 0;
-
- tmp[i*4+0] = t0 + t3;
- tmp[i*4+1] = t1 + t2;
- tmp[i*4+2] = t1 - t2;
- tmp[i*4+3] = t0 - t3;
+ t0 = block[0 * 4 + i] + block[2 * 4 + i];
+ t1 = block[0 * 4 + i] - block[2 * 4 + i];
+ t2 = MUL_35468(block[1 * 4 + i]) - MUL_20091(block[3 * 4 + i]);
+ t3 = MUL_20091(block[1 * 4 + i]) + MUL_35468(block[3 * 4 + i]);
+ block[0 * 4 + i] = 0;
+ block[1 * 4 + i] = 0;
+ block[2 * 4 + i] = 0;
+ block[3 * 4 + i] = 0;
+
+ tmp[i * 4 + 0] = t0 + t3;
+ tmp[i * 4 + 1] = t1 + t2;
+ tmp[i * 4 + 2] = t1 - t2;
+ tmp[i * 4 + 3] = t0 - t3;
}
for (i = 0; i < 4; i++) {
- t0 = tmp[0*4+i] + tmp[2*4+i];
- t1 = tmp[0*4+i] - tmp[2*4+i];
- t2 = MUL_35468(tmp[1*4+i]) - MUL_20091(tmp[3*4+i]);
- t3 = MUL_20091(tmp[1*4+i]) + MUL_35468(tmp[3*4+i]);
+ t0 = tmp[0 * 4 + i] + tmp[2 * 4 + i];
+ t1 = tmp[0 * 4 + i] - tmp[2 * 4 + i];
+ t2 = MUL_35468(tmp[1 * 4 + i]) - MUL_20091(tmp[3 * 4 + i]);
+ t3 = MUL_20091(tmp[1 * 4 + i]) + MUL_35468(tmp[3 * 4 + i]);
dst[0] = av_clip_uint8(dst[0] + ((t0 + t3 + 4) >> 3));
dst[1] = av_clip_uint8(dst[1] + ((t1 + t2 + 4) >> 3));
dst[2] = av_clip_uint8(dst[2] + ((t1 - t2 + 4) >> 3));
dst[3] = av_clip_uint8(dst[3] + ((t0 - t3 + 4) >> 3));
- dst += stride;
+ dst += stride;
}
}
@@ -123,46 +236,34 @@ static void vp8_idct_dc_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
dst[1] = av_clip_uint8(dst[1] + dc);
dst[2] = av_clip_uint8(dst[2] + dc);
dst[3] = av_clip_uint8(dst[3] + dc);
- dst += stride;
+ dst += stride;
}
}
-static void vp8_idct_dc_add4uv_c(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
-{
- vp8_idct_dc_add_c(dst+stride*0+0, block[0], stride);
- vp8_idct_dc_add_c(dst+stride*0+4, block[1], stride);
- vp8_idct_dc_add_c(dst+stride*4+0, block[2], stride);
- vp8_idct_dc_add_c(dst+stride*4+4, block[3], stride);
-}
-
-static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
-{
- vp8_idct_dc_add_c(dst+ 0, block[0], stride);
- vp8_idct_dc_add_c(dst+ 4, block[1], stride);
- vp8_idct_dc_add_c(dst+ 8, block[2], stride);
- vp8_idct_dc_add_c(dst+12, block[3], stride);
-}
+MK_IDCT_DC_ADD4_C(vp8)
+#endif /* CONFIG_VP8_DECODER */
// because I like only having two parameters to pass functions...
-#define LOAD_PIXELS\
- int av_unused p3 = p[-4*stride];\
- int av_unused p2 = p[-3*stride];\
- int av_unused p1 = p[-2*stride];\
- int av_unused p0 = p[-1*stride];\
- int av_unused q0 = p[ 0*stride];\
- int av_unused q1 = p[ 1*stride];\
- int av_unused q2 = p[ 2*stride];\
- int av_unused q3 = p[ 3*stride];
-
-#define clip_int8(n) (cm[n+0x80]-0x80)
-
-static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride, int is4tap)
+#define LOAD_PIXELS \
+ int av_unused p3 = p[-4 * stride]; \
+ int av_unused p2 = p[-3 * stride]; \
+ int av_unused p1 = p[-2 * stride]; \
+ int av_unused p0 = p[-1 * stride]; \
+ int av_unused q0 = p[ 0 * stride]; \
+ int av_unused q1 = p[ 1 * stride]; \
+ int av_unused q2 = p[ 2 * stride]; \
+ int av_unused q3 = p[ 3 * stride];
+
+#define clip_int8(n) (cm[n + 0x80] - 0x80)
+
+static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride,
+ int is4tap, int is_vp7)
{
LOAD_PIXELS
int a, f1, f2;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
- a = 3*(q0 - p0);
+ a = 3 * (q0 - p0);
if (is4tap)
a += clip_int8(p1 - q1);
@@ -171,222 +272,286 @@ static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride, int is4
// We deviate from the spec here with c(a+3) >> 3
// since that's what libvpx does.
- f1 = FFMIN(a+4, 127) >> 3;
- f2 = FFMIN(a+3, 127) >> 3;
+ f1 = FFMIN(a + 4, 127) >> 3;
+
+ if (is_vp7)
+ f2 = f1 - ((a & 7) == 4);
+ else
+ f2 = FFMIN(a + 3, 127) >> 3;
// Despite what the spec says, we do need to clamp here to
// be bitexact with libvpx.
- p[-1*stride] = cm[p0 + f2];
- p[ 0*stride] = cm[q0 - f1];
+ p[-1 * stride] = cm[p0 + f2];
+ p[ 0 * stride] = cm[q0 - f1];
// only used for _inner on blocks without high edge variance
if (!is4tap) {
- a = (f1+1)>>1;
- p[-2*stride] = cm[p1 + a];
- p[ 1*stride] = cm[q1 - a];
+ a = (f1 + 1) >> 1;
+ p[-2 * stride] = cm[p1 + a];
+ p[ 1 * stride] = cm[q1 - a];
}
}
-static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)
+static av_always_inline void vp7_filter_common(uint8_t *p, ptrdiff_t stride,
+ int is4tap)
+{
+ filter_common(p, stride, is4tap, IS_VP7);
+}
+
+static av_always_inline void vp8_filter_common(uint8_t *p, ptrdiff_t stride,
+ int is4tap)
+{
+ filter_common(p, stride, is4tap, IS_VP8);
+}
+
+static av_always_inline int vp7_simple_limit(uint8_t *p, ptrdiff_t stride,
+ int flim)
+{
+ LOAD_PIXELS
+ return FFABS(p0 - q0) <= flim;
+}
+
+static av_always_inline int vp8_simple_limit(uint8_t *p, ptrdiff_t stride,
+ int flim)
{
LOAD_PIXELS
- return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim;
+ return 2 * FFABS(p0 - q0) + (FFABS(p1 - q1) >> 1) <= flim;
}
/**
* E - limit at the macroblock edge
* I - limit for interior difference
*/
-static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride, int E, int I)
-{
- LOAD_PIXELS
- return simple_limit(p, stride, E)
- && FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I
- && FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;
+#define NORMAL_LIMIT(vpn) \
+static av_always_inline int vp ## vpn ## _normal_limit(uint8_t *p, \
+ ptrdiff_t stride, \
+ int E, int I) \
+{ \
+ LOAD_PIXELS \
+ return vp ## vpn ## _simple_limit(p, stride, E) && \
+ FFABS(p3 - p2) <= I && FFABS(p2 - p1) <= I && \
+ FFABS(p1 - p0) <= I && FFABS(q3 - q2) <= I && \
+ FFABS(q2 - q1) <= I && FFABS(q1 - q0) <= I; \
}
+NORMAL_LIMIT(7)
+NORMAL_LIMIT(8)
+
// high edge variance
static av_always_inline int hev(uint8_t *p, ptrdiff_t stride, int thresh)
{
LOAD_PIXELS
- return FFABS(p1-p0) > thresh || FFABS(q1-q0) > thresh;
+ return FFABS(p1 - p0) > thresh || FFABS(q1 - q0) > thresh;
}
static av_always_inline void filter_mbedge(uint8_t *p, ptrdiff_t stride)
{
int a0, a1, a2, w;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
LOAD_PIXELS
- w = clip_int8(p1-q1);
- w = clip_int8(w + 3*(q0-p0));
+ w = clip_int8(p1 - q1);
+ w = clip_int8(w + 3 * (q0 - p0));
- a0 = (27*w + 63) >> 7;
- a1 = (18*w + 63) >> 7;
- a2 = ( 9*w + 63) >> 7;
+ a0 = (27 * w + 63) >> 7;
+ a1 = (18 * w + 63) >> 7;
+ a2 = (9 * w + 63) >> 7;
- p[-3*stride] = cm[p2 + a2];
- p[-2*stride] = cm[p1 + a1];
- p[-1*stride] = cm[p0 + a0];
- p[ 0*stride] = cm[q0 - a0];
- p[ 1*stride] = cm[q1 - a1];
- p[ 2*stride] = cm[q2 - a2];
+ p[-3 * stride] = cm[p2 + a2];
+ p[-2 * stride] = cm[p1 + a1];
+ p[-1 * stride] = cm[p0 + a0];
+ p[ 0 * stride] = cm[q0 - a0];
+ p[ 1 * stride] = cm[q1 - a1];
+ p[ 2 * stride] = cm[q2 - a2];
}
-#define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline) \
-static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, ptrdiff_t stride,\
- int flim_E, int flim_I, int hev_thresh)\
-{\
- int i;\
-\
- for (i = 0; i < size; i++)\
- if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\
- if (hev(dst+i*stridea, strideb, hev_thresh))\
- filter_common(dst+i*stridea, strideb, 1);\
- else\
- filter_mbedge(dst+i*stridea, strideb);\
- }\
-}\
-\
-static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, ptrdiff_t stride,\
- int flim_E, int flim_I, int hev_thresh)\
-{\
- int i;\
-\
- for (i = 0; i < size; i++)\
- if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\
- int hv = hev(dst+i*stridea, strideb, hev_thresh);\
- if (hv) \
- filter_common(dst+i*stridea, strideb, 1);\
- else \
- filter_common(dst+i*stridea, strideb, 0);\
- }\
+#define LOOP_FILTER(vpn, dir, size, stridea, strideb, maybe_inline) \
+static maybe_inline \
+void vpn ## _ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, \
+ ptrdiff_t stride, \
+ int flim_E, int flim_I, \
+ int hev_thresh) \
+{ \
+ int i; \
+ for (i = 0; i < size; i++) \
+ if (vpn ## _normal_limit(dst + i * stridea, strideb, \
+ flim_E, flim_I)) { \
+ if (hev(dst + i * stridea, strideb, hev_thresh)) \
+ vpn ## _filter_common(dst + i * stridea, strideb, 1); \
+ else \
+ filter_mbedge(dst + i * stridea, strideb); \
+ } \
+} \
+ \
+static maybe_inline \
+void vpn ## _ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, \
+ ptrdiff_t stride, \
+ int flim_E, \
+ int flim_I, \
+ int hev_thresh) \
+{ \
+ int i; \
+ for (i = 0; i < size; i++) \
+ if (vpn ## _normal_limit(dst + i * stridea, strideb, \
+ flim_E, flim_I)) { \
+ int hv = hev(dst + i * stridea, strideb, hev_thresh); \
+ if (hv) \
+ vpn ## _filter_common(dst + i * stridea, strideb, 1); \
+ else \
+ vpn ## _filter_common(dst + i * stridea, strideb, 0); \
+ } \
}
-LOOP_FILTER(v, 16, 1, stride,)
-LOOP_FILTER(h, 16, stride, 1,)
-
-#define UV_LOOP_FILTER(dir, stridea, strideb) \
-LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline) \
-static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,\
- int fE, int fI, int hev_thresh)\
-{\
- vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);\
- vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);\
-}\
-static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,\
- int fE, int fI, int hev_thresh)\
-{\
- vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);\
- vp8_ ## dir ## _loop_filter8_inner_c(dstV, stride, fE, fI, hev_thresh);\
+#define UV_LOOP_FILTER(vpn, dir, stridea, strideb) \
+LOOP_FILTER(vpn, dir, 8, stridea, strideb, av_always_inline) \
+static void vpn ## _ ## dir ## _loop_filter8uv_c(uint8_t *dstU, \
+ uint8_t *dstV, \
+ ptrdiff_t stride, int fE, \
+ int fI, int hev_thresh) \
+{ \
+ vpn ## _ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh); \
+ vpn ## _ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh); \
+} \
+ \
+static void vpn ## _ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, \
+ uint8_t *dstV, \
+ ptrdiff_t stride, \
+ int fE, int fI, \
+ int hev_thresh) \
+{ \
+ vpn ## _ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, \
+ hev_thresh); \
+ vpn ## _ ## dir ## _loop_filter8_inner_c(dstV, stride, fE, fI, \
+ hev_thresh); \
}
-UV_LOOP_FILTER(v, 1, stride)
-UV_LOOP_FILTER(h, stride, 1)
-
-static void vp8_v_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
-{
- int i;
-
- for (i = 0; i < 16; i++)
- if (simple_limit(dst+i, stride, flim))
- filter_common(dst+i, stride, 1);
+#define LOOP_FILTER_SIMPLE(vpn) \
+static void vpn ## _v_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, \
+ int flim) \
+{ \
+ int i; \
+ for (i = 0; i < 16; i++) \
+ if (vpn ## _simple_limit(dst + i, stride, flim)) \
+ vpn ## _filter_common(dst + i, stride, 1); \
+} \
+ \
+static void vpn ## _h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, \
+ int flim) \
+{ \
+ int i; \
+ for (i = 0; i < 16; i++) \
+ if (vpn ## _simple_limit(dst + i * stride, 1, flim)) \
+ vpn ## _filter_common(dst + i * stride, 1, 1); \
}
-static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
-{
- int i;
-
- for (i = 0; i < 16; i++)
- if (simple_limit(dst+i*stride, 1, flim))
- filter_common(dst+i*stride, 1, 1);
-}
+#define LOOP_FILTERS(vpn) \
+ LOOP_FILTER(vpn, v, 16, 1, stride, ) \
+ LOOP_FILTER(vpn, h, 16, stride, 1, ) \
+ UV_LOOP_FILTER(vpn, v, 1, stride) \
+ UV_LOOP_FILTER(vpn, h, stride, 1) \
+ LOOP_FILTER_SIMPLE(vpn) \
static const uint8_t subpel_filters[7][6] = {
- { 0, 6, 123, 12, 1, 0 },
- { 2, 11, 108, 36, 8, 1 },
- { 0, 9, 93, 50, 6, 0 },
- { 3, 16, 77, 77, 16, 3 },
- { 0, 6, 50, 93, 9, 0 },
- { 1, 8, 36, 108, 11, 2 },
- { 0, 1, 12, 123, 6, 0 },
+ { 0, 6, 123, 12, 1, 0 },
+ { 2, 11, 108, 36, 8, 1 },
+ { 0, 9, 93, 50, 6, 0 },
+ { 3, 16, 77, 77, 16, 3 },
+ { 0, 6, 50, 93, 9, 0 },
+ { 1, 8, 36, 108, 11, 2 },
+ { 0, 1, 12, 123, 6, 0 },
};
-#define PUT_PIXELS(WIDTH) \
-static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int x, int y) { \
- int i; \
- for (i = 0; i < h; i++, dst+= dststride, src+= srcstride) { \
- memcpy(dst, src, WIDTH); \
- } \
+#define PUT_PIXELS(WIDTH) \
+static void put_vp8_pixels ## WIDTH ## _c(uint8_t *dst, ptrdiff_t dststride, \
+ uint8_t *src, ptrdiff_t srcstride, \
+ int h, int x, int y) \
+{ \
+ int i; \
+ for (i = 0; i < h; i++, dst += dststride, src += srcstride) \
+ memcpy(dst, src, WIDTH); \
}
PUT_PIXELS(16)
PUT_PIXELS(8)
PUT_PIXELS(4)
-#define FILTER_6TAP(src, F, stride) \
- cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + F[0]*src[x-2*stride] + \
- F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + F[5]*src[x+3*stride] + 64) >> 7]
-
-#define FILTER_4TAP(src, F, stride) \
- cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + \
- F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7]
-
-#define VP8_EPEL_H(SIZE, TAPS) \
-static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
-{ \
- const uint8_t *filter = subpel_filters[mx-1]; \
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
- int x, y; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = FILTER_ ## TAPS ## TAP(src, filter, 1); \
- dst += dststride; \
- src += srcstride; \
- } \
+#define FILTER_6TAP(src, F, stride) \
+ cm[(F[2] * src[x + 0 * stride] - F[1] * src[x - 1 * stride] + \
+ F[0] * src[x - 2 * stride] + F[3] * src[x + 1 * stride] - \
+ F[4] * src[x + 2 * stride] + F[5] * src[x + 3 * stride] + 64) >> 7]
+
+#define FILTER_4TAP(src, F, stride) \
+ cm[(F[2] * src[x + 0 * stride] - F[1] * src[x - 1 * stride] + \
+ F[3] * src[x + 1 * stride] - F[4] * src[x + 2 * stride] + 64) >> 7]
+
+#define VP8_EPEL_H(SIZE, TAPS) \
+static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, \
+ ptrdiff_t dststride, \
+ uint8_t *src, \
+ ptrdiff_t srcstride, \
+ int h, int mx, int my) \
+{ \
+ const uint8_t *filter = subpel_filters[mx - 1]; \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ int x, y; \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = FILTER_ ## TAPS ## TAP(src, filter, 1); \
+ dst += dststride; \
+ src += srcstride; \
+ } \
}
-#define VP8_EPEL_V(SIZE, TAPS) \
-static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
-{ \
- const uint8_t *filter = subpel_filters[my-1]; \
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
- int x, y; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = FILTER_ ## TAPS ## TAP(src, filter, srcstride); \
- dst += dststride; \
- src += srcstride; \
- } \
+
+#define VP8_EPEL_V(SIZE, TAPS) \
+static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, \
+ ptrdiff_t dststride, \
+ uint8_t *src, \
+ ptrdiff_t srcstride, \
+ int h, int mx, int my) \
+{ \
+ const uint8_t *filter = subpel_filters[my - 1]; \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ int x, y; \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = FILTER_ ## TAPS ## TAP(src, filter, srcstride); \
+ dst += dststride; \
+ src += srcstride; \
+ } \
}
-#define VP8_EPEL_HV(SIZE, HTAPS, VTAPS) \
-static void put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
-{ \
- const uint8_t *filter = subpel_filters[mx-1]; \
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
- int x, y; \
- uint8_t tmp_array[(2*SIZE+VTAPS-1)*SIZE]; \
- uint8_t *tmp = tmp_array; \
- src -= (2-(VTAPS==4))*srcstride; \
-\
- for (y = 0; y < h+VTAPS-1; y++) { \
- for (x = 0; x < SIZE; x++) \
- tmp[x] = FILTER_ ## HTAPS ## TAP(src, filter, 1); \
- tmp += SIZE; \
- src += srcstride; \
- } \
-\
- tmp = tmp_array + (2-(VTAPS==4))*SIZE; \
- filter = subpel_filters[my-1]; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = FILTER_ ## VTAPS ## TAP(tmp, filter, SIZE); \
- dst += dststride; \
- tmp += SIZE; \
- } \
+
+#define VP8_EPEL_HV(SIZE, HTAPS, VTAPS) \
+static void \
+put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, \
+ ptrdiff_t dststride, \
+ uint8_t *src, \
+ ptrdiff_t srcstride, \
+ int h, int mx, \
+ int my) \
+{ \
+ const uint8_t *filter = subpel_filters[mx - 1]; \
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
+ int x, y; \
+ uint8_t tmp_array[(2 * SIZE + VTAPS - 1) * SIZE]; \
+ uint8_t *tmp = tmp_array; \
+ src -= (2 - (VTAPS == 4)) * srcstride; \
+ \
+ for (y = 0; y < h + VTAPS - 1; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ tmp[x] = FILTER_ ## HTAPS ## TAP(src, filter, 1); \
+ tmp += SIZE; \
+ src += srcstride; \
+ } \
+ tmp = tmp_array + (2 - (VTAPS == 4)) * SIZE; \
+ filter = subpel_filters[my - 1]; \
+ \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = FILTER_ ## VTAPS ## TAP(tmp, filter, SIZE); \
+ dst += dststride; \
+ tmp += SIZE; \
+ } \
}
VP8_EPEL_H(16, 4)
@@ -401,6 +566,7 @@ VP8_EPEL_V(4, 4)
VP8_EPEL_V(16, 6)
VP8_EPEL_V(8, 6)
VP8_EPEL_V(4, 6)
+
VP8_EPEL_HV(16, 4, 4)
VP8_EPEL_HV(8, 4, 4)
VP8_EPEL_HV(4, 4, 4)
@@ -414,74 +580,78 @@ VP8_EPEL_HV(16, 6, 6)
VP8_EPEL_HV(8, 6, 6)
VP8_EPEL_HV(4, 6, 6)
-#define VP8_BILINEAR(SIZE) \
-static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t dstride, uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) \
-{ \
- int a = 8-mx, b = mx; \
- int x, y; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \
- dst += dstride; \
- src += sstride; \
- } \
-} \
-static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t dstride, uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) \
-{ \
- int c = 8-my, d = my; \
- int x, y; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = (c*src[x] + d*src[x+sstride] + 4) >> 3; \
- dst += dstride; \
- src += sstride; \
- } \
-} \
-\
-static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, ptrdiff_t dstride, uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) \
-{ \
- int a = 8-mx, b = mx; \
- int c = 8-my, d = my; \
- int x, y; \
- uint8_t tmp_array[(2*SIZE+1)*SIZE]; \
- uint8_t *tmp = tmp_array; \
-\
- for (y = 0; y < h+1; y++) { \
- for (x = 0; x < SIZE; x++) \
- tmp[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \
- tmp += SIZE; \
- src += sstride; \
- } \
-\
- tmp = tmp_array; \
-\
- for (y = 0; y < h; y++) { \
- for (x = 0; x < SIZE; x++) \
- dst[x] = (c*tmp[x] + d*tmp[x+SIZE] + 4) >> 3; \
- dst += dstride; \
- tmp += SIZE; \
- } \
+#define VP8_BILINEAR(SIZE) \
+static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t dstride, \
+ uint8_t *src, ptrdiff_t sstride, \
+ int h, int mx, int my) \
+{ \
+ int a = 8 - mx, b = mx; \
+ int x, y; \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = (a * src[x] + b * src[x + 1] + 4) >> 3; \
+ dst += dstride; \
+ src += sstride; \
+ } \
+} \
+ \
+static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t dstride, \
+ uint8_t *src, ptrdiff_t sstride, \
+ int h, int mx, int my) \
+{ \
+ int c = 8 - my, d = my; \
+ int x, y; \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = (c * src[x] + d * src[x + sstride] + 4) >> 3; \
+ dst += dstride; \
+ src += sstride; \
+ } \
+} \
+ \
+static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, \
+ ptrdiff_t dstride, \
+ uint8_t *src, \
+ ptrdiff_t sstride, \
+ int h, int mx, int my) \
+{ \
+ int a = 8 - mx, b = mx; \
+ int c = 8 - my, d = my; \
+ int x, y; \
+ uint8_t tmp_array[(2 * SIZE + 1) * SIZE]; \
+ uint8_t *tmp = tmp_array; \
+ for (y = 0; y < h + 1; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ tmp[x] = (a * src[x] + b * src[x + 1] + 4) >> 3; \
+ tmp += SIZE; \
+ src += sstride; \
+ } \
+ tmp = tmp_array; \
+ for (y = 0; y < h; y++) { \
+ for (x = 0; x < SIZE; x++) \
+ dst[x] = (c * tmp[x] + d * tmp[x + SIZE] + 4) >> 3; \
+ dst += dstride; \
+ tmp += SIZE; \
+ } \
}
VP8_BILINEAR(16)
VP8_BILINEAR(8)
VP8_BILINEAR(4)
-#define VP8_MC_FUNC(IDX, SIZE) \
- dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
- dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \
- dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \
- dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \
+#define VP78_MC_FUNC(IDX, SIZE) \
+ dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
+ dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \
+ dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \
+ dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \
dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \
dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \
- dsp->put_vp8_epel_pixels_tab[IDX][2][0] = put_vp8_epel ## SIZE ## _v6_c; \
+ dsp->put_vp8_epel_pixels_tab[IDX][2][0] = put_vp8_epel ## SIZE ## _v6_c; \
dsp->put_vp8_epel_pixels_tab[IDX][2][1] = put_vp8_epel ## SIZE ## _h4v6_c; \
dsp->put_vp8_epel_pixels_tab[IDX][2][2] = put_vp8_epel ## SIZE ## _h6v6_c
-#define VP8_BILINEAR_MC_FUNC(IDX, SIZE) \
- dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
+#define VP78_BILINEAR_MC_FUNC(IDX, SIZE) \
+ dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = put_vp8_bilinear ## SIZE ## _h_c; \
dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = put_vp8_bilinear ## SIZE ## _h_c; \
dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = put_vp8_bilinear ## SIZE ## _v_c; \
@@ -491,6 +661,54 @@ VP8_BILINEAR(4)
dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = put_vp8_bilinear ## SIZE ## _hv_c
+av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
+{
+ VP78_MC_FUNC(0, 16);
+ VP78_MC_FUNC(1, 8);
+ VP78_MC_FUNC(2, 4);
+
+ VP78_BILINEAR_MC_FUNC(0, 16);
+ VP78_BILINEAR_MC_FUNC(1, 8);
+ VP78_BILINEAR_MC_FUNC(2, 4);
+
+ if (ARCH_ARM)
+ ff_vp78dsp_init_arm(dsp);
+ if (ARCH_PPC)
+ ff_vp78dsp_init_ppc(dsp);
+ if (ARCH_X86)
+ ff_vp78dsp_init_x86(dsp);
+}
+
+#if CONFIG_VP7_DECODER
+LOOP_FILTERS(vp7)
+
+av_cold void ff_vp7dsp_init(VP8DSPContext *dsp)
+{
+ dsp->vp8_luma_dc_wht = vp7_luma_dc_wht_c;
+ dsp->vp8_luma_dc_wht_dc = vp7_luma_dc_wht_dc_c;
+ dsp->vp8_idct_add = vp7_idct_add_c;
+ dsp->vp8_idct_dc_add = vp7_idct_dc_add_c;
+ dsp->vp8_idct_dc_add4y = vp7_idct_dc_add4y_c;
+ dsp->vp8_idct_dc_add4uv = vp7_idct_dc_add4uv_c;
+
+ dsp->vp8_v_loop_filter16y = vp7_v_loop_filter16_c;
+ dsp->vp8_h_loop_filter16y = vp7_h_loop_filter16_c;
+ dsp->vp8_v_loop_filter8uv = vp7_v_loop_filter8uv_c;
+ dsp->vp8_h_loop_filter8uv = vp7_h_loop_filter8uv_c;
+
+ dsp->vp8_v_loop_filter16y_inner = vp7_v_loop_filter16_inner_c;
+ dsp->vp8_h_loop_filter16y_inner = vp7_h_loop_filter16_inner_c;
+ dsp->vp8_v_loop_filter8uv_inner = vp7_v_loop_filter8uv_inner_c;
+ dsp->vp8_h_loop_filter8uv_inner = vp7_h_loop_filter8uv_inner_c;
+
+ dsp->vp8_v_loop_filter_simple = vp7_v_loop_filter_simple_c;
+ dsp->vp8_h_loop_filter_simple = vp7_h_loop_filter_simple_c;
+}
+#endif /* CONFIG_VP7_DECODER */
+
+#if CONFIG_VP8_DECODER
+LOOP_FILTERS(vp8)
+
av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
{
dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c;
@@ -513,18 +731,9 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c;
dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c;
- VP8_MC_FUNC(0, 16);
- VP8_MC_FUNC(1, 8);
- VP8_MC_FUNC(2, 4);
-
- VP8_BILINEAR_MC_FUNC(0, 16);
- VP8_BILINEAR_MC_FUNC(1, 8);
- VP8_BILINEAR_MC_FUNC(2, 4);
-
if (ARCH_ARM)
ff_vp8dsp_init_arm(dsp);
- if (ARCH_PPC)
- ff_vp8dsp_init_ppc(dsp);
if (ARCH_X86)
ff_vp8dsp_init_x86(dsp);
}
+#endif /* CONFIG_VP8_DECODER */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp8dsp.h b/chromium/third_party/ffmpeg/libavcodec/vp8dsp.h
index 58ec65a5688..5fdd3af70da 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp8dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp8dsp.h
@@ -30,8 +30,8 @@
#include <stddef.h>
#include <stdint.h>
-typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, ptrdiff_t dstStride,
- uint8_t *src/*align 1*/, ptrdiff_t srcStride,
+typedef void (*vp8_mc_func)(uint8_t *dst /* align 8 */, ptrdiff_t dstStride,
+ uint8_t *src /* align 1 */, ptrdiff_t srcStride,
int h, int x, int y);
typedef struct VP8DSPContext {
@@ -88,9 +88,18 @@ void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
int h, int x, int y);
+void ff_vp7dsp_init(VP8DSPContext *c);
+
+void ff_vp78dsp_init(VP8DSPContext *c);
+void ff_vp78dsp_init_arm(VP8DSPContext *c);
+void ff_vp78dsp_init_ppc(VP8DSPContext *c);
+void ff_vp78dsp_init_x86(VP8DSPContext *c);
+
void ff_vp8dsp_init(VP8DSPContext *c);
-void ff_vp8dsp_init_x86(VP8DSPContext *c);
void ff_vp8dsp_init_arm(VP8DSPContext *c);
-void ff_vp8dsp_init_ppc(VP8DSPContext *c);
+void ff_vp8dsp_init_x86(VP8DSPContext *c);
+
+#define IS_VP7 1
+#define IS_VP8 0
#endif /* AVCODEC_VP8DSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp9.c b/chromium/third_party/ffmpeg/libavcodec/vp9.c
index a52924c7c90..000e9918a52 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp9.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp9.c
@@ -210,19 +210,31 @@ typedef struct VP9Context {
enum CompPredMode comppredmode;
// contextual (left/above) cache
- uint8_t left_partition_ctx[8], *above_partition_ctx;
- uint8_t left_mode_ctx[16], *above_mode_ctx;
+ DECLARE_ALIGNED(16, uint8_t, left_y_nnz_ctx)[16];
+ DECLARE_ALIGNED(16, uint8_t, left_mode_ctx)[16];
+ DECLARE_ALIGNED(16, VP56mv, left_mv_ctx)[16][2];
+ DECLARE_ALIGNED(8, uint8_t, left_uv_nnz_ctx)[2][8];
+ DECLARE_ALIGNED(8, uint8_t, left_partition_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_skip_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_txfm_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_segpred_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_intra_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_comp_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_ref_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_filter_ctx)[8];
+ uint8_t *above_partition_ctx;
+ uint8_t *above_mode_ctx;
// FIXME maybe merge some of the below in a flags field?
- uint8_t left_y_nnz_ctx[16], *above_y_nnz_ctx;
- uint8_t left_uv_nnz_ctx[2][8], *above_uv_nnz_ctx[2];
- uint8_t left_skip_ctx[8], *above_skip_ctx; // 1bit
- uint8_t left_txfm_ctx[8], *above_txfm_ctx; // 2bit
- uint8_t left_segpred_ctx[8], *above_segpred_ctx; // 1bit
- uint8_t left_intra_ctx[8], *above_intra_ctx; // 1bit
- uint8_t left_comp_ctx[8], *above_comp_ctx; // 1bit
- uint8_t left_ref_ctx[8], *above_ref_ctx; // 2bit
- uint8_t left_filter_ctx[8], *above_filter_ctx;
- VP56mv left_mv_ctx[16][2], (*above_mv_ctx)[2];
+ uint8_t *above_y_nnz_ctx;
+ uint8_t *above_uv_nnz_ctx[2];
+ uint8_t *above_skip_ctx; // 1bit
+ uint8_t *above_txfm_ctx; // 2bit
+ uint8_t *above_segpred_ctx; // 1bit
+ uint8_t *above_intra_ctx; // 1bit
+ uint8_t *above_comp_ctx; // 1bit
+ uint8_t *above_ref_ctx; // 2bit
+ uint8_t *above_filter_ctx;
+ VP56mv (*above_mv_ctx)[2];
// whole-frame cache
uint8_t *intra_pred_data[3];
@@ -230,9 +242,10 @@ typedef struct VP9Context {
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
// block reconstruction intermediates
+ int block_alloc_using_2pass;
int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
uint8_t *eob_base, *uveob_base[2], *eob, *uveob[2];
- VP56mv min_mv, max_mv;
+ struct { int x, y; } min_mv, max_mv;
DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
} VP9Context;
@@ -264,7 +277,8 @@ static int vp9_alloc_frame(AVCodecContext *ctx, VP9Frame *f)
f->mv = (struct VP9mvrefPair *) (f->extradata->data + sz);
// retain segmentation map if it doesn't update
- if (s->segmentation.enabled && !s->segmentation.update_map) {
+ if (s->segmentation.enabled && !s->segmentation.update_map &&
+ !s->intraonly && !s->keyframe) {
memcpy(f->segmentation_map, s->frames[LAST_FRAME].segmentation_map, sz);
}
@@ -301,7 +315,7 @@ static int update_size(AVCodecContext *ctx, int w, int h)
av_assert0(w > 0 && h > 0);
- if (s->above_partition_ctx && w == ctx->width && h == ctx->height)
+ if (s->intra_pred_data[0] && w == ctx->width && h == ctx->height)
return 0;
ctx->width = w;
@@ -312,32 +326,46 @@ static int update_size(AVCodecContext *ctx, int w, int h)
s->rows = (h + 7) >> 3;
#define assign(var, type, n) var = (type) p; p += s->sb_cols * n * sizeof(*var)
- av_freep(&s->above_partition_ctx);
+ av_freep(&s->intra_pred_data[0]);
p = av_malloc(s->sb_cols * (240 + sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));
if (!p)
return AVERROR(ENOMEM);
+ assign(s->intra_pred_data[0], uint8_t *, 64);
+ assign(s->intra_pred_data[1], uint8_t *, 32);
+ assign(s->intra_pred_data[2], uint8_t *, 32);
+ assign(s->above_y_nnz_ctx, uint8_t *, 16);
+ assign(s->above_mode_ctx, uint8_t *, 16);
+ assign(s->above_mv_ctx, VP56mv(*)[2], 16);
assign(s->above_partition_ctx, uint8_t *, 8);
assign(s->above_skip_ctx, uint8_t *, 8);
assign(s->above_txfm_ctx, uint8_t *, 8);
- assign(s->above_mode_ctx, uint8_t *, 16);
- assign(s->above_y_nnz_ctx, uint8_t *, 16);
assign(s->above_uv_nnz_ctx[0], uint8_t *, 8);
assign(s->above_uv_nnz_ctx[1], uint8_t *, 8);
- assign(s->intra_pred_data[0], uint8_t *, 64);
- assign(s->intra_pred_data[1], uint8_t *, 32);
- assign(s->intra_pred_data[2], uint8_t *, 32);
assign(s->above_segpred_ctx, uint8_t *, 8);
assign(s->above_intra_ctx, uint8_t *, 8);
assign(s->above_comp_ctx, uint8_t *, 8);
assign(s->above_ref_ctx, uint8_t *, 8);
assign(s->above_filter_ctx, uint8_t *, 8);
assign(s->lflvl, struct VP9Filter *, 1);
- assign(s->above_mv_ctx, VP56mv(*)[2], 16);
#undef assign
+ // these will be re-allocated a little later
+ av_freep(&s->b_base);
+ av_freep(&s->block_base);
+
+ return 0;
+}
+
+static int update_block_buffers(AVCodecContext *ctx)
+{
+ VP9Context *s = ctx->priv_data;
+
+ if (s->b_base && s->block_base && s->block_alloc_using_2pass == s->uses_2pass)
+ return 0;
+
av_free(s->b_base);
av_free(s->block_base);
- if (ctx->active_thread_type == FF_THREAD_FRAME && s->refreshctx && !s->parallelmode) {
+ if (s->uses_2pass) {
int sbs = s->sb_cols * s->sb_rows;
s->b_base = av_malloc(sizeof(VP9Block) * s->cols * s->rows);
@@ -360,6 +388,7 @@ static int update_size(AVCodecContext *ctx, int w, int h)
s->uveob_base[0] = s->eob_base + 256;
s->uveob_base[1] = s->uveob_base[0] + 64;
}
+ s->block_alloc_using_2pass = s->uses_2pass;
return 0;
}
@@ -466,7 +495,6 @@ static int decode_frame_header(AVCodecContext *ctx,
last_invisible = s->invisible;
s->invisible = !get_bits1(&s->gb);
s->errorres = get_bits1(&s->gb);
- // FIXME disable this upon resolution change
s->use_last_frame_mvs = !s->errorres && !last_invisible;
if (s->keyframe) {
if (get_bits_long(&s->gb, 24) != VP9_SYNCCODE) { // synccode
@@ -525,6 +553,11 @@ static int decode_frame_header(AVCodecContext *ctx,
w = get_bits(&s->gb, 16) + 1;
h = get_bits(&s->gb, 16) + 1;
}
+ // Note that in this code, "CUR_FRAME" is actually before we
+ // have formally allocated a frame, and thus actually represents
+ // the _last_ frame
+ s->use_last_frame_mvs &= s->frames[CUR_FRAME].tf.f->width == w &&
+ s->frames[CUR_FRAME].tf.f->height == h;
if (get_bits1(&s->gb)) // display size
skip_bits(&s->gb, 32);
s->highprecisionmvs = get_bits1(&s->gb);
@@ -588,10 +621,19 @@ static int decode_frame_header(AVCodecContext *ctx,
for (i = 0; i < 7; i++)
s->prob.seg[i] = get_bits1(&s->gb) ?
get_bits(&s->gb, 8) : 255;
- if ((s->segmentation.temporal = get_bits1(&s->gb)))
+ if ((s->segmentation.temporal = get_bits1(&s->gb))) {
for (i = 0; i < 3; i++)
s->prob.segpred[i] = get_bits1(&s->gb) ?
get_bits(&s->gb, 8) : 255;
+ }
+ }
+ if ((!s->segmentation.update_map || s->segmentation.temporal) &&
+ (w != s->frames[CUR_FRAME].tf.f->width ||
+ h != s->frames[CUR_FRAME].tf.f->height)) {
+ av_log(ctx, AV_LOG_ERROR,
+ "Reference segmap (temp=%d,update=%d) enabled on size-change!\n",
+ s->segmentation.temporal, s->segmentation.update_map);
+ return AVERROR_INVALIDDATA;
}
if (get_bits1(&s->gb)) {
@@ -1159,7 +1201,7 @@ static void fill_mv(VP9Context *s,
VP9Block *b = s->b;
if (mode == ZEROMV) {
- memset(mv, 0, sizeof(*mv) * 2);
+ AV_ZERO64(mv);
} else {
int hp;
@@ -1226,6 +1268,52 @@ static void fill_mv(VP9Context *s,
}
}
+static av_always_inline void setctx_2d(uint8_t *ptr, int w, int h,
+ ptrdiff_t stride, int v)
+{
+ switch (w) {
+ case 1:
+ do {
+ *ptr = v;
+ ptr += stride;
+ } while (--h);
+ break;
+ case 2: {
+ int v16 = v * 0x0101;
+ do {
+ AV_WN16A(ptr, v16);
+ ptr += stride;
+ } while (--h);
+ break;
+ }
+ case 4: {
+ uint32_t v32 = v * 0x01010101;
+ do {
+ AV_WN32A(ptr, v32);
+ ptr += stride;
+ } while (--h);
+ break;
+ }
+ case 8: {
+#if HAVE_FAST_64BIT
+ uint64_t v64 = v * 0x0101010101010101ULL;
+ do {
+ AV_WN64A(ptr, v64);
+ ptr += stride;
+ } while (--h);
+#else
+ uint32_t v32 = v * 0x01010101;
+ do {
+ AV_WN32A(ptr, v32);
+ AV_WN32A(ptr + 4, v32);
+ ptr += stride;
+ } while (--h);
+#endif
+ break;
+ }
+ }
+}
+
static void decode_mode(AVCodecContext *ctx)
{
static const uint8_t left_ctx[N_BS_SIZES] = {
@@ -1245,12 +1333,12 @@ static void decode_mode(AVCodecContext *ctx)
int w4 = FFMIN(s->cols - col, bwh_tab[1][b->bs][0]);
int h4 = FFMIN(s->rows - row, bwh_tab[1][b->bs][1]), y;
int have_a = row > 0, have_l = col > s->tiling.tile_col_start;
+ int vref, filter_id;
if (!s->segmentation.enabled) {
b->seg_id = 0;
} else if (s->keyframe || s->intraonly) {
- b->seg_id = s->segmentation.update_map ?
- vp8_rac_get_tree(&s->c, vp9_segmentation_tree, s->prob.seg) : 0;
+ b->seg_id = vp8_rac_get_tree(&s->c, vp9_segmentation_tree, s->prob.seg);
} else if (!s->segmentation.update_map ||
(s->segmentation.temporal &&
vp56_rac_get_prob_branchy(&s->c,
@@ -1276,11 +1364,10 @@ static void decode_mode(AVCodecContext *ctx)
memset(&s->above_segpred_ctx[col], 0, w4);
memset(&s->left_segpred_ctx[row7], 0, h4);
}
- if ((s->segmentation.enabled && s->segmentation.update_map) || s->keyframe) {
- uint8_t *segmap = s->frames[CUR_FRAME].segmentation_map;
-
- for (y = 0; y < h4; y++)
- memset(&segmap[(y + row) * 8 * s->sb_cols + col], b->seg_id, w4);
+ if (s->segmentation.enabled &&
+ (s->segmentation.update_map || s->keyframe || s->intraonly)) {
+ setctx_2d(&s->frames[CUR_FRAME].segmentation_map[row * 8 * s->sb_cols + col],
+ w4, h4, 8 * s->sb_cols, b->seg_id);
}
b->skip = s->segmentation.enabled &&
@@ -1738,9 +1825,10 @@ static void decode_mode(AVCodecContext *ctx)
c = 3;
}
- b->filter = vp8_rac_get_tree(&s->c, vp9_filter_tree,
+ filter_id = vp8_rac_get_tree(&s->c, vp9_filter_tree,
s->prob.p.filter[c]);
- s->counts.filter[c][b->filter]++;
+ s->counts.filter[c][filter_id]++;
+ b->filter = vp9_filter_lut[filter_id];
} else {
b->filter = s->filtermode;
}
@@ -1797,27 +1885,80 @@ static void decode_mode(AVCodecContext *ctx)
AV_COPY32(&b->mv[2][1], &b->mv[0][1]);
AV_COPY32(&b->mv[3][1], &b->mv[0][1]);
}
+
+ vref = b->ref[b->comp ? s->signbias[s->varcompref[0]] : 0];
+ }
+
+#if HAVE_FAST_64BIT
+#define SPLAT_CTX(var, val, n) \
+ switch (n) { \
+ case 1: var = val; break; \
+ case 2: AV_WN16A(&var, val * 0x0101); break; \
+ case 4: AV_WN32A(&var, val * 0x01010101); break; \
+ case 8: AV_WN64A(&var, val * 0x0101010101010101ULL); break; \
+ case 16: { \
+ uint64_t v64 = val * 0x0101010101010101ULL; \
+ AV_WN64A( &var, v64); \
+ AV_WN64A(&((uint8_t *) &var)[8], v64); \
+ break; \
+ } \
+ }
+#else
+#define SPLAT_CTX(var, val, n) \
+ switch (n) { \
+ case 1: var = val; break; \
+ case 2: AV_WN16A(&var, val * 0x0101); break; \
+ case 4: AV_WN32A(&var, val * 0x01010101); break; \
+ case 8: { \
+ uint32_t v32 = val * 0x01010101; \
+ AV_WN32A( &var, v32); \
+ AV_WN32A(&((uint8_t *) &var)[4], v32); \
+ break; \
+ } \
+ case 16: { \
+ uint32_t v32 = val * 0x01010101; \
+ AV_WN32A( &var, v32); \
+ AV_WN32A(&((uint8_t *) &var)[4], v32); \
+ AV_WN32A(&((uint8_t *) &var)[8], v32); \
+ AV_WN32A(&((uint8_t *) &var)[12], v32); \
+ break; \
+ } \
+ }
+#endif
+
+ switch (bwh_tab[1][b->bs][0]) {
+#define SET_CTXS(dir, off, n) \
+ do { \
+ SPLAT_CTX(s->dir##_skip_ctx[off], b->skip, n); \
+ SPLAT_CTX(s->dir##_txfm_ctx[off], b->tx, n); \
+ SPLAT_CTX(s->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
+ if (!s->keyframe && !s->intraonly) { \
+ SPLAT_CTX(s->dir##_intra_ctx[off], b->intra, n); \
+ SPLAT_CTX(s->dir##_comp_ctx[off], b->comp, n); \
+ SPLAT_CTX(s->dir##_mode_ctx[off], b->mode[3], n); \
+ if (!b->intra) { \
+ SPLAT_CTX(s->dir##_ref_ctx[off], vref, n); \
+ if (s->filtermode == FILTER_SWITCHABLE) { \
+ SPLAT_CTX(s->dir##_filter_ctx[off], filter_id, n); \
+ } \
+ } \
+ } \
+ } while (0)
+ case 1: SET_CTXS(above, col, 1); break;
+ case 2: SET_CTXS(above, col, 2); break;
+ case 4: SET_CTXS(above, col, 4); break;
+ case 8: SET_CTXS(above, col, 8); break;
}
+ switch (bwh_tab[1][b->bs][1]) {
+ case 1: SET_CTXS(left, row7, 1); break;
+ case 2: SET_CTXS(left, row7, 2); break;
+ case 4: SET_CTXS(left, row7, 4); break;
+ case 8: SET_CTXS(left, row7, 8); break;
+ }
+#undef SPLAT_CTX
+#undef SET_CTXS
- // FIXME this can probably be optimized
- memset(&s->above_skip_ctx[col], b->skip, w4);
- memset(&s->left_skip_ctx[row7], b->skip, h4);
- memset(&s->above_txfm_ctx[col], b->tx, w4);
- memset(&s->left_txfm_ctx[row7], b->tx, h4);
- memset(&s->above_partition_ctx[col], above_ctx[b->bs], w4);
- memset(&s->left_partition_ctx[row7], left_ctx[b->bs], h4);
if (!s->keyframe && !s->intraonly) {
- memset(&s->above_intra_ctx[col], b->intra, w4);
- memset(&s->left_intra_ctx[row7], b->intra, h4);
- memset(&s->above_comp_ctx[col], b->comp, w4);
- memset(&s->left_comp_ctx[row7], b->comp, h4);
- memset(&s->above_mode_ctx[col], b->mode[3], w4);
- memset(&s->left_mode_ctx[row7], b->mode[3], h4);
- if (s->filtermode == FILTER_SWITCHABLE && !b->intra ) {
- memset(&s->above_filter_ctx[col], b->filter, w4);
- memset(&s->left_filter_ctx[row7], b->filter, h4);
- b->filter = vp9_filter_lut[b->filter];
- }
if (b->bs > BS_8x8) {
int mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
@@ -1841,14 +1982,6 @@ static void decode_mode(AVCodecContext *ctx)
AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][1], mv1);
}
}
-
- if (!b->intra) { // FIXME write 0xff or -1 if intra, so we can use this
- // as a direct check in above branches
- int vref = b->ref[b->comp ? s->signbias[s->varcompref[0]] : 0];
-
- memset(&s->above_ref_ctx[col], vref, w4);
- memset(&s->left_ref_ctx[row7], vref, h4);
- }
}
// FIXME kinda ugly
@@ -1878,12 +2011,13 @@ static void decode_mode(AVCodecContext *ctx)
}
}
-// FIXME remove tx argument, and merge cnt/eob arguments?
-static int decode_coeffs_b(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
- enum TxfmMode tx, unsigned (*cnt)[6][3],
- unsigned (*eob)[6][2], uint8_t (*p)[6][11],
- int nnz, const int16_t *scan, const int16_t (*nb)[2],
- const int16_t *band_counts, const int16_t *qmul)
+// FIXME merge cnt/eob arguments?
+static av_always_inline int
+decode_coeffs_b_generic(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
+ int is_tx32x32, unsigned (*cnt)[6][3],
+ unsigned (*eob)[6][2], uint8_t (*p)[6][11],
+ int nnz, const int16_t *scan, const int16_t (*nb)[2],
+ const int16_t *band_counts, const int16_t *qmul)
{
int i = 0, band = 0, band_left = band_counts[band];
uint8_t *tp = p[0][nnz];
@@ -1975,7 +2109,7 @@ static int decode_coeffs_b(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
}
if (!--band_left)
band_left = band_counts[++band];
- if (tx == TX_32X32) // FIXME slow
+ if (is_tx32x32)
coef[rc] = ((vp8_rac_get(c) ? -val : val) * qmul[!!i]) / 2;
else
coef[rc] = (vp8_rac_get(c) ? -val : val) * qmul[!!i];
@@ -1986,6 +2120,26 @@ static int decode_coeffs_b(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
return i;
}
+static int decode_coeffs_b(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
+ unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
+ uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+ const int16_t (*nb)[2], const int16_t *band_counts,
+ const int16_t *qmul)
+{
+ return decode_coeffs_b_generic(c, coef, n_coeffs, 0, cnt, eob, p,
+ nnz, scan, nb, band_counts, qmul);
+}
+
+static int decode_coeffs_b32(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
+ unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
+ uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+ const int16_t (*nb)[2], const int16_t *band_counts,
+ const int16_t *qmul)
+{
+ return decode_coeffs_b_generic(c, coef, n_coeffs, 1, cnt, eob, p,
+ nnz, scan, nb, band_counts, qmul);
+}
+
static void decode_coeffs(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
@@ -1997,8 +2151,7 @@ static void decode_coeffs(AVCodecContext *ctx)
int w4 = bwh_tab[1][b->bs][0] << 1, h4 = bwh_tab[1][b->bs][1] << 1;
int end_x = FFMIN(2 * (s->cols - col), w4);
int end_y = FFMIN(2 * (s->rows - row), h4);
- int n, pl, x, y, step1d = 1 << b->tx, step = 1 << (b->tx * 2);
- int uvstep1d = 1 << b->uvtx, uvstep = 1 << (b->uvtx * 2), res;
+ int n, pl, x, y, res;
int16_t (*qmul)[2] = s->segmentation.feat[b->seg_id].qmul;
int tx = 4 * s->lossless + b->tx;
const int16_t * const *yscans = vp9_scans[tx];
@@ -2016,37 +2169,101 @@ static void decode_coeffs(AVCodecContext *ctx)
const int16_t *y_band_counts = band_counts[b->tx];
const int16_t *uv_band_counts = band_counts[b->uvtx];
- /* y tokens */
- if (b->tx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += step1d)
- for (x = 1; x < step1d; x++)
- l[y] |= l[y + x];
- for (x = 0; x < end_x; x += step1d)
- for (y = 1; y < step1d; y++)
- a[x] |= a[x + y];
+#define MERGE(la, end, step, rd) \
+ for (n = 0; n < end; n += step) \
+ la[n] = !!rd(&la[n])
+#define MERGE_CTX(step, rd) \
+ do { \
+ MERGE(l, end_y, step, rd); \
+ MERGE(a, end_x, step, rd); \
+ } while (0)
+
+#define DECODE_Y_COEF_LOOP(step, mode_index, v) \
+ for (n = 0, y = 0; y < end_y; y += step) { \
+ for (x = 0; x < end_x; x += step, n += step * step) { \
+ enum TxfmType txtp = vp9_intra_txfm_type[b->mode[mode_index]]; \
+ res = decode_coeffs_b##v(&s->c, s->block + 16 * n, 16 * step * step, \
+ c, e, p, a[x] + l[y], yscans[txtp], \
+ ynbs[txtp], y_band_counts, qmul[0]); \
+ a[x] = l[y] = !!res; \
+ if (step >= 4) { \
+ AV_WN16A(&s->eob[n], res); \
+ } else { \
+ s->eob[n] = res; \
+ } \
+ } \
}
- for (n = 0, y = 0; y < end_y; y += step1d) {
- for (x = 0; x < end_x; x += step1d, n += step) {
- enum TxfmType txtp = vp9_intra_txfm_type[b->mode[b->tx == TX_4X4 &&
- b->bs > BS_8x8 ?
- n : 0]];
- int nnz = a[x] + l[y];
- res = decode_coeffs_b(&s->c, s->block + 16 * n, 16 * step,
- b->tx, c, e, p, nnz, yscans[txtp],
- ynbs[txtp], y_band_counts, qmul[0]);
- a[x] = l[y] = !!res;
- if (b->tx > TX_8X8) {
- AV_WN16A(&s->eob[n], res);
- } else {
- s->eob[n] = res;
- }
- }
+
+#define SPLAT(la, end, step, cond) \
+ if (step == 2) { \
+ for (n = 1; n < end; n += step) \
+ la[n] = la[n - 1]; \
+ } else if (step == 4) { \
+ if (cond) { \
+ for (n = 0; n < end; n += step) \
+ AV_WN32A(&la[n], la[n] * 0x01010101); \
+ } else { \
+ for (n = 0; n < end; n += step) \
+ memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
+ } \
+ } else /* step == 8 */ { \
+ if (cond) { \
+ if (HAVE_FAST_64BIT) { \
+ for (n = 0; n < end; n += step) \
+ AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
+ } else { \
+ for (n = 0; n < end; n += step) { \
+ uint32_t v32 = la[n] * 0x01010101; \
+ AV_WN32A(&la[n], v32); \
+ AV_WN32A(&la[n + 4], v32); \
+ } \
+ } \
+ } else { \
+ for (n = 0; n < end; n += step) \
+ memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
+ } \
}
- if (b->tx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += step1d)
- memset(&l[y + 1], l[y], FFMIN(end_y - y - 1, step1d - 1));
- for (x = 0; x < end_x; x += step1d)
- memset(&a[x + 1], a[x], FFMIN(end_x - x - 1, step1d - 1));
+#define SPLAT_CTX(step) \
+ do { \
+ SPLAT(a, end_x, step, end_x == w4); \
+ SPLAT(l, end_y, step, end_y == h4); \
+ } while (0)
+
+ /* y tokens */
+ switch (b->tx) {
+ case TX_4X4:
+ DECODE_Y_COEF_LOOP(1, b->bs > BS_8x8 ? n : 0,);
+ break;
+ case TX_8X8:
+ MERGE_CTX(2, AV_RN16A);
+ DECODE_Y_COEF_LOOP(2, 0,);
+ SPLAT_CTX(2);
+ break;
+ case TX_16X16:
+ MERGE_CTX(4, AV_RN32A);
+ DECODE_Y_COEF_LOOP(4, 0,);
+ SPLAT_CTX(4);
+ break;
+ case TX_32X32:
+ MERGE_CTX(8, AV_RN64A);
+ DECODE_Y_COEF_LOOP(8, 0, 32);
+ SPLAT_CTX(8);
+ break;
+ }
+
+#define DECODE_UV_COEF_LOOP(step) \
+ for (n = 0, y = 0; y < end_y; y += step) { \
+ for (x = 0; x < end_x; x += step, n += step * step) { \
+ res = decode_coeffs_b(&s->c, s->uvblock[pl] + 16 * n, \
+ 16 * step * step, c, e, p, a[x] + l[y], \
+ uvscan, uvnb, uv_band_counts, qmul[1]); \
+ a[x] = l[y] = !!res; \
+ if (step >= 4) { \
+ AV_WN16A(&s->uveob[pl][n], res); \
+ } else { \
+ s->uveob[pl][n] = res; \
+ } \
+ } \
}
p = s->prob.coef[b->uvtx][1 /* uv */][!b->intra];
@@ -2059,33 +2276,31 @@ static void decode_coeffs(AVCodecContext *ctx)
for (pl = 0; pl < 2; pl++) {
a = &s->above_uv_nnz_ctx[pl][col];
l = &s->left_uv_nnz_ctx[pl][row & 7];
- if (b->uvtx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += uvstep1d)
- for (x = 1; x < uvstep1d; x++)
- l[y] |= l[y + x];
- for (x = 0; x < end_x; x += uvstep1d)
- for (y = 1; y < uvstep1d; y++)
- a[x] |= a[x + y];
- }
- for (n = 0, y = 0; y < end_y; y += uvstep1d) {
- for (x = 0; x < end_x; x += uvstep1d, n += uvstep) {
- int nnz = a[x] + l[y];
- res = decode_coeffs_b(&s->c, s->uvblock[pl] + 16 * n,
- 16 * uvstep, b->uvtx, c, e, p, nnz,
- uvscan, uvnb, uv_band_counts, qmul[1]);
- a[x] = l[y] = !!res;
- if (b->uvtx > TX_8X8) {
- AV_WN16A(&s->uveob[pl][n], res);
- } else {
- s->uveob[pl][n] = res;
- }
- }
- }
- if (b->uvtx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += uvstep1d)
- memset(&l[y + 1], l[y], FFMIN(end_y - y - 1, uvstep1d - 1));
- for (x = 0; x < end_x; x += uvstep1d)
- memset(&a[x + 1], a[x], FFMIN(end_x - x - 1, uvstep1d - 1));
+ switch (b->uvtx) {
+ case TX_4X4:
+ DECODE_UV_COEF_LOOP(1);
+ break;
+ case TX_8X8:
+ MERGE_CTX(2, AV_RN16A);
+ DECODE_UV_COEF_LOOP(2);
+ SPLAT_CTX(2);
+ break;
+ case TX_16X16:
+ MERGE_CTX(4, AV_RN32A);
+ DECODE_UV_COEF_LOOP(4);
+ SPLAT_CTX(4);
+ break;
+ case TX_32X32:
+ MERGE_CTX(8, AV_RN64A);
+ // a 64x64 (max) uv block can ever only contain 1 tx32x32 block
+ // so there is no need to loop
+ res = decode_coeffs_b32(&s->c, s->uvblock[pl],
+ 1024, c, e, p, a[0] + l[0],
+ uvscan, uvnb, uv_band_counts, qmul[1]);
+ a[0] = l[0] = !!res;
+ AV_WN16A(&s->uveob[pl][0], res);
+ SPLAT_CTX(8);
+ break;
}
}
}
@@ -2211,11 +2426,11 @@ static av_always_inline int check_intra_mode(VP9Context *s, int mode, uint8_t **
if (n_px_need <= n_px_have) {
for (i = 0; i < n_px_need; i++)
- l[i] = dst[i * stride - 1];
+ l[n_px_need - 1 - i] = dst[i * stride - 1];
} else {
for (i = 0; i < n_px_have; i++)
- l[i] = dst[i * stride - 1];
- memset(&l[i], l[i - 1], n_px_need - n_px_have);
+ l[n_px_need - 1 - i] = dst[i * stride - 1];
+ memset(l, l[n_px_need - n_px_have], n_px_need - n_px_have);
}
} else {
memset(l, 129, 4 << tx);
@@ -2237,6 +2452,8 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;
int uvstep1d = 1 << b->uvtx, p;
uint8_t *dst = s->dst[0], *dst_r = s->frames[CUR_FRAME].tf.f->data[0] + y_off;
+ LOCAL_ALIGNED_32(uint8_t, a_buf, [64]);
+ LOCAL_ALIGNED_32(uint8_t, l, [32]);
for (n = 0, y = 0; y < end_y; y += step1d) {
uint8_t *ptr = dst, *ptr_r = dst_r;
@@ -2244,8 +2461,7 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
ptr_r += 4 * step1d, n += step) {
int mode = b->mode[b->bs > BS_8x8 && b->tx == TX_4X4 ?
y * 2 + x : 0];
- LOCAL_ALIGNED_16(uint8_t, a_buf, [48]);
- uint8_t *a = &a_buf[16], l[32];
+ uint8_t *a = &a_buf[32];
enum TxfmType txtp = vp9_intra_txfm_type[mode];
int eob = b->skip ? 0 : b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
@@ -2276,8 +2492,7 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d,
ptr_r += 4 * uvstep1d, n += step) {
int mode = b->uvmode;
- LOCAL_ALIGNED_16(uint8_t, a_buf, [48]);
- uint8_t *a = &a_buf[16], l[32];
+ uint8_t *a = &a_buf[16];
int eob = b->skip ? 0 : b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n]) : s->uveob[p][n];
mode = check_intra_mode(s, mode, &a, ptr_r,
@@ -2381,48 +2596,53 @@ static void inter_recon(AVCodecContext *ctx)
VP9Context *s = ctx->priv_data;
VP9Block *b = s->b;
int row = s->row, col = s->col;
- ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]];
- AVFrame *ref1 = tref1->f;
- ThreadFrame *tref2 = b->comp ? &s->refs[s->refidx[b->ref[1]]] : NULL;
- AVFrame *ref2 = b->comp ? tref2->f : NULL;
- int w = ctx->width, h = ctx->height;
+ ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]], *tref2;
+ AVFrame *ref1 = tref1->f, *ref2;
+ int w1 = ref1->width, h1 = ref1->height, w2, h2;
ptrdiff_t ls_y = s->y_stride, ls_uv = s->uv_stride;
+ if (b->comp) {
+ tref2 = &s->refs[s->refidx[b->ref[1]]];
+ ref2 = tref2->f;
+ w2 = ref2->width;
+ h2 = ref2->height;
+ }
+
// y inter pred
if (b->bs > BS_8x8) {
if (b->bs == BS_8x4) {
mc_luma_dir(s, s->dsp.mc[3][b->filter][0], s->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, col << 3, &b->mv[0][0], 8, 4, w, h);
+ row << 3, col << 3, &b->mv[0][0], 8, 4, w1, h1);
mc_luma_dir(s, s->dsp.mc[3][b->filter][0],
s->dst[0] + 4 * ls_y, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- (row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w, h);
+ (row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w1, h1);
if (b->comp) {
mc_luma_dir(s, s->dsp.mc[3][b->filter][1], s->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, col << 3, &b->mv[0][1], 8, 4, w, h);
+ row << 3, col << 3, &b->mv[0][1], 8, 4, w2, h2);
mc_luma_dir(s, s->dsp.mc[3][b->filter][1],
s->dst[0] + 4 * ls_y, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- (row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w, h);
+ (row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w2, h2);
}
} else if (b->bs == BS_4x8) {
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, col << 3, &b->mv[0][0], 4, 8, w, h);
+ row << 3, col << 3, &b->mv[0][0], 4, 8, w1, h1);
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w, h);
+ row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w1, h1);
if (b->comp) {
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, col << 3, &b->mv[0][1], 4, 8, w, h);
+ row << 3, col << 3, &b->mv[0][1], 4, 8, w2, h2);
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w, h);
+ row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w2, h2);
}
} else {
av_assert2(b->bs == BS_4x4);
@@ -2431,34 +2651,34 @@ static void inter_recon(AVCodecContext *ctx)
// do a w8 instead of a w4 call
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, col << 3, &b->mv[0][0], 4, 4, w, h);
+ row << 3, col << 3, &b->mv[0][0], 4, 4, w1, h1);
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w, h);
+ row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w1, h1);
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
s->dst[0] + 4 * ls_y, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- (row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w, h);
+ (row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w1, h1);
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
s->dst[0] + 4 * ls_y + 4, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- (row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w, h);
+ (row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w1, h1);
if (b->comp) {
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, col << 3, &b->mv[0][1], 4, 4, w, h);
+ row << 3, col << 3, &b->mv[0][1], 4, 4, w2, h2);
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w, h);
+ row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w2, h2);
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
s->dst[0] + 4 * ls_y, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- (row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w, h);
+ (row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w2, h2);
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
s->dst[0] + 4 * ls_y + 4, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- (row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w, h);
+ (row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w2, h2);
}
}
} else {
@@ -2467,12 +2687,12 @@ static void inter_recon(AVCodecContext *ctx)
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], s->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
- row << 3, col << 3, &b->mv[0][0],bw, bh, w, h);
+ row << 3, col << 3, &b->mv[0][0],bw, bh, w1, h1);
if (b->comp)
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], s->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
- row << 3, col << 3, &b->mv[0][1], bw, bh, w, h);
+ row << 3, col << 3, &b->mv[0][1], bw, bh, w2, h2);
}
// uv inter pred
@@ -2481,8 +2701,12 @@ static void inter_recon(AVCodecContext *ctx)
int bw = bwh_tab[1][b->bs][0] * 4, bh = bwh_tab[1][b->bs][1] * 4;
VP56mv mvuv;
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
+ w1 = (w1 + 1) >> 1;
+ h1 = (h1 + 1) >> 1;
+ if (b->comp) {
+ w2 = (w2 + 1) >> 1;
+ h2 = (h2 + 1) >> 1;
+ }
if (b->bs > BS_8x8) {
mvuv.x = ROUNDED_DIV(b->mv[0][0].x + b->mv[1][0].x + b->mv[2][0].x + b->mv[3][0].x, 4);
mvuv.y = ROUNDED_DIV(b->mv[0][0].y + b->mv[1][0].y + b->mv[2][0].y + b->mv[3][0].y, 4);
@@ -2494,7 +2718,7 @@ static void inter_recon(AVCodecContext *ctx)
s->dst[1], s->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
- row << 2, col << 2, &mvuv, bw, bh, w, h);
+ row << 2, col << 2, &mvuv, bw, bh, w1, h1);
if (b->comp) {
if (b->bs > BS_8x8) {
@@ -2507,7 +2731,7 @@ static void inter_recon(AVCodecContext *ctx)
s->dst[1], s->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
- row << 2, col << 2, &mvuv, bw, bh, w, h);
+ row << 2, col << 2, &mvuv, bw, bh, w2, h2);
}
}
@@ -2698,7 +2922,7 @@ static void decode_b(AVCodecContext *ctx, int row, int col,
VP9Context *s = ctx->priv_data;
VP9Block *b = s->b;
enum BlockSize bs = bl * 3 + bp;
- int y, w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
+ int w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
int emu[2];
AVFrame *f = s->frames[CUR_FRAME].tf.f;
@@ -2720,13 +2944,34 @@ static void decode_b(AVCodecContext *ctx, int row, int col,
if (!b->skip) {
decode_coeffs(ctx);
} else {
- int pl;
+ int row7 = s->row7;
+
+#define SPLAT_ZERO_CTX(v, n) \
+ switch (n) { \
+ case 1: v = 0; break; \
+ case 2: AV_ZERO16(&v); break; \
+ case 4: AV_ZERO32(&v); break; \
+ case 8: AV_ZERO64(&v); break; \
+ case 16: AV_ZERO128(&v); break; \
+ }
+#define SPLAT_ZERO_YUV(dir, var, off, n) \
+ do { \
+ SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
+ SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
+ SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
+ } while (0)
- memset(&s->above_y_nnz_ctx[col * 2], 0, w4 * 2);
- memset(&s->left_y_nnz_ctx[(row & 7) << 1], 0, h4 * 2);
- for (pl = 0; pl < 2; pl++) {
- memset(&s->above_uv_nnz_ctx[pl][col], 0, w4);
- memset(&s->left_uv_nnz_ctx[pl][row & 7], 0, h4);
+ switch (w4) {
+ case 1: SPLAT_ZERO_YUV(above, nnz_ctx, col, 1); break;
+ case 2: SPLAT_ZERO_YUV(above, nnz_ctx, col, 2); break;
+ case 4: SPLAT_ZERO_YUV(above, nnz_ctx, col, 4); break;
+ case 8: SPLAT_ZERO_YUV(above, nnz_ctx, col, 8); break;
+ }
+ switch (h4) {
+ case 1: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 1); break;
+ case 2: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 2); break;
+ case 4: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 4); break;
+ case 8: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 8); break;
}
}
if (s->pass == 1) {
@@ -2746,9 +2991,9 @@ static void decode_b(AVCodecContext *ctx, int row, int col,
// allows to support emu-edge and so on even if we have large block
// overhangs
emu[0] = (col + w4) * 8 > f->linesize[0] ||
- (row + h4) > s->rows + 2 * !(ctx->flags & CODEC_FLAG_EMU_EDGE);
+ (row + h4) > s->rows;
emu[1] = (col + w4) * 4 > f->linesize[1] ||
- (row + h4) > s->rows + 2 * !(ctx->flags & CODEC_FLAG_EMU_EDGE);
+ (row + h4) > s->rows;
if (emu[0]) {
s->dst[0] = s->tmp_y;
s->y_stride = 64;
@@ -2806,12 +3051,11 @@ static void decode_b(AVCodecContext *ctx, int row, int col,
(lvl = s->segmentation.feat[b->seg_id].lflvl[b->intra ? 0 : b->ref[0] + 1]
[b->mode[3] != ZEROMV]) > 0) {
int x_end = FFMIN(s->cols - col, w4), y_end = FFMIN(s->rows - row, h4);
- int skip_inter = !b->intra && b->skip;
+ int skip_inter = !b->intra && b->skip, col7 = s->col7, row7 = s->row7;
- for (y = 0; y < h4; y++)
- memset(&lflvl->level[((row & 7) + y) * 8 + (col & 7)], lvl, w4);
- mask_edges(lflvl, 0, row & 7, col & 7, x_end, y_end, 0, 0, b->tx, skip_inter);
- mask_edges(lflvl, 1, row & 7, col & 7, x_end, y_end,
+ setctx_2d(&lflvl->level[row7 * 8 + col7], w4, h4, 8, lvl);
+ mask_edges(lflvl, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
+ mask_edges(lflvl, 1, row7, col7, x_end, y_end,
s->cols & 1 && col + w4 >= s->cols ? s->cols & 7 : 0,
s->rows & 1 && row + h4 >= s->rows ? s->rows & 7 : 0,
b->uvtx, skip_inter);
@@ -3449,6 +3693,13 @@ static void adapt_probs(VP9Context *s)
}
}
+static void free_buffers(VP9Context *s)
+{
+ av_freep(&s->intra_pred_data[0]);
+ av_freep(&s->b_base);
+ av_freep(&s->block_base);
+}
+
static av_cold int vp9_decode_free(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
@@ -3467,11 +3718,9 @@ static av_cold int vp9_decode_free(AVCodecContext *ctx)
ff_thread_release_buffer(ctx, &s->next_refs[i]);
av_frame_free(&s->next_refs[i].f);
}
- av_freep(&s->above_partition_ctx);
+ free_buffers(s);
av_freep(&s->c_b);
s->c_b_size = 0;
- av_freep(&s->b_base);
- av_freep(&s->block_base);
return 0;
}
@@ -3544,16 +3793,24 @@ static int vp9_decode_frame(AVCodecContext *ctx, void *frame,
memset(s->above_segpred_ctx, 0, s->cols);
s->pass = s->uses_2pass =
ctx->active_thread_type == FF_THREAD_FRAME && s->refreshctx && !s->parallelmode;
+ if ((res = update_block_buffers(ctx)) < 0) {
+ av_log(ctx, AV_LOG_ERROR,
+ "Failed to allocate block buffers\n");
+ return res;
+ }
if (s->refreshctx && s->parallelmode) {
int j, k, l, m;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++)
for (k = 0; k < 2; k++)
for (l = 0; l < 6; l++)
for (m = 0; m < 6; m++)
memcpy(s->prob_ctx[s->framectxid].coef[i][j][k][l][m],
s->prob.coef[i][j][k][l][m], 3);
+ if (s->txfmmode == i)
+ break;
+ }
s->prob_ctx[s->framectxid].p = s->prob.p;
ff_thread_finish_setup(ctx);
}
@@ -3583,11 +3840,15 @@ static int vp9_decode_frame(AVCodecContext *ctx, void *frame,
data += 4;
size -= 4;
}
- if (tile_size > size)
+ if (tile_size > size) {
+ ff_thread_report_progress(&s->frames[CUR_FRAME].tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
+ }
ff_vp56_init_range_decoder(&s->c_b[tile_col], data, tile_size);
- if (vp56_rac_get_prob_branchy(&s->c_b[tile_col], 128)) // marker bit
+ if (vp56_rac_get_prob_branchy(&s->c_b[tile_col], 128)) { // marker bit
+ ff_thread_report_progress(&s->frames[CUR_FRAME].tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
+ }
data += tile_size;
size -= tile_size;
}
@@ -3758,7 +4019,11 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
int i, res;
VP9Context *s = dst->priv_data, *ssrc = src->priv_data;
- // FIXME scalability, size, etc.
+ // detect size changes in other threads
+ if (s->intra_pred_data[0] &&
+ (!ssrc->intra_pred_data[0] || s->cols != ssrc->cols || s->rows != ssrc->rows)) {
+ free_buffers(s);
+ }
for (i = 0; i < 2; i++) {
if (s->frames[i].tf.f->data[0])
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp9_parser.c b/chromium/third_party/ffmpeg/libavcodec/vp9_parser.c
index 24f588f4412..af033c25e64 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp9_parser.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp9_parser.c
@@ -73,14 +73,14 @@ static int parse(AVCodecParserContext *ctx,
#define case_n(a, rd) \
case a: \
while (n_frames--) { \
- int sz = rd; \
+ unsigned sz = rd; \
idx += a; \
if (sz > size) { \
s->n_frames = 0; \
- av_log(ctx, AV_LOG_ERROR, \
- "Superframe packet size too big: %d > %d\n", \
+ av_log(avctx, AV_LOG_ERROR, \
+ "Superframe packet size too big: %u > %d\n", \
sz, size); \
- return AVERROR_INVALIDDATA; \
+ return size; \
} \
if (first) { \
first = 0; \
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp9dsp.c b/chromium/third_party/ffmpeg/libavcodec/vp9dsp.c
index ec0b411c937..e2f99f72c84 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp9dsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vp9dsp.c
@@ -84,10 +84,10 @@ static void vert_32x32_c(uint8_t *dst, ptrdiff_t stride,
static void hor_4x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *left, const uint8_t *top)
{
- AV_WN32A(dst + stride * 0, left[0] * 0x01010101U);
- AV_WN32A(dst + stride * 1, left[1] * 0x01010101U);
- AV_WN32A(dst + stride * 2, left[2] * 0x01010101U);
- AV_WN32A(dst + stride * 3, left[3] * 0x01010101U);
+ AV_WN32A(dst + stride * 0, left[3] * 0x01010101U);
+ AV_WN32A(dst + stride * 1, left[2] * 0x01010101U);
+ AV_WN32A(dst + stride * 2, left[1] * 0x01010101U);
+ AV_WN32A(dst + stride * 3, left[0] * 0x01010101U);
}
static void hor_8x8_c(uint8_t *dst, ptrdiff_t stride,
@@ -96,7 +96,7 @@ static void hor_8x8_c(uint8_t *dst, ptrdiff_t stride,
int y;
for (y = 0; y < 8; y++) {
- AV_WN64A(dst, left[y] * 0x0101010101010101ULL);
+ AV_WN64A(dst, left[7 - y] * 0x0101010101010101ULL);
dst += stride;
}
}
@@ -107,7 +107,7 @@ static void hor_16x16_c(uint8_t *dst, ptrdiff_t stride,
int y;
for (y = 0; y < 16; y++) {
- uint64_t p8 = left[y] * 0x0101010101010101ULL;
+ uint64_t p8 = left[15 - y] * 0x0101010101010101ULL;
AV_WN64A(dst + 0, p8);
AV_WN64A(dst + 8, p8);
@@ -121,7 +121,7 @@ static void hor_32x32_c(uint8_t *dst, ptrdiff_t stride,
int y;
for (y = 0; y < 32; y++) {
- uint64_t p8 = left[y] * 0x0101010101010101ULL;
+ uint64_t p8 = left[31 - y] * 0x0101010101010101ULL;
AV_WN64A(dst + 0, p8);
AV_WN64A(dst + 8, p8);
@@ -137,7 +137,7 @@ static void tm_4x4_c(uint8_t *dst, ptrdiff_t stride,
int y, tl = top[-1];
for (y = 0; y < 4; y++) {
- int l_m_tl = left[y] - tl;
+ int l_m_tl = left[3 - y] - tl;
dst[0] = av_clip_uint8(top[0] + l_m_tl);
dst[1] = av_clip_uint8(top[1] + l_m_tl);
@@ -153,7 +153,7 @@ static void tm_8x8_c(uint8_t *dst, ptrdiff_t stride,
int y, tl = top[-1];
for (y = 0; y < 8; y++) {
- int l_m_tl = left[y] - tl;
+ int l_m_tl = left[7 - y] - tl;
dst[0] = av_clip_uint8(top[0] + l_m_tl);
dst[1] = av_clip_uint8(top[1] + l_m_tl);
@@ -173,7 +173,7 @@ static void tm_16x16_c(uint8_t *dst, ptrdiff_t stride,
int y, tl = top[-1];
for (y = 0; y < 16; y++) {
- int l_m_tl = left[y] - tl;
+ int l_m_tl = left[15 - y] - tl;
dst[ 0] = av_clip_uint8(top[ 0] + l_m_tl);
dst[ 1] = av_clip_uint8(top[ 1] + l_m_tl);
@@ -201,7 +201,7 @@ static void tm_32x32_c(uint8_t *dst, ptrdiff_t stride,
int y, tl = top[-1];
for (y = 0; y < 32; y++) {
- int l_m_tl = left[y] - tl;
+ int l_m_tl = left[31 - y] - tl;
dst[ 0] = av_clip_uint8(top[ 0] + l_m_tl);
dst[ 1] = av_clip_uint8(top[ 1] + l_m_tl);
@@ -613,7 +613,7 @@ static void diag_downright_4x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *left, const uint8_t *top)
{
int tl = top[-1], a0 = top[0], a1 = top[1], a2 = top[2], a3 = top[3],
- l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3];
+ l0 = left[3], l1 = left[2], l2 = left[1], l3 = left[0];
DST(0,3) = (l1 + l2 * 2 + l3 + 2) >> 2;
DST(0,2) = DST(1,3) = (l0 + l1 * 2 + l2 + 2) >> 2;
@@ -632,11 +632,11 @@ static void diag_downright_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
uint8_t v[size + size - 1]; \
\
for (i = 0; i < size - 2; i++) { \
- v[i ] = (left[size - 1 - i] + left[size - 2 - i] * 2 + left[size - 3 - i] + 2) >> 2; \
- v[size + 1 + i] = (top[i] + top[i + 1] * 2 + top[i + 2] + 2) >> 2; \
+ v[i ] = (left[i] + left[i + 1] * 2 + left[i + 2] + 2) >> 2; \
+ v[size + 1 + i] = (top[i] + top[i + 1] * 2 + top[i + 2] + 2) >> 2; \
} \
- v[size - 2] = (left[1] + left[0] * 2 + top[-1] + 2) >> 2; \
- v[size - 1] = (left[0] + top[-1] * 2 + top[ 0] + 2) >> 2; \
+ v[size - 2] = (left[size - 2] + left[size - 1] * 2 + top[-1] + 2) >> 2; \
+ v[size - 1] = (left[size - 1] + top[-1] * 2 + top[ 0] + 2) >> 2; \
v[size ] = (top[-1] + top[0] * 2 + top[ 1] + 2) >> 2; \
\
for (j = 0; j < size; j++) \
@@ -651,7 +651,7 @@ static void vert_right_4x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *left, const uint8_t *top)
{
int tl = top[-1], a0 = top[0], a1 = top[1], a2 = top[2], a3 = top[3],
- l0 = left[0], l1 = left[1], l2 = left[2];
+ l0 = left[3], l1 = left[2], l2 = left[1];
DST(0,3) = (l0 + l1 * 2 + l2 + 2) >> 2;
DST(0,2) = (tl + l0 * 2 + l1 + 2) >> 2;
@@ -673,14 +673,14 @@ static void vert_right_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
uint8_t ve[size + size/2 - 1], vo[size + size/2 - 1]; \
\
for (i = 0; i < size/2 - 2; i++) { \
- vo[i] = (left[size - 4 - i*2] + left[size - 3 - i*2] * 2 + left[size - 2 - i*2] + 2) >> 2; \
- ve[i] = (left[size - 5 - i*2] + left[size - 4 - i*2] * 2 + left[size - 3 - i*2] + 2) >> 2; \
+ vo[i] = (left[i*2 + 3] + left[i*2 + 2] * 2 + left[i*2 + 1] + 2) >> 2; \
+ ve[i] = (left[i*2 + 4] + left[i*2 + 3] * 2 + left[i*2 + 2] + 2) >> 2; \
} \
- vo[size/2 - 2] = (left[0] + left[1] * 2 + left[2] + 2) >> 2; \
- ve[size/2 - 2] = (top[-1] + left[0] * 2 + left[1] + 2) >> 2; \
+ vo[size/2 - 2] = (left[size - 1] + left[size - 2] * 2 + left[size - 3] + 2) >> 2; \
+ ve[size/2 - 2] = (top[-1] + left[size - 1] * 2 + left[size - 2] + 2) >> 2; \
\
ve[size/2 - 1] = (top[-1] + top[0] + 1) >> 1; \
- vo[size/2 - 1] = (left[0] + top[-1] * 2 + top[0] + 2) >> 2; \
+ vo[size/2 - 1] = (left[size - 1] + top[-1] * 2 + top[0] + 2) >> 2; \
for (i = 0; i < size - 1; i++) { \
ve[size/2 + i] = (top[i] + top[i + 1] + 1) >> 1; \
vo[size/2 + i] = (top[i - 1] + top[i] * 2 + top[i + 1] + 2) >> 2; \
@@ -699,7 +699,7 @@ def_vert_right(32)
static void hor_down_4x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *left, const uint8_t *top)
{
- int l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3],
+ int l0 = left[3], l1 = left[2], l2 = left[1], l3 = left[0],
tl = top[-1], a0 = top[0], a1 = top[1], a2 = top[2];
DST(2,0) = (tl + a0 * 2 + a1 + 2) >> 2;
@@ -722,14 +722,14 @@ static void hor_down_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
uint8_t v[size * 3 - 2]; \
\
for (i = 0; i < size - 2; i++) { \
- v[i*2 ] = (left[size - 2 - i] + left[size - 1 - i] + 1) >> 1; \
- v[i*2 + 1] = (left[size - 3 - i] + left[size - 2 - i] * 2 + left[size - 1 - i] + 2) >> 2; \
+ v[i*2 ] = (left[i + 1] + left[i + 0] + 1) >> 1; \
+ v[i*2 + 1] = (left[i + 2] + left[i + 1] * 2 + left[i + 0] + 2) >> 2; \
v[size*2 + i] = (top[i - 1] + top[i] * 2 + top[i + 1] + 2) >> 2; \
} \
- v[size*2 - 2] = (top[-1] + left[0] + 1) >> 1; \
- v[size*2 - 4] = (left[0] + left[1] + 1) >> 1; \
- v[size*2 - 1] = (top[0] + top[-1] * 2 + left[0] + 2) >> 2; \
- v[size*2 - 3] = (top[-1] + left[0] * 2 + left[1] + 2) >> 2; \
+ v[size*2 - 2] = (top[-1] + left[size - 1] + 1) >> 1; \
+ v[size*2 - 4] = (left[size - 1] + left[size - 2] + 1) >> 1; \
+ v[size*2 - 1] = (top[0] + top[-1] * 2 + left[size - 1] + 2) >> 2; \
+ v[size*2 - 3] = (top[-1] + left[size - 1] * 2 + left[size - 2] + 2) >> 2; \
\
for (j = 0; j < size; j++) \
memcpy(dst + j*stride, v + size*2 - 2 - j*2, size); \
@@ -786,7 +786,7 @@ def_vert_left(32)
static void hor_up_4x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *left, const uint8_t *top)
{
- int l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3];
+ int l0 = left[3], l1 = left[2], l2 = left[1], l3 = left[0];
DST(0,0) = (l0 + l1 + 1) >> 1;
DST(1,0) = (l0 + l1 * 2 + l2 + 2) >> 2;
@@ -805,17 +805,17 @@ static void hor_up_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
uint8_t v[size*2 - 2]; \
\
for (i = 0; i < size - 2; i++) { \
- v[i*2 ] = (left[i] + left[i + 1] + 1) >> 1; \
- v[i*2 + 1] = (left[i] + left[i + 1] * 2 + left[i + 2] + 2) >> 2; \
+ v[i*2 ] = (left[size - i - 1] + left[size - i - 2] + 1) >> 1; \
+ v[i*2 + 1] = (left[size - i - 1] + left[size - i - 2] * 2 + left[size - i - 3] + 2) >> 2; \
} \
- v[size*2 - 4] = (left[size - 2] + left[size - 1] + 1) >> 1; \
- v[size*2 - 3] = (left[size - 2] + left[size - 1] * 3 + 2) >> 2; \
+ v[size*2 - 4] = (left[1] + left[0] + 1) >> 1; \
+ v[size*2 - 3] = (left[1] + left[0] * 3 + 2) >> 2; \
\
for (j = 0; j < size / 2; j++) \
memcpy(dst + j*stride, v + j*2, size); \
for (j = size / 2; j < size; j++) { \
memcpy(dst + j*stride, v + j*2, size*2 - 2 - j*2); \
- memset(dst + j*stride + size*2 - 2 - j*2, left[size - 1], \
+ memset(dst + j*stride + size*2 - 2 - j*2, left[0], \
2 + j*2 - size); \
} \
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/vp9dsp.h b/chromium/third_party/ffmpeg/libavcodec/vp9dsp.h
index 74124e44bed..db0a92e210c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vp9dsp.h
+++ b/chromium/third_party/ffmpeg/libavcodec/vp9dsp.h
@@ -104,7 +104,7 @@ typedef struct VP9DSPContext {
* dimension 2: filter type (0: smooth, 1: regular, 2: sharp, 3: bilin)
* dimension 3: averaging type (0: put, 1: avg)
* dimension 4: x subpel interpolation (0: none, 1: 8tap/bilin)
- * dimension 5: y subpel interpolation (1: none, 1: 8tap/bilin)
+ * dimension 5: y subpel interpolation (0: none, 1: 8tap/bilin)
*
* dst/stride are aligned by hsize
*/
diff --git a/chromium/third_party/ffmpeg/libavcodec/vqavideo.c b/chromium/third_party/ffmpeg/libavcodec/vqavideo.c
index 911e71339c4..c34849d5773 100644
--- a/chromium/third_party/ffmpeg/libavcodec/vqavideo.c
+++ b/chromium/third_party/ffmpeg/libavcodec/vqavideo.c
@@ -179,7 +179,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
/* allocate decode buffer */
s->decode_buffer_size = (s->width / s->vector_width) *
(s->height / s->vector_height) * 2;
- s->decode_buffer = av_malloc(s->decode_buffer_size);
+ s->decode_buffer = av_mallocz(s->decode_buffer_size);
if (!s->decode_buffer)
goto fail;
@@ -238,7 +238,7 @@ static int decode_format80(VqaContext *s, int src_size,
/* 0x80 means that frame is finished */
if (opcode == 0x80)
- return 0;
+ break;
if (dest_index >= dest_size) {
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
@@ -303,9 +303,11 @@ static int decode_format80(VqaContext *s, int src_size,
* codebook entry; it is not important for compressed codebooks because
* not every entry needs to be filled */
if (check_size)
- if (dest_index < dest_size)
+ if (dest_index < dest_size) {
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
dest_index, dest_size);
+ memset(dest + dest_index, 0, dest_size - dest_index);
+ }
return 0; // let's display what we decoded anyway
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/wavpack.c b/chromium/third_party/ffmpeg/libavcodec/wavpack.c
index 6036a5c7ddf..a2d82e6c2ec 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wavpack.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wavpack.c
@@ -487,6 +487,13 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
} while (!last && count < s->samples);
wv_reset_saved_context(s);
+
+ if (last && count < s->samples) {
+ int size = av_get_bytes_per_sample(type);
+ memset((uint8_t*)dst_l + count*size, 0, (s->samples-count)*size);
+ memset((uint8_t*)dst_r + count*size, 0, (s->samples-count)*size);
+ }
+
if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
wv_check_crc(s, crc, crc_extra_bits))
return AVERROR_INVALIDDATA;
@@ -548,6 +555,12 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
} while (!last && count < s->samples);
wv_reset_saved_context(s);
+
+ if (last && count < s->samples) {
+ int size = av_get_bytes_per_sample(type);
+ memset((uint8_t*)dst + count*size, 0, (s->samples-count)*size);
+ }
+
if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
int ret = wv_check_crc(s, crc, crc_extra_bits);
if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
@@ -609,7 +622,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
ThreadFrame tframe = { .f = frame };
WavpackFrameContext *s;
GetByteContext gb;
- void *samples_l, *samples_r;
+ void *samples_l = NULL, *samples_r = NULL;
int ret;
int got_terms = 0, got_weights = 0, got_samples = 0,
got_entropy = 0, got_bs = 0, got_float = 0, got_hybrid = 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/webp.c b/chromium/third_party/ffmpeg/libavcodec/webp.c
index c6d41bea15c..19cb1fc2236 100644
--- a/chromium/third_party/ffmpeg/libavcodec/webp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/webp.c
@@ -31,16 +31,20 @@
* Lossless decoder
* Compressed alpha for lossy
*
+ * @author James Almer <jamrial@gmail.com>
+ * Exif metadata
+ *
* Unimplemented:
* - Animation
* - ICC profile
- * - Exif and XMP metadata
+ * - XMP metadata
*/
#define BITSTREAM_READER_LE
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
+#include "exif.h"
#include "internal.h"
#include "get_bits.h"
#include "thread.h"
@@ -191,6 +195,8 @@ typedef struct WebPContext {
enum AlphaFilter alpha_filter; /* filtering method for alpha chunk */
uint8_t *alpha_data; /* alpha chunk data */
int alpha_data_size; /* alpha chunk data size */
+ int has_exif; /* set after an EXIF chunk has been processed */
+ AVDictionary *exif_metadata; /* EXIF chunk data */
int width; /* image width */
int height; /* image height */
int lossless; /* indicates lossless or lossy */
@@ -303,7 +309,7 @@ static int huff_reader_build_canonical(HuffReader *r, int *code_lengths,
if (max_code_length == 0 || max_code_length > MAX_HUFFMAN_CODE_LENGTH)
return AVERROR(EINVAL);
- codes = av_malloc(alphabet_size * sizeof(*codes));
+ codes = av_malloc_array(alphabet_size, sizeof(*codes));
if (!codes)
return AVERROR(ENOMEM);
@@ -1326,6 +1332,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->height = 0;
*got_frame = 0;
s->has_alpha = 0;
+ s->has_exif = 0;
bytestream2_init(&gb, avpkt->data, avpkt->size);
if (bytestream2_get_bytes_left(&gb) < 12)
@@ -1345,6 +1352,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
+ av_dict_free(&s->exif_metadata);
while (bytestream2_get_bytes_left(&gb) > 0) {
char chunk_str[5] = { 0 };
@@ -1418,10 +1426,44 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
break;
}
+ case MKTAG('E', 'X', 'I', 'F'): {
+ int le, ifd_offset, exif_offset = bytestream2_tell(&gb);
+ GetByteContext exif_gb;
+
+ if (s->has_exif) {
+ av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra EXIF chunk\n");
+ goto exif_end;
+ }
+ if (!(vp8x_flags & VP8X_FLAG_EXIF_METADATA))
+ av_log(avctx, AV_LOG_WARNING,
+ "EXIF chunk present, but Exif bit not set in the "
+ "VP8X header\n");
+
+ s->has_exif = 1;
+ bytestream2_init(&exif_gb, avpkt->data + exif_offset,
+ avpkt->size - exif_offset);
+ if (ff_tdecode_header(&exif_gb, &le, &ifd_offset) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "invalid TIFF header "
+ "in Exif data\n");
+ goto exif_end;
+ }
+
+ bytestream2_seek(&exif_gb, ifd_offset, SEEK_SET);
+ if (avpriv_exif_decode_ifd(avctx, &exif_gb, le, 0, &s->exif_metadata) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error decoding Exif data\n");
+ goto exif_end;
+ }
+
+ av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0);
+
+exif_end:
+ av_dict_free(&s->exif_metadata);
+ bytestream2_skip(&gb, chunk_size);
+ break;
+ }
case MKTAG('I', 'C', 'C', 'P'):
case MKTAG('A', 'N', 'I', 'M'):
case MKTAG('A', 'N', 'M', 'F'):
- case MKTAG('E', 'X', 'I', 'F'):
case MKTAG('X', 'M', 'P', ' '):
AV_WL32(chunk_str, chunk_type);
av_log(avctx, AV_LOG_VERBOSE, "skipping unsupported chunk: %s\n",
diff --git a/chromium/third_party/ffmpeg/libavcodec/wma.c b/chromium/third_party/ffmpeg/libavcodec/wma.c
index 0122ee6fe3f..f2519f543ba 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wma.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wma.c
@@ -45,10 +45,10 @@ static av_cold void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);
- run_table = av_malloc(n * sizeof(uint16_t));
- level_table = av_malloc(n * sizeof(uint16_t));
- flevel_table= av_malloc(n * sizeof(*flevel_table));
- int_table = av_malloc(n * sizeof(uint16_t));
+ run_table = av_malloc_array(n, sizeof(uint16_t));
+ level_table = av_malloc_array(n, sizeof(uint16_t));
+ flevel_table= av_malloc_array(n, sizeof(*flevel_table));
+ int_table = av_malloc_array(n, sizeof(uint16_t));
i = 2;
level = 1;
k = 0;
@@ -386,9 +386,9 @@ int ff_wma_end(AVCodecContext *avctx)
}
for (i = 0; i < 2; i++) {
ff_free_vlc(&s->coef_vlc[i]);
- av_free(s->run_table[i]);
- av_free(s->level_table[i]);
- av_free(s->int_table[i]);
+ av_freep(&s->run_table[i]);
+ av_freep(&s->level_table[i]);
+ av_freep(&s->int_table[i]);
}
return 0;
diff --git a/chromium/third_party/ffmpeg/libavcodec/wmadec.c b/chromium/third_party/ffmpeg/libavcodec/wmadec.c
index e6a0b04779e..466c1a9a105 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wmadec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wmadec.c
@@ -100,6 +100,9 @@ static av_cold int wma_decode_init(AVCodecContext * avctx)
}
}
+ for (i=0; i<MAX_CHANNELS; i++)
+ s->max_exponent[i] = 1.0;
+
if(ff_wma_init(avctx, flags2)<0)
return -1;
@@ -924,7 +927,7 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data,
samples_offset += s->frame_len;
}
- av_dlog(s->avctx, "%d %d %d %d outbytes:%td eaten:%d\n",
+ av_dlog(s->avctx, "%d %d %d %d outbytes:%"PTRDIFF_SPECIFIER" eaten:%d\n",
s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len,
(int8_t *)samples - (int8_t *)data, avctx->block_align);
diff --git a/chromium/third_party/ffmpeg/libavcodec/wmalosslessdec.c b/chromium/third_party/ffmpeg/libavcodec/wmalosslessdec.c
index 7a80248ffc4..99139eba78e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wmalosslessdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wmalosslessdec.c
@@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
@@ -127,8 +129,8 @@ typedef struct WmallDecodeCtx {
int8_t mclms_order;
int8_t mclms_scaling;
- int16_t mclms_coeffs[128];
- int16_t mclms_coeffs_cur[4];
+ int16_t mclms_coeffs[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS * 32];
+ int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS];
int16_t mclms_prevvalues[WMALL_MAX_CHANNELS * 2 * 32];
int16_t mclms_updates[WMALL_MAX_CHANNELS * 2 * 32];
int mclms_recent;
@@ -197,7 +199,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
avpriv_report_missing_feature(avctx, "Bit-depth higher than 16");
return AVERROR_PATCHWELCOME;
} else {
- av_log(avctx, AV_LOG_ERROR, "Unknown bit-depth: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "Unknown bit-depth: %"PRIu8"\n",
s->bits_per_sample);
return AVERROR_INVALIDDATA;
}
@@ -239,7 +241,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->bV3RTM = s->decode_flags & 0x100;
if (s->max_num_subframes > MAX_SUBFRAMES) {
- av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %i\n",
+ av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %"PRIu8"\n",
s->max_num_subframes);
return AVERROR_INVALIDDATA;
}
@@ -257,7 +259,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
if (s->num_channels < 0) {
- av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n",
+ av_log(avctx, AV_LOG_ERROR, "invalid number of channels %"PRId8"\n",
s->num_channels);
return AVERROR_INVALIDDATA;
} else if (s->num_channels > WMALL_MAX_CHANNELS) {
@@ -348,11 +350,11 @@ static int decode_tilehdr(WmallDecodeCtx *s)
if (num_samples[c] == min_channel_len) {
if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
(min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
- contains_subframe[c] = in_use = 1;
+ contains_subframe[c] = 1;
} else {
- if (get_bits1(&s->gb))
- contains_subframe[c] = in_use = 1;
+ contains_subframe[c] = get_bits1(&s->gb);
}
+ in_use |= contains_subframe[c];
} else
contains_subframe[c] = 0;
}
@@ -382,7 +384,7 @@ static int decode_tilehdr(WmallDecodeCtx *s)
++chan->num_subframes;
if (num_samples[c] > s->samples_per_frame) {
av_log(s->avctx, AV_LOG_ERROR, "broken frame: "
- "channel len(%d) > samples_per_frame(%d)\n",
+ "channel len(%"PRIu16") > samples_per_frame(%"PRIu16")\n",
num_samples[c], s->samples_per_frame);
return AVERROR_INVALIDDATA;
}
@@ -652,10 +654,10 @@ static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
if (s->mclms_recent == 0) {
memcpy(&s->mclms_prevvalues[order * num_channels],
s->mclms_prevvalues,
- 2 * order * num_channels);
+ sizeof(int16_t) * order * num_channels);
memcpy(&s->mclms_updates[order * num_channels],
s->mclms_updates,
- 2 * order * num_channels);
+ sizeof(int16_t) * order * num_channels);
s->mclms_recent = num_channels * order;
}
}
@@ -1038,9 +1040,10 @@ static int decode_frame(WmallDecodeCtx *s)
len = get_bits(gb, s->log2_frame_size);
/* decode tile information */
- if (decode_tilehdr(s)) {
+ if ((ret = decode_tilehdr(s))) {
s->packet_loss = 1;
- return 0;
+ av_frame_unref(s->frame);
+ return ret;
}
/* read drc info */
@@ -1075,8 +1078,11 @@ static int decode_frame(WmallDecodeCtx *s)
/* decode all subframes */
while (!s->parsed_all_subframes) {
+ int decoded_samples = s->channel[0].decoded_samples;
if (decode_subframe(s) < 0) {
s->packet_loss = 1;
+ if (s->frame->nb_samples)
+ s->frame->nb_samples = decoded_samples;
return 0;
}
}
@@ -1090,7 +1096,8 @@ static int decode_frame(WmallDecodeCtx *s)
if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
/* FIXME: not sure if this is always an error */
av_log(s->avctx, AV_LOG_ERROR,
- "frame[%i] would have to skip %i bits\n", s->frame_num,
+ "frame[%"PRIu32"] would have to skip %i bits\n",
+ s->frame_num,
len - (get_bits_count(gb) - s->frame_offset) - 1);
s->packet_loss = 1;
return 0;
@@ -1209,7 +1216,8 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
- av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
+ av_log(avctx, AV_LOG_ERROR,
+ "Packet loss detected! seq %"PRIx8" vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
diff --git a/chromium/third_party/ffmpeg/libavcodec/wmaprodec.c b/chromium/third_party/ffmpeg/libavcodec/wmaprodec.c
index d57c24dddf5..2f6c4858919 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wmaprodec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wmaprodec.c
@@ -86,6 +86,8 @@
* subframe in order to reconstruct the output samples.
*/
+#include <inttypes.h>
+
#include "libavutil/float_dsp.h"
#include "libavutil/intfloat.h"
#include "libavutil/intreadwrite.h"
@@ -237,7 +239,7 @@ typedef struct WMAProDecodeCtx {
static av_cold void dump_context(WMAProDecodeCtx *s)
{
#define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b);
-#define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b);
+#define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %"PRIx32"\n", a, b);
PRINT("ed sample bit depth", s->bits_per_sample);
PRINT_HEX("ed decode flags", s->decode_flags);
@@ -336,7 +338,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->dynamic_range_compression = (s->decode_flags & 0x80);
if (s->max_num_subframes > MAX_SUBFRAMES) {
- av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %i\n",
+ av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %"PRId8"\n",
s->max_num_subframes);
return AVERROR_INVALIDDATA;
}
@@ -1421,7 +1423,8 @@ static int decode_frame(WMAProDecodeCtx *s, AVFrame *frame, int *got_frame_ptr)
if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
/** FIXME: not sure if this is always an error */
av_log(s->avctx, AV_LOG_ERROR,
- "frame[%i] would have to skip %i bits\n", s->frame_num,
+ "frame[%"PRIu32"] would have to skip %i bits\n",
+ s->frame_num,
len - (get_bits_count(gb) - s->frame_offset) - 1);
s->packet_loss = 1;
return 0;
@@ -1553,7 +1556,8 @@ static int decode_packet(AVCodecContext *avctx, void *data,
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
- av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
+ av_log(avctx, AV_LOG_ERROR,
+ "Packet loss detected! seq %"PRIx8" vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
diff --git a/chromium/third_party/ffmpeg/libavcodec/wmv2.c b/chromium/third_party/ffmpeg/libavcodec/wmv2.c
index 30c8bc1d3a6..b8df6ca065d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wmv2.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wmv2.c
@@ -117,17 +117,17 @@ void ff_mspel_motion(MpegEncContext *s,
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + (src_y * linesize) + src_x;
- if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
- || src_y + h+1 >= v_edge_pos){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
- ptr - 1 - s->linesize,
- s->linesize, s->linesize,
- 19, 19,
- src_x - 1, src_y - 1,
- s->h_edge_pos, s->v_edge_pos);
- ptr= s->edge_emu_buffer + 1 + s->linesize;
- emu=1;
- }
+ if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
+ || src_y + h+1 >= v_edge_pos){
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
+ ptr - 1 - s->linesize,
+ s->linesize, s->linesize,
+ 19, 19,
+ src_x - 1, src_y - 1,
+ s->h_edge_pos, s->v_edge_pos);
+ ptr= s->edge_emu_buffer + 1 + s->linesize;
+ emu=1;
+ }
s->dsp.put_mspel_pixels_tab[dxy](dest_y , ptr , linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y+8 , ptr+8 , linesize);
diff --git a/chromium/third_party/ffmpeg/libavcodec/wmv2dec.c b/chromium/third_party/ffmpeg/libavcodec/wmv2dec.c
index 4f2a5e996dc..f35c818fc56 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wmv2dec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wmv2dec.c
@@ -19,6 +19,7 @@
*/
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "mathops.h"
@@ -476,5 +477,8 @@ AVCodec ff_wmv2_decoder = {
.close = wmv2_decode_end,
.decode = ff_h263_decode_frame,
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .pix_fmts = ff_pixfmt_list_420,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+ },
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/wnv1.c b/chromium/third_party/ffmpeg/libavcodec/wnv1.c
index d8532e4b16b..99aee3cd1c5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/wnv1.c
+++ b/chromium/third_party/ffmpeg/libavcodec/wnv1.c
@@ -78,6 +78,7 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
+ memset(rbuf + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_free(rbuf);
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/Makefile b/chromium/third_party/ffmpeg/libavcodec/x86/Makefile
index 2d2d5a09af2..1607d42b90e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/Makefile
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/Makefile
@@ -1,28 +1,37 @@
OBJS += x86/constants.o \
x86/fmtconvert_init.o \
-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o
OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o
-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o
OBJS-$(CONFIG_DCT) += x86/dct_init.o
-OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc.o
OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_init.o \
x86/dsputil_x86.o
OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \
x86/fdct.o \
x86/motion_est.o
OBJS-$(CONFIG_FFT) += x86/fft_init.o
+OBJS-$(CONFIG_FLAC_DECODER) += x86/flacdsp_init.o
+OBJS-$(CONFIG_FLAC_ENCODER) += x86/flacdsp_init.o
OBJS-$(CONFIG_H263DSP) += x86/h263dsp_init.o
OBJS-$(CONFIG_H264CHROMA) += x86/h264chroma_init.o
OBJS-$(CONFIG_H264DSP) += x86/h264dsp_init.o
OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
OBJS-$(CONFIG_H264QPEL) += x86/h264_qpel.o
+OBJS-$(CONFIG_HEVC_DECODER) += x86/hevcdsp_init.o
OBJS-$(CONFIG_HPELDSP) += x86/hpeldsp_init.o
+OBJS-$(CONFIG_LLVIDDSP) += x86/lossless_videodsp_init.o
OBJS-$(CONFIG_LPC) += x86/lpc.o
-OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o
OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodsp.o
OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o
OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoenc.o
+OBJS-$(CONFIG_VIDEODSP) += x86/videodsp_init.o
+OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp_init.o
+OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
+
+OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o
+OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o
+OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o
+OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o
+OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o
OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o
OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp_init.o
@@ -30,27 +39,25 @@ OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o
OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp_init.o \
x86/rv40dsp_init.o
OBJS-$(CONFIG_V210_DECODER) += x86/v210-init.o
+OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp_init.o
OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o
OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_init.o
-OBJS-$(CONFIG_VIDEODSP) += x86/videodsp_init.o
OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o
-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp_init.o
OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp_init.o
+OBJS-$(CONFIG_VP7_DECODER) += x86/vp8dsp_init.o
OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o
OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o
OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp_init.o
-OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
MMX-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_mmx.o \
x86/fpel_mmx.o \
x86/idct_mmx_xvid.o \
x86/idct_sse2_xvid.o \
- x86/rnd_mmx.o \
x86/simple_idct.o
MMX-OBJS-$(CONFIG_DIRAC_DECODER) += x86/dirac_dwt.o
MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \
- x86/hpeldsp_mmx.o \
- x86/rnd_mmx.o
+ x86/hpeldsp_mmx.o
+
MMX-OBJS-$(CONFIG_SNOW_DECODER) += x86/snowdsp.o
MMX-OBJS-$(CONFIG_SNOW_ENCODER) += x86/snowdsp.o
MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o
@@ -58,17 +65,18 @@ MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o
YASM-OBJS += x86/deinterlace.o \
x86/fmtconvert.o \
-YASM-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp.o
YASM-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp.o
YASM-OBJS-$(CONFIG_DCT) += x86/dct32.o
YASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_mmx.o x86/diracdsp_yasm.o\
x86/dwt_yasm.o
+YASM-OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc.o
YASM-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil.o \
x86/fpel.o \
x86/mpeg4qpel.o \
x86/qpel.o
YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc.o
YASM-OBJS-$(CONFIG_FFT) += x86/fft.o
+YASM-OBJS-$(CONFIG_FLAC_DECODER) += x86/flacdsp.o
YASM-OBJS-$(CONFIG_H263DSP) += x86/h263_loopfilter.o
YASM-OBJS-$(CONFIG_H264CHROMA) += x86/h264_chromamc.o \
x86/h264_chromamc_10bit.o
@@ -84,23 +92,33 @@ YASM-OBJS-$(CONFIG_H264QPEL) += x86/h264_qpel_8bit.o \
x86/h264_qpel_10bit.o \
x86/fpel.o \
x86/qpel.o
+YASM-OBJS-$(CONFIG_HEVC_DECODER) += x86/hevc_mc.o
YASM-OBJS-$(CONFIG_HPELDSP) += x86/fpel.o \
x86/hpeldsp.o
+YASM-OBJS-$(CONFIG_LLVIDDSP) += x86/lossless_videodsp.o
YASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o
+YASM-OBJS-$(CONFIG_VIDEODSP) += x86/videodsp.o
+YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o
+
+YASM-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp.o
+YASM-OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp.o
YASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o
YASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o
YASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o
YASM-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp.o
YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp.o \
x86/rv40dsp.o
+YASM-OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp.o
YASM-OBJS-$(CONFIG_V210_DECODER) += x86/v210.o
YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp.o
-YASM-OBJS-$(CONFIG_VIDEODSP) += x86/videodsp.o
YASM-OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp.o
-YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o
YASM-OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp.o
+YASM-OBJS-$(CONFIG_VP7_DECODER) += x86/vp8dsp.o \
+ x86/vp8dsp_loopfilter.o
YASM-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp.o \
x86/vp8dsp_loopfilter.o
-YASM-OBJS-$(CONFIG_VP9_DECODER) += x86/vp9itxfm.o \
+YASM-OBJS-$(CONFIG_VP9_DECODER) += x86/vp9intrapred.o \
+ x86/vp9itxfm.o \
+ x86/vp9lpf.o \
x86/vp9mc.o
YASM-OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp.o
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp.asm
index 89a64f50d4b..b24441614b7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp.asm
@@ -1,5 +1,5 @@
;*****************************************************************************
-;* x86-optimized AC-3 DSP utils
+;* x86-optimized AC-3 DSP functions
;* Copyright (c) 2011 Justin Ruggles
;*
;* This file is part of FFmpeg.
@@ -35,6 +35,10 @@ pw_bap_mul2: dw 5, 7, 0, 7, 5, 7, 0, 7
pd_1: times 4 dd 1
pd_151: times 4 dd 151
+; used in ff_apply_window_int16()
+pb_revwords: SHUFFLE_MASK_W 7, 6, 5, 4, 3, 2, 1, 0
+pd_16384: times 4 dd 16384
+
SECTION .text
;-----------------------------------------------------------------------------
@@ -419,3 +423,130 @@ AC3_EXTRACT_EXPONENTS
INIT_XMM ssse3
AC3_EXTRACT_EXPONENTS
%endif
+
+;-----------------------------------------------------------------------------
+; void ff_apply_window_int16(int16_t *output, const int16_t *input,
+; const int16_t *window, unsigned int len)
+;-----------------------------------------------------------------------------
+
+%macro REVERSE_WORDS 1-2
+%if cpuflag(ssse3) && notcpuflag(atom)
+ pshufb %1, %2
+%elif cpuflag(sse2)
+ pshuflw %1, %1, 0x1B
+ pshufhw %1, %1, 0x1B
+ pshufd %1, %1, 0x4E
+%elif cpuflag(mmxext)
+ pshufw %1, %1, 0x1B
+%endif
+%endmacro
+
+%macro MUL16FIXED 3
+%if cpuflag(ssse3) ; dst, src, unused
+; dst = ((dst * src) + (1<<14)) >> 15
+ pmulhrsw %1, %2
+%elif cpuflag(mmxext) ; dst, src, temp
+; dst = (dst * src) >> 15
+; pmulhw cuts off the bottom bit, so we have to lshift by 1 and add it back
+; in from the pmullw result.
+ mova %3, %1
+ pmulhw %1, %2
+ pmullw %3, %2
+ psrlw %3, 15
+ psllw %1, 1
+ por %1, %3
+%endif
+%endmacro
+
+%macro APPLY_WINDOW_INT16 1 ; %1 bitexact version
+%if %1
+cglobal apply_window_int16, 4,5,6, output, input, window, offset, offset2
+%else
+cglobal apply_window_int16_round, 4,5,6, output, input, window, offset, offset2
+%endif
+ lea offset2q, [offsetq-mmsize]
+%if cpuflag(ssse3) && notcpuflag(atom)
+ mova m5, [pb_revwords]
+ ALIGN 16
+%elif %1
+ mova m5, [pd_16384]
+%endif
+.loop:
+%if cpuflag(ssse3)
+ ; This version does the 16x16->16 multiplication in-place without expanding
+ ; to 32-bit. The ssse3 version is bit-identical.
+ mova m0, [windowq+offset2q]
+ mova m1, [ inputq+offset2q]
+ pmulhrsw m1, m0
+ REVERSE_WORDS m0, m5
+ pmulhrsw m0, [ inputq+offsetq ]
+ mova [outputq+offset2q], m1
+ mova [outputq+offsetq ], m0
+%elif %1
+ ; This version expands 16-bit to 32-bit, multiplies by the window,
+ ; adds 16384 for rounding, right shifts 15, then repacks back to words to
+ ; save to the output. The window is reversed for the second half.
+ mova m3, [windowq+offset2q]
+ mova m4, [ inputq+offset2q]
+ pxor m0, m0
+ punpcklwd m0, m3
+ punpcklwd m1, m4
+ pmaddwd m0, m1
+ paddd m0, m5
+ psrad m0, 15
+ pxor m2, m2
+ punpckhwd m2, m3
+ punpckhwd m1, m4
+ pmaddwd m2, m1
+ paddd m2, m5
+ psrad m2, 15
+ packssdw m0, m2
+ mova [outputq+offset2q], m0
+ REVERSE_WORDS m3
+ mova m4, [ inputq+offsetq]
+ pxor m0, m0
+ punpcklwd m0, m3
+ punpcklwd m1, m4
+ pmaddwd m0, m1
+ paddd m0, m5
+ psrad m0, 15
+ pxor m2, m2
+ punpckhwd m2, m3
+ punpckhwd m1, m4
+ pmaddwd m2, m1
+ paddd m2, m5
+ psrad m2, 15
+ packssdw m0, m2
+ mova [outputq+offsetq], m0
+%else
+ ; This version does the 16x16->16 multiplication in-place without expanding
+ ; to 32-bit. The mmxext and sse2 versions do not use rounding, and
+ ; therefore are not bit-identical to the C version.
+ mova m0, [windowq+offset2q]
+ mova m1, [ inputq+offset2q]
+ mova m2, [ inputq+offsetq ]
+ MUL16FIXED m1, m0, m3
+ REVERSE_WORDS m0
+ MUL16FIXED m2, m0, m3
+ mova [outputq+offset2q], m1
+ mova [outputq+offsetq ], m2
+%endif
+ add offsetd, mmsize
+ sub offset2d, mmsize
+ jae .loop
+ REP_RET
+%endmacro
+
+INIT_MMX mmxext
+APPLY_WINDOW_INT16 0
+INIT_XMM sse2
+APPLY_WINDOW_INT16 0
+
+INIT_MMX mmxext
+APPLY_WINDOW_INT16 1
+INIT_XMM sse2
+APPLY_WINDOW_INT16 1
+INIT_XMM ssse3
+APPLY_WINDOW_INT16 1
+INIT_XMM ssse3, atom
+APPLY_WINDOW_INT16 1
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp_init.c
index 5819d0021c6..30a85f996ea 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/ac3dsp_init.c
@@ -1,5 +1,5 @@
/*
- * x86-optimized AC-3 DSP utils
+ * x86-optimized AC-3 DSP functions
* Copyright (c) 2011 Justin Ruggles
*
* This file is part of FFmpeg.
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
-#include "dsputil_x86.h"
#include "libavcodec/ac3.h"
#include "libavcodec/ac3dsp.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/cabac.h b/chromium/third_party/ffmpeg/libavcodec/x86/cabac.h
index 558d287032b..3510336f957 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/cabac.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/cabac.h
@@ -23,12 +23,13 @@
#include "libavcodec/cabac.h"
#include "libavutil/attributes.h"
+#include "libavutil/macros.h"
#include "libavutil/x86/asm.h"
-#include "libavutil/internal.h"
#include "config.h"
#if (defined(__i386) && defined(__clang__) && (__clang_major__<2 || (__clang_major__==2 && __clang_minor__<10)))\
- || ( !defined(__clang__) && defined(__llvm__) && __GNUC__==4 && __GNUC_MINOR__==2 && __GNUC_PATCHLEVEL__<=1)
+ || ( !defined(__clang__) && defined(__llvm__) && __GNUC__==4 && __GNUC_MINOR__==2 && __GNUC_PATCHLEVEL__<=1)\
+ || (defined(__INTEL_COMPILER) && defined(_MSC_VER))
# define BROKEN_COMPILER 1
#else
# define BROKEN_COMPILER 0
@@ -110,7 +111,7 @@
"2: \n\t"
#else /* BROKEN_RELOCATIONS */
-#define TABLES_ARG
+#define TABLES_ARG NAMED_CONSTRAINTS_ARRAY_ADD(ff_h264_cabac_tables)
#define RIP_ARG
#if HAVE_FAST_CMOV
@@ -184,6 +185,7 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c,
__asm__ volatile(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
+ : NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)
);
#endif
@@ -205,7 +207,7 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c,
);
return bit & 1;
}
-#endif /* HAVE_7REGS */
+#endif /* HAVE_7REGS && !BROKEN_COMPILER */
#if !BROKEN_COMPILER
#define get_cabac_bypass_sign get_cabac_bypass_sign_x86
@@ -218,7 +220,7 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val)
"shl $17, %k1 \n\t"
"add %%eax, %%eax \n\t"
"sub %k1, %%eax \n\t"
- "cltd \n\t"
+ "cdq \n\t"
"and %%edx, %k1 \n\t"
"add %k1, %%eax \n\t"
"xor %%edx, %%ecx \n\t"
@@ -265,7 +267,7 @@ static av_always_inline int get_cabac_bypass_x86(CABACContext *c)
"shl $17, %k1 \n\t"
"add %%eax, %%eax \n\t"
"sub %k1, %%eax \n\t"
- "cltd \n\t"
+ "cdq \n\t"
"and %%edx, %k1 \n\t"
"add %k1, %%eax \n\t"
"inc %%edx \n\t"
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/cavsdsp.c b/chromium/third_party/ffmpeg/libavcodec/x86/cavsdsp.c
index aaa09d1784a..b45126cf011 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/cavsdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/cavsdsp.c
@@ -30,6 +30,7 @@
#include "libavcodec/cavsdsp.h"
#include "constants.h"
#include "dsputil_x86.h"
+#include "fpel.h"
#include "config.h"
#if HAVE_MMX_INLINE
@@ -210,10 +211,10 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
****************************************************************************/
/* vertical filter [-1 -2 96 42 -7 0] */
-#define QPEL_CAVSV1(A,B,C,D,E,F,OP,MUL2) \
+#define QPEL_CAVSV1(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
"movd (%0), "#F" \n\t"\
"movq "#C", %%mm6 \n\t"\
- "pmullw %5, %%mm6 \n\t"\
+ "pmullw "MANGLE(MUL1)", %%mm6\n\t"\
"movq "#D", %%mm7 \n\t"\
"pmullw "MANGLE(MUL2)", %%mm7\n\t"\
"psllw $3, "#E" \n\t"\
@@ -228,35 +229,35 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
"psubw "#B", %%mm6 \n\t"\
"psraw $1, "#B" \n\t"\
"psubw "#A", %%mm6 \n\t"\
- "paddw %4, %%mm6 \n\t"\
+ "paddw "MANGLE(ADD)", %%mm6 \n\t"\
"psraw $7, %%mm6 \n\t"\
"packuswb %%mm6, %%mm6 \n\t"\
OP(%%mm6, (%1), A, d) \
"add %3, %1 \n\t"
/* vertical filter [ 0 -1 5 5 -1 0] */
-#define QPEL_CAVSV2(A,B,C,D,E,F,OP,MUL2) \
+#define QPEL_CAVSV2(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
"movd (%0), "#F" \n\t"\
"movq "#C", %%mm6 \n\t"\
"paddw "#D", %%mm6 \n\t"\
- "pmullw %5, %%mm6 \n\t"\
+ "pmullw "MANGLE(MUL1)", %%mm6\n\t"\
"add %2, %0 \n\t"\
"punpcklbw %%mm7, "#F" \n\t"\
"psubw "#B", %%mm6 \n\t"\
"psubw "#E", %%mm6 \n\t"\
- "paddw %4, %%mm6 \n\t"\
+ "paddw "MANGLE(ADD)", %%mm6 \n\t"\
"psraw $3, %%mm6 \n\t"\
"packuswb %%mm6, %%mm6 \n\t"\
OP(%%mm6, (%1), A, d) \
"add %3, %1 \n\t"
/* vertical filter [ 0 -7 42 96 -2 -1] */
-#define QPEL_CAVSV3(A,B,C,D,E,F,OP,MUL2) \
+#define QPEL_CAVSV3(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
"movd (%0), "#F" \n\t"\
"movq "#C", %%mm6 \n\t"\
"pmullw "MANGLE(MUL2)", %%mm6\n\t"\
"movq "#D", %%mm7 \n\t"\
- "pmullw %5, %%mm7 \n\t"\
+ "pmullw "MANGLE(MUL1)", %%mm7\n\t"\
"psllw $3, "#B" \n\t"\
"psubw "#B", %%mm6 \n\t"\
"psraw $3, "#B" \n\t"\
@@ -269,7 +270,7 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
"psubw "#E", %%mm6 \n\t"\
"psraw $1, "#E" \n\t"\
"psubw "#F", %%mm6 \n\t"\
- "paddw %4, %%mm6 \n\t"\
+ "paddw "MANGLE(ADD)", %%mm6 \n\t"\
"psraw $7, %%mm6 \n\t"\
"packuswb %%mm6, %%mm6 \n\t"\
OP(%%mm6, (%1), A, d) \
@@ -298,32 +299,34 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
"punpcklbw %%mm7, %%mm2 \n\t"\
"punpcklbw %%mm7, %%mm3 \n\t"\
"punpcklbw %%mm7, %%mm4 \n\t"\
- VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
- VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
- VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
- VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
- VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
- VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
- VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
- VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
+ VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
\
: "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
+ : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
+ NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
: "memory"\
);\
if(h==16){\
__asm__ volatile(\
- VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
- VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
- VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, MUL2)\
- VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, MUL2)\
- VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, MUL2)\
- VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, MUL2)\
- VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, MUL2)\
- VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, MUL2)\
+ VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
+ VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
\
: "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride), "m"(ADD), "m"(MUL1)\
+ : "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
+ NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
: "memory"\
);\
}\
@@ -336,7 +339,7 @@ static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstSt
int h=8;\
__asm__ volatile(\
"pxor %%mm7, %%mm7 \n\t"\
- "movq %5, %%mm6 \n\t"\
+ "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
"1: \n\t"\
"movq (%0), %%mm0 \n\t"\
"movq 1(%0), %%mm2 \n\t"\
@@ -362,7 +365,7 @@ static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstSt
"paddw %%mm3, %%mm5 \n\t"\
"psubw %%mm2, %%mm0 \n\t"\
"psubw %%mm5, %%mm1 \n\t"\
- "movq %6, %%mm5 \n\t"\
+ "movq "MANGLE(ff_pw_4)", %%mm5\n\t"\
"paddw %%mm5, %%mm0 \n\t"\
"paddw %%mm5, %%mm1 \n\t"\
"psraw $3, %%mm0 \n\t"\
@@ -374,7 +377,8 @@ static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstSt
"decl %2 \n\t"\
" jnz 1b \n\t"\
: "+a"(src), "+c"(dst), "+m"(h)\
- : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\
+ : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
+ NAMED_CONSTRAINTS_ADD(ff_pw_4,ff_pw_5)\
: "memory"\
);\
}\
@@ -384,7 +388,7 @@ static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *sr
}\
\
static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5) \
+ QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_42) \
}\
\
static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/constants.h b/chromium/third_party/ffmpeg/libavcodec/x86/constants.h
index 8097bc49f0f..4bf74ff76c8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/constants.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/constants.h
@@ -31,6 +31,7 @@ extern const xmm_reg ff_pw_3;
extern const xmm_reg ff_pw_4;
extern const xmm_reg ff_pw_5;
extern const xmm_reg ff_pw_8;
+extern const xmm_reg ff_pw_9;
extern const uint64_t ff_pw_15;
extern const xmm_reg ff_pw_16;
extern const xmm_reg ff_pw_18;
@@ -45,6 +46,7 @@ extern const uint64_t ff_pw_255;
extern const xmm_reg ff_pb_1;
extern const xmm_reg ff_pb_3;
+extern const xmm_reg ff_pb_80;
extern const xmm_reg ff_pb_F8;
extern const uint64_t ff_pb_FC;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dca.h b/chromium/third_party/ffmpeg/libavcodec/x86/dca.h
new file mode 100644
index 00000000000..c9be50d065b
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dca.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012-2014 Christophe Gisquet <christophe.gisquet@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_DCA_H
+#define AVCODEC_X86_DCA_H
+
+#include "config.h"
+
+#if ARCH_X86_64 && HAVE_SSE2_INLINE
+# include "libavutil/x86/asm.h"
+# include "libavutil/mem.h"
+#include "libavcodec/dcadsp.h"
+
+# define int8x8_fmul_int32 int8x8_fmul_int32
+static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
+ float *dst, const int8_t *src, int scale)
+{
+ DECLARE_ALIGNED(16, static const uint32_t, inverse16) = 0x3D800000;
+ __asm__ volatile (
+ "cvtsi2ss %2, %%xmm0 \n\t"
+ "mulss %3, %%xmm0 \n\t"
+ "movq (%1), %%xmm1 \n\t"
+ "punpcklbw %%xmm1, %%xmm1 \n\t"
+ "movaps %%xmm1, %%xmm2 \n\t"
+ "punpcklwd %%xmm1, %%xmm1 \n\t"
+ "punpckhwd %%xmm2, %%xmm2 \n\t"
+ "psrad $24, %%xmm1 \n\t"
+ "psrad $24, %%xmm2 \n\t"
+ "shufps $0, %%xmm0, %%xmm0 \n\t"
+ "cvtdq2ps %%xmm1, %%xmm1 \n\t"
+ "cvtdq2ps %%xmm2, %%xmm2 \n\t"
+ "mulps %%xmm0, %%xmm1 \n\t"
+ "mulps %%xmm0, %%xmm2 \n\t"
+ "movaps %%xmm1, 0(%0) \n\t"
+ "movaps %%xmm2, 16(%0) \n\t"
+ :: "r"(dst), "r"(src), "m"(scale), "m"(inverse16)
+ XMM_CLOBBERS_ONLY("xmm0", "xmm1", "xmm2")
+ );
+}
+
+#endif /* ARCH_X86_64 && HAVE_SSE2_INLINE */
+
+#endif /* AVCODEC_X86_DCA_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp.asm
new file mode 100644
index 00000000000..1ac237885a2
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp.asm
@@ -0,0 +1,431 @@
+;******************************************************************************
+;* SSE-optimized functions for the DCA decoder
+;* Copyright (C) 2012-2014 Christophe Gisquet <christophe.gisquet@gmail.com>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+pf_inv16: times 4 dd 0x3D800000 ; 1/16
+
+SECTION_TEXT
+
+; void decode_hf(float dst[DCA_SUBBANDS][8], const int32_t vq_num[DCA_SUBBANDS],
+; const int8_t hf_vq[1024][32], intptr_t vq_offset,
+; int32_t scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end)
+
+%macro DECODE_HF 0
+cglobal decode_hf, 6,6,5, dst, num, src, offset, scale, start, end
+ lea srcq, [srcq + offsetq]
+ shl startq, 2
+ mov offsetd, endm
+%define DICT offsetq
+ shl offsetq, 2
+ mov endm, offsetq
+.loop:
+%if ARCH_X86_64
+ mov offsetd, [scaleq + 2 * startq]
+ cvtsi2ss m0, offsetd
+%else
+ cvtsi2ss m0, [scaleq + 2 * startq]
+%endif
+ mov offsetd, [numq + startq]
+ mulss m0, [pf_inv16]
+ shl DICT, 5
+ shufps m0, m0, 0
+%if cpuflag(sse2)
+%if cpuflag(sse4)
+ pmovsxbd m1, [srcq + DICT + 0]
+ pmovsxbd m2, [srcq + DICT + 4]
+%else
+ movq m1, [srcq + DICT]
+ punpcklbw m1, m1
+ mova m2, m1
+ punpcklwd m1, m1
+ punpckhwd m2, m2
+ psrad m1, 24
+ psrad m2, 24
+%endif
+ cvtdq2ps m1, m1
+ cvtdq2ps m2, m2
+%else
+ movd mm0, [srcq + DICT + 0]
+ movd mm1, [srcq + DICT + 4]
+ punpcklbw mm0, mm0
+ punpcklbw mm1, mm1
+ movq mm2, mm0
+ movq mm3, mm1
+ punpcklwd mm0, mm0
+ punpcklwd mm1, mm1
+ punpckhwd mm2, mm2
+ punpckhwd mm3, mm3
+ psrad mm0, 24
+ psrad mm1, 24
+ psrad mm2, 24
+ psrad mm3, 24
+ cvtpi2ps m1, mm0
+ cvtpi2ps m2, mm1
+ cvtpi2ps m3, mm2
+ cvtpi2ps m4, mm3
+ shufps m0, m0, 0
+ shufps m1, m3, q1010
+ shufps m2, m4, q1010
+%endif
+ mulps m1, m0
+ mulps m2, m0
+ mova [dstq + 8 * startq + 0], m1
+ mova [dstq + 8 * startq + 16], m2
+ add startq, 4
+ cmp startq, endm
+ jl .loop
+.end:
+%if notcpuflag(sse2)
+ emms
+%endif
+ REP_RET
+%endmacro
+
+%if ARCH_X86_32
+INIT_XMM sse
+DECODE_HF
+%endif
+
+INIT_XMM sse2
+DECODE_HF
+
+INIT_XMM sse4
+DECODE_HF
+
+; %1=v0/v1 %2=in1 %3=in2
+%macro FIR_LOOP 2-3
+.loop%1:
+%define va m1
+%define vb m2
+%if %1
+%define OFFSET 0
+%else
+%define OFFSET NUM_COEF*count
+%endif
+; for v0, incrementing and for v1, decrementing
+ mova va, [cf0q + OFFSET]
+ mova vb, [cf0q + OFFSET + 4*NUM_COEF]
+%if %0 == 3
+ mova m4, [cf0q + OFFSET + mmsize]
+ mova m0, [cf0q + OFFSET + 4*NUM_COEF + mmsize]
+%endif
+ mulps va, %2
+ mulps vb, %2
+%if %0 == 3
+%if cpuflag(fma3)
+ fmaddps va, m4, %3, va
+ fmaddps vb, m0, %3, vb
+%else
+ mulps m4, %3
+ mulps m0, %3
+ addps va, m4
+ addps vb, m0
+%endif
+%endif
+ ; va = va1 va2 va3 va4
+ ; vb = vb1 vb2 vb3 vb4
+%if %1
+ SWAP va, vb
+%endif
+ mova m4, va
+ unpcklps va, vb ; va3 vb3 va4 vb4
+ unpckhps m4, vb ; va1 vb1 va2 vb2
+ addps m4, va ; va1+3 vb1+3 va2+4 vb2+4
+ movhlps vb, m4 ; va1+3 vb1+3
+ addps vb, m4 ; va0..4 vb0..4
+ movlps [outq + count], vb
+%if %1
+ sub cf0q, 8*NUM_COEF
+%endif
+ add count, 8
+ jl .loop%1
+%endmacro
+
+; void dca_lfe_fir(float *out, float *in, float *coefs)
+%macro DCA_LFE_FIR 1
+cglobal dca_lfe_fir%1, 3,3,6-%1, out, in, cf0
+%define IN1 m3
+%define IN2 m5
+%define count inq
+%define NUM_COEF 4*(2-%1)
+%define NUM_OUT 32*(%1+1)
+
+ movu IN1, [inq + 4 - 1*mmsize]
+ shufps IN1, IN1, q0123
+%if %1 == 0
+ movu IN2, [inq + 4 - 2*mmsize]
+ shufps IN2, IN2, q0123
+%endif
+
+ mov count, -4*NUM_OUT
+ add cf0q, 4*NUM_COEF*NUM_OUT
+ add outq, 4*NUM_OUT
+ ; compute v0 first
+%if %1 == 0
+ FIR_LOOP 0, IN1, IN2
+%else
+ FIR_LOOP 0, IN1
+%endif
+ shufps IN1, IN1, q0123
+ mov count, -4*NUM_OUT
+ ; cf1 already correctly positioned
+ add outq, 4*NUM_OUT ; outq now at out2
+ sub cf0q, 8*NUM_COEF
+%if %1 == 0
+ shufps IN2, IN2, q0123
+ FIR_LOOP 1, IN2, IN1
+%else
+ FIR_LOOP 1, IN1
+%endif
+ RET
+%endmacro
+
+INIT_XMM sse
+DCA_LFE_FIR 0
+DCA_LFE_FIR 1
+%if HAVE_FMA3_EXTERNAL
+INIT_XMM fma3
+DCA_LFE_FIR 0
+%endif
+
+%macro SETZERO 1
+%if cpuflag(sse2) && notcpuflag(avx)
+ pxor %1, %1
+%else
+ xorps %1, %1, %1
+%endif
+%endmacro
+
+%macro SHUF 3
+%if cpuflag(avx)
+ mova %3, [%2 - 16]
+ vperm2f128 %1, %3, %3, 1
+ vshufps %1, %1, %1, q0123
+%elif cpuflag(sse2)
+ pshufd %1, [%2], q0123
+%else
+ mova %1, [%2]
+ shufps %1, %1, q0123
+%endif
+%endmacro
+
+%macro INNER_LOOP 1
+ ; reading backwards: ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
+ ;~ a += window[i + j] * (-synth_buf[15 - i + j])
+ ;~ b += window[i + j + 16] * (synth_buf[i + j])
+ SHUF m5, ptr2 + j + (15 - 3) * 4, m6
+ mova m6, [ptr1 + j]
+%if ARCH_X86_64
+ SHUF m11, ptr2 + j + (15 - 3) * 4 - mmsize, m12
+ mova m12, [ptr1 + j + mmsize]
+%endif
+%if cpuflag(fma3)
+ fmaddps m2, m6, [win + %1 + j + 16 * 4], m2
+ fnmaddps m1, m5, [win + %1 + j], m1
+%if ARCH_X86_64
+ fmaddps m8, m12, [win + %1 + j + mmsize + 16 * 4], m8
+ fnmaddps m7, m11, [win + %1 + j + mmsize], m7
+%endif
+%else ; non-FMA
+ mulps m6, m6, [win + %1 + j + 16 * 4]
+ mulps m5, m5, [win + %1 + j]
+%if ARCH_X86_64
+ mulps m12, m12, [win + %1 + j + mmsize + 16 * 4]
+ mulps m11, m11, [win + %1 + j + mmsize]
+%endif
+ addps m2, m2, m6
+ subps m1, m1, m5
+%if ARCH_X86_64
+ addps m8, m8, m12
+ subps m7, m7, m11
+%endif
+%endif ; cpuflag(fma3)
+ ;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
+ ;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
+ SHUF m6, ptr2 + j + (31 - 3) * 4, m5
+ mova m5, [ptr1 + j + 16 * 4]
+%if ARCH_X86_64
+ SHUF m12, ptr2 + j + (31 - 3) * 4 - mmsize, m11
+ mova m11, [ptr1 + j + mmsize + 16 * 4]
+%endif
+%if cpuflag(fma3)
+ fmaddps m3, m5, [win + %1 + j + 32 * 4], m3
+ fmaddps m4, m6, [win + %1 + j + 48 * 4], m4
+%if ARCH_X86_64
+ fmaddps m9, m11, [win + %1 + j + mmsize + 32 * 4], m9
+ fmaddps m10, m12, [win + %1 + j + mmsize + 48 * 4], m10
+%endif
+%else ; non-FMA
+ mulps m5, m5, [win + %1 + j + 32 * 4]
+ mulps m6, m6, [win + %1 + j + 48 * 4]
+%if ARCH_X86_64
+ mulps m11, m11, [win + %1 + j + mmsize + 32 * 4]
+ mulps m12, m12, [win + %1 + j + mmsize + 48 * 4]
+%endif
+ addps m3, m3, m5
+ addps m4, m4, m6
+%if ARCH_X86_64
+ addps m9, m9, m11
+ addps m10, m10, m12
+%endif
+%endif ; cpuflag(fma3)
+ sub j, 64 * 4
+%endmacro
+
+; void ff_synth_filter_inner_<opt>(float *synth_buf, float synth_buf2[32],
+; const float window[512], float out[32],
+; intptr_t offset, float scale)
+%macro SYNTH_FILTER 0
+cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
+ synth_buf, synth_buf2, window, out, off, scale
+%define scale m0
+%if ARCH_X86_32 || WIN64
+%if cpuflag(sse2) && notcpuflag(avx)
+ movd scale, scalem
+ SPLATD m0
+%else
+ VBROADCASTSS m0, scalem
+%endif
+; Make sure offset is in a register and not on the stack
+%define OFFQ r4q
+%else
+ SPLATD xmm0
+%if cpuflag(avx)
+ vinsertf128 m0, m0, xmm0, 1
+%endif
+%define OFFQ offq
+%endif
+ ; prepare inner counter limit 1
+ mov r5q, 480
+ sub r5q, offmp
+ and r5q, -64
+ shl r5q, 2
+%if ARCH_X86_32 || notcpuflag(avx)
+ mov OFFQ, r5q
+%define i r5q
+ mov i, 16 * 4 - (ARCH_X86_64 + 1) * mmsize ; main loop counter
+%else
+%define i 0
+%define OFFQ r5q
+%endif
+
+%define buf2 synth_buf2q
+%if ARCH_X86_32
+ mov buf2, synth_buf2mp
+%endif
+.mainloop
+ ; m1 = a m2 = b m3 = c m4 = d
+ SETZERO m3
+ SETZERO m4
+ mova m1, [buf2 + i]
+ mova m2, [buf2 + i + 16 * 4]
+%if ARCH_X86_32
+%define ptr1 r0q
+%define ptr2 r1q
+%define win r2q
+%define j r3q
+ mov win, windowm
+ mov ptr1, synth_bufm
+%if ARCH_X86_32 || notcpuflag(avx)
+ add win, i
+ add ptr1, i
+%endif
+%else ; ARCH_X86_64
+%define ptr1 r6q
+%define ptr2 r7q ; must be loaded
+%define win r8q
+%define j r9q
+ SETZERO m9
+ SETZERO m10
+ mova m7, [buf2 + i + mmsize]
+ mova m8, [buf2 + i + mmsize + 16 * 4]
+ lea win, [windowq + i]
+ lea ptr1, [synth_bufq + i]
+%endif
+ mov ptr2, synth_bufmp
+ ; prepare the inner loop counter
+ mov j, OFFQ
+%if ARCH_X86_32 || notcpuflag(avx)
+ sub ptr2, i
+%endif
+.loop1:
+ INNER_LOOP 0
+ jge .loop1
+
+ mov j, 448 * 4
+ sub j, OFFQ
+ jz .end
+ sub ptr1, j
+ sub ptr2, j
+ add win, OFFQ ; now at j-64, so define OFFSET
+ sub j, 64 * 4
+.loop2:
+ INNER_LOOP 64 * 4
+ jge .loop2
+
+.end:
+%if ARCH_X86_32
+ mov buf2, synth_buf2m ; needed for next iteration anyway
+ mov outq, outmp ; j, which will be set again during it
+%endif
+ ;~ out[i] = a * scale;
+ ;~ out[i + 16] = b * scale;
+ mulps m1, m1, scale
+ mulps m2, m2, scale
+%if ARCH_X86_64
+ mulps m7, m7, scale
+ mulps m8, m8, scale
+%endif
+ ;~ synth_buf2[i] = c;
+ ;~ synth_buf2[i + 16] = d;
+ mova [buf2 + i + 0 * 4], m3
+ mova [buf2 + i + 16 * 4], m4
+%if ARCH_X86_64
+ mova [buf2 + i + 0 * 4 + mmsize], m9
+ mova [buf2 + i + 16 * 4 + mmsize], m10
+%endif
+ ;~ out[i] = a;
+ ;~ out[i + 16] = a;
+ mova [outq + i + 0 * 4], m1
+ mova [outq + i + 16 * 4], m2
+%if ARCH_X86_64
+ mova [outq + i + 0 * 4 + mmsize], m7
+ mova [outq + i + 16 * 4 + mmsize], m8
+%endif
+%if ARCH_X86_32 || notcpuflag(avx)
+ sub i, (ARCH_X86_64 + 1) * mmsize
+ jge .mainloop
+%endif
+ RET
+%endmacro
+
+%if ARCH_X86_32
+INIT_XMM sse
+SYNTH_FILTER
+%endif
+INIT_XMM sse2
+SYNTH_FILTER
+INIT_YMM avx
+SYNTH_FILTER
+INIT_YMM fma3
+SYNTH_FILTER
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp_init.c
new file mode 100644
index 00000000000..bb86c260371
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dcadsp_init.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012-2014 Christophe Gisquet <christophe.gisquet@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/dcadsp.h"
+
+void ff_decode_hf_sse(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_decode_hf_sse2(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_decode_hf_sse4(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+ const int8_t hf_vq[1024][32], intptr_t vq_offset,
+ int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_dca_lfe_fir0_sse(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir1_sse(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir0_fma3(float *out, const float *in, const float *coefs);
+
+av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (EXTERNAL_SSE(cpu_flags)) {
+#if ARCH_X86_32
+ s->decode_hf = ff_decode_hf_sse;
+#endif
+ s->lfe_fir[0] = ff_dca_lfe_fir0_sse;
+ s->lfe_fir[1] = ff_dca_lfe_fir1_sse;
+ }
+
+ if (EXTERNAL_SSE2(cpu_flags)) {
+ s->decode_hf = ff_decode_hf_sse2;
+ }
+
+ if (EXTERNAL_SSE4(cpu_flags)) {
+ s->decode_hf = ff_decode_hf_sse4;
+ }
+
+ if (EXTERNAL_FMA3(cpu_flags)) {
+ s->lfe_fir[0] = ff_dca_lfe_fir0_fma3;
+ }
+}
+
+
+#define SYNTH_FILTER_FUNC(opt) \
+void ff_synth_filter_inner_##opt(float *synth_buf_ptr, float synth_buf2[32], \
+ const float window[512], \
+ float out[32], intptr_t offset, float scale); \
+static void synth_filter_##opt(FFTContext *imdct, \
+ float *synth_buf_ptr, int *synth_buf_offset, \
+ float synth_buf2[32], const float window[512], \
+ float out[32], const float in[32], float scale) \
+{ \
+ float *synth_buf= synth_buf_ptr + *synth_buf_offset; \
+ \
+ imdct->imdct_half(imdct, synth_buf, in); \
+ \
+ ff_synth_filter_inner_##opt(synth_buf, synth_buf2, window, \
+ out, *synth_buf_offset, scale); \
+ \
+ *synth_buf_offset = (*synth_buf_offset - 32) & 511; \
+} \
+
+#if HAVE_YASM
+#if ARCH_X86_32
+SYNTH_FILTER_FUNC(sse)
+#endif
+SYNTH_FILTER_FUNC(sse2)
+SYNTH_FILTER_FUNC(avx)
+SYNTH_FILTER_FUNC(fma3)
+#endif /* HAVE_YASM */
+
+av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
+{
+#if HAVE_YASM
+ int cpu_flags = av_get_cpu_flags();
+
+#if ARCH_X86_32
+ if (EXTERNAL_SSE(cpu_flags)) {
+ s->synth_filter_float = synth_filter_sse;
+ }
+#endif
+ if (EXTERNAL_SSE2(cpu_flags)) {
+ s->synth_filter_float = synth_filter_sse2;
+ }
+ if (EXTERNAL_AVX(cpu_flags)) {
+ s->synth_filter_float = synth_filter_avx;
+ }
+ if (EXTERNAL_FMA3(cpu_flags)) {
+ s->synth_filter_float = synth_filter_fma3;
+ }
+#endif /* HAVE_YASM */
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/deinterlace.asm b/chromium/third_party/ffmpeg/libavcodec/x86/deinterlace.asm
index 3812dbe601f..baa9249db2b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/deinterlace.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/deinterlace.asm
@@ -1,5 +1,5 @@
;******************************************************************************
-;* MMX optimized deinterlacing functions
+;* SIMD-optimized deinterlacing functions
;* Copyright (c) 2010 Vitor Sessak
;* Copyright (c) 2002 Michael Niedermayer
;*
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.asm b/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.asm
new file mode 100644
index 00000000000..9dd6d51ee65
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.asm
@@ -0,0 +1,49 @@
+;************************************************************************
+;* VC3/DNxHD SIMD functions
+;* Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
+;* Copyright (c) 2014 Tiancheng "Timothy" Gu <timothygu99@gmail.com>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+section .text
+
+; void get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels,
+; ptrdiff_t line_size)
+INIT_XMM sse2
+cglobal get_pixels_8x4_sym, 3,3,5, block, pixels, linesize
+ pxor m4, m4
+ movq m0, [pixelsq]
+ add pixelsq, linesizeq
+ movq m1, [pixelsq]
+ movq m2, [pixelsq+linesizeq]
+ movq m3, [pixelsq+linesizeq*2]
+ punpcklbw m0, m4
+ punpcklbw m1, m4
+ punpcklbw m2, m4
+ punpcklbw m3, m4
+ mova [blockq ], m0
+ mova [blockq+16 ], m1
+ mova [blockq+32 ], m2
+ mova [blockq+48 ], m3
+ mova [blockq+64 ], m3
+ mova [blockq+80 ], m2
+ mova [blockq+96 ], m1
+ mova [blockq+112], m0
+ RET
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.c b/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.c
deleted file mode 100644
index c7e776a4c1f..00000000000
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * VC3/DNxHD SIMD functions
- * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
- *
- * VC-3 encoder funded by the British Broadcasting Corporation
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dnxhdenc.h"
-
-#if HAVE_SSE2_INLINE
-
-static void get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels, int line_size)
-{
- __asm__ volatile(
- "pxor %%xmm5, %%xmm5 \n\t"
- "movq (%0), %%xmm0 \n\t"
- "add %2, %0 \n\t"
- "movq (%0), %%xmm1 \n\t"
- "movq (%0, %2), %%xmm2 \n\t"
- "movq (%0, %2,2), %%xmm3 \n\t"
- "punpcklbw %%xmm5, %%xmm0 \n\t"
- "punpcklbw %%xmm5, %%xmm1 \n\t"
- "punpcklbw %%xmm5, %%xmm2 \n\t"
- "punpcklbw %%xmm5, %%xmm3 \n\t"
- "movdqa %%xmm0, (%1) \n\t"
- "movdqa %%xmm1, 16(%1) \n\t"
- "movdqa %%xmm2, 32(%1) \n\t"
- "movdqa %%xmm3, 48(%1) \n\t"
- "movdqa %%xmm3 , 64(%1) \n\t"
- "movdqa %%xmm2 , 80(%1) \n\t"
- "movdqa %%xmm1 , 96(%1) \n\t"
- "movdqa %%xmm0, 112(%1) \n\t"
- : "+r" (pixels)
- : "r" (block), "r" ((x86_reg)line_size)
- );
-}
-
-#endif /* HAVE_SSE2_INLINE */
-
-av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)
-{
-#if HAVE_SSE2_INLINE
- if (INLINE_SSE2(av_get_cpu_flags())) {
- if (ctx->cid_table->bit_depth == 8)
- ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
- }
-#endif /* HAVE_SSE2_INLINE */
-}
diff --git a/chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.c b/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc_init.c
index 414d6ca50e0..3b022641883 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sparc/dsputil_vis.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dnxhdenc_init.c
@@ -1,5 +1,8 @@
/*
- * Copyright (C) 2003 David S. Miller <davem@redhat.com>
+ * VC3/DNxHD SIMD functions
+ * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
+ *
+ * VC-3 encoder funded by the British Broadcasting Corporation
*
* This file is part of FFmpeg.
*
@@ -19,22 +22,18 @@
*/
#include "libavutil/attributes.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_vis.h"
-#include "vis.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/dnxhdenc.h"
-av_cold void ff_dsputil_init_vis(DSPContext *c, AVCodecContext *avctx)
-{
- /* VIS-specific optimizations */
- int accel = vis_level ();
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
+void ff_get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size);
- if (accel & ACCEL_SPARC_VIS && !high_bit_depth) {
- if (avctx->idct_algo == FF_IDCT_SIMPLEVIS) {
- c->idct_put = ff_simple_idct_put_vis;
- c->idct_add = ff_simple_idct_add_vis;
- c->idct = ff_simple_idct_vis;
- c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
- }
- }
+av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)
+{
+#if HAVE_SSE2_EXTERNAL
+ if (EXTERNAL_SSE2(av_get_cpu_flags())) {
+ if (ctx->cid_table->bit_depth == 8)
+ ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_sse2;
+ }
+#endif /* HAVE_SSE2_EXTERNAL */
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil.asm b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil.asm
index 77069e20f81..c1ea9bf4e20 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil.asm
@@ -29,14 +29,12 @@ pb_zzzzzzzz77777777: times 8 db -1
pb_7: times 8 db 7
pb_zzzz3333zzzzbbbb: db -1,-1,-1,-1,3,3,3,3,-1,-1,-1,-1,11,11,11,11
pb_zz11zz55zz99zzdd: db -1,-1,1,1,-1,-1,5,5,-1,-1,9,9,-1,-1,13,13
-pb_revwords: SHUFFLE_MASK_W 7, 6, 5, 4, 3, 2, 1, 0
-pd_16384: times 4 dd 16384
pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
SECTION_TEXT
%macro SCALARPRODUCT 0
-; int scalarproduct_int16(int16_t *v1, int16_t *v2, int order)
+; int ff_scalarproduct_int16(int16_t *v1, int16_t *v2, int order)
cglobal scalarproduct_int16, 3,3,3, v1, v2, order
shl orderq, 1
add v1q, orderq
@@ -52,18 +50,15 @@ cglobal scalarproduct_int16, 3,3,3, v1, v2, order
paddd m2, m1
add orderq, mmsize*2
jl .loop
-%if mmsize == 16
- movhlps m0, m2
- paddd m2, m0
- pshuflw m0, m2, 0x4e
-%else
- pshufw m0, m2, 0x4e
-%endif
- paddd m2, m0
+ HADDD m2, m0
movd eax, m2
+%if mmsize == 8
+ emms
+%endif
RET
-; int scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul)
+; int ff_scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3,
+; int order, int mul)
cglobal scalarproduct_and_madd_int16, 4,4,8, v1, v2, v3, order, mul
shl orderq, 1
movd m7, mulm
@@ -97,14 +92,7 @@ cglobal scalarproduct_and_madd_int16, 4,4,8, v1, v2, v3, order, mul
mova [v1q + orderq + mmsize], m3
add orderq, mmsize*2
jl .loop
-%if mmsize == 16
- movhlps m0, m6
- paddd m6, m0
- pshuflw m0, m6, 0x4e
-%else
- pshufw m0, m6, 0x4e
-%endif
- paddd m6, m0
+ HADDD m6, m0
movd eax, m6
RET
%endmacro
@@ -159,7 +147,8 @@ align 16
%endif
%endmacro
-; int scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul)
+; int ff_scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3,
+; int order, int mul)
INIT_XMM ssse3
cglobal scalarproduct_and_madd_int16, 4,5,10, v1, v2, v3, order, mul
shl orderq, 1
@@ -197,143 +186,14 @@ SCALARPRODUCT_LOOP 4
SCALARPRODUCT_LOOP 2
SCALARPRODUCT_LOOP 0
.end:
- movhlps m0, m6
- paddd m6, m0
- pshuflw m0, m6, 0x4e
- paddd m6, m0
+ HADDD m6, m0
movd eax, m6
RET
-;-----------------------------------------------------------------------------
-; void ff_apply_window_int16(int16_t *output, const int16_t *input,
-; const int16_t *window, unsigned int len)
-;-----------------------------------------------------------------------------
-
-%macro REVERSE_WORDS 1-2
-%if cpuflag(ssse3) && notcpuflag(atom)
- pshufb %1, %2
-%elif cpuflag(sse2)
- pshuflw %1, %1, 0x1B
- pshufhw %1, %1, 0x1B
- pshufd %1, %1, 0x4E
-%elif cpuflag(mmxext)
- pshufw %1, %1, 0x1B
-%endif
-%endmacro
-
-%macro MUL16FIXED 3
-%if cpuflag(ssse3) ; dst, src, unused
-; dst = ((dst * src) + (1<<14)) >> 15
- pmulhrsw %1, %2
-%elif cpuflag(mmxext) ; dst, src, temp
-; dst = (dst * src) >> 15
-; pmulhw cuts off the bottom bit, so we have to lshift by 1 and add it back
-; in from the pmullw result.
- mova %3, %1
- pmulhw %1, %2
- pmullw %3, %2
- psrlw %3, 15
- psllw %1, 1
- por %1, %3
-%endif
-%endmacro
-
-%macro APPLY_WINDOW_INT16 1 ; %1 bitexact version
-%if %1
-cglobal apply_window_int16, 4,5,6, output, input, window, offset, offset2
-%else
-cglobal apply_window_int16_round, 4,5,6, output, input, window, offset, offset2
-%endif
- lea offset2q, [offsetq-mmsize]
-%if cpuflag(ssse3) && notcpuflag(atom)
- mova m5, [pb_revwords]
- ALIGN 16
-%elif %1
- mova m5, [pd_16384]
-%endif
-.loop:
-%if cpuflag(ssse3)
- ; This version does the 16x16->16 multiplication in-place without expanding
- ; to 32-bit. The ssse3 version is bit-identical.
- mova m0, [windowq+offset2q]
- mova m1, [ inputq+offset2q]
- pmulhrsw m1, m0
- REVERSE_WORDS m0, m5
- pmulhrsw m0, [ inputq+offsetq ]
- mova [outputq+offset2q], m1
- mova [outputq+offsetq ], m0
-%elif %1
- ; This version expands 16-bit to 32-bit, multiplies by the window,
- ; adds 16384 for rounding, right shifts 15, then repacks back to words to
- ; save to the output. The window is reversed for the second half.
- mova m3, [windowq+offset2q]
- mova m4, [ inputq+offset2q]
- pxor m0, m0
- punpcklwd m0, m3
- punpcklwd m1, m4
- pmaddwd m0, m1
- paddd m0, m5
- psrad m0, 15
- pxor m2, m2
- punpckhwd m2, m3
- punpckhwd m1, m4
- pmaddwd m2, m1
- paddd m2, m5
- psrad m2, 15
- packssdw m0, m2
- mova [outputq+offset2q], m0
- REVERSE_WORDS m3
- mova m4, [ inputq+offsetq]
- pxor m0, m0
- punpcklwd m0, m3
- punpcklwd m1, m4
- pmaddwd m0, m1
- paddd m0, m5
- psrad m0, 15
- pxor m2, m2
- punpckhwd m2, m3
- punpckhwd m1, m4
- pmaddwd m2, m1
- paddd m2, m5
- psrad m2, 15
- packssdw m0, m2
- mova [outputq+offsetq], m0
-%else
- ; This version does the 16x16->16 multiplication in-place without expanding
- ; to 32-bit. The mmxext and sse2 versions do not use rounding, and
- ; therefore are not bit-identical to the C version.
- mova m0, [windowq+offset2q]
- mova m1, [ inputq+offset2q]
- mova m2, [ inputq+offsetq ]
- MUL16FIXED m1, m0, m3
- REVERSE_WORDS m0
- MUL16FIXED m2, m0, m3
- mova [outputq+offset2q], m1
- mova [outputq+offsetq ], m2
-%endif
- add offsetd, mmsize
- sub offset2d, mmsize
- jae .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-APPLY_WINDOW_INT16 0
-INIT_XMM sse2
-APPLY_WINDOW_INT16 0
-
-INIT_MMX mmxext
-APPLY_WINDOW_INT16 1
-INIT_XMM sse2
-APPLY_WINDOW_INT16 1
-INIT_XMM ssse3
-APPLY_WINDOW_INT16 1
-INIT_XMM ssse3, atom
-APPLY_WINDOW_INT16 1
-
-
-; void add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top)
+; void ff_add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top,
+; const uint8_t *diff, int w,
+; int *left, int *left_top)
INIT_MMX mmxext
cglobal add_hfyu_median_prediction, 6,6,0, dst, top, diff, w, left, left_top
movq mm0, [topq]
@@ -436,7 +296,8 @@ cglobal add_hfyu_median_prediction, 6,6,0, dst, top, diff, w, left, left_top
RET
%endmacro
-; int add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src, int w, int left)
+; int ff_add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src,
+; int w, int left)
INIT_MMX ssse3
cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left
.skip_prologue:
@@ -465,6 +326,7 @@ cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left
.src_unaligned:
ADD_HFYU_LEFT_LOOP 0, 0
+
;-----------------------------------------------------------------------------
; void ff_vector_clip_int32(int32_t *dst, const int32_t *src, int32_t min,
; int32_t max, unsigned int len)
@@ -597,7 +459,7 @@ VECTOR_CLIP_INT32 6, 1, 0, 0
add r0, 16
%endmacro
-; void bswap_buf(uint32_t *dst, const uint32_t *src, int w);
+; void ff_bswap_buf(uint32_t *dst, const uint32_t *src, int w);
%macro BSWAP32_BUF 0
%if cpuflag(ssse3)
cglobal bswap32_buf, 3,4,3
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_init.c
index 4c9f4990218..6c7b5218c46 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_init.c
@@ -25,9 +25,13 @@
#include "libavutil/internal.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
+#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
+#include "libavcodec/pixels.h"
#include "libavcodec/simple_idct.h"
+#include "libavcodec/version.h"
#include "dsputil_x86.h"
+#include "fpel.h"
#include "idct_xvid.h"
void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
@@ -44,29 +48,29 @@ void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
void ff_put_no_rnd_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
int dstStride, int src1Stride, int h);
void ff_put_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int h);
+ int dstStride, int srcStride, int h);
void ff_avg_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int h);
+ int dstStride, int srcStride, int h);
void ff_put_no_rnd_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
int dstStride, int srcStride,
int h);
void ff_put_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int h);
+ int dstStride, int srcStride, int h);
void ff_avg_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int h);
+ int dstStride, int srcStride, int h);
void ff_put_no_rnd_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
int dstStride, int srcStride,
int h);
void ff_put_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride);
+ int dstStride, int srcStride);
void ff_avg_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride);
+ int dstStride, int srcStride);
void ff_put_no_rnd_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
int dstStride, int srcStride);
void ff_put_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride);
+ int dstStride, int srcStride);
void ff_avg_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride);
+ int dstStride, int srcStride);
void ff_put_no_rnd_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
int dstStride, int srcStride);
#define ff_put_no_rnd_pixels16_mmxext ff_put_pixels16_mmxext
@@ -92,28 +96,28 @@ void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
void ff_add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top,
const uint8_t *diff, int w,
int *left, int *left_top);
-int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src,
- int w, int left);
-int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
+int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src,
int w, int left);
+int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
+ int w, int left);
-void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src,
- int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src,
- int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_mmx(int32_t *dst, const int32_t *src,
+ int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse2(int32_t *dst, const int32_t *src,
+ int32_t min, int32_t max, unsigned int len);
void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse4 (int32_t *dst, const int32_t *src,
- int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse4(int32_t *dst, const int32_t *src,
+ int32_t min, int32_t max, unsigned int len);
#if HAVE_YASM
-PIXELS16(static, ff_avg, , , _mmxext)
-PIXELS16(static, ff_put, , , _mmxext)
+CALL_2X_PIXELS(ff_avg_pixels16_mmxext, ff_avg_pixels8_mmxext, 8)
+CALL_2X_PIXELS(ff_put_pixels16_mmxext, ff_put_pixels8_mmxext, 8)
#define QPEL_OP(OPNAME, RND, MMX) \
-static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, \
- ptrdiff_t stride) \
+static void OPNAME ## qpel8_mc00_ ## MMX(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
{ \
ff_ ## OPNAME ## pixels8_ ## MMX(dst, src, stride, 8); \
} \
@@ -122,7 +126,7 @@ static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[8]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, \
stride, 8); \
ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half, \
@@ -140,7 +144,7 @@ static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[8]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, \
stride, 8); \
ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + 1, half, stride, \
@@ -151,7 +155,7 @@ static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[8]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, \
8, stride); \
ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half, \
@@ -169,7 +173,7 @@ static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[8]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, \
8, stride); \
ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + stride, half, stride,\
@@ -180,8 +184,8 @@ static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, \
@@ -195,8 +199,8 @@ static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
@@ -210,8 +214,8 @@ static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, \
@@ -225,8 +229,8 @@ static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
@@ -240,8 +244,8 @@ static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
@@ -253,8 +257,8 @@ static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half) + 64; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 64; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
@@ -266,7 +270,7 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, \
@@ -279,7 +283,7 @@ static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[8 + 9]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8, \
@@ -292,15 +296,15 @@ static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[9]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, \
stride, 9); \
ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
stride, 8); \
} \
\
-static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, \
- ptrdiff_t stride) \
+static void OPNAME ## qpel16_mc00_ ## MMX(uint8_t *dst, uint8_t *src, \
+ ptrdiff_t stride) \
{ \
ff_ ## OPNAME ## pixels16_ ## MMX(dst, src, stride, 16); \
} \
@@ -309,7 +313,7 @@ static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[32]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, \
stride, 16); \
ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, \
@@ -327,7 +331,7 @@ static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[32]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t*) temp; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, \
stride, 16); \
ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src + 1, half, \
@@ -338,7 +342,7 @@ static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[32]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, \
stride); \
ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, \
@@ -356,7 +360,7 @@ static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t temp[32]; \
- uint8_t * const half = (uint8_t*)temp; \
+ uint8_t *const half = (uint8_t *) temp; \
ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, \
stride); \
ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half, \
@@ -367,8 +371,8 @@ static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
@@ -383,8 +387,8 @@ static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
@@ -399,8 +403,8 @@ static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
@@ -415,8 +419,8 @@ static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
@@ -431,8 +435,8 @@ static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
@@ -445,8 +449,8 @@ static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[16 * 2 + 17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half) + 256; \
- uint8_t * const halfHV = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half + 256; \
+ uint8_t *const halfHV = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
@@ -459,7 +463,7 @@ static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, \
@@ -472,7 +476,7 @@ static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16, \
@@ -485,7 +489,7 @@ static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
ptrdiff_t stride) \
{ \
uint64_t half[17 * 2]; \
- uint8_t * const halfH = ((uint8_t*)half); \
+ uint8_t *const halfH = (uint8_t *) half; \
ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, \
stride, 17); \
ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
@@ -495,10 +499,11 @@ static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
QPEL_OP(put_, _, mmxext)
QPEL_OP(avg_, _, mmxext)
QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
+
#endif /* HAVE_YASM */
#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \
- do { \
+do { \
c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \
@@ -515,14 +520,12 @@ QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \
c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \
c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
- } while (0)
+} while (0)
static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_MMX_INLINE
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
@@ -546,11 +549,9 @@ static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
}
static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_MMXEXT_INLINE
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX && avctx->lowres == 0) {
c->idct_put = ff_idct_xvid_mmxext_put;
c->idct_add = ff_idct_xvid_mmxext_add;
@@ -577,26 +578,19 @@ static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
}
static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_SSE_INLINE
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
+ c->vector_clipf = ff_vector_clipf_sse;
+
+ /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
+ if (CONFIG_XVMC && avctx->hwaccel && avctx->hwaccel->decode_mb)
+ return;
if (!high_bit_depth) {
-#if FF_API_XVMC
-FF_DISABLE_DEPRECATION_WARNINGS
- if (!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)) {
- /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif /* FF_API_XVMC */
c->clear_block = ff_clear_block_sse;
c->clear_blocks = ff_clear_blocks_sse;
-#if FF_API_XVMC
- }
-#endif /* FF_API_XVMC */
}
-
- c->vector_clipf = ff_vector_clipf_sse;
#endif /* HAVE_SSE_INLINE */
#if HAVE_YASM
@@ -607,11 +601,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_SSE2_INLINE
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX && avctx->lowres == 0) {
c->idct_put = ff_idct_xvid_sse2_put;
c->idct_add = ff_idct_xvid_sse2_add;
@@ -633,7 +625,7 @@ static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
}
static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_SSSE3_EXTERNAL
c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3;
@@ -647,14 +639,15 @@ static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
}
static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags)
+ int cpu_flags, unsigned high_bit_depth)
{
#if HAVE_SSE4_EXTERNAL
c->vector_clip_int32 = ff_vector_clip_int32_sse4;
#endif /* HAVE_SSE4_EXTERNAL */
}
-av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
@@ -667,7 +660,7 @@ av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx)
#if HAVE_INLINE_ASM
const int idct_algo = avctx->idct_algo;
- if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
+ if (avctx->lowres == 0 && !high_bit_depth) {
if (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_SIMPLEMMX) {
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
@@ -681,24 +674,24 @@ av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx)
}
#endif /* HAVE_INLINE_ASM */
- dsputil_init_mmx(c, avctx, cpu_flags);
+ dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
}
if (X86_MMXEXT(cpu_flags))
- dsputil_init_mmxext(c, avctx, cpu_flags);
+ dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
if (X86_SSE(cpu_flags))
- dsputil_init_sse(c, avctx, cpu_flags);
+ dsputil_init_sse(c, avctx, cpu_flags, high_bit_depth);
if (X86_SSE2(cpu_flags))
- dsputil_init_sse2(c, avctx, cpu_flags);
+ dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
if (EXTERNAL_SSSE3(cpu_flags))
- dsputil_init_ssse3(c, avctx, cpu_flags);
+ dsputil_init_ssse3(c, avctx, cpu_flags, high_bit_depth);
if (EXTERNAL_SSE4(cpu_flags))
- dsputil_init_sse4(c, avctx, cpu_flags);
+ dsputil_init_sse4(c, avctx, cpu_flags, high_bit_depth);
if (CONFIG_ENCODERS)
- ff_dsputilenc_init_mmx(c, avctx);
+ ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_mmx.c b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_mmx.c
index df8cfdb4645..86100ba6ff8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_mmx.c
@@ -26,10 +26,13 @@
#include "libavutil/avassert.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/asm.h"
+#include "libavcodec/pixels.h"
#include "libavcodec/videodsp.h"
#include "constants.h"
-#include "dsputil_x86.h"
#include "diracdsp_mmx.h"
+#include "dsputil_x86.h"
+#include "fpel.h"
+#include "inline_asm.h"
#if HAVE_INLINE_ASM
@@ -60,8 +63,8 @@ void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
"movq %%mm2, (%0, %1) \n\t"
"movq %%mm4, (%0, %1, 2) \n\t"
"movq %%mm6, (%0, %2) \n\t"
- :: "r"(pix), "r"((x86_reg)line_size), "r"((x86_reg)line_size * 3),
- "r"(p)
+ :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
+ "r" (p)
: "memory");
pix += line_size * 4;
p += 32;
@@ -86,7 +89,8 @@ void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
"movq %%mm2, (%0, %1) \n\t"
"movq %%mm4, (%0, %1, 2) \n\t"
"movq %%mm6, (%0, %2) \n\t"
- :: "r"(pix), "r"((x86_reg)line_size), "r"((x86_reg)line_size * 3), "r"(p)
+ :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
+ "r" (p)
: "memory");
}
@@ -120,8 +124,9 @@ void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
put_signed_pixels_clamped_mmx_half(0)
"lea (%0, %3, 4), %0 \n\t"
put_signed_pixels_clamped_mmx_half(64)
- : "+&r"(pixels), "=&r"(line_skip3)
- : "r"(block), "r"(line_skip)
+ : "+&r" (pixels), "=&r" (line_skip3)
+ : "r" (block), "r" (line_skip)
+ NAMED_CONSTRAINTS_ADD(ff_pb_80)
: "memory");
}
@@ -159,8 +164,8 @@ void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, %0 \n\t"
"movq %%mm2, %1 \n\t"
- : "+m"(*pix), "+m"(*(pix + line_size))
- : "r"(p)
+ : "+m" (*pix), "+m" (*(pix + line_size))
+ : "r" (p)
: "memory");
pix += line_size * 2;
p += 16;
@@ -172,7 +177,7 @@ void name(int16_t *blocks) \
{ \
__asm__ volatile ( \
"pxor %%mm7, %%mm7 \n\t" \
- "mov %1, %%"REG_a" \n\t" \
+ "mov $-"#n", %%"REG_a" \n\t" \
"1: \n\t" \
"movq %%mm7, (%0, %%"REG_a") \n\t" \
"movq %%mm7, 8(%0, %%"REG_a") \n\t" \
@@ -180,13 +185,11 @@ void name(int16_t *blocks) \
"movq %%mm7, 24(%0, %%"REG_a") \n\t" \
"add $32, %%"REG_a" \n\t" \
"js 1b \n\t" \
- :: "r"(((uint8_t *)blocks) + 128 * n), \
- "i"(-128 * n) \
- : "%"REG_a \
- ); \
+ :: "r"(((uint8_t *) blocks) + n) \
+ : "%"REG_a); \
}
-CLEAR_BLOCKS(ff_clear_blocks_mmx, 6)
-CLEAR_BLOCKS(ff_clear_block_mmx, 1)
+CLEAR_BLOCKS(ff_clear_blocks_mmx, 768)
+CLEAR_BLOCKS(ff_clear_block_mmx, 128)
void ff_clear_block_sse(int16_t *block)
{
@@ -200,16 +203,15 @@ void ff_clear_block_sse(int16_t *block)
"movaps %%xmm0, 80(%0) \n"
"movaps %%xmm0, 96(%0) \n"
"movaps %%xmm0, 112(%0) \n"
- :: "r"(block)
- : "memory"
- );
+ :: "r" (block)
+ : "memory");
}
void ff_clear_blocks_sse(int16_t *blocks)
{
__asm__ volatile (
"xorps %%xmm0, %%xmm0 \n"
- "mov %1, %%"REG_a" \n"
+ "mov $-768, %%"REG_a" \n"
"1: \n"
"movaps %%xmm0, (%0, %%"REG_a") \n"
"movaps %%xmm0, 16(%0, %%"REG_a") \n"
@@ -221,15 +223,14 @@ void ff_clear_blocks_sse(int16_t *blocks)
"movaps %%xmm0, 112(%0, %%"REG_a") \n"
"add $128, %%"REG_a" \n"
"js 1b \n"
- :: "r"(((uint8_t *)blocks) + 128 * 6),
- "i"(-128 * 6)
- : "%"REG_a
- );
+ :: "r"(((uint8_t *) blocks) + 128 * 6)
+ : "%"REG_a);
}
void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
{
x86_reg i = 0;
+
__asm__ volatile (
"jmp 2f \n\t"
"1: \n\t"
@@ -245,10 +246,10 @@ void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
"2: \n\t"
"cmp %3, %0 \n\t"
"js 1b \n\t"
- : "+r"(i)
- : "r"(src), "r"(dst), "r"((x86_reg)w - 15)
- );
- for ( ; i < w; i++)
+ : "+r" (i)
+ : "r" (src), "r" (dst), "r" ((x86_reg) w - 15));
+
+ for (; i < w; i++)
dst[i + 0] += src[i + 0];
}
@@ -279,10 +280,10 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
"add %1, %0 \n\t"
"cmp %3, %0 \n\t"
"jb 1b \n\t"
- : "+r"(ptr)
- : "r"((x86_reg)wrap), "r"((x86_reg)width), "r"(ptr + wrap * height)
- );
- } else if(w==16){
+ : "+r" (ptr)
+ : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+ "r" (ptr + wrap * height));
+ } else if (w == 16) {
__asm__ volatile (
"1: \n\t"
"movd (%0), %%mm0 \n\t"
@@ -319,9 +320,9 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
"add %1, %0 \n\t"
"cmp %3, %0 \n\t"
"jb 1b \n\t"
- : "+r"(ptr)
- : "r"((x86_reg)wrap), "r"((x86_reg)width), "r"(ptr + wrap * height)
- );
+ : "+r" (ptr)
+ : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+ "r" (ptr + wrap * height));
}
/* top and bottom (and hopefully also the corners) */
@@ -338,10 +339,10 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
"add $8, %0 \n\t"
"cmp %4, %0 \n\t"
"jb 1b \n\t"
- : "+r"(ptr)
- : "r"((x86_reg)buf - (x86_reg)ptr - w), "r"((x86_reg) -wrap),
- "r"((x86_reg) -wrap * 3), "r"(ptr + width + 2 * w)
- );
+ : "+r" (ptr)
+ : "r" ((x86_reg) buf - (x86_reg) ptr - w),
+ "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3),
+ "r" (ptr + width + 2 * w));
}
}
@@ -358,11 +359,10 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
"add $8, %0 \n\t"
"cmp %4, %0 \n\t"
"jb 1b \n\t"
- : "+r"(ptr)
- : "r"((x86_reg)last_line - (x86_reg)ptr - w),
- "r"((x86_reg)wrap), "r"((x86_reg)wrap * 3),
- "r"(ptr + width + 2 * w)
- );
+ : "+r" (ptr)
+ : "r" ((x86_reg) last_line - (x86_reg) ptr - w),
+ "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3),
+ "r" (ptr + width + 2 * w));
}
}
}
@@ -391,7 +391,7 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src,
const uint16_t r4[4] = { r, r, r, r };
const uint16_t dxy4[4] = { dxys, dxys, dxys, dxys };
const uint16_t dyy4[4] = { dyys, dyys, dyys, dyys };
- const uint64_t shift2 = 2 * shift;
+ const uint64_t shift2 = 2 * shift;
#define MAX_STRIDE 4096U
#define MAX_H 8U
uint8_t edge_buf[(MAX_H + 1) * MAX_STRIDE];
@@ -401,15 +401,15 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src,
const int dyh = (dyy - (1 << (16 + shift))) * (h - 1);
const int dxh = dxy * (h - 1);
const int dyw = dyx * (w - 1);
- int need_emu = (unsigned)ix >= width - w ||
- (unsigned)iy >= height - h;
+ int need_emu = (unsigned) ix >= width - w ||
+ (unsigned) iy >= height - h;
if ( // non-constant fullpel offset (3% of blocks)
((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) |
- (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift)
+ (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift) ||
// uses more than 16 bits of subpel mv (only at huge resolution)
- || (dxx | dxy | dyx | dyy) & 15
- || (need_emu && (h > MAX_H || stride > MAX_STRIDE))) {
+ (dxx | dxy | dyx | dyy) & 15 ||
+ (need_emu && (h > MAX_H || stride > MAX_STRIDE))) {
// FIXME could still use mmx for some of the rows
ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy,
shift, r, width, height);
@@ -427,8 +427,7 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src,
"pxor %%mm7, %%mm7 \n\t"
"punpcklwd %%mm6, %%mm6 \n\t"
"punpcklwd %%mm6, %%mm6 \n\t"
- :: "r"(1<<shift)
- );
+ :: "r" (1 << shift));
for (x = 0; x < w; x += 4) {
uint16_t dx4[4] = { oxs - dxys + dxxs * (x + 0),
@@ -450,9 +449,8 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src,
"movq %%mm5, %1 \n\t"
"psrlw $12, %%mm4 \n\t"
"psrlw $12, %%mm5 \n\t"
- : "+m"(*dx4), "+m"(*dy4)
- : "m"(*dxy4), "m"(*dyy4)
- );
+ : "+m" (*dx4), "+m" (*dy4)
+ : "m" (*dxy4), "m" (*dyy4));
__asm__ volatile (
"movq %%mm6, %%mm2 \n\t"
@@ -488,11 +486,10 @@ static av_always_inline void gmc(uint8_t *dst, uint8_t *src,
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, %0 \n\t"
- : "=m"(dst[x + y * stride])
- : "m"(src[0]), "m"(src[1]),
- "m"(src[stride]), "m"(src[stride + 1]),
- "m"(*r4), "m"(shift2)
- );
+ : "=m" (dst[x + y * stride])
+ : "m" (src[0]), "m" (src[1]),
+ "m" (src[stride]), "m" (src[stride + 1]),
+ "m" (*r4), "m" (shift2));
src += stride;
}
src += 4 - h * stride;
@@ -558,7 +555,7 @@ void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[
}
#if HAVE_MMX_INLINE
-PIXELS16(static, ff_avg, , , _mmxext)
+CALL_2X_PIXELS(ff_avg_pixels16_mmxext, ff_avg_pixels8_mmxext, 8)
DIRAC_PIXOP(put, ff_put, mmx)
DIRAC_PIXOP(avg, ff_avg, mmx)
#endif
@@ -629,10 +626,9 @@ void ff_vector_clipf_sse(float *dst, const float *src,
"movaps %%xmm3, 48(%1, %0) \n\t"
"sub $64, %0 \n\t"
"jge 1b \n\t"
- : "+&r"(i)
- : "r"(dst), "r"(src), "m"(min), "m"(max)
- : "memory"
- );
+ : "+&r" (i)
+ : "r" (dst), "r" (src), "m" (min), "m" (max)
+ : "memory");
}
#endif /* HAVE_INLINE_ASM */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_qns_template.c b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_qns_template.c
index bde6b0a606f..ebaad252f4e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_qns_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_qns_template.c
@@ -22,6 +22,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <assert.h>
+#include <stdint.h>
+
+#include "libavutil/common.h"
+#include "libavutil/x86/asm.h"
+
+#include "inline_asm.h"
+
#define MAX_ABS (512 >> (SCALE_OFFSET>0 ? SCALE_OFFSET : 0))
static int DEF(try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale)
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_x86.h b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_x86.h
index 356b2c142f5..6a50a09e5d9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_x86.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputil_x86.h
@@ -19,96 +19,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_X86_DSPUTIL_MMX_H
-#define AVCODEC_X86_DSPUTIL_MMX_H
+#ifndef AVCODEC_X86_DSPUTIL_X86_H
+#define AVCODEC_X86_DSPUTIL_X86_H
-#include <stddef.h>
#include <stdint.h>
+#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
-#include "libavutil/x86/asm.h"
-#include "constants.h"
-#define MOVQ_WONE(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
- "psrlw $15, %%" #regd ::)
+void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth);
+void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx);
-#define JUMPALIGN() __asm__ volatile (".p2align 3"::)
-#define MOVQ_ZERO(regd) __asm__ volatile ("pxor %%"#regd", %%"#regd ::)
-
-#define MOVQ_BFE(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%"#regd", %%"#regd" \n\t" \
- "paddb %%"#regd", %%"#regd" \n\t" ::)
-
-#ifndef PIC
-#define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_wtwo))
-#else
-// for shared library it's better to use this way for accessing constants
-// pcmpeqd -> -1
-#define MOVQ_WTWO(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%"#regd", %%"#regd" \n\t" \
- "psrlw $15, %%"#regd" \n\t" \
- "psllw $1, %%"#regd" \n\t"::)
-
-#endif
-
-// using regr as temporary and for the output result
-// first argument is unmodifed and second is trashed
-// regfe is supposed to contain 0xfefefefefefefefe
-#define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \
- "movq "#rega", "#regr" \n\t" \
- "pand "#regb", "#regr" \n\t" \
- "pxor "#rega", "#regb" \n\t" \
- "pand "#regfe", "#regb" \n\t" \
- "psrlq $1, "#regb" \n\t" \
- "paddb "#regb", "#regr" \n\t"
-
-#define PAVGB_MMX(rega, regb, regr, regfe) \
- "movq "#rega", "#regr" \n\t" \
- "por "#regb", "#regr" \n\t" \
- "pxor "#rega", "#regb" \n\t" \
- "pand "#regfe", "#regb" \n\t" \
- "psrlq $1, "#regb" \n\t" \
- "psubb "#regb", "#regr" \n\t"
-
-// mm6 is supposed to contain 0xfefefefefefefefe
-#define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \
- "movq "#rega", "#regr" \n\t" \
- "movq "#regc", "#regp" \n\t" \
- "pand "#regb", "#regr" \n\t" \
- "pand "#regd", "#regp" \n\t" \
- "pxor "#rega", "#regb" \n\t" \
- "pxor "#regc", "#regd" \n\t" \
- "pand %%mm6, "#regb" \n\t" \
- "pand %%mm6, "#regd" \n\t" \
- "psrlq $1, "#regb" \n\t" \
- "psrlq $1, "#regd" \n\t" \
- "paddb "#regb", "#regr" \n\t" \
- "paddb "#regd", "#regp" \n\t"
-
-#define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \
- "movq "#rega", "#regr" \n\t" \
- "movq "#regc", "#regp" \n\t" \
- "por "#regb", "#regr" \n\t" \
- "por "#regd", "#regp" \n\t" \
- "pxor "#rega", "#regb" \n\t" \
- "pxor "#regc", "#regd" \n\t" \
- "pand %%mm6, "#regb" \n\t" \
- "pand %%mm6, "#regd" \n\t" \
- "psrlq $1, "#regd" \n\t" \
- "psrlq $1, "#regb" \n\t" \
- "psubb "#regb", "#regr" \n\t" \
- "psubb "#regd", "#regp" \n\t"
-
-void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
-
-void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
-void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
-void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
+void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+ int line_size);
+void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+ int line_size);
+void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+ int line_size);
void ff_clear_block_mmx(int16_t *block);
void ff_clear_block_sse(int16_t *block);
@@ -137,62 +65,8 @@ void ff_gmc_sse(uint8_t *dst, uint8_t *src,
void ff_vector_clipf_sse(float *dst, const float *src,
float min, float max, int len);
-void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-
-void ff_avg_pixels8_x2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-
-void ff_avg_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-
-void ff_put_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-
void ff_mmx_idct(int16_t *block);
void ff_mmxext_idct(int16_t *block);
-void ff_deinterlace_line_mmx(uint8_t *dst,
- const uint8_t *lum_m4, const uint8_t *lum_m3,
- const uint8_t *lum_m2, const uint8_t *lum_m1,
- const uint8_t *lum,
- int size);
-
-void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4,
- const uint8_t *lum_m3,
- const uint8_t *lum_m2,
- const uint8_t *lum_m1,
- const uint8_t *lum, int size);
-
-#define PIXELS16(STATIC, PFX1, PFX2, TYPE, CPUEXT) \
-STATIC void PFX1 ## _pixels16 ## TYPE ## CPUEXT(uint8_t *block, \
- const uint8_t *pixels, \
- ptrdiff_t line_size, \
- int h) \
-{ \
- PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block, pixels, \
- line_size, h); \
- PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block + 8, pixels + 8, \
- line_size, h); \
-}
-
-#endif /* AVCODEC_X86_DSPUTIL_MMX_H */
+#endif /* AVCODEC_X86_DSPUTIL_X86_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc.asm b/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc.asm
index 1839bee24a3..1f496ad32e7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc.asm
@@ -209,8 +209,8 @@ hadamard8x8_diff %+ SUFFIX:
hadamard8_16_wrapper %1, 3
%elif cpuflag(mmx)
ALIGN 16
-; int hadamard8_diff_##cpu(void *s, uint8_t *src1, uint8_t *src2,
-; int stride, int h)
+; int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1,
+; uint8_t *src2, int stride, int h)
; r0 = void *s = unused, int h = unused (always 8)
; note how r1, r2 and r3 are not clobbered in this function, so 16x16
; can simply call this 2x2x (and that's why we access rsp+gprsize
@@ -275,7 +275,8 @@ INIT_XMM ssse3
HADAMARD8_DIFF 9
INIT_XMM sse2
-; sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+; int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+; int line_size, int h);
cglobal sse16, 5, 5, 8
shr r4d, 1
pxor m0, m0 ; mm0 = 0
@@ -335,7 +336,7 @@ cglobal sse16, 5, 5, 8
RET
INIT_MMX mmx
-; get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size)
+; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size)
cglobal get_pixels, 3,4
movsxdifnidn r2, r2d
add r0, 128
@@ -392,7 +393,8 @@ cglobal get_pixels, 3, 4
RET
INIT_MMX mmx
-; diff_pixels_mmx(int16_t *block, const uint8_t *s1, const unint8_t *s2, stride)
+; void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+; int stride);
cglobal diff_pixels, 4,5
movsxdifnidn r3, r3d
pxor m7, m7
@@ -418,7 +420,7 @@ cglobal diff_pixels, 4,5
REP_RET
INIT_MMX mmx
-; pix_sum16_mmx(uint8_t * pix, int line_size)
+; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
cglobal pix_sum16, 2, 3
movsxdifnidn r1, r1d
mov r2, r1
@@ -453,7 +455,7 @@ cglobal pix_sum16, 2, 3
RET
INIT_MMX mmx
-; pix_norm1_mmx(uint8_t *pix, int line_size)
+; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
cglobal pix_norm1, 2, 4
movsxdifnidn r1, r1d
mov r2, 16
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc_mmx.c b/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
index 5de8ade8b1d..1100fb07f76 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
@@ -34,637 +34,672 @@
void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size);
void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size);
-void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride);
-int ff_pix_sum16_mmx(uint8_t * pix, int line_size);
+void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+ int stride);
+int ff_pix_sum16_mmx(uint8_t *pix, int line_size);
int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
#if HAVE_INLINE_ASM
-static int sse8_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int sse8_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
int tmp;
- __asm__ volatile (
- "movl %4,%%ecx\n"
- "shr $1,%%ecx\n"
- "pxor %%mm0,%%mm0\n" /* mm0 = 0 */
- "pxor %%mm7,%%mm7\n" /* mm7 holds the sum */
- "1:\n"
- "movq (%0),%%mm1\n" /* mm1 = pix1[0][0-7] */
- "movq (%1),%%mm2\n" /* mm2 = pix2[0][0-7] */
- "movq (%0,%3),%%mm3\n" /* mm3 = pix1[1][0-7] */
- "movq (%1,%3),%%mm4\n" /* mm4 = pix2[1][0-7] */
-
- /* todo: mm1-mm2, mm3-mm4 */
- /* algo: subtract mm1 from mm2 with saturation and vice versa */
- /* OR the results to get absolute difference */
- "movq %%mm1,%%mm5\n"
- "movq %%mm3,%%mm6\n"
- "psubusb %%mm2,%%mm1\n"
- "psubusb %%mm4,%%mm3\n"
- "psubusb %%mm5,%%mm2\n"
- "psubusb %%mm6,%%mm4\n"
-
- "por %%mm1,%%mm2\n"
- "por %%mm3,%%mm4\n"
-
- /* now convert to 16-bit vectors so we can square them */
- "movq %%mm2,%%mm1\n"
- "movq %%mm4,%%mm3\n"
-
- "punpckhbw %%mm0,%%mm2\n"
- "punpckhbw %%mm0,%%mm4\n"
- "punpcklbw %%mm0,%%mm1\n" /* mm1 now spread over (mm1,mm2) */
- "punpcklbw %%mm0,%%mm3\n" /* mm4 now spread over (mm3,mm4) */
-
- "pmaddwd %%mm2,%%mm2\n"
- "pmaddwd %%mm4,%%mm4\n"
- "pmaddwd %%mm1,%%mm1\n"
- "pmaddwd %%mm3,%%mm3\n"
-
- "lea (%0,%3,2), %0\n" /* pix1 += 2*line_size */
- "lea (%1,%3,2), %1\n" /* pix2 += 2*line_size */
-
- "paddd %%mm2,%%mm1\n"
- "paddd %%mm4,%%mm3\n"
- "paddd %%mm1,%%mm7\n"
- "paddd %%mm3,%%mm7\n"
-
- "decl %%ecx\n"
- "jnz 1b\n"
-
- "movq %%mm7,%%mm1\n"
- "psrlq $32, %%mm7\n" /* shift hi dword to lo */
- "paddd %%mm7,%%mm1\n"
- "movd %%mm1,%2\n"
- : "+r" (pix1), "+r" (pix2), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+
+ __asm__ volatile (
+ "movl %4, %%ecx \n"
+ "shr $1, %%ecx \n"
+ "pxor %%mm0, %%mm0 \n" /* mm0 = 0 */
+ "pxor %%mm7, %%mm7 \n" /* mm7 holds the sum */
+ "1: \n"
+ "movq (%0), %%mm1 \n" /* mm1 = pix1[0][0 - 7] */
+ "movq (%1), %%mm2 \n" /* mm2 = pix2[0][0 - 7] */
+ "movq (%0, %3), %%mm3 \n" /* mm3 = pix1[1][0 - 7] */
+ "movq (%1, %3), %%mm4 \n" /* mm4 = pix2[1][0 - 7] */
+
+ /* todo: mm1-mm2, mm3-mm4 */
+ /* algo: subtract mm1 from mm2 with saturation and vice versa */
+ /* OR the results to get absolute difference */
+ "movq %%mm1, %%mm5 \n"
+ "movq %%mm3, %%mm6 \n"
+ "psubusb %%mm2, %%mm1 \n"
+ "psubusb %%mm4, %%mm3 \n"
+ "psubusb %%mm5, %%mm2 \n"
+ "psubusb %%mm6, %%mm4 \n"
+
+ "por %%mm1, %%mm2 \n"
+ "por %%mm3, %%mm4 \n"
+
+ /* now convert to 16-bit vectors so we can square them */
+ "movq %%mm2, %%mm1 \n"
+ "movq %%mm4, %%mm3 \n"
+
+ "punpckhbw %%mm0, %%mm2 \n"
+ "punpckhbw %%mm0, %%mm4 \n"
+ "punpcklbw %%mm0, %%mm1 \n" /* mm1 now spread over (mm1, mm2) */
+ "punpcklbw %%mm0, %%mm3 \n" /* mm4 now spread over (mm3, mm4) */
+
+ "pmaddwd %%mm2, %%mm2 \n"
+ "pmaddwd %%mm4, %%mm4 \n"
+ "pmaddwd %%mm1, %%mm1 \n"
+ "pmaddwd %%mm3, %%mm3 \n"
+
+ "lea (%0, %3, 2), %0 \n" /* pix1 += 2 * line_size */
+ "lea (%1, %3, 2), %1 \n" /* pix2 += 2 * line_size */
+
+ "paddd %%mm2, %%mm1 \n"
+ "paddd %%mm4, %%mm3 \n"
+ "paddd %%mm1, %%mm7 \n"
+ "paddd %%mm3, %%mm7 \n"
+
+ "decl %%ecx \n"
+ "jnz 1b \n"
+
+ "movq %%mm7, %%mm1 \n"
+ "psrlq $32, %%mm7 \n" /* shift hi dword to lo */
+ "paddd %%mm7, %%mm1 \n"
+ "movd %%mm1, %2 \n"
+ : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp;
}
-static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int sse16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
int tmp;
- __asm__ volatile (
- "movl %4,%%ecx\n"
- "pxor %%mm0,%%mm0\n" /* mm0 = 0 */
- "pxor %%mm7,%%mm7\n" /* mm7 holds the sum */
- "1:\n"
- "movq (%0),%%mm1\n" /* mm1 = pix1[0-7] */
- "movq (%1),%%mm2\n" /* mm2 = pix2[0-7] */
- "movq 8(%0),%%mm3\n" /* mm3 = pix1[8-15] */
- "movq 8(%1),%%mm4\n" /* mm4 = pix2[8-15] */
-
- /* todo: mm1-mm2, mm3-mm4 */
- /* algo: subtract mm1 from mm2 with saturation and vice versa */
- /* OR the results to get absolute difference */
- "movq %%mm1,%%mm5\n"
- "movq %%mm3,%%mm6\n"
- "psubusb %%mm2,%%mm1\n"
- "psubusb %%mm4,%%mm3\n"
- "psubusb %%mm5,%%mm2\n"
- "psubusb %%mm6,%%mm4\n"
-
- "por %%mm1,%%mm2\n"
- "por %%mm3,%%mm4\n"
-
- /* now convert to 16-bit vectors so we can square them */
- "movq %%mm2,%%mm1\n"
- "movq %%mm4,%%mm3\n"
-
- "punpckhbw %%mm0,%%mm2\n"
- "punpckhbw %%mm0,%%mm4\n"
- "punpcklbw %%mm0,%%mm1\n" /* mm1 now spread over (mm1,mm2) */
- "punpcklbw %%mm0,%%mm3\n" /* mm4 now spread over (mm3,mm4) */
-
- "pmaddwd %%mm2,%%mm2\n"
- "pmaddwd %%mm4,%%mm4\n"
- "pmaddwd %%mm1,%%mm1\n"
- "pmaddwd %%mm3,%%mm3\n"
-
- "add %3,%0\n"
- "add %3,%1\n"
-
- "paddd %%mm2,%%mm1\n"
- "paddd %%mm4,%%mm3\n"
- "paddd %%mm1,%%mm7\n"
- "paddd %%mm3,%%mm7\n"
-
- "decl %%ecx\n"
- "jnz 1b\n"
-
- "movq %%mm7,%%mm1\n"
- "psrlq $32, %%mm7\n" /* shift hi dword to lo */
- "paddd %%mm7,%%mm1\n"
- "movd %%mm1,%2\n"
- : "+r" (pix1), "+r" (pix2), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+
+ __asm__ volatile (
+ "movl %4, %%ecx\n"
+ "pxor %%mm0, %%mm0\n" /* mm0 = 0 */
+ "pxor %%mm7, %%mm7\n" /* mm7 holds the sum */
+ "1:\n"
+ "movq (%0), %%mm1\n" /* mm1 = pix1[0 - 7] */
+ "movq (%1), %%mm2\n" /* mm2 = pix2[0 - 7] */
+ "movq 8(%0), %%mm3\n" /* mm3 = pix1[8 - 15] */
+ "movq 8(%1), %%mm4\n" /* mm4 = pix2[8 - 15] */
+
+ /* todo: mm1-mm2, mm3-mm4 */
+ /* algo: subtract mm1 from mm2 with saturation and vice versa */
+ /* OR the results to get absolute difference */
+ "movq %%mm1, %%mm5\n"
+ "movq %%mm3, %%mm6\n"
+ "psubusb %%mm2, %%mm1\n"
+ "psubusb %%mm4, %%mm3\n"
+ "psubusb %%mm5, %%mm2\n"
+ "psubusb %%mm6, %%mm4\n"
+
+ "por %%mm1, %%mm2\n"
+ "por %%mm3, %%mm4\n"
+
+ /* now convert to 16-bit vectors so we can square them */
+ "movq %%mm2, %%mm1\n"
+ "movq %%mm4, %%mm3\n"
+
+ "punpckhbw %%mm0, %%mm2\n"
+ "punpckhbw %%mm0, %%mm4\n"
+ "punpcklbw %%mm0, %%mm1\n" /* mm1 now spread over (mm1, mm2) */
+ "punpcklbw %%mm0, %%mm3\n" /* mm4 now spread over (mm3, mm4) */
+
+ "pmaddwd %%mm2, %%mm2\n"
+ "pmaddwd %%mm4, %%mm4\n"
+ "pmaddwd %%mm1, %%mm1\n"
+ "pmaddwd %%mm3, %%mm3\n"
+
+ "add %3, %0\n"
+ "add %3, %1\n"
+
+ "paddd %%mm2, %%mm1\n"
+ "paddd %%mm4, %%mm3\n"
+ "paddd %%mm1, %%mm7\n"
+ "paddd %%mm3, %%mm7\n"
+
+ "decl %%ecx\n"
+ "jnz 1b\n"
+
+ "movq %%mm7, %%mm1\n"
+ "psrlq $32, %%mm7\n" /* shift hi dword to lo */
+ "paddd %%mm7, %%mm1\n"
+ "movd %%mm1, %2\n"
+ : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp;
}
-static int hf_noise8_mmx(uint8_t * pix1, int line_size, int h) {
+static int hf_noise8_mmx(uint8_t *pix1, int line_size, int h)
+{
int tmp;
- __asm__ volatile (
- "movl %3,%%ecx\n"
- "pxor %%mm7,%%mm7\n"
- "pxor %%mm6,%%mm6\n"
-
- "movq (%0),%%mm0\n"
- "movq %%mm0, %%mm1\n"
- "psllq $8, %%mm0\n"
- "psrlq $8, %%mm1\n"
- "psrlq $8, %%mm0\n"
- "movq %%mm0, %%mm2\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm0\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm2\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm0\n"
- "psubw %%mm3, %%mm2\n"
-
- "add %2,%0\n"
-
- "movq (%0),%%mm4\n"
- "movq %%mm4, %%mm1\n"
- "psllq $8, %%mm4\n"
- "psrlq $8, %%mm1\n"
- "psrlq $8, %%mm4\n"
- "movq %%mm4, %%mm5\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm4\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm5\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm4\n"
- "psubw %%mm3, %%mm5\n"
- "psubw %%mm4, %%mm0\n"
- "psubw %%mm5, %%mm2\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm0, %%mm3\n\t"
- "pcmpgtw %%mm2, %%mm1\n\t"
- "pxor %%mm3, %%mm0\n"
- "pxor %%mm1, %%mm2\n"
- "psubw %%mm3, %%mm0\n"
- "psubw %%mm1, %%mm2\n"
- "paddw %%mm0, %%mm2\n"
- "paddw %%mm2, %%mm6\n"
-
- "add %2,%0\n"
- "1:\n"
-
- "movq (%0),%%mm0\n"
- "movq %%mm0, %%mm1\n"
- "psllq $8, %%mm0\n"
- "psrlq $8, %%mm1\n"
- "psrlq $8, %%mm0\n"
- "movq %%mm0, %%mm2\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm0\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm2\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm0\n"
- "psubw %%mm3, %%mm2\n"
- "psubw %%mm0, %%mm4\n"
- "psubw %%mm2, %%mm5\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm4, %%mm3\n\t"
- "pcmpgtw %%mm5, %%mm1\n\t"
- "pxor %%mm3, %%mm4\n"
- "pxor %%mm1, %%mm5\n"
- "psubw %%mm3, %%mm4\n"
- "psubw %%mm1, %%mm5\n"
- "paddw %%mm4, %%mm5\n"
- "paddw %%mm5, %%mm6\n"
-
- "add %2,%0\n"
-
- "movq (%0),%%mm4\n"
- "movq %%mm4, %%mm1\n"
- "psllq $8, %%mm4\n"
- "psrlq $8, %%mm1\n"
- "psrlq $8, %%mm4\n"
- "movq %%mm4, %%mm5\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm4\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm5\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm4\n"
- "psubw %%mm3, %%mm5\n"
- "psubw %%mm4, %%mm0\n"
- "psubw %%mm5, %%mm2\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm0, %%mm3\n\t"
- "pcmpgtw %%mm2, %%mm1\n\t"
- "pxor %%mm3, %%mm0\n"
- "pxor %%mm1, %%mm2\n"
- "psubw %%mm3, %%mm0\n"
- "psubw %%mm1, %%mm2\n"
- "paddw %%mm0, %%mm2\n"
- "paddw %%mm2, %%mm6\n"
-
- "add %2,%0\n"
- "subl $2, %%ecx\n"
- " jnz 1b\n"
-
- "movq %%mm6, %%mm0\n"
- "punpcklwd %%mm7,%%mm0\n"
- "punpckhwd %%mm7,%%mm6\n"
- "paddd %%mm0, %%mm6\n"
-
- "movq %%mm6,%%mm0\n"
- "psrlq $32, %%mm6\n"
- "paddd %%mm6,%%mm0\n"
- "movd %%mm0,%1\n"
- : "+r" (pix1), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "g" (h-2)
- : "%ecx");
- return tmp;
+
+ __asm__ volatile (
+ "movl %3, %%ecx\n"
+ "pxor %%mm7, %%mm7\n"
+ "pxor %%mm6, %%mm6\n"
+
+ "movq (%0), %%mm0\n"
+ "movq %%mm0, %%mm1\n"
+ "psllq $8, %%mm0\n"
+ "psrlq $8, %%mm1\n"
+ "psrlq $8, %%mm0\n"
+ "movq %%mm0, %%mm2\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm0\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm2\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm0\n"
+ "psubw %%mm3, %%mm2\n"
+
+ "add %2, %0\n"
+
+ "movq (%0), %%mm4\n"
+ "movq %%mm4, %%mm1\n"
+ "psllq $8, %%mm4\n"
+ "psrlq $8, %%mm1\n"
+ "psrlq $8, %%mm4\n"
+ "movq %%mm4, %%mm5\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm4\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm5\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm4\n"
+ "psubw %%mm3, %%mm5\n"
+ "psubw %%mm4, %%mm0\n"
+ "psubw %%mm5, %%mm2\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm0, %%mm3\n\t"
+ "pcmpgtw %%mm2, %%mm1\n\t"
+ "pxor %%mm3, %%mm0\n"
+ "pxor %%mm1, %%mm2\n"
+ "psubw %%mm3, %%mm0\n"
+ "psubw %%mm1, %%mm2\n"
+ "paddw %%mm0, %%mm2\n"
+ "paddw %%mm2, %%mm6\n"
+
+ "add %2, %0\n"
+ "1:\n"
+
+ "movq (%0), %%mm0\n"
+ "movq %%mm0, %%mm1\n"
+ "psllq $8, %%mm0\n"
+ "psrlq $8, %%mm1\n"
+ "psrlq $8, %%mm0\n"
+ "movq %%mm0, %%mm2\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm0\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm2\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm0\n"
+ "psubw %%mm3, %%mm2\n"
+ "psubw %%mm0, %%mm4\n"
+ "psubw %%mm2, %%mm5\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm4, %%mm3\n\t"
+ "pcmpgtw %%mm5, %%mm1\n\t"
+ "pxor %%mm3, %%mm4\n"
+ "pxor %%mm1, %%mm5\n"
+ "psubw %%mm3, %%mm4\n"
+ "psubw %%mm1, %%mm5\n"
+ "paddw %%mm4, %%mm5\n"
+ "paddw %%mm5, %%mm6\n"
+
+ "add %2, %0\n"
+
+ "movq (%0), %%mm4\n"
+ "movq %%mm4, %%mm1\n"
+ "psllq $8, %%mm4\n"
+ "psrlq $8, %%mm1\n"
+ "psrlq $8, %%mm4\n"
+ "movq %%mm4, %%mm5\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm4\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm5\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm4\n"
+ "psubw %%mm3, %%mm5\n"
+ "psubw %%mm4, %%mm0\n"
+ "psubw %%mm5, %%mm2\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm0, %%mm3\n\t"
+ "pcmpgtw %%mm2, %%mm1\n\t"
+ "pxor %%mm3, %%mm0\n"
+ "pxor %%mm1, %%mm2\n"
+ "psubw %%mm3, %%mm0\n"
+ "psubw %%mm1, %%mm2\n"
+ "paddw %%mm0, %%mm2\n"
+ "paddw %%mm2, %%mm6\n"
+
+ "add %2, %0\n"
+ "subl $2, %%ecx\n"
+ " jnz 1b\n"
+
+ "movq %%mm6, %%mm0\n"
+ "punpcklwd %%mm7, %%mm0\n"
+ "punpckhwd %%mm7, %%mm6\n"
+ "paddd %%mm0, %%mm6\n"
+
+ "movq %%mm6, %%mm0\n"
+ "psrlq $32, %%mm6\n"
+ "paddd %%mm6, %%mm0\n"
+ "movd %%mm0, %1\n"
+ : "+r" (pix1), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "g" (h - 2)
+ : "%ecx");
+
+ return tmp;
}
-static int hf_noise16_mmx(uint8_t * pix1, int line_size, int h) {
+static int hf_noise16_mmx(uint8_t *pix1, int line_size, int h)
+{
int tmp;
- uint8_t * pix= pix1;
- __asm__ volatile (
- "movl %3,%%ecx\n"
- "pxor %%mm7,%%mm7\n"
- "pxor %%mm6,%%mm6\n"
-
- "movq (%0),%%mm0\n"
- "movq 1(%0),%%mm1\n"
- "movq %%mm0, %%mm2\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm0\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm2\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm0\n"
- "psubw %%mm3, %%mm2\n"
-
- "add %2,%0\n"
-
- "movq (%0),%%mm4\n"
- "movq 1(%0),%%mm1\n"
- "movq %%mm4, %%mm5\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm4\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm5\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm4\n"
- "psubw %%mm3, %%mm5\n"
- "psubw %%mm4, %%mm0\n"
- "psubw %%mm5, %%mm2\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm0, %%mm3\n\t"
- "pcmpgtw %%mm2, %%mm1\n\t"
- "pxor %%mm3, %%mm0\n"
- "pxor %%mm1, %%mm2\n"
- "psubw %%mm3, %%mm0\n"
- "psubw %%mm1, %%mm2\n"
- "paddw %%mm0, %%mm2\n"
- "paddw %%mm2, %%mm6\n"
-
- "add %2,%0\n"
- "1:\n"
-
- "movq (%0),%%mm0\n"
- "movq 1(%0),%%mm1\n"
- "movq %%mm0, %%mm2\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm0\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm2\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm0\n"
- "psubw %%mm3, %%mm2\n"
- "psubw %%mm0, %%mm4\n"
- "psubw %%mm2, %%mm5\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm4, %%mm3\n\t"
- "pcmpgtw %%mm5, %%mm1\n\t"
- "pxor %%mm3, %%mm4\n"
- "pxor %%mm1, %%mm5\n"
- "psubw %%mm3, %%mm4\n"
- "psubw %%mm1, %%mm5\n"
- "paddw %%mm4, %%mm5\n"
- "paddw %%mm5, %%mm6\n"
-
- "add %2,%0\n"
-
- "movq (%0),%%mm4\n"
- "movq 1(%0),%%mm1\n"
- "movq %%mm4, %%mm5\n"
- "movq %%mm1, %%mm3\n"
- "punpcklbw %%mm7,%%mm4\n"
- "punpcklbw %%mm7,%%mm1\n"
- "punpckhbw %%mm7,%%mm5\n"
- "punpckhbw %%mm7,%%mm3\n"
- "psubw %%mm1, %%mm4\n"
- "psubw %%mm3, %%mm5\n"
- "psubw %%mm4, %%mm0\n"
- "psubw %%mm5, %%mm2\n"
- "pxor %%mm3, %%mm3\n"
- "pxor %%mm1, %%mm1\n"
- "pcmpgtw %%mm0, %%mm3\n\t"
- "pcmpgtw %%mm2, %%mm1\n\t"
- "pxor %%mm3, %%mm0\n"
- "pxor %%mm1, %%mm2\n"
- "psubw %%mm3, %%mm0\n"
- "psubw %%mm1, %%mm2\n"
- "paddw %%mm0, %%mm2\n"
- "paddw %%mm2, %%mm6\n"
-
- "add %2,%0\n"
- "subl $2, %%ecx\n"
- " jnz 1b\n"
-
- "movq %%mm6, %%mm0\n"
- "punpcklwd %%mm7,%%mm0\n"
- "punpckhwd %%mm7,%%mm6\n"
- "paddd %%mm0, %%mm6\n"
-
- "movq %%mm6,%%mm0\n"
- "psrlq $32, %%mm6\n"
- "paddd %%mm6,%%mm0\n"
- "movd %%mm0,%1\n"
- : "+r" (pix1), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "g" (h-2)
- : "%ecx");
- return tmp + hf_noise8_mmx(pix+8, line_size, h);
+ uint8_t *pix = pix1;
+
+ __asm__ volatile (
+ "movl %3, %%ecx\n"
+ "pxor %%mm7, %%mm7\n"
+ "pxor %%mm6, %%mm6\n"
+
+ "movq (%0), %%mm0\n"
+ "movq 1(%0), %%mm1\n"
+ "movq %%mm0, %%mm2\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm0\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm2\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm0\n"
+ "psubw %%mm3, %%mm2\n"
+
+ "add %2, %0\n"
+
+ "movq (%0), %%mm4\n"
+ "movq 1(%0), %%mm1\n"
+ "movq %%mm4, %%mm5\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm4\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm5\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm4\n"
+ "psubw %%mm3, %%mm5\n"
+ "psubw %%mm4, %%mm0\n"
+ "psubw %%mm5, %%mm2\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm0, %%mm3\n\t"
+ "pcmpgtw %%mm2, %%mm1\n\t"
+ "pxor %%mm3, %%mm0\n"
+ "pxor %%mm1, %%mm2\n"
+ "psubw %%mm3, %%mm0\n"
+ "psubw %%mm1, %%mm2\n"
+ "paddw %%mm0, %%mm2\n"
+ "paddw %%mm2, %%mm6\n"
+
+ "add %2, %0\n"
+ "1:\n"
+
+ "movq (%0), %%mm0\n"
+ "movq 1(%0), %%mm1\n"
+ "movq %%mm0, %%mm2\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm0\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm2\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm0\n"
+ "psubw %%mm3, %%mm2\n"
+ "psubw %%mm0, %%mm4\n"
+ "psubw %%mm2, %%mm5\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm4, %%mm3\n\t"
+ "pcmpgtw %%mm5, %%mm1\n\t"
+ "pxor %%mm3, %%mm4\n"
+ "pxor %%mm1, %%mm5\n"
+ "psubw %%mm3, %%mm4\n"
+ "psubw %%mm1, %%mm5\n"
+ "paddw %%mm4, %%mm5\n"
+ "paddw %%mm5, %%mm6\n"
+
+ "add %2, %0\n"
+
+ "movq (%0), %%mm4\n"
+ "movq 1(%0), %%mm1\n"
+ "movq %%mm4, %%mm5\n"
+ "movq %%mm1, %%mm3\n"
+ "punpcklbw %%mm7, %%mm4\n"
+ "punpcklbw %%mm7, %%mm1\n"
+ "punpckhbw %%mm7, %%mm5\n"
+ "punpckhbw %%mm7, %%mm3\n"
+ "psubw %%mm1, %%mm4\n"
+ "psubw %%mm3, %%mm5\n"
+ "psubw %%mm4, %%mm0\n"
+ "psubw %%mm5, %%mm2\n"
+ "pxor %%mm3, %%mm3\n"
+ "pxor %%mm1, %%mm1\n"
+ "pcmpgtw %%mm0, %%mm3\n\t"
+ "pcmpgtw %%mm2, %%mm1\n\t"
+ "pxor %%mm3, %%mm0\n"
+ "pxor %%mm1, %%mm2\n"
+ "psubw %%mm3, %%mm0\n"
+ "psubw %%mm1, %%mm2\n"
+ "paddw %%mm0, %%mm2\n"
+ "paddw %%mm2, %%mm6\n"
+
+ "add %2, %0\n"
+ "subl $2, %%ecx\n"
+ " jnz 1b\n"
+
+ "movq %%mm6, %%mm0\n"
+ "punpcklwd %%mm7, %%mm0\n"
+ "punpckhwd %%mm7, %%mm6\n"
+ "paddd %%mm0, %%mm6\n"
+
+ "movq %%mm6, %%mm0\n"
+ "psrlq $32, %%mm6\n"
+ "paddd %%mm6, %%mm0\n"
+ "movd %%mm0, %1\n"
+ : "+r" (pix1), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "g" (h - 2)
+ : "%ecx");
+
+ return tmp + hf_noise8_mmx(pix + 8, line_size, h);
}
-static int nsse16_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
- MpegEncContext *c = p;
+static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
int score1, score2;
- if(c) score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h);
- else score1 = sse16_mmx(c, pix1, pix2, line_size, h);
- score2= hf_noise16_mmx(pix1, line_size, h) - hf_noise16_mmx(pix2, line_size, h);
-
- if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
- else return score1 + FFABS(score2)*8;
+ if (c)
+ score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h);
+ else
+ score1 = sse16_mmx(c, pix1, pix2, line_size, h);
+ score2 = hf_noise16_mmx(pix1, line_size, h) -
+ hf_noise16_mmx(pix2, line_size, h);
+
+ if (c)
+ return score1 + FFABS(score2) * c->avctx->nsse_weight;
+ else
+ return score1 + FFABS(score2) * 8;
}
-static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
- MpegEncContext *c = p;
- int score1= sse8_mmx(c, pix1, pix2, line_size, h);
- int score2= hf_noise8_mmx(pix1, line_size, h) - hf_noise8_mmx(pix2, line_size, h);
-
- if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
- else return score1 + FFABS(score2)*8;
+static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
+ int score1 = sse8_mmx(c, pix1, pix2, line_size, h);
+ int score2 = hf_noise8_mmx(pix1, line_size, h) -
+ hf_noise8_mmx(pix2, line_size, h);
+
+ if (c)
+ return score1 + FFABS(score2) * c->avctx->nsse_weight;
+ else
+ return score1 + FFABS(score2) * 8;
}
-static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
+static int vsad_intra16_mmx(MpegEncContext *v, uint8_t *pix, uint8_t *dummy,
+ int line_size, int h)
+{
int tmp;
- av_assert2( (((int)pix) & 7) == 0);
- av_assert2((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
- "movq (%0), %%mm2\n"\
- "movq 8(%0), %%mm3\n"\
- "add %2,%0\n"\
- "movq %%mm2, " #out0 "\n"\
- "movq %%mm3, " #out1 "\n"\
- "psubusb " #in0 ", %%mm2\n"\
- "psubusb " #in1 ", %%mm3\n"\
- "psubusb " #out0 ", " #in0 "\n"\
- "psubusb " #out1 ", " #in1 "\n"\
- "por %%mm2, " #in0 "\n"\
- "por %%mm3, " #in1 "\n"\
- "movq " #in0 ", %%mm2\n"\
- "movq " #in1 ", %%mm3\n"\
- "punpcklbw %%mm7, " #in0 "\n"\
- "punpcklbw %%mm7, " #in1 "\n"\
- "punpckhbw %%mm7, %%mm2\n"\
- "punpckhbw %%mm7, %%mm3\n"\
- "paddw " #in1 ", " #in0 "\n"\
- "paddw %%mm3, %%mm2\n"\
- "paddw %%mm2, " #in0 "\n"\
- "paddw " #in0 ", %%mm6\n"
-
-
- __asm__ volatile (
- "movl %3,%%ecx\n"
- "pxor %%mm6,%%mm6\n"
- "pxor %%mm7,%%mm7\n"
- "movq (%0),%%mm0\n"
- "movq 8(%0),%%mm1\n"
- "add %2,%0\n"
- "jmp 2f\n"
- "1:\n"
-
- SUM(%%mm4, %%mm5, %%mm0, %%mm1)
- "2:\n"
- SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
- "subl $2, %%ecx\n"
- "jnz 1b\n"
-
- "movq %%mm6,%%mm0\n"
- "psrlq $32, %%mm6\n"
- "paddw %%mm6,%%mm0\n"
- "movq %%mm0,%%mm6\n"
- "psrlq $16, %%mm0\n"
- "paddw %%mm6,%%mm0\n"
- "movd %%mm0,%1\n"
- : "+r" (pix), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+ av_assert2((((int) pix) & 7) == 0);
+ av_assert2((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1) \
+ "movq (%0), %%mm2\n" \
+ "movq 8(%0), %%mm3\n" \
+ "add %2,%0\n" \
+ "movq %%mm2, " #out0 "\n" \
+ "movq %%mm3, " #out1 "\n" \
+ "psubusb " #in0 ", %%mm2\n" \
+ "psubusb " #in1 ", %%mm3\n" \
+ "psubusb " #out0 ", " #in0 "\n" \
+ "psubusb " #out1 ", " #in1 "\n" \
+ "por %%mm2, " #in0 "\n" \
+ "por %%mm3, " #in1 "\n" \
+ "movq " #in0 ", %%mm2\n" \
+ "movq " #in1 ", %%mm3\n" \
+ "punpcklbw %%mm7, " #in0 "\n" \
+ "punpcklbw %%mm7, " #in1 "\n" \
+ "punpckhbw %%mm7, %%mm2\n" \
+ "punpckhbw %%mm7, %%mm3\n" \
+ "paddw " #in1 ", " #in0 "\n" \
+ "paddw %%mm3, %%mm2\n" \
+ "paddw %%mm2, " #in0 "\n" \
+ "paddw " #in0 ", %%mm6\n"
+
+
+ __asm__ volatile (
+ "movl %3, %%ecx\n"
+ "pxor %%mm6, %%mm6\n"
+ "pxor %%mm7, %%mm7\n"
+ "movq (%0), %%mm0\n"
+ "movq 8(%0), %%mm1\n"
+ "add %2, %0\n"
+ "jmp 2f\n"
+ "1:\n"
+
+ SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+ "2:\n"
+ SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+ "subl $2, %%ecx\n"
+ "jnz 1b\n"
+
+ "movq %%mm6, %%mm0\n"
+ "psrlq $32, %%mm6\n"
+ "paddw %%mm6, %%mm0\n"
+ "movq %%mm0, %%mm6\n"
+ "psrlq $16, %%mm0\n"
+ "paddw %%mm6, %%mm0\n"
+ "movd %%mm0, %1\n"
+ : "+r" (pix), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp & 0xFFFF;
}
#undef SUM
-static int vsad_intra16_mmxext(void *v, uint8_t *pix, uint8_t *dummy,
+static int vsad_intra16_mmxext(MpegEncContext *v, uint8_t *pix, uint8_t *dummy,
int line_size, int h)
{
int tmp;
- av_assert2( (((int)pix) & 7) == 0);
- av_assert2((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
- "movq (%0), " #out0 "\n"\
- "movq 8(%0), " #out1 "\n"\
- "add %2,%0\n"\
- "psadbw " #out0 ", " #in0 "\n"\
- "psadbw " #out1 ", " #in1 "\n"\
- "paddw " #in1 ", " #in0 "\n"\
- "paddw " #in0 ", %%mm6\n"
-
- __asm__ volatile (
- "movl %3,%%ecx\n"
- "pxor %%mm6,%%mm6\n"
- "pxor %%mm7,%%mm7\n"
- "movq (%0),%%mm0\n"
- "movq 8(%0),%%mm1\n"
- "add %2,%0\n"
- "jmp 2f\n"
- "1:\n"
-
- SUM(%%mm4, %%mm5, %%mm0, %%mm1)
- "2:\n"
- SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
- "subl $2, %%ecx\n"
- "jnz 1b\n"
-
- "movd %%mm6,%1\n"
- : "+r" (pix), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+ av_assert2((((int) pix) & 7) == 0);
+ av_assert2((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1) \
+ "movq (%0), " #out0 "\n" \
+ "movq 8(%0), " #out1 "\n" \
+ "add %2, %0\n" \
+ "psadbw " #out0 ", " #in0 "\n" \
+ "psadbw " #out1 ", " #in1 "\n" \
+ "paddw " #in1 ", " #in0 "\n" \
+ "paddw " #in0 ", %%mm6\n"
+
+ __asm__ volatile (
+ "movl %3, %%ecx\n"
+ "pxor %%mm6, %%mm6\n"
+ "pxor %%mm7, %%mm7\n"
+ "movq (%0), %%mm0\n"
+ "movq 8(%0), %%mm1\n"
+ "add %2, %0\n"
+ "jmp 2f\n"
+ "1:\n"
+
+ SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+ "2:\n"
+ SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+ "subl $2, %%ecx\n"
+ "jnz 1b\n"
+
+ "movd %%mm6, %1\n"
+ : "+r" (pix), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp;
}
#undef SUM
-static int vsad16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int vsad16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h)
+{
int tmp;
- av_assert2( (((int)pix1) & 7) == 0);
- av_assert2( (((int)pix2) & 7) == 0);
- av_assert2((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
- "movq (%0),%%mm2\n"\
- "movq (%1)," #out0 "\n"\
- "movq 8(%0),%%mm3\n"\
- "movq 8(%1)," #out1 "\n"\
- "add %3,%0\n"\
- "add %3,%1\n"\
- "psubb " #out0 ", %%mm2\n"\
- "psubb " #out1 ", %%mm3\n"\
- "pxor %%mm7, %%mm2\n"\
- "pxor %%mm7, %%mm3\n"\
- "movq %%mm2, " #out0 "\n"\
- "movq %%mm3, " #out1 "\n"\
- "psubusb " #in0 ", %%mm2\n"\
- "psubusb " #in1 ", %%mm3\n"\
- "psubusb " #out0 ", " #in0 "\n"\
- "psubusb " #out1 ", " #in1 "\n"\
- "por %%mm2, " #in0 "\n"\
- "por %%mm3, " #in1 "\n"\
- "movq " #in0 ", %%mm2\n"\
- "movq " #in1 ", %%mm3\n"\
- "punpcklbw %%mm7, " #in0 "\n"\
- "punpcklbw %%mm7, " #in1 "\n"\
- "punpckhbw %%mm7, %%mm2\n"\
- "punpckhbw %%mm7, %%mm3\n"\
- "paddw " #in1 ", " #in0 "\n"\
- "paddw %%mm3, %%mm2\n"\
- "paddw %%mm2, " #in0 "\n"\
- "paddw " #in0 ", %%mm6\n"
-
-
- __asm__ volatile (
- "movl %4,%%ecx\n"
- "pxor %%mm6,%%mm6\n"
- "pcmpeqw %%mm7,%%mm7\n"
- "psllw $15, %%mm7\n"
- "packsswb %%mm7, %%mm7\n"
- "movq (%0),%%mm0\n"
- "movq (%1),%%mm2\n"
- "movq 8(%0),%%mm1\n"
- "movq 8(%1),%%mm3\n"
- "add %3,%0\n"
- "add %3,%1\n"
- "psubb %%mm2, %%mm0\n"
- "psubb %%mm3, %%mm1\n"
- "pxor %%mm7, %%mm0\n"
- "pxor %%mm7, %%mm1\n"
- "jmp 2f\n"
- "1:\n"
-
- SUM(%%mm4, %%mm5, %%mm0, %%mm1)
- "2:\n"
- SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
- "subl $2, %%ecx\n"
- "jnz 1b\n"
-
- "movq %%mm6,%%mm0\n"
- "psrlq $32, %%mm6\n"
- "paddw %%mm6,%%mm0\n"
- "movq %%mm0,%%mm6\n"
- "psrlq $16, %%mm0\n"
- "paddw %%mm6,%%mm0\n"
- "movd %%mm0,%2\n"
- : "+r" (pix1), "+r" (pix2), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+ av_assert2((((int) pix1) & 7) == 0);
+ av_assert2((((int) pix2) & 7) == 0);
+ av_assert2((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1) \
+ "movq (%0), %%mm2\n" \
+ "movq (%1), " #out0 "\n" \
+ "movq 8(%0), %%mm3\n" \
+ "movq 8(%1), " #out1 "\n" \
+ "add %3, %0\n" \
+ "add %3, %1\n" \
+ "psubb " #out0 ", %%mm2\n" \
+ "psubb " #out1 ", %%mm3\n" \
+ "pxor %%mm7, %%mm2\n" \
+ "pxor %%mm7, %%mm3\n" \
+ "movq %%mm2, " #out0 "\n" \
+ "movq %%mm3, " #out1 "\n" \
+ "psubusb " #in0 ", %%mm2\n" \
+ "psubusb " #in1 ", %%mm3\n" \
+ "psubusb " #out0 ", " #in0 "\n" \
+ "psubusb " #out1 ", " #in1 "\n" \
+ "por %%mm2, " #in0 "\n" \
+ "por %%mm3, " #in1 "\n" \
+ "movq " #in0 ", %%mm2\n" \
+ "movq " #in1 ", %%mm3\n" \
+ "punpcklbw %%mm7, " #in0 "\n" \
+ "punpcklbw %%mm7, " #in1 "\n" \
+ "punpckhbw %%mm7, %%mm2\n" \
+ "punpckhbw %%mm7, %%mm3\n" \
+ "paddw " #in1 ", " #in0 "\n" \
+ "paddw %%mm3, %%mm2\n" \
+ "paddw %%mm2, " #in0 "\n" \
+ "paddw " #in0 ", %%mm6\n"
+
+
+ __asm__ volatile (
+ "movl %4, %%ecx\n"
+ "pxor %%mm6, %%mm6\n"
+ "pcmpeqw %%mm7, %%mm7\n"
+ "psllw $15, %%mm7\n"
+ "packsswb %%mm7, %%mm7\n"
+ "movq (%0), %%mm0\n"
+ "movq (%1), %%mm2\n"
+ "movq 8(%0), %%mm1\n"
+ "movq 8(%1), %%mm3\n"
+ "add %3, %0\n"
+ "add %3, %1\n"
+ "psubb %%mm2, %%mm0\n"
+ "psubb %%mm3, %%mm1\n"
+ "pxor %%mm7, %%mm0\n"
+ "pxor %%mm7, %%mm1\n"
+ "jmp 2f\n"
+ "1:\n"
+
+ SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+ "2:\n"
+ SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+ "subl $2, %%ecx\n"
+ "jnz 1b\n"
+
+ "movq %%mm6, %%mm0\n"
+ "psrlq $32, %%mm6\n"
+ "paddw %%mm6, %%mm0\n"
+ "movq %%mm0, %%mm6\n"
+ "psrlq $16, %%mm0\n"
+ "paddw %%mm6, %%mm0\n"
+ "movd %%mm0, %2\n"
+ : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp & 0x7FFF;
}
#undef SUM
-static int vsad16_mmxext(void *v, uint8_t *pix1, uint8_t *pix2,
+static int vsad16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
int line_size, int h)
{
int tmp;
- av_assert2( (((int)pix1) & 7) == 0);
- av_assert2( (((int)pix2) & 7) == 0);
- av_assert2((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
- "movq (%0)," #out0 "\n"\
- "movq (%1),%%mm2\n"\
- "movq 8(%0)," #out1 "\n"\
- "movq 8(%1),%%mm3\n"\
- "add %3,%0\n"\
- "add %3,%1\n"\
- "psubb %%mm2, " #out0 "\n"\
- "psubb %%mm3, " #out1 "\n"\
- "pxor %%mm7, " #out0 "\n"\
- "pxor %%mm7, " #out1 "\n"\
- "psadbw " #out0 ", " #in0 "\n"\
- "psadbw " #out1 ", " #in1 "\n"\
- "paddw " #in1 ", " #in0 "\n"\
- "paddw " #in0 ", %%mm6\n"
-
- __asm__ volatile (
- "movl %4,%%ecx\n"
- "pxor %%mm6,%%mm6\n"
- "pcmpeqw %%mm7,%%mm7\n"
- "psllw $15, %%mm7\n"
- "packsswb %%mm7, %%mm7\n"
- "movq (%0),%%mm0\n"
- "movq (%1),%%mm2\n"
- "movq 8(%0),%%mm1\n"
- "movq 8(%1),%%mm3\n"
- "add %3,%0\n"
- "add %3,%1\n"
- "psubb %%mm2, %%mm0\n"
- "psubb %%mm3, %%mm1\n"
- "pxor %%mm7, %%mm0\n"
- "pxor %%mm7, %%mm1\n"
- "jmp 2f\n"
- "1:\n"
-
- SUM(%%mm4, %%mm5, %%mm0, %%mm1)
- "2:\n"
- SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
- "subl $2, %%ecx\n"
- "jnz 1b\n"
-
- "movd %%mm6,%2\n"
- : "+r" (pix1), "+r" (pix2), "=r"(tmp)
- : "r" ((x86_reg)line_size) , "m" (h)
- : "%ecx");
+ av_assert2((((int) pix1) & 7) == 0);
+ av_assert2((((int) pix2) & 7) == 0);
+ av_assert2((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1) \
+ "movq (%0), " #out0 "\n" \
+ "movq (%1), %%mm2\n" \
+ "movq 8(%0), " #out1 "\n" \
+ "movq 8(%1), %%mm3\n" \
+ "add %3, %0\n" \
+ "add %3, %1\n" \
+ "psubb %%mm2, " #out0 "\n" \
+ "psubb %%mm3, " #out1 "\n" \
+ "pxor %%mm7, " #out0 "\n" \
+ "pxor %%mm7, " #out1 "\n" \
+ "psadbw " #out0 ", " #in0 "\n" \
+ "psadbw " #out1 ", " #in1 "\n" \
+ "paddw " #in1 ", " #in0 "\n" \
+ "paddw " #in0 ", %%mm6\n "
+
+ __asm__ volatile (
+ "movl %4, %%ecx\n"
+ "pxor %%mm6, %%mm6\n"
+ "pcmpeqw %%mm7, %%mm7\n"
+ "psllw $15, %%mm7\n"
+ "packsswb %%mm7, %%mm7\n"
+ "movq (%0), %%mm0\n"
+ "movq (%1), %%mm2\n"
+ "movq 8(%0), %%mm1\n"
+ "movq 8(%1), %%mm3\n"
+ "add %3, %0\n"
+ "add %3, %1\n"
+ "psubb %%mm2, %%mm0\n"
+ "psubb %%mm3, %%mm1\n"
+ "pxor %%mm7, %%mm0\n"
+ "pxor %%mm7, %%mm1\n"
+ "jmp 2f\n"
+ "1:\n"
+
+ SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+ "2:\n"
+ SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+ "subl $2, %%ecx\n"
+ "jnz 1b\n"
+
+ "movd %%mm6, %2\n"
+ : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+ : "r" ((x86_reg) line_size), "m" (h)
+ : "%ecx");
+
return tmp;
}
#undef SUM
-static void diff_bytes_mmx(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w){
- x86_reg i=0;
- if(w>=16)
- __asm__ volatile(
+static void diff_bytes_mmx(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w)
+{
+ x86_reg i = 0;
+
+ if (w >= 16)
+ __asm__ volatile (
"1: \n\t"
"movq (%2, %0), %%mm0 \n\t"
"movq (%1, %0), %%mm1 \n\t"
@@ -678,20 +713,20 @@ static void diff_bytes_mmx(uint8_t *dst, const uint8_t *src1, const uint8_t *src
"cmp %4, %0 \n\t"
" jb 1b \n\t"
: "+r" (i)
- : "r"(src1), "r"(src2), "r"(dst), "r"((x86_reg)w-15)
- );
- for(; i<w; i++)
- dst[i+0] = src1[i+0]-src2[i+0];
+ : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w - 15));
+
+ for (; i < w; i++)
+ dst[i + 0] = src1[i + 0] - src2[i + 0];
}
static void sub_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *src1,
const uint8_t *src2, int w,
int *left, int *left_top)
{
- x86_reg i=0;
+ x86_reg i = 0;
uint8_t l, lt;
- __asm__ volatile(
+ __asm__ volatile (
"movq (%1, %0), %%mm0 \n\t" // LT
"psllq $8, %%mm0 \n\t"
"1: \n\t"
@@ -713,139 +748,142 @@ static void sub_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *src1,
"cmp %4, %0 \n\t"
" jb 1b \n\t"
: "+r" (i)
- : "r"(src1), "r"(src2), "r"(dst), "r"((x86_reg)w)
- );
+ : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w));
- l= *left;
- lt= *left_top;
+ l = *left;
+ lt = *left_top;
- dst[0]= src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt)&0xFF);
+ dst[0] = src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt) & 0xFF);
- *left_top= src1[w-1];
- *left = src2[w-1];
+ *left_top = src1[w - 1];
+ *left = src2[w - 1];
}
-#define MMABS_MMX(a,z)\
- "pxor " #z ", " #z " \n\t"\
- "pcmpgtw " #a ", " #z " \n\t"\
- "pxor " #z ", " #a " \n\t"\
- "psubw " #z ", " #a " \n\t"
-
-#define MMABS_MMXEXT(a, z) \
- "pxor " #z ", " #z " \n\t"\
- "psubw " #a ", " #z " \n\t"\
- "pmaxsw " #z ", " #a " \n\t"
-
-#define MMABS_SSSE3(a,z)\
- "pabsw " #a ", " #a " \n\t"
-
-#define MMABS_SUM(a,z, sum)\
- MMABS(a,z)\
- "paddusw " #a ", " #sum " \n\t"
-
-/* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get up to
- * about 100k on extreme inputs. But that's very unlikely to occur in natural video,
- * and it's even more unlikely to not have any alternative mvs/modes with lower cost. */
-#define HSUM_MMX(a, t, dst)\
- "movq "#a", "#t" \n\t"\
- "psrlq $32, "#a" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "movq "#a", "#t" \n\t"\
- "psrlq $16, "#a" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "movd "#a", "#dst" \n\t"\
-
-#define HSUM_MMXEXT(a, t, dst) \
- "pshufw $0x0E, "#a", "#t" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "pshufw $0x01, "#a", "#t" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "movd "#a", "#dst" \n\t"\
-
-#define HSUM_SSE2(a, t, dst)\
- "movhlps "#a", "#t" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "pshuflw $0x0E, "#a", "#t" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "pshuflw $0x01, "#a", "#t" \n\t"\
- "paddusw "#t", "#a" \n\t"\
- "movd "#a", "#dst" \n\t"\
-
-#define DCT_SAD4(m,mm,o)\
- "mov"#m" "#o"+ 0(%1), "#mm"2 \n\t"\
- "mov"#m" "#o"+16(%1), "#mm"3 \n\t"\
- "mov"#m" "#o"+32(%1), "#mm"4 \n\t"\
- "mov"#m" "#o"+48(%1), "#mm"5 \n\t"\
- MMABS_SUM(mm##2, mm##6, mm##0)\
- MMABS_SUM(mm##3, mm##7, mm##1)\
- MMABS_SUM(mm##4, mm##6, mm##0)\
- MMABS_SUM(mm##5, mm##7, mm##1)\
-
-#define DCT_SAD_MMX\
- "pxor %%mm0, %%mm0 \n\t"\
- "pxor %%mm1, %%mm1 \n\t"\
- DCT_SAD4(q, %%mm, 0)\
- DCT_SAD4(q, %%mm, 8)\
- DCT_SAD4(q, %%mm, 64)\
- DCT_SAD4(q, %%mm, 72)\
- "paddusw %%mm1, %%mm0 \n\t"\
+#define MMABS_MMX(a,z) \
+ "pxor " #z ", " #z " \n\t" \
+ "pcmpgtw " #a ", " #z " \n\t" \
+ "pxor " #z ", " #a " \n\t" \
+ "psubw " #z ", " #a " \n\t"
+
+#define MMABS_MMXEXT(a, z) \
+ "pxor " #z ", " #z " \n\t" \
+ "psubw " #a ", " #z " \n\t" \
+ "pmaxsw " #z ", " #a " \n\t"
+
+#define MMABS_SSSE3(a,z) \
+ "pabsw " #a ", " #a " \n\t"
+
+#define MMABS_SUM(a,z, sum) \
+ MMABS(a,z) \
+ "paddusw " #a ", " #sum " \n\t"
+
+/* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get
+ * up to about 100k on extreme inputs. But that's very unlikely to occur in
+ * natural video, and it's even more unlikely to not have any alternative
+ * mvs/modes with lower cost. */
+#define HSUM_MMX(a, t, dst) \
+ "movq " #a ", " #t " \n\t" \
+ "psrlq $32, " #a " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "movq " #a ", " #t " \n\t" \
+ "psrlq $16, " #a " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "movd " #a ", " #dst " \n\t" \
+
+#define HSUM_MMXEXT(a, t, dst) \
+ "pshufw $0x0E, " #a ", " #t " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "pshufw $0x01, " #a ", " #t " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "movd " #a ", " #dst " \n\t" \
+
+#define HSUM_SSE2(a, t, dst) \
+ "movhlps " #a ", " #t " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "pshuflw $0x0E, " #a ", " #t " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "pshuflw $0x01, " #a ", " #t " \n\t" \
+ "paddusw " #t ", " #a " \n\t" \
+ "movd " #a ", " #dst " \n\t" \
+
+#define DCT_SAD4(m, mm, o) \
+ "mov"#m" "#o" + 0(%1), " #mm "2 \n\t" \
+ "mov"#m" "#o" + 16(%1), " #mm "3 \n\t" \
+ "mov"#m" "#o" + 32(%1), " #mm "4 \n\t" \
+ "mov"#m" "#o" + 48(%1), " #mm "5 \n\t" \
+ MMABS_SUM(mm ## 2, mm ## 6, mm ## 0) \
+ MMABS_SUM(mm ## 3, mm ## 7, mm ## 1) \
+ MMABS_SUM(mm ## 4, mm ## 6, mm ## 0) \
+ MMABS_SUM(mm ## 5, mm ## 7, mm ## 1) \
+
+#define DCT_SAD_MMX \
+ "pxor %%mm0, %%mm0 \n\t" \
+ "pxor %%mm1, %%mm1 \n\t" \
+ DCT_SAD4(q, %%mm, 0) \
+ DCT_SAD4(q, %%mm, 8) \
+ DCT_SAD4(q, %%mm, 64) \
+ DCT_SAD4(q, %%mm, 72) \
+ "paddusw %%mm1, %%mm0 \n\t" \
HSUM(%%mm0, %%mm1, %0)
-#define DCT_SAD_SSE2\
- "pxor %%xmm0, %%xmm0 \n\t"\
- "pxor %%xmm1, %%xmm1 \n\t"\
- DCT_SAD4(dqa, %%xmm, 0)\
- DCT_SAD4(dqa, %%xmm, 64)\
- "paddusw %%xmm1, %%xmm0 \n\t"\
+#define DCT_SAD_SSE2 \
+ "pxor %%xmm0, %%xmm0 \n\t" \
+ "pxor %%xmm1, %%xmm1 \n\t" \
+ DCT_SAD4(dqa, %%xmm, 0) \
+ DCT_SAD4(dqa, %%xmm, 64) \
+ "paddusw %%xmm1, %%xmm0 \n\t" \
HSUM(%%xmm0, %%xmm1, %0)
-#define DCT_SAD_FUNC(cpu) \
-static int sum_abs_dctelem_##cpu(int16_t *block){\
- int sum;\
- __asm__ volatile(\
- DCT_SAD\
- :"=r"(sum)\
- :"r"(block)\
- );\
- return sum&0xFFFF;\
+#define DCT_SAD_FUNC(cpu) \
+static int sum_abs_dctelem_ ## cpu(int16_t *block) \
+{ \
+ int sum; \
+ __asm__ volatile ( \
+ DCT_SAD \
+ :"=r"(sum) \
+ :"r"(block)); \
+ return sum & 0xFFFF; \
}
-#define DCT_SAD DCT_SAD_MMX
-#define HSUM(a,t,dst) HSUM_MMX(a,t,dst)
-#define MMABS(a,z) MMABS_MMX(a,z)
+#define DCT_SAD DCT_SAD_MMX
+#define HSUM(a, t, dst) HSUM_MMX(a, t, dst)
+#define MMABS(a, z) MMABS_MMX(a, z)
DCT_SAD_FUNC(mmx)
#undef MMABS
#undef HSUM
-#define HSUM(a,t,dst) HSUM_MMXEXT(a,t,dst)
-#define MMABS(a,z) MMABS_MMXEXT(a,z)
+#define HSUM(a, t, dst) HSUM_MMXEXT(a, t, dst)
+#define MMABS(a, z) MMABS_MMXEXT(a, z)
DCT_SAD_FUNC(mmxext)
#undef HSUM
#undef DCT_SAD
-#define DCT_SAD DCT_SAD_SSE2
-#define HSUM(a,t,dst) HSUM_SSE2(a,t,dst)
+#define DCT_SAD DCT_SAD_SSE2
+#define HSUM(a, t, dst) HSUM_SSE2(a, t, dst)
DCT_SAD_FUNC(sse2)
#undef MMABS
#if HAVE_SSSE3_INLINE
-#define MMABS(a,z) MMABS_SSSE3(a,z)
+#define MMABS(a, z) MMABS_SSSE3(a, z)
DCT_SAD_FUNC(ssse3)
#undef MMABS
#endif
#undef HSUM
#undef DCT_SAD
-static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int size){
+static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2,
+ int size)
+{
int sum;
- x86_reg i=size;
- __asm__ volatile(
+ x86_reg i = size;
+
+ __asm__ volatile (
"pxor %%mm4, %%mm4 \n"
"1: \n"
"sub $8, %0 \n"
- "movq (%2,%0), %%mm2 \n"
- "movq (%3,%0,2), %%mm0 \n"
- "movq 8(%3,%0,2), %%mm1 \n"
+ "movq (%2, %0), %%mm2 \n"
+ "movq (%3, %0, 2), %%mm0 \n"
+ "movq 8(%3, %0, 2), %%mm1 \n"
"punpckhbw %%mm2, %%mm3 \n"
"punpcklbw %%mm2, %%mm2 \n"
"psraw $8, %%mm3 \n"
@@ -861,28 +899,29 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
"psrlq $32, %%mm3 \n"
"paddd %%mm3, %%mm4 \n"
"movd %%mm4, %1 \n"
- :"+r"(i), "=r"(sum)
- :"r"(pix1), "r"(pix2)
- );
+ : "+r" (i), "=r" (sum)
+ : "r" (pix1), "r" (pix2));
+
return sum;
}
-#define PHADDD(a, t)\
- "movq "#a", "#t" \n\t"\
- "psrlq $32, "#a" \n\t"\
- "paddd "#t", "#a" \n\t"
+#define PHADDD(a, t) \
+ "movq " #a ", " #t " \n\t" \
+ "psrlq $32, " #a " \n\t" \
+ "paddd " #t ", " #a " \n\t"
+
/*
- pmulhw: dst[0-15]=(src[0-15]*dst[0-15])[16-31]
- pmulhrw: dst[0-15]=(src[0-15]*dst[0-15] + 0x8000)[16-31]
- pmulhrsw: dst[0-15]=(src[0-15]*dst[0-15] + 0x4000)[15-30]
+ * pmulhw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15])[16 - 31]
+ * pmulhrw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x8000)[16 - 31]
+ * pmulhrsw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x4000)[15 - 30]
*/
-#define PMULHRW(x, y, s, o)\
- "pmulhw " #s ", "#x " \n\t"\
- "pmulhw " #s ", "#y " \n\t"\
- "paddw " #o ", "#x " \n\t"\
- "paddw " #o ", "#y " \n\t"\
- "psraw $1, "#x " \n\t"\
- "psraw $1, "#y " \n\t"
+#define PMULHRW(x, y, s, o) \
+ "pmulhw " #s ", " #x " \n\t" \
+ "pmulhw " #s ", " #y " \n\t" \
+ "paddw " #o ", " #x " \n\t" \
+ "paddw " #o ", " #y " \n\t" \
+ "psraw $1, " #x " \n\t" \
+ "psraw $1, " #y " \n\t"
#define DEF(x) x ## _mmx
#define SET_RND MOVQ_WONE
#define SCALE_OFFSET 1
@@ -897,9 +936,9 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
#define DEF(x) x ## _3dnow
#define SET_RND(x)
#define SCALE_OFFSET 0
-#define PMULHRW(x, y, s, o)\
- "pmulhrw " #s ", "#x " \n\t"\
- "pmulhrw " #s ", "#y " \n\t"
+#define PMULHRW(x, y, s, o) \
+ "pmulhrw " #s ", " #x " \n\t" \
+ "pmulhrw " #s ", " #y " \n\t"
#include "dsputil_qns_template.c"
@@ -913,12 +952,15 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
#define DEF(x) x ## _ssse3
#define SET_RND(x)
#define SCALE_OFFSET -1
-#define PHADDD(a, t)\
- "pshufw $0x0E, "#a", "#t" \n\t"\
- "paddd "#t", "#a" \n\t" /* faster than phaddd on core2 */
-#define PMULHRW(x, y, s, o)\
- "pmulhrsw " #s ", "#x " \n\t"\
- "pmulhrsw " #s ", "#y " \n\t"
+
+#define PHADDD(a, t) \
+ "pshufw $0x0E, " #a ", " #t " \n\t" \
+ /* faster than phaddd on core2 */ \
+ "paddd " #t ", " #a " \n\t"
+
+#define PMULHRW(x, y, s, o) \
+ "pmulhrsw " #s ", " #x " \n\t" \
+ "pmulhrsw " #s ", " #y " \n\t"
#include "dsputil_qns_template.c"
@@ -931,63 +973,58 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
#endif /* HAVE_INLINE_ASM */
-int ff_sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
+int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+ int line_size, int h);
-#define hadamard_func(cpu) \
-int ff_hadamard8_diff_##cpu (void *s, uint8_t *src1, uint8_t *src2, \
- int stride, int h); \
-int ff_hadamard8_diff16_##cpu(void *s, uint8_t *src1, uint8_t *src2, \
- int stride, int h);
+#define hadamard_func(cpu) \
+ int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1, \
+ uint8_t *src2, int stride, int h); \
+ int ff_hadamard8_diff16_ ## cpu(MpegEncContext *s, uint8_t *src1, \
+ uint8_t *src2, int stride, int h);
hadamard_func(mmx)
hadamard_func(mmxext)
hadamard_func(sse2)
hadamard_func(ssse3)
-av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
+av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
+ unsigned high_bit_depth)
{
int cpu_flags = av_get_cpu_flags();
const int dct_algo = avctx->dct_algo;
-#if HAVE_YASM
- int bit_depth = avctx->bits_per_raw_sample;
-
if (EXTERNAL_MMX(cpu_flags)) {
- if (bit_depth <= 8)
+ if (!high_bit_depth)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
- c->pix_sum = ff_pix_sum16_mmx;
-
- c->pix_norm1 = ff_pix_norm1_mmx;
+ c->pix_sum = ff_pix_sum16_mmx;
+ c->pix_norm1 = ff_pix_norm1_mmx;
}
+
if (EXTERNAL_SSE2(cpu_flags))
- if (bit_depth <= 8)
+ if (!high_bit_depth)
c->get_pixels = ff_get_pixels_sse2;
-#endif /* HAVE_YASM */
#if HAVE_INLINE_ASM
if (INLINE_MMX(cpu_flags)) {
- if (avctx->bits_per_raw_sample <= 8 &&
+ if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmx;
- c->diff_bytes= diff_bytes_mmx;
- c->sum_abs_dctelem= sum_abs_dctelem_mmx;
+ c->diff_bytes = diff_bytes_mmx;
+ c->sum_abs_dctelem = sum_abs_dctelem_mmx;
- c->sse[0] = sse16_mmx;
- c->sse[1] = sse8_mmx;
- c->vsad[4]= vsad_intra16_mmx;
+ c->sse[0] = sse16_mmx;
+ c->sse[1] = sse8_mmx;
+ c->vsad[4] = vsad_intra16_mmx;
c->nsse[0] = nsse16_mmx;
c->nsse[1] = nsse8_mmx;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->vsad[0] = vsad16_mmx;
- }
-
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->try_8x8basis= try_8x8basis_mmx;
+ if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+ c->vsad[0] = vsad16_mmx;
+ c->try_8x8basis = try_8x8basis_mmx;
}
- c->add_8x8basis= add_8x8basis_mmx;
+ c->add_8x8basis = add_8x8basis_mmx;
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
}
@@ -1000,14 +1037,14 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
}
if (INLINE_MMXEXT(cpu_flags)) {
- if (avctx->bits_per_raw_sample <= 8 &&
+ if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_mmxext;
c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
c->vsad[4] = vsad_intra16_mmxext;
- if (!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->vsad[0] = vsad16_mmxext;
}
@@ -1015,11 +1052,11 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
}
if (INLINE_SSE2(cpu_flags)) {
- if (avctx->bits_per_raw_sample <= 8 &&
+ if (!high_bit_depth &&
(dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
c->fdct = ff_fdct_sse2;
- c->sum_abs_dctelem= sum_abs_dctelem_sse2;
+ c->sum_abs_dctelem = sum_abs_dctelem_sse2;
}
#if HAVE_SSSE3_INLINE
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/fdct.c b/chromium/third_party/ffmpeg/libavcodec/x86/fdct.c
index 11a13bb7043..f0cd471d363 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/fdct.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/fdct.c
@@ -1,5 +1,5 @@
/*
- * MMX optimized forward DCT
+ * SIMD-optimized forward DCT
* The gcc porting is Copyright (c) 2001 Fabrice Bellard.
* cleanup/optimizations are Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
* SSE2 optimization is Copyright (c) 2004 Denes Balatoni.
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp.asm
new file mode 100644
index 00000000000..37ee87b163f
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp.asm
@@ -0,0 +1,74 @@
+;******************************************************************************
+;* FLAC DSP SIMD optimizations
+;*
+;* Copyright (C) 2014 Loren Merritt
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION .text
+
+%macro LPC_32 1
+INIT_XMM %1
+cglobal flac_lpc_32, 5,6,5, decoded, coeffs, pred_order, qlevel, len, j
+ sub lend, pred_orderd
+ jle .ret
+ lea decodedq, [decodedq+pred_orderq*4-8]
+ lea coeffsq, [coeffsq+pred_orderq*4]
+ neg pred_orderq
+ movd m4, qlevelm
+ALIGN 16
+.loop_sample:
+ movd m0, [decodedq+pred_orderq*4+8]
+ add decodedq, 8
+ movd m1, [coeffsq+pred_orderq*4]
+ pxor m2, m2
+ pxor m3, m3
+ lea jq, [pred_orderq+1]
+ test jq, jq
+ jz .end_order
+.loop_order:
+ PMACSDQL m2, m0, m1, m2, m0
+ movd m0, [decodedq+jq*4]
+ PMACSDQL m3, m1, m0, m3, m1
+ movd m1, [coeffsq+jq*4]
+ inc jq
+ jl .loop_order
+.end_order:
+ PMACSDQL m2, m0, m1, m2, m0
+ psrlq m2, m4
+ movd m0, [decodedq]
+ paddd m0, m2
+ movd [decodedq], m0
+ sub lend, 2
+ jl .ret
+ PMACSDQL m3, m1, m0, m3, m1
+ psrlq m3, m4
+ movd m1, [decodedq+4]
+ paddd m1, m3
+ movd [decodedq+4], m1
+ jg .loop_sample
+.ret:
+ REP_RET
+%endmacro
+
+%if HAVE_XOP_EXTERNAL
+LPC_32 xop
+%endif
+LPC_32 sse4
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp_init.c
new file mode 100644
index 00000000000..a071b3d3b79
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/flacdsp_init.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 James Almer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/flacdsp.h"
+#include "libavutil/x86/cpu.h"
+#include "config.h"
+
+void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order,
+ int qlevel, int len);
+void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
+ int qlevel, int len);
+
+av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt,
+ int bps)
+{
+#if HAVE_YASM
+ int cpu_flags = av_get_cpu_flags();
+
+ if (EXTERNAL_SSE4(cpu_flags)) {
+ if (bps > 16 && CONFIG_FLAC_DECODER)
+ c->lpc = ff_flac_lpc_32_sse4;
+ }
+ if (EXTERNAL_XOP(cpu_flags)) {
+ if (bps > 16 && CONFIG_FLAC_DECODER)
+ c->lpc = ff_flac_lpc_32_xop;
+ }
+#endif
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/fmtconvert.asm b/chromium/third_party/ffmpeg/libavcodec/x86/fmtconvert.asm
index 60078e2c2c7..0d3f821c9f8 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/fmtconvert.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/fmtconvert.asm
@@ -31,9 +31,10 @@ SECTION_TEXT
%endif
%endmacro
-;---------------------------------------------------------------------------------
-; void int32_to_float_fmul_scalar(float *dst, const int32_t *src, float mul, int len);
-;---------------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_int32_to_float_fmul_scalar(float *dst, const int32_t *src, float mul,
+; int len);
+;------------------------------------------------------------------------------
%macro INT32_TO_FLOAT_FMUL_SCALAR 1
%if UNIX64
cglobal int32_to_float_fmul_scalar, 3, 3, %1, dst, src, len
@@ -243,8 +244,10 @@ FLOAT_TO_INT16_INTERLEAVE2
INIT_XMM sse2
FLOAT_TO_INT16_INTERLEAVE2
+;-----------------------------------------------------------------------------
+; void ff_float_to_int16_interleave6(int16_t *dst, const float **src, int len)
+;-----------------------------------------------------------------------------
%macro FLOAT_TO_INT16_INTERLEAVE6 0
-; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len)
cglobal float_to_int16_interleave6, 2, 8, 0, dst, src, src1, src2, src3, src4, src5, len
%if ARCH_X86_64
mov lend, r2d
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/fpel.asm b/chromium/third_party/ffmpeg/libavcodec/x86/fpel.asm
index dc363d1a635..de6b1d6c1b5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/fpel.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/fpel.asm
@@ -1,5 +1,5 @@
;******************************************************************************
-;* MMX optimized DSP utils
+;* SIMD-optimized fullpel functions
;* Copyright (c) 2008 Loren Merritt
;* Copyright (c) 2003-2013 Michael Niedermayer
;* Copyright (c) 2013 Daniel Kang
@@ -26,7 +26,8 @@
SECTION .text
INIT_MMX mmxext
-; void pixels(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put/avg_pixels(uint8_t *block, const uint8_t *pixels,
+; ptrdiff_t line_size, int h)
%macro PIXELS48 2
%if %2 == 4
%define OP movh
@@ -65,7 +66,8 @@ PIXELS48 avg, 8
INIT_XMM sse2
-; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+; ptrdiff_t line_size, int h)
cglobal put_pixels16, 4,5,4
lea r4, [r2*3]
.loop:
@@ -83,7 +85,8 @@ cglobal put_pixels16, 4,5,4
jnz .loop
REP_RET
-; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+; ptrdiff_t line_size, int h)
cglobal avg_pixels16, 4,5,4
lea r4, [r2*3]
.loop:
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/fpel.h b/chromium/third_party/ffmpeg/libavcodec/x86/fpel.h
new file mode 100644
index 00000000000..2fbbfce26f6
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/fpel.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_FPEL_H
+#define AVCODEC_X86_FPEL_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+
+#endif /* AVCODEC_X86_FPEL_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/fpel_mmx.c b/chromium/third_party/ffmpeg/libavcodec/x86/fpel_mmx.c
index 384ab89d9c5..45cc57e6d71 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/fpel_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/fpel_mmx.c
@@ -25,7 +25,8 @@
#include <stdint.h>
#include "config.h"
-#include "dsputil_x86.h"
+#include "fpel.h"
+#include "inline_asm.h"
#if HAVE_MMX_INLINE
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h263_loopfilter.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h263_loopfilter.asm
index a21baf16294..2fcd1a26e54 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h263_loopfilter.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h263_loopfilter.asm
@@ -101,7 +101,7 @@ SECTION_TEXT
%endmacro
INIT_MMX mmx
-; void h263_v_loop_filter(uint8_t *src, int stride, int qscale)
+; void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale)
cglobal h263_v_loop_filter, 3,5
movsxdifnidn r1, r1d
movsxdifnidn r2, r2d
@@ -142,7 +142,7 @@ cglobal h263_v_loop_filter, 3,5
%endmacro
-; void h263_h_loop_filter(uint8_t *src, int stride, int qscale)
+; void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale)
INIT_MMX mmx
cglobal h263_h_loop_filter, 3,5,0,32
movsxdifnidn r1, r1d
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc.asm
index 32681aafd7f..107ae51cbcc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc.asm
@@ -103,8 +103,9 @@ SECTION .text
%else
%define extra_regs 0
%endif ; rv40
-; put/avg_h264_chroma_mc8_*(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/,
-; int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc8_*(uint8_t *dst /* align 8 */,
+; uint8_t *src /* align 1 */,
+; int stride, int h, int mx, int my)
cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
%if ARCH_X86_64
movsxd r2, r2d
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm
index beb7c0fe208..c3584820923 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm
@@ -57,11 +57,10 @@ SECTION .text
%endmacro
;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc8(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc8(pixel *dst, pixel *src, int stride, int h,
+; int mx, int my)
;-----------------------------------------------------------------------------
%macro CHROMA_MC8 1
-; put/avg_h264_chroma_mc8_*(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/,
-; int stride, int h, int mx, int my)
cglobal %1_h264_chroma_mc8_10, 6,7,8
movsxdifnidn r2, r2d
mov r6d, r5d
@@ -150,7 +149,8 @@ cglobal %1_h264_chroma_mc8_10, 6,7,8
%endmacro
;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h,
+; int mx, int my)
;-----------------------------------------------------------------------------
;TODO: xmm mc4
%macro MC4_OP 2
@@ -200,7 +200,8 @@ cglobal %1_h264_chroma_mc4_10, 6,6,7
%endmacro
;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc2(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc2(pixel *dst, pixel *src, int stride, int h,
+; int mx, int my)
;-----------------------------------------------------------------------------
%macro CHROMA_MC2 1
cglobal %1_h264_chroma_mc2_10, 6,7
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock.asm
index 1317783bec6..e5cc442943d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock.asm
@@ -283,7 +283,8 @@ cextern pb_3
%if ARCH_X86_64
;-----------------------------------------------------------------------------
-; void deblock_v_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_luma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
%macro DEBLOCK_LUMA 0
cglobal deblock_v_luma_8, 5,5,10
@@ -328,7 +329,8 @@ cglobal deblock_v_luma_8, 5,5,10
RET
;-----------------------------------------------------------------------------
-; void deblock_h_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
INIT_MMX cpuname
cglobal deblock_h_luma_8, 5,9,0,0x60+16*WIN64
@@ -391,7 +393,8 @@ DEBLOCK_LUMA
%macro DEBLOCK_LUMA 2
;-----------------------------------------------------------------------------
-; void deblock_v8_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v8_luma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
cglobal deblock_%1_luma_8, 5,5,8,2*%2
lea r4, [r1*3]
@@ -439,7 +442,8 @@ cglobal deblock_%1_luma_8, 5,5,8,2*%2
RET
;-----------------------------------------------------------------------------
-; void deblock_h_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
INIT_MMX cpuname
cglobal deblock_h_luma_8, 0,5,8,0x60+HAVE_ALIGNED_STACK*12
@@ -639,7 +643,7 @@ DEBLOCK_LUMA v, 16
%endif
;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
;-----------------------------------------------------------------------------
%if WIN64
cglobal deblock_%1_luma_intra_8, 4,6,16,0x10
@@ -699,7 +703,7 @@ cglobal deblock_%1_luma_intra_8, 4,6,16,ARCH_X86_64*0x50-0x50
INIT_MMX cpuname
%if ARCH_X86_64
;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
;-----------------------------------------------------------------------------
cglobal deblock_h_luma_intra_8, 4,9,0,0x80
movsxd r7, r1d
@@ -804,7 +808,8 @@ INIT_MMX mmxext
%define t6 r6
;-----------------------------------------------------------------------------
-; void ff_deblock_v_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_chroma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
cglobal deblock_v_chroma_8, 5,6
CHROMA_V_START
@@ -818,7 +823,8 @@ cglobal deblock_v_chroma_8, 5,6
RET
;-----------------------------------------------------------------------------
-; void ff_deblock_h_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_chroma(uint8_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
cglobal deblock_h_chroma_8, 5,7
%if UNIX64
@@ -874,9 +880,9 @@ ff_chroma_inter_body_mmxext:
%define t5 r4
%define t6 r5
-;-----------------------------------------------------------------------------
-; void ff_deblock_v_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_deblock_v_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
+;------------------------------------------------------------------------------
cglobal deblock_v_chroma_intra_8, 4,5
CHROMA_V_START
movq m0, [t5]
@@ -888,9 +894,9 @@ cglobal deblock_v_chroma_intra_8, 4,5
movq [r0], m2
RET
-;-----------------------------------------------------------------------------
-; void ff_deblock_h_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_deblock_h_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
+;------------------------------------------------------------------------------
cglobal deblock_h_chroma_intra_8, 4,6
CHROMA_H_START
TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6)
@@ -914,10 +920,10 @@ ff_chroma_intra_body_mmxext:
ret
;-----------------------------------------------------------------------------
-; void h264_loop_filter_strength(int16_t bs[2][4][4], uint8_t nnz[40],
-; int8_t ref[2][40], int16_t mv[2][40][2],
-; int bidir, int edges, int step,
-; int mask_mv0, int mask_mv1, int field);
+; void ff_h264_loop_filter_strength(int16_t bs[2][4][4], uint8_t nnz[40],
+; int8_t ref[2][40], int16_t mv[2][40][2],
+; int bidir, int edges, int step,
+; int mask_mv0, int mask_mv1, int field);
;
; bidir is 0 or 1
; edges is 1 or 4
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm
index fdaf510bd62..fc4f4d7770e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm
@@ -152,7 +152,8 @@ cextern pw_4
%macro DEBLOCK_LUMA 0
;-----------------------------------------------------------------------------
-; void deblock_v_luma( uint16_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_luma_10(uint16_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
cglobal deblock_v_luma_10, 5,5,8*(mmsize/16)
%assign pad 5*mmsize+12-(stack_offset&15)
@@ -600,7 +601,8 @@ DEBLOCK_LUMA_64
%if ARCH_X86_64
;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra_10(uint16_t *pix, int stride, int alpha,
+; int beta)
;-----------------------------------------------------------------------------
%macro DEBLOCK_LUMA_INTRA_64 0
cglobal deblock_v_luma_intra_10, 4,7,16
@@ -651,7 +653,8 @@ cglobal deblock_v_luma_intra_10, 4,7,16
REP_RET
;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra_10(uint16_t *pix, int stride, int alpha,
+; int beta)
;-----------------------------------------------------------------------------
cglobal deblock_h_luma_intra_10, 4,7,16
%define t0 m15
@@ -723,7 +726,8 @@ DEBLOCK_LUMA_INTRA_64
%macro DEBLOCK_LUMA_INTRA 0
;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra_10(uint16_t *pix, int stride, int alpha,
+; int beta)
;-----------------------------------------------------------------------------
cglobal deblock_v_luma_intra_10, 4,7,8*(mmsize/16)
LUMA_INTRA_INIT 3
@@ -751,7 +755,8 @@ cglobal deblock_v_luma_intra_10, 4,7,8*(mmsize/16)
RET
;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra_10(uint16_t *pix, int stride, int alpha,
+; int beta)
;-----------------------------------------------------------------------------
cglobal deblock_h_luma_intra_10, 4,7,8*(mmsize/16)
LUMA_INTRA_INIT 8
@@ -849,7 +854,8 @@ DEBLOCK_LUMA_INTRA
%macro DEBLOCK_CHROMA 0
;-----------------------------------------------------------------------------
-; void deblock_v_chroma( uint16_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_chroma_10(uint16_t *pix, int stride, int alpha, int beta,
+; int8_t *tc0)
;-----------------------------------------------------------------------------
cglobal deblock_v_chroma_10, 5,7-(mmsize/16),8*(mmsize/16)
mov r5, r0
@@ -883,7 +889,8 @@ cglobal deblock_v_chroma_10, 5,7-(mmsize/16),8*(mmsize/16)
%endif
;-----------------------------------------------------------------------------
-; void deblock_v_chroma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_chroma_intra_10(uint16_t *pix, int stride, int alpha,
+; int beta)
;-----------------------------------------------------------------------------
cglobal deblock_v_chroma_intra_10, 4,6-(mmsize/16),8*(mmsize/16)
mov r4, r0
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_i386.h b/chromium/third_party/ffmpeg/libavcodec/x86/h264_i386.h
index 0dc0a7cb0f3..ef65cf86b78 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_i386.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_i386.h
@@ -38,7 +38,7 @@
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
//as that would make optimization work hard)
-#if HAVE_7REGS
+#if HAVE_7REGS && !BROKEN_COMPILER
#define decode_significance decode_significance_x86
static int decode_significance_x86(CABACContext *c, int max_coeff,
uint8_t *significant_coeff_ctx_base,
@@ -55,6 +55,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
__asm__ volatile(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
+ : NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)
);
#endif
@@ -130,6 +131,7 @@ static int decode_significance_8x8_x86(CABACContext *c,
__asm__ volatile(
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
: "=&r"(tables)
+ : NAMED_CONSTRAINTS_ARRAY(ff_h264_cabac_tables)
);
#endif
@@ -198,7 +200,7 @@ static int decode_significance_8x8_x86(CABACContext *c,
);
return coeff_count;
}
-#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
+#endif /* HAVE_7REGS && BROKEN_COMPILER */
#endif /* HAVE_INLINE_ASM */
#endif /* AVCODEC_X86_H264_I386_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct.asm
index 9af98a9a0c1..7fafe195f15 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct.asm
@@ -80,7 +80,7 @@ SECTION .text
%endmacro
INIT_MMX mmx
-; ff_h264_idct_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct_add_8, 3, 3, 0
IDCT4_ADD r0, r1, r2
RET
@@ -202,7 +202,7 @@ cglobal h264_idct_add_8, 3, 3, 0
%endmacro
INIT_MMX mmx
-; ff_h264_idct8_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct8_add_8, 3, 4, 0
%assign pad 128+4-(stack_offset&7)
SUB rsp, pad
@@ -270,7 +270,7 @@ cglobal h264_idct8_add_8, 3, 4, 0
%endmacro
INIT_XMM sse2
-; ff_h264_idct8_add_8_sse2(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_add_8_sse2(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct8_add_8, 3, 4, 10
IDCT8_ADD_SSE r0, r1, r2, r3
RET
@@ -307,7 +307,7 @@ cglobal h264_idct8_add_8, 3, 4, 10
%endmacro
INIT_MMX mmxext
-; ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
%if ARCH_X86_64
cglobal h264_idct_dc_add_8, 3, 4, 0
movsx r3, word [r1]
@@ -316,7 +316,7 @@ cglobal h264_idct_dc_add_8, 3, 4, 0
DC_ADD_MMXEXT_OP movh, r0, r2, r3
RET
-; ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct8_dc_add_8, 3, 4, 0
movsx r3, word [r1]
mov dword [r1], 0
@@ -326,7 +326,7 @@ cglobal h264_idct8_dc_add_8, 3, 4, 0
DC_ADD_MMXEXT_OP mova, r0, r2, r3
RET
%else
-; ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct_dc_add_8, 2, 3, 0
movsx r2, word [r1]
mov dword [r1], 0
@@ -335,7 +335,7 @@ cglobal h264_idct_dc_add_8, 2, 3, 0
DC_ADD_MMXEXT_OP movh, r0, r1, r2
RET
-; ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
cglobal h264_idct8_dc_add_8, 2, 3, 0
movsx r2, word [r1]
mov dword [r1], 0
@@ -348,9 +348,9 @@ cglobal h264_idct8_dc_add_8, 2, 3, 0
%endif
INIT_MMX mmx
-; ff_h264_idct_add16_8_mmx(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_mmx(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
xor r5, r5
%ifdef PIC
@@ -371,9 +371,9 @@ cglobal h264_idct_add16_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride,
jl .nextblock
REP_RET
-; ff_h264_idct8_add4_8_mmx(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_mmx(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct8_add4_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
%assign pad 128+4-(stack_offset&7)
SUB rsp, pad
@@ -405,9 +405,9 @@ cglobal h264_idct8_add4_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride,
RET
INIT_MMX mmxext
-; ff_h264_idct_add16_8_mmxext(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_mmxext(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
xor r5, r5
%ifdef PIC
@@ -452,9 +452,9 @@ cglobal h264_idct_add16_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride
REP_RET
INIT_MMX mmx
-; ff_h264_idct_add16intra_8_mmx(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_mmx(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16intra_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
xor r5, r5
%ifdef PIC
@@ -477,9 +477,9 @@ cglobal h264_idct_add16intra_8, 5, 7 + npicregs, 0, dst, block_offset, block, st
REP_RET
INIT_MMX mmxext
-; ff_h264_idct_add16intra_8_mmxext(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_mmxext(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16intra_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
xor r5, r5
%ifdef PIC
@@ -521,9 +521,9 @@ cglobal h264_idct_add16intra_8, 5, 8 + npicregs, 0, dst1, block_offset, block, s
jl .nextblock
REP_RET
-; ff_h264_idct8_add4_8_mmxext(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_mmxext(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct8_add4_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
%assign pad 128+4-(stack_offset&7)
SUB rsp, pad
@@ -583,9 +583,9 @@ cglobal h264_idct8_add4_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride
RET
INIT_XMM sse2
-; ff_h264_idct8_add4_8_sse2(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_sse2(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct8_add4_8, 5, 8 + npicregs, 10, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
xor r5, r5
%ifdef PIC
@@ -660,8 +660,9 @@ h264_idct_add8_mmx_plane:
jnz .nextblock
rep ret
-; ff_h264_idct_add8_8_mmx(uint8_t **dest, const int *block_offset,
-; int16_t *block, int stride, const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_mmx(uint8_t **dest, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add8_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
mov r5, 16
add r2, 512
@@ -725,9 +726,9 @@ h264_idct_add8_mmxext_plane:
rep ret
INIT_MMX mmxext
-; ff_h264_idct_add8_8_mmxext(uint8_t **dest, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_mmxext(uint8_t **dest, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add8_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
mov r5, 16
add r2, 512
@@ -809,9 +810,9 @@ h264_add8x4_idct_sse2:
%endif
%endmacro
-; ff_h264_idct_add16_8_sse2(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_sse2(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16_8, 5, 5 + ARCH_X86_64, 8
%if ARCH_X86_64
mov r5, r0
@@ -857,9 +858,9 @@ cglobal h264_idct_add16_8, 5, 5 + ARCH_X86_64, 8
%endif
%endmacro
-; ff_h264_idct_add16intra_8_sse2(uint8_t *dst, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_sse2(uint8_t *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add16intra_8, 5, 7 + ARCH_X86_64, 8
%if ARCH_X86_64
mov r7, r0
@@ -909,9 +910,9 @@ cglobal h264_idct_add16intra_8, 5, 7 + ARCH_X86_64, 8
%endif
%endmacro
-; ff_h264_idct_add8_8_sse2(uint8_t **dest, const int *block_offset,
-; int16_t *block, int stride,
-; const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_sse2(uint8_t **dest, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6 * 8])
cglobal h264_idct_add8_8, 5, 7 + ARCH_X86_64, 8
add r2, 512
%if ARCH_X86_64
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct_10bit.asm
index df212888dc8..5c3acb1d380 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_idct_10bit.asm
@@ -32,7 +32,7 @@ pd_32: times 4 dd 32
SECTION .text
;-----------------------------------------------------------------------------
-; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro STORE_DIFFx2 6
psrad %1, 6
@@ -89,7 +89,9 @@ IDCT_ADD_10
%endif
;-----------------------------------------------------------------------------
-; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add16_10(pixel *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6*8])
;-----------------------------------------------------------------------------
;;;;;;; NO FATE SAMPLES TRIGGER THIS
%macro ADD4x4IDCT 0
@@ -163,7 +165,7 @@ IDCT_ADD16_10
%endif
;-----------------------------------------------------------------------------
-; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct_dc_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT_DC_ADD_OP_10 3
pxor m5, m5
@@ -205,7 +207,7 @@ cglobal h264_idct_dc_add_10,3,3
RET
;-----------------------------------------------------------------------------
-; void h264_idct8_dc_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct8_dc_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT8_DC_ADD 0
cglobal h264_idct8_dc_add_10,3,4,7
@@ -230,7 +232,9 @@ IDCT8_DC_ADD
%endif
;-----------------------------------------------------------------------------
-; h264_idct_add16intra(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add16intra_10(pixel *dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6*8])
;-----------------------------------------------------------------------------
%macro AC 1
.ac%1:
@@ -304,7 +308,9 @@ IDCT_ADD16INTRA_10
%assign last_block 36
;-----------------------------------------------------------------------------
-; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add8_10(pixel **dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6*8])
;-----------------------------------------------------------------------------
%macro IDCT_ADD8 0
cglobal h264_idct_add8_10,5,8,7
@@ -340,7 +346,7 @@ IDCT_ADD8
%endif
;-----------------------------------------------------------------------------
-; void h264_idct8_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct8_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT8_1D 2
SWAP 0, 1
@@ -549,7 +555,9 @@ IDCT8_ADD
%endif
;-----------------------------------------------------------------------------
-; h264_idct8_add4(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct8_add4_10(pixel **dst, const int *block_offset,
+; int16_t *block, int stride,
+; const uint8_t nnzc[6*8])
;-----------------------------------------------------------------------------
;;;;;;; NO FATE SAMPLES TRIGGER THIS
%macro IDCT8_ADD4_OP 2
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred.asm
index 3064ec5201c..3e13ccb05d2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred.asm
@@ -49,7 +49,7 @@ cextern pw_17
cextern pw_32
;-----------------------------------------------------------------------------
-; void pred16x16_vertical_8(uint8_t *src, int stride)
+; void ff_pred16x16_vertical_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmx
@@ -85,7 +85,7 @@ cglobal pred16x16_vertical_8, 2,3
REP_RET
;-----------------------------------------------------------------------------
-; void pred16x16_horizontal_8(uint8_t *src, int stride)
+; void ff_pred16x16_horizontal_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_H 0
@@ -126,7 +126,7 @@ INIT_XMM ssse3
PRED16x16_H
;-----------------------------------------------------------------------------
-; void pred16x16_dc_8(uint8_t *src, int stride)
+; void ff_pred16x16_dc_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_DC 0
@@ -188,7 +188,7 @@ INIT_XMM ssse3
PRED16x16_DC
;-----------------------------------------------------------------------------
-; void pred16x16_tm_vp8_8(uint8_t *src, int stride)
+; void ff_pred16x16_tm_vp8_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_TM 0
@@ -269,7 +269,7 @@ cglobal pred16x16_tm_vp8_8, 2,6,6
REP_RET
;-----------------------------------------------------------------------------
-; void pred16x16_plane_*_8(uint8_t *src, int stride)
+; void ff_pred16x16_plane_*_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro H264_PRED16x16_PLANE 1
@@ -550,7 +550,7 @@ H264_PRED16x16_PLANE rv40
H264_PRED16x16_PLANE svq3
;-----------------------------------------------------------------------------
-; void pred8x8_plane_8(uint8_t *src, int stride)
+; void ff_pred8x8_plane_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro H264_PRED8x8_PLANE 0
@@ -724,7 +724,7 @@ INIT_XMM ssse3
H264_PRED8x8_PLANE
;-----------------------------------------------------------------------------
-; void pred8x8_vertical_8(uint8_t *src, int stride)
+; void ff_pred8x8_vertical_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmx
@@ -741,7 +741,7 @@ cglobal pred8x8_vertical_8, 2,2
RET
;-----------------------------------------------------------------------------
-; void pred8x8_horizontal_8(uint8_t *src, int stride)
+; void ff_pred8x8_horizontal_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8_H 0
@@ -769,7 +769,7 @@ INIT_MMX ssse3
PRED8x8_H
;-----------------------------------------------------------------------------
-; void pred8x8_top_dc_8_mmxext(uint8_t *src, int stride)
+; void ff_pred8x8_top_dc_8_mmxext(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred8x8_top_dc_8, 2,5
@@ -803,7 +803,7 @@ cglobal pred8x8_top_dc_8, 2,5
RET
;-----------------------------------------------------------------------------
-; void pred8x8_dc_8_mmxext(uint8_t *src, int stride)
+; void ff_pred8x8_dc_8_mmxext(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -864,7 +864,7 @@ cglobal pred8x8_dc_8, 2,5
RET
;-----------------------------------------------------------------------------
-; void pred8x8_dc_rv40_8(uint8_t *src, int stride)
+; void ff_pred8x8_dc_rv40_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -901,7 +901,7 @@ cglobal pred8x8_dc_rv40_8, 2,7
REP_RET
;-----------------------------------------------------------------------------
-; void pred8x8_tm_vp8_8(uint8_t *src, int stride)
+; void ff_pred8x8_tm_vp8_8(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8_TM 0
@@ -1013,7 +1013,8 @@ cglobal pred8x8_tm_vp8_8, 2,3,6
%endmacro
;-----------------------------------------------------------------------------
-; void pred8x8l_top_dc_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_top_dc_8(uint8_t *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_TOP_DC 0
cglobal pred8x8l_top_dc_8, 4,4
@@ -1068,7 +1069,8 @@ INIT_MMX ssse3
PRED8x8L_TOP_DC
;-----------------------------------------------------------------------------
-;void pred8x8l_dc_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_dc_8(uint8_t *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_DC 0
@@ -1171,7 +1173,8 @@ INIT_MMX ssse3
PRED8x8L_DC
;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_HORIZONTAL 0
@@ -1242,7 +1245,8 @@ INIT_MMX ssse3
PRED8x8L_HORIZONTAL
;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_8(uint8_t *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_VERTICAL 0
@@ -1292,7 +1296,8 @@ INIT_MMX ssse3
PRED8x8L_VERTICAL
;-----------------------------------------------------------------------------
-;void pred8x8l_down_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_left_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -1492,7 +1497,8 @@ INIT_MMX ssse3
PRED8x8L_DOWN_LEFT
;-----------------------------------------------------------------------------
-;void pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -1743,7 +1749,8 @@ INIT_MMX ssse3
PRED8x8L_DOWN_RIGHT
;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_right_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -1970,7 +1977,8 @@ INIT_MMX ssse3
PRED8x8L_VERTICAL_RIGHT
;-----------------------------------------------------------------------------
-;void pred8x8l_vertical_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_left_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_VERTICAL_LEFT 0
@@ -2059,7 +2067,8 @@ INIT_MMX ssse3
PRED8x8L_VERTICAL_LEFT
;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_up_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_up_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_HORIZONTAL_UP 0
@@ -2146,7 +2155,8 @@ INIT_MMX ssse3
PRED8x8L_HORIZONTAL_UP
;-----------------------------------------------------------------------------
-;void pred8x8l_horizontal_down_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_down_8(uint8_t *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -2393,9 +2403,9 @@ PRED8x8L_HORIZONTAL_DOWN
INIT_MMX ssse3
PRED8x8L_HORIZONTAL_DOWN
-;-----------------------------------------------------------------------------
-; void pred4x4_dc_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred4x4_dc_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-------------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_dc_8, 3,5
@@ -2424,7 +2434,8 @@ cglobal pred4x4_dc_8, 3,5
RET
;-----------------------------------------------------------------------------
-; void pred4x4_tm_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_tm_vp8_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED4x4_TM 0
@@ -2502,7 +2513,8 @@ cglobal pred4x4_tm_vp8_8, 3,3
RET
;-----------------------------------------------------------------------------
-; void pred4x4_vertical_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_vertical_vp8_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -2522,7 +2534,8 @@ cglobal pred4x4_vertical_vp8_8, 3,3
RET
;-----------------------------------------------------------------------------
-; void pred4x4_down_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_down_left_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_down_left_8, 3,3
@@ -2547,9 +2560,10 @@ cglobal pred4x4_down_left_8, 3,3
movd [r1+r2*2], m0
RET
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_vertical_left_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
+;------------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_vertical_left_8, 3,3
@@ -2572,9 +2586,10 @@ cglobal pred4x4_vertical_left_8, 3,3
movh [r1+r2*2], m0
RET
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_up_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
+;------------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_horizontal_up_8, 3,3
@@ -2605,9 +2620,10 @@ cglobal pred4x4_horizontal_up_8, 3,3
movd [r1+r2*2], m1
RET
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_down_8_mmxext(uint8_t *src,
+; const uint8_t *topright, int stride)
+;------------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_horizontal_down_8, 3,3
@@ -2641,7 +2657,8 @@ cglobal pred4x4_horizontal_down_8, 3,3
RET
;-----------------------------------------------------------------------------
-; void pred4x4_vertical_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_vertical_right_8_mmxext(uint8_t *src,
+; const uint8_t *topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
@@ -2671,7 +2688,8 @@ cglobal pred4x4_vertical_right_8, 3,3
RET
;-----------------------------------------------------------------------------
-; void pred4x4_down_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_down_right_8_mmxext(uint8_t *src, const uint8_t *topright,
+; int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm
index 54eaee53c5c..9dee577e1db 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm
@@ -50,7 +50,7 @@ SECTION .text
%endmacro
;-----------------------------------------------------------------------------
-; void pred4x4_down_right(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_down_right(pixel *src, const pixel *topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED4x4_DR 0
cglobal pred4x4_down_right_10, 3, 3
@@ -87,9 +87,9 @@ INIT_XMM avx
PRED4x4_DR
%endif
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_right(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_vertical_right(pixel *src, const pixel *topright, int stride)
+;------------------------------------------------------------------------------
%macro PRED4x4_VR 0
cglobal pred4x4_vertical_right_10, 3, 3, 6
sub r0, r2
@@ -126,9 +126,9 @@ INIT_XMM avx
PRED4x4_VR
%endif
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride)
+;-------------------------------------------------------------------------------
%macro PRED4x4_HD 0
cglobal pred4x4_horizontal_down_10, 3, 3
sub r0, r2
@@ -169,24 +169,8 @@ PRED4x4_HD
%endif
;-----------------------------------------------------------------------------
-; void pred4x4_dc(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_dc(pixel *src, const pixel *topright, int stride)
;-----------------------------------------------------------------------------
-%macro HADDD 2 ; sum junk
-%if mmsize == 16
- movhlps %2, %1
- paddd %1, %2
- pshuflw %2, %1, 0xE
- paddd %1, %2
-%else
- pshufw %2, %1, 0xE
- paddd %1, %2
-%endif
-%endmacro
-
-%macro HADDW 2
- pmaddwd %1, [pw_1]
- HADDD %1, %2
-%endmacro
INIT_MMX mmxext
cglobal pred4x4_dc_10, 3, 3
@@ -210,7 +194,7 @@ cglobal pred4x4_dc_10, 3, 3
RET
;-----------------------------------------------------------------------------
-; void pred4x4_down_left(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_down_left(pixel *src, const pixel *topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED4x4_DL 0
cglobal pred4x4_down_left_10, 3, 3
@@ -240,7 +224,7 @@ PRED4x4_DL
%endif
;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_vertical_left(pixel *src, const pixel *topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED4x4_VL 0
cglobal pred4x4_vertical_left_10, 3, 3
@@ -269,7 +253,7 @@ PRED4x4_VL
%endif
;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride)
;-----------------------------------------------------------------------------
INIT_MMX mmxext
cglobal pred4x4_horizontal_up_10, 3, 3
@@ -303,7 +287,7 @@ cglobal pred4x4_horizontal_up_10, 3, 3
;-----------------------------------------------------------------------------
-; void pred8x8_vertical(pixel *src, int stride)
+; void ff_pred8x8_vertical(pixel *src, int stride)
;-----------------------------------------------------------------------------
INIT_XMM sse2
cglobal pred8x8_vertical_10, 2, 2
@@ -319,7 +303,7 @@ cglobal pred8x8_vertical_10, 2, 2
RET
;-----------------------------------------------------------------------------
-; void pred8x8_horizontal(pixel *src, int stride)
+; void ff_pred8x8_horizontal(pixel *src, int stride)
;-----------------------------------------------------------------------------
INIT_XMM sse2
cglobal pred8x8_horizontal_10, 2, 3
@@ -339,7 +323,7 @@ cglobal pred8x8_horizontal_10, 2, 3
REP_RET
;-----------------------------------------------------------------------------
-; void predict_8x8_dc(pixel *src, int stride)
+; void ff_predict_8x8_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro MOV8 2-3
; sort of a hack, but it works
@@ -426,7 +410,7 @@ INIT_XMM sse2
PRED8x8_DC pshuflw
;-----------------------------------------------------------------------------
-; void pred8x8_top_dc(pixel *src, int stride)
+; void ff_pred8x8_top_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
INIT_XMM sse2
cglobal pred8x8_top_dc_10, 2, 4
@@ -453,7 +437,7 @@ cglobal pred8x8_top_dc_10, 2, 4
RET
;-----------------------------------------------------------------------------
-; void pred8x8_plane(pixel *src, int stride)
+; void ff_pred8x8_plane(pixel *src, int stride)
;-----------------------------------------------------------------------------
INIT_XMM sse2
cglobal pred8x8_plane_10, 2, 7, 7
@@ -516,7 +500,8 @@ cglobal pred8x8_plane_10, 2, 7, 7
;-----------------------------------------------------------------------------
-; void pred8x8l_128_dc(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_128_dc(pixel *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_128_DC 0
cglobal pred8x8l_128_dc_10, 4, 4
@@ -540,7 +525,8 @@ INIT_XMM sse2
PRED8x8L_128_DC
;-----------------------------------------------------------------------------
-; void pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_TOP_DC 0
cglobal pred8x8l_top_dc_10, 4, 4, 6
@@ -578,9 +564,9 @@ INIT_XMM avx
PRED8x8L_TOP_DC
%endif
-;-----------------------------------------------------------------------------
-;void pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride)
+;-------------------------------------------------------------------------------
;TODO: see if scalar is faster
%macro PRED8x8L_DC 0
cglobal pred8x8l_dc_10, 4, 6, 6
@@ -638,7 +624,8 @@ PRED8x8L_DC
%endif
;-----------------------------------------------------------------------------
-; void pred8x8l_vertical(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical(pixel *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_VERTICAL 0
cglobal pred8x8l_vertical_10, 4, 4, 6
@@ -673,7 +660,8 @@ PRED8x8L_VERTICAL
%endif
;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_HORIZONTAL 0
cglobal pred8x8l_horizontal_10, 4, 4, 5
@@ -729,7 +717,8 @@ PRED8x8L_HORIZONTAL
%endif
;-----------------------------------------------------------------------------
-;void pred8x8l_down_left(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_left(pixel *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_DOWN_LEFT 0
cglobal pred8x8l_down_left_10, 4, 4, 7
@@ -797,7 +786,8 @@ PRED8x8L_DOWN_LEFT
%endif
;-----------------------------------------------------------------------------
-;void pred8x8l_down_right(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_right(pixel *src, int has_topleft, int has_topright,
+; int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_DOWN_RIGHT 0
; standard forbids this when has_topleft is false
@@ -871,7 +861,8 @@ PRED8x8L_DOWN_RIGHT
%endif
;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_right(pixel *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_VERTICAL_RIGHT 0
; likewise with 8x8l_down_right
@@ -941,7 +932,8 @@ PRED8x8L_VERTICAL_RIGHT
%endif
;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_up(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_up(pixel *src, int has_topleft,
+; int has_topright, int stride)
;-----------------------------------------------------------------------------
%macro PRED8x8L_HORIZONTAL_UP 0
cglobal pred8x8l_horizontal_up_10, 4, 4, 6
@@ -1003,7 +995,7 @@ PRED8x8L_HORIZONTAL_UP
;-----------------------------------------------------------------------------
-; void pred16x16_vertical(pixel *src, int stride)
+; void ff_pred16x16_vertical(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro MOV16 3-5
mova [%1+ 0], %2
@@ -1039,7 +1031,7 @@ INIT_XMM sse2
PRED16x16_VERTICAL
;-----------------------------------------------------------------------------
-; void pred16x16_horizontal(pixel *src, int stride)
+; void ff_pred16x16_horizontal(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_HORIZONTAL 0
cglobal pred16x16_horizontal_10, 2, 3
@@ -1063,7 +1055,7 @@ INIT_XMM sse2
PRED16x16_HORIZONTAL
;-----------------------------------------------------------------------------
-; void pred16x16_dc(pixel *src, int stride)
+; void ff_pred16x16_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_DC 0
cglobal pred16x16_dc_10, 2, 6
@@ -1109,7 +1101,7 @@ INIT_XMM sse2
PRED16x16_DC
;-----------------------------------------------------------------------------
-; void pred16x16_top_dc(pixel *src, int stride)
+; void ff_pred16x16_top_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_TOP_DC 0
cglobal pred16x16_top_dc_10, 2, 3
@@ -1141,7 +1133,7 @@ INIT_XMM sse2
PRED16x16_TOP_DC
;-----------------------------------------------------------------------------
-; void pred16x16_left_dc(pixel *src, int stride)
+; void ff_pred16x16_left_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_LEFT_DC 0
cglobal pred16x16_left_dc_10, 2, 6
@@ -1178,7 +1170,7 @@ INIT_XMM sse2
PRED16x16_LEFT_DC
;-----------------------------------------------------------------------------
-; void pred16x16_128_dc(pixel *src, int stride)
+; void ff_pred16x16_128_dc(pixel *src, int stride)
;-----------------------------------------------------------------------------
%macro PRED16x16_128_DC 0
cglobal pred16x16_128_dc_10, 2,3
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_init.c
index ad2984bc043..24110eb2e08 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_intrapred_init.c
@@ -191,16 +191,16 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
if (EXTERNAL_MMX(cpu_flags)) {
h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmx;
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmx;
- if (chroma_format_idc == 1) {
+ if (chroma_format_idc <= 1) {
h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_mmx;
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmx;
}
- if (codec_id == AV_CODEC_ID_VP8) {
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_mmx;
h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_mmx;
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmx;
} else {
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_mmx;
if (codec_id == AV_CODEC_ID_SVQ3) {
if (cpu_flags & AV_CPU_FLAG_CMOV)
@@ -216,7 +216,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
if (EXTERNAL_MMXEXT(cpu_flags)) {
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmxext;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmxext;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmxext;
h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmxext;
h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_mmxext;
@@ -231,7 +231,8 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_8_mmxext;
h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_8_mmxext;
h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_8_mmxext;
- if (codec_id == AV_CODEC_ID_VP8 || codec_id == AV_CODEC_ID_H264) {
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8 ||
+ codec_id == AV_CODEC_ID_H264) {
h->pred4x4 [DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_8_mmxext;
}
if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) {
@@ -241,19 +242,19 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_8_mmxext;
}
if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) {
- if (chroma_format_idc == 1) {
+ if (chroma_format_idc <= 1) {
h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_8_mmxext;
h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_8_mmxext;
}
}
- if (codec_id == AV_CODEC_ID_VP8) {
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_mmxext;
h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_8_mmxext;
h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_mmxext;
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmxext;
h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_8_mmxext;
} else {
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_mmxext;
if (codec_id == AV_CODEC_ID_SVQ3) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_8_mmxext;
@@ -276,11 +277,11 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_8_sse2;
h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_8_sse2;
h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_sse2;
- if (codec_id == AV_CODEC_ID_VP8) {
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_sse2;
h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_sse2;
} else {
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_sse2;
if (codec_id == AV_CODEC_ID_SVQ3) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_sse2;
@@ -295,7 +296,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
if (EXTERNAL_SSSE3(cpu_flags)) {
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_ssse3;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_ssse3;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_ssse3;
h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_ssse3;
h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_ssse3;
@@ -307,11 +308,11 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_8_ssse3;
h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_8_ssse3;
h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_ssse3;
- if (codec_id == AV_CODEC_ID_VP8) {
+ if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_ssse3;
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_ssse3;
} else {
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_ssse3;
if (codec_id == AV_CODEC_ID_SVQ3) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_ssse3;
@@ -327,7 +328,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext;
h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext;
h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext;
@@ -346,7 +347,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2;
h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2;
- if (chroma_format_idc == 1) {
+ if (chroma_format_idc <= 1) {
h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2;
h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2;
h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel.c b/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel.c
index fd6068ffb12..8edaeacde62 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel.c
@@ -25,7 +25,8 @@
#include "libavutil/x86/cpu.h"
#include "libavcodec/h264qpel.h"
#include "libavcodec/mpegvideo.h"
-#include "dsputil_x86.h"
+#include "libavcodec/pixels.h"
+#include "fpel.h"
#if HAVE_YASM
void ff_put_pixels4_mmxext(uint8_t *block, const uint8_t *pixels,
@@ -49,8 +50,8 @@ void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
#define ff_put_pixels16_l2_sse2 ff_put_pixels16_l2_mmxext
#define ff_avg_pixels16_l2_sse2 ff_avg_pixels16_l2_mmxext
-PIXELS16(static, ff_avg, , , _mmxext)
-PIXELS16(static, ff_put, , , _mmxext)
+CALL_2X_PIXELS(ff_avg_pixels16_mmxext, ff_avg_pixels8_mmxext, 8)
+CALL_2X_PIXELS(ff_put_pixels16_mmxext, ff_put_pixels8_mmxext, 8)
#define DEF_QPEL(OPNAME)\
void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
@@ -496,7 +497,7 @@ QPEL16_OP(mc31, MMX)\
QPEL16_OP(mc32, MMX)\
QPEL16_OP(mc33, MMX)
-#if ARCH_X86_32 && HAVE_YASM && CONFIG_H264QPEL // ARCH_X86_64 implies SSE2+
+#if ARCH_X86_32 // ARCH_X86_64 implies SSE2+
QPEL16(mmxext)
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm
index 456187140c1..e7ce1b8b44e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm
@@ -167,7 +167,7 @@ stub_%1_h264_qpel%3_%2_10 %+ SUFFIX:
%endmacro
;-----------------------------------------------------------------------------
-; void h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro COPY4 0
movu m0, [r1 ]
@@ -221,7 +221,7 @@ MC00 put
MC00 avg
;-----------------------------------------------------------------------------
-; void h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC_CACHE 1
%define OP_MOV mova
@@ -305,7 +305,7 @@ cglobal_mc %1, mc20, %2, 3,4,9
MC_CACHE MC20
;-----------------------------------------------------------------------------
-; void h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC30 2
cglobal_mc %1, mc30, %2, 3,5,9
@@ -316,7 +316,7 @@ cglobal_mc %1, mc30, %2, 3,5,9
MC_CACHE MC30
;-----------------------------------------------------------------------------
-; void h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC10 2
cglobal_mc %1, mc10, %2, 3,5,9
@@ -383,7 +383,7 @@ cglobal_mc %1, mc10, %2, 3,5,9
MC_CACHE MC10
;-----------------------------------------------------------------------------
-; void h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro V_FILT 10
v_filt%9_%10_10
@@ -432,7 +432,7 @@ cglobal_mc %1, mc02, %2, 3,4,8
MC MC02
;-----------------------------------------------------------------------------
-; void h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC01 2
cglobal_mc %1, mc01, %2, 3,5,8
@@ -458,7 +458,7 @@ cglobal_mc %1, mc01, %2, 3,5,8
MC MC01
;-----------------------------------------------------------------------------
-; void h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC03 2
cglobal_mc %1, mc03, %2, 3,5,8
@@ -469,7 +469,7 @@ cglobal_mc %1, mc03, %2, 3,5,8
MC MC03
;-----------------------------------------------------------------------------
-; void h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro H_FILT_AVG 2-3
h_filt%1_%2_10:
@@ -551,7 +551,7 @@ cglobal_mc %1, mc11, %2, 3,6,8
MC MC11
;-----------------------------------------------------------------------------
-; void h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC31 2
cglobal_mc %1, mc31, %2, 3,6,8
@@ -563,7 +563,7 @@ cglobal_mc %1, mc31, %2, 3,6,8
MC MC31
;-----------------------------------------------------------------------------
-; void h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC13 2
cglobal_mc %1, mc13, %2, 3,7,12
@@ -574,7 +574,7 @@ cglobal_mc %1, mc13, %2, 3,7,12
MC MC13
;-----------------------------------------------------------------------------
-; void h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC33 2
cglobal_mc %1, mc33, %2, 3,6,8
@@ -586,7 +586,7 @@ cglobal_mc %1, mc33, %2, 3,6,8
MC MC33
;-----------------------------------------------------------------------------
-; void h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro FILT_H2 3
psubw %1, %2 ; a-b
@@ -757,7 +757,7 @@ cglobal_mc %1, mc22, %2, 3,7,12
MC MC22
;-----------------------------------------------------------------------------
-; void h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC12 2
cglobal_mc %1, mc12, %2, 3,7,12
@@ -802,7 +802,7 @@ cglobal_mc %1, mc12, %2, 3,7,12
MC MC12
;-----------------------------------------------------------------------------
-; void h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC32 2
cglobal_mc %1, mc32, %2, 3,7,12
@@ -820,7 +820,7 @@ cglobal_mc %1, mc32, %2, 3,7,12
MC MC32
;-----------------------------------------------------------------------------
-; void h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro H_NRD 1
put_h%1_10:
@@ -873,7 +873,7 @@ cglobal_mc %1, mc21, %2, 3,7,12
MC MC21
;-----------------------------------------------------------------------------
-; void h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride)
;-----------------------------------------------------------------------------
%macro MC23 2
cglobal_mc %1, mc23, %2, 3,7,12
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight.asm
index 4759a063a61..b4fb9db3098 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight.asm
@@ -28,12 +28,12 @@ SECTION .text
;-----------------------------------------------------------------------------
; biweight pred:
;
-; void h264_biweight_16_sse2(uint8_t *dst, uint8_t *src, int stride,
-; int height, int log2_denom, int weightd,
-; int weights, int offset);
+; void ff_h264_biweight_16_sse2(uint8_t *dst, uint8_t *src, int stride,
+; int height, int log2_denom, int weightd,
+; int weights, int offset);
; and
-; void h264_weight_16_sse2(uint8_t *dst, int stride, int height,
-; int log2_denom, int weight, int offset);
+; void ff_h264_weight_16_sse2(uint8_t *dst, int stride, int height,
+; int log2_denom, int weight, int offset);
;-----------------------------------------------------------------------------
%macro WEIGHT_SETUP 0
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight_10bit.asm b/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight_10bit.asm
index b7845fd74a4..5d9496224ac 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight_10bit.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264_weight_10bit.asm
@@ -35,8 +35,8 @@ cextern pw_1
SECTION .text
;-----------------------------------------------------------------------------
-; void h264_weight(uint8_t *dst, int stride, int height, int log2_denom,
-; int weight, int offset);
+; void ff_h264_weight_16_10(uint8_t *dst, int stride, int height,
+; int log2_denom, int weight, int offset);
;-----------------------------------------------------------------------------
%macro WEIGHT_PROLOGUE 0
.prologue:
@@ -151,8 +151,9 @@ WEIGHT_FUNC_HALF_MM
;-----------------------------------------------------------------------------
-; void h264_biweight(uint8_t *dst, uint8_t *src, int stride, int height,
-; int log2_denom, int weightd, int weights, int offset);
+; void ff_h264_biweight_16_10(uint8_t *dst, uint8_t *src, int stride,
+; int height, int log2_denom, int weightd,
+; int weights, int offset);
;-----------------------------------------------------------------------------
%if ARCH_X86_32
DECLARE_REG_TMP 3
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264chroma_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/h264chroma_init.c
index 3d8d5b0fe1a..e08af2759e2 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264chroma_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264chroma_init.c
@@ -69,7 +69,6 @@ CHROMA_MC(avg, 8, 10, avx)
av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth)
{
-#if HAVE_YASM
int high_bit_depth = bit_depth > 8;
int cpu_flags = av_get_cpu_flags();
@@ -115,5 +114,4 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth)
c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx;
c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx;
}
-#endif
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/h264dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/h264dsp_init.c
index 30801c4bc81..311df5f8561 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/h264dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/h264dsp_init.c
@@ -23,7 +23,6 @@
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/h264dsp.h"
-#include "dsputil_x86.h"
/***********************************/
/* IDCT */
@@ -214,7 +213,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
- if (chroma_format_idc == 1 && EXTERNAL_MMXEXT(cpu_flags))
+ if (chroma_format_idc <= 1 && EXTERNAL_MMXEXT(cpu_flags))
c->h264_loop_filter_strength = ff_h264_loop_filter_strength_mmxext;
if (bit_depth == 8) {
@@ -226,7 +225,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
c->h264_idct_add16 = ff_h264_idct_add16_8_mmx;
c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmx;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = ff_h264_idct_add8_8_mmx;
c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx;
if (cpu_flags & AV_CPU_FLAG_CMOV)
@@ -237,13 +236,13 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmxext;
c->h264_idct_add16 = ff_h264_idct_add16_8_mmxext;
c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmxext;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = ff_h264_idct_add8_8_mmxext;
c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmxext;
c->h264_v_loop_filter_chroma = ff_deblock_v_chroma_8_mmxext;
c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_8_mmxext;
- if (chroma_format_idc == 1) {
+ if (chroma_format_idc <= 1) {
c->h264_h_loop_filter_chroma = ff_deblock_h_chroma_8_mmxext;
c->h264_h_loop_filter_chroma_intra = ff_deblock_h_chroma_intra_8_mmxext;
}
@@ -266,7 +265,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
c->h264_idct_add16 = ff_h264_idct_add16_8_sse2;
c->h264_idct8_add4 = ff_h264_idct8_add4_8_sse2;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = ff_h264_idct_add8_8_sse2;
c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2;
c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_sse2;
@@ -309,7 +308,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_sse2;
c->h264_idct_add16 = ff_h264_idct_add16_10_sse2;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = ff_h264_idct_add8_10_sse2;
c->h264_idct_add16intra = ff_h264_idct_add16intra_10_sse2;
#if HAVE_ALIGNED_STACK
@@ -349,7 +348,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_avx;
c->h264_idct_add16 = ff_h264_idct_add16_10_avx;
- if (chroma_format_idc == 1)
+ if (chroma_format_idc <= 1)
c->h264_idct_add8 = ff_h264_idct_add8_10_avx;
c->h264_idct_add16intra = ff_h264_idct_add16intra_10_avx;
#if HAVE_ALIGNED_STACK
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hevc_mc.asm b/chromium/third_party/ffmpeg/libavcodec/x86/hevc_mc.asm
new file mode 100644
index 00000000000..1fae38c6153
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hevc_mc.asm
@@ -0,0 +1,1256 @@
+; /*
+; * Provide SSE luma and chroma mc functions for HEVC decoding
+; * Copyright (c) 2013 Pierre-Edouard LEPERE
+; *
+; * This file is part of FFmpeg.
+; *
+; * FFmpeg is free software; you can redistribute it and/or
+; * modify it under the terms of the GNU Lesser General Public
+; * License as published by the Free Software Foundation; either
+; * version 2.1 of the License, or (at your option) any later version.
+; *
+; * FFmpeg is distributed in the hope that it will be useful,
+; * but WITHOUT ANY WARRANTY; without even the implied warranty of
+; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+; * Lesser General Public License for more details.
+; *
+; * You should have received a copy of the GNU Lesser General Public
+; * License along with FFmpeg; if not, write to the Free Software
+; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+; */
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+pw_8: times 8 dw 512
+pw_10: times 8 dw 2048
+pw_bi_8: times 8 dw 256
+pw_bi_10: times 8 dw 1024
+max_pixels_10: times 8 dw 1023
+zero: times 4 dd 0
+one_per_32: times 4 dd 1
+
+SECTION .text
+%macro EPEL_TABLE 4
+hevc_epel_filters_%4_%1 times %2 d%3 -2, 58
+ times %2 d%3 10, -2
+ times %2 d%3 -4, 54
+ times %2 d%3 16, -2
+ times %2 d%3 -6, 46
+ times %2 d%3 28, -4
+ times %2 d%3 -4, 36
+ times %2 d%3 36, -4
+ times %2 d%3 -4, 28
+ times %2 d%3 46, -6
+ times %2 d%3 -2, 16
+ times %2 d%3 54, -4
+ times %2 d%3 -2, 10
+ times %2 d%3 58, -2
+%endmacro
+
+
+
+EPEL_TABLE 8, 8, b, sse4
+EPEL_TABLE 10, 4, w, sse4
+
+%macro QPEL_TABLE 4
+hevc_qpel_filters_%4_%1 times %2 d%3 -1, 4
+ times %2 d%3 -10, 58
+ times %2 d%3 17, -5
+ times %2 d%3 1, 0
+ times %2 d%3 -1, 4
+ times %2 d%3 -11, 40
+ times %2 d%3 40,-11
+ times %2 d%3 4, -1
+ times %2 d%3 0, 1
+ times %2 d%3 -5, 17
+ times %2 d%3 58,-10
+ times %2 d%3 4, -1
+%endmacro
+
+QPEL_TABLE 8, 8, b, sse4
+QPEL_TABLE 10, 4, w, sse4
+
+%define hevc_qpel_filters_sse4_14 hevc_qpel_filters_sse4_10
+
+%if ARCH_X86_64
+
+%macro SIMPLE_BILOAD 4 ;width, tab, r1, r2
+%if %1 <= 4
+ movq %3, [%2] ; load data from source2
+%elif %1 <= 8
+ movdqa %3, [%2] ; load data from source2
+%elif %1 <= 12
+ movdqa %3, [%2] ; load data from source2
+ movq %4, [%2+16] ; load data from source2
+%else
+ movdqa %3, [%2] ; load data from source2
+ movdqa %4, [%2+16] ; load data from source2
+%endif
+%endmacro
+
+%macro SIMPLE_LOAD 4 ;width, bitd, tab, r1
+%if %1 == 2 || (%2 == 8 && %1 <= 4)
+ movd %4, [%3] ; load data from source
+%elif %1 == 4 || (%2 == 8 && %1 <= 8)
+ movq %4, [%3] ; load data from source
+%else
+ movdqu %4, [%3] ; load data from source
+%endif
+%endmacro
+
+%macro SIMPLE_8LOAD 5 ;width, bitd, tab, r1, r2
+%if %1 == 2 || (%2 == 8 && %1 <= 4)
+ movq %4, [%3] ; load data from source2
+%elif %1 == 4 || (%2 == 8 && %1 <= 8)
+ movdqa %4, [%3] ; load data from source2
+%elif %1 <= 12
+ movdqa %4, [%3] ; load data from source2
+ movq %5, [%3+16] ; load data from source2
+%else
+ movdqa %4, [%3] ; load data from source2
+ movdqa %5, [%3+16] ; load data from source2
+%endif
+%endmacro
+
+%macro EPEL_FILTER 2 ; bit depth, filter index
+%ifdef PIC
+ lea rfilterq, [hevc_epel_filters_sse4_%1]
+%else
+ %define rfilterq hevc_epel_filters_sse4_%1
+%endif
+ sub %2q, 1
+ shl %2q, 5 ; multiply by 32
+ movdqa m14, [rfilterq + %2q] ; get 2 first values of filters
+ movdqa m15, [rfilterq + %2q+16] ; get 2 last values of filters
+%endmacro
+
+%macro EPEL_HV_FILTER 1
+%ifdef PIC
+ lea rfilterq, [hevc_epel_filters_sse4_%1]
+%else
+ %define rfilterq hevc_epel_filters_sse4_%1
+%endif
+ sub mxq, 1
+ sub myq, 1
+ shl mxq, 5 ; multiply by 32
+ shl myq, 5 ; multiply by 32
+ movdqa m14, [rfilterq + mxq] ; get 2 first values of filters
+ movdqa m15, [rfilterq + mxq+16] ; get 2 last values of filters
+ lea r3srcq, [srcstrideq*3]
+
+%ifdef PIC
+ lea rfilterq, [hevc_epel_filters_sse4_10]
+%else
+ %define rfilterq hevc_epel_filters_sse4_10
+%endif
+ movdqa m12, [rfilterq + myq] ; get 2 first values of filters
+ movdqa m13, [rfilterq + myq+16] ; get 2 last values of filters
+%endmacro
+
+%macro QPEL_FILTER 2
+%ifdef PIC
+ lea rfilterq, [hevc_qpel_filters_sse4_%1]
+%else
+ %define rfilterq hevc_qpel_filters_sse4_%1
+%endif
+ lea %2q, [%2q*8-8]
+ movdqa m12, [rfilterq + %2q*8] ; get 4 first values of filters
+ movdqa m13, [rfilterq + %2q*8 + 16] ; get 4 first values of filters
+ movdqa m14, [rfilterq + %2q*8 + 32] ; get 4 first values of filters
+ movdqa m15, [rfilterq + %2q*8 + 48] ; get 4 first values of filters
+%endmacro
+
+%macro EPEL_LOAD 4
+%ifdef PIC
+ lea rfilterq, [%2]
+%else
+ %define rfilterq %2
+%endif
+ movdqu m0, [rfilterq ] ;load 128bit of x
+%ifnum %3
+ movdqu m1, [rfilterq+ %3] ;load 128bit of x+stride
+ movdqu m2, [rfilterq+2*%3] ;load 128bit of x+2*stride
+ movdqu m3, [rfilterq+3*%3] ;load 128bit of x+3*stride
+%else
+ movdqu m1, [rfilterq+ %3q] ;load 128bit of x+stride
+ movdqu m2, [rfilterq+2*%3q] ;load 128bit of x+2*stride
+ movdqu m3, [rfilterq+r3srcq] ;load 128bit of x+2*stride
+%endif
+
+%if %1 == 8
+%if %4 > 8
+ SBUTTERFLY bw, 0, 1, 10
+ SBUTTERFLY bw, 2, 3, 10
+%else
+ punpcklbw m0, m1
+ punpcklbw m2, m3
+%endif
+%else
+%if %4 > 4
+ SBUTTERFLY wd, 0, 1, 10
+ SBUTTERFLY wd, 2, 3, 10
+%else
+ punpcklwd m0, m1
+ punpcklwd m2, m3
+%endif
+%endif
+%endmacro
+
+
+%macro QPEL_H_LOAD 4
+%assign %%stride (%1+7)/8
+%if %1 == 8
+%if %3 <= 4
+%define %%load movd
+%elif %3 == 8
+%define %%load movq
+%else
+%define %%load movdqu
+%endif
+%else
+%if %3 == 2
+%define %%load movd
+%elif %3 == 4
+%define %%load movq
+%else
+%define %%load movdqu
+%endif
+%endif
+ %%load m0, [%2-3*%%stride] ;load data from source
+ %%load m1, [%2-2*%%stride]
+ %%load m2, [%2-%%stride ]
+ %%load m3, [%2 ]
+ %%load m4, [%2+%%stride ]
+ %%load m5, [%2+2*%%stride]
+ %%load m6, [%2+3*%%stride]
+ %%load m7, [%2+4*%%stride]
+
+%if %1 == 8
+%if %3 > 8
+ SBUTTERFLY wd, 0, 1, %4
+ SBUTTERFLY wd, 2, 3, %4
+ SBUTTERFLY wd, 4, 5, %4
+ SBUTTERFLY wd, 6, 7, %4
+%else
+ punpcklwd m0, m1
+ punpcklwd m2, m3
+ punpcklwd m4, m5
+ punpcklwd m6, m7
+%endif
+%else
+%if %3 > 4
+ SBUTTERFLY dq, 0, 1, %4
+ SBUTTERFLY dq, 2, 3, %4
+ SBUTTERFLY dq, 4, 5, %4
+ SBUTTERFLY dq, 6, 7, %4
+%else
+ punpckldq m0, m1
+ punpckldq m2, m3
+ punpckldq m4, m5
+ punpckldq m6, m7
+%endif
+%endif
+%endmacro
+
+%macro QPEL_V_LOAD 4
+ lea r12q, [%2]
+ sub r12q, r3srcq
+ movdqu m0, [r12 ] ;load x- 3*srcstride
+ movdqu m1, [r12+ %3q ] ;load x- 2*srcstride
+ movdqu m2, [r12+ 2*%3q ] ;load x-srcstride
+ movdqu m3, [%2 ] ;load x
+ movdqu m4, [%2+ %3q] ;load x+stride
+ movdqu m5, [%2+ 2*%3q] ;load x+2*stride
+ movdqu m6, [%2+r3srcq] ;load x+3*stride
+ movdqu m7, [%2+ 4*%3q] ;load x+4*stride
+%if %1 == 8
+%if %4 > 8
+ SBUTTERFLY bw, 0, 1, 8
+ SBUTTERFLY bw, 2, 3, 8
+ SBUTTERFLY bw, 4, 5, 8
+ SBUTTERFLY bw, 6, 7, 8
+%else
+ punpcklbw m0, m1
+ punpcklbw m2, m3
+ punpcklbw m4, m5
+ punpcklbw m6, m7
+%endif
+%else
+%if %4 > 4
+ SBUTTERFLY wd, 0, 1, 8
+ SBUTTERFLY wd, 2, 3, 8
+ SBUTTERFLY wd, 4, 5, 8
+ SBUTTERFLY wd, 6, 7, 8
+%else
+ punpcklwd m0, m1
+ punpcklwd m2, m3
+ punpcklwd m4, m5
+ punpcklwd m6, m7
+%endif
+%endif
+%endmacro
+
+%macro PEL_10STORE2 3
+ movd [%1], %2
+%endmacro
+%macro PEL_10STORE4 3
+ movq [%1], %2
+%endmacro
+%macro PEL_10STORE6 3
+ movq [%1], %2
+ psrldq %2, 8
+ movd [%1+8], %2
+%endmacro
+%macro PEL_10STORE8 3
+ movdqa [%1], %2
+%endmacro
+%macro PEL_10STORE12 3
+ movdqa [%1], %2
+ movq [%1+16], %3
+%endmacro
+%macro PEL_10STORE16 3
+ PEL_10STORE8 %1, %2, %3
+ movdqa [%1+16], %3
+%endmacro
+
+%macro PEL_8STORE2 3
+ pextrw [%1], %2, 0
+%endmacro
+%macro PEL_8STORE4 3
+ movd [%1], %2
+%endmacro
+%macro PEL_8STORE6 3
+ movd [%1], %2
+ pextrw [%1+4], %2, 2
+%endmacro
+%macro PEL_8STORE8 3
+ movq [%1], %2
+%endmacro
+%macro PEL_8STORE12 3
+ movq [%1], %2
+ psrldq %2, 8
+ movd [%1+8], %2
+%endmacro
+%macro PEL_8STORE16 3
+ movdqa [%1], %2
+%endmacro
+
+%macro LOOP_END 4
+ lea %1q, [%1q+2*%2q] ; dst += dststride
+ lea %3q, [%3q+ %4q] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+%endmacro
+
+
+%macro MC_PIXEL_COMPUTE 2 ;width, bitdepth
+%if %2 == 8
+%if %1 > 8
+ punpckhbw m1, m0, m2
+ psllw m1, 14-%2
+%endif
+ punpcklbw m0, m2
+%endif
+ psllw m0, 14-%2
+%endmacro
+
+
+%macro EPEL_COMPUTE 4 ; bitdepth, width, filter1, filter2
+%if %1 == 8
+ pmaddubsw m0, %3 ;x1*c1+x2*c2
+ pmaddubsw m2, %4 ;x3*c3+x4*c4
+ paddw m0, m2
+%if %2 > 8
+ pmaddubsw m1, %3
+ pmaddubsw m3, %4
+ paddw m1, m3
+%endif
+%else
+ pmaddwd m0, %3
+ pmaddwd m2, %4
+ paddd m0, m2
+%if %2 > 4
+ pmaddwd m1, %3
+ pmaddwd m3, %4
+ paddd m1, m3
+%endif
+ psrad m0, %1-8
+ psrad m1, %1-8
+ packssdw m0, m1
+%endif
+%endmacro
+
+%macro QPEL_HV_COMPUTE 4 ; width, bitdepth, filter idx
+%ifdef PIC
+ lea rfilterq, [hevc_qpel_filters_sse4_%2]
+%else
+ %define rfilterq hevc_qpel_filters_sse4_%2
+%endif
+
+%if %2 == 8
+ pmaddubsw m0, [rfilterq + %3q*8 ] ;x1*c1+x2*c2
+ pmaddubsw m2, [rfilterq + %3q*8+16] ;x3*c3+x4*c4
+ pmaddubsw m4, [rfilterq + %3q*8+32] ;x5*c5+x6*c6
+ pmaddubsw m6, [rfilterq + %3q*8+48] ;x7*c7+x8*c8
+ paddw m0, m2
+ paddw m4, m6
+ paddw m0, m4
+%else
+ pmaddwd m0, [rfilterq + %3q*8 ]
+ pmaddwd m2, [rfilterq + %3q*8+16]
+ pmaddwd m4, [rfilterq + %3q*8+32]
+ pmaddwd m6, [rfilterq + %3q*8+48]
+ paddd m0, m2
+ paddd m4, m6
+ paddd m0, m4
+ psrad m0, %2-8
+%if %1 > 4
+ pmaddwd m1, [rfilterq + %3q*8 ]
+ pmaddwd m3, [rfilterq + %3q*8+16]
+ pmaddwd m5, [rfilterq + %3q*8+32]
+ pmaddwd m7, [rfilterq + %3q*8+48]
+ paddd m1, m3
+ paddd m5, m7
+ paddd m1, m5
+ psrad m1, %2-8
+%endif
+ p%4 m0, m1
+%endif
+%endmacro
+
+%macro QPEL_COMPUTE 2 ; width, bitdepth
+%if %2 == 8
+ pmaddubsw m0, m12 ;x1*c1+x2*c2
+ pmaddubsw m2, m13 ;x3*c3+x4*c4
+ pmaddubsw m4, m14 ;x5*c5+x6*c6
+ pmaddubsw m6, m15 ;x7*c7+x8*c8
+ paddw m0, m2
+ paddw m4, m6
+ paddw m0, m4
+%if %1 > 8
+ pmaddubsw m1, m12
+ pmaddubsw m3, m13
+ pmaddubsw m5, m14
+ pmaddubsw m7, m15
+ paddw m1, m3
+ paddw m5, m7
+ paddw m1, m5
+%endif
+%else
+ pmaddwd m0, m12
+ pmaddwd m2, m13
+ pmaddwd m4, m14
+ pmaddwd m6, m15
+ paddd m0, m2
+ paddd m4, m6
+ paddd m0, m4
+ psrad m0, %2-8
+%if %1 > 4
+ pmaddwd m1, m12
+ pmaddwd m3, m13
+ pmaddwd m5, m14
+ pmaddwd m7, m15
+ paddd m1, m3
+ paddd m5, m7
+ paddd m1, m5
+ psrad m1, %2-8
+%endif
+%endif
+%endmacro
+
+%macro BI_COMPUTE 7 ; width, bitd, src1l, src1h, scr2l, scr2h, pw
+ paddsw %3, %5
+%if %1 > 8
+ paddsw %4, %6
+%endif
+ UNI_COMPUTE %1, %2, %3, %4, %7
+%endmacro
+
+%macro UNI_COMPUTE 5
+ pmulhrsw %3, %5
+%if %1 > 8 || (%2 > 8 && %1 > 4)
+ pmulhrsw %4, %5
+%endif
+%if %2 == 8
+ packuswb %3, %4
+%else
+ pminsw %3, [max_pixels_%2]
+ pmaxsw %3, [zero]
+%if %1 > 8
+ pminsw %4, [max_pixels_%2]
+ pmaxsw %4, [zero]
+%endif
+%endif
+%endmacro
+
+INIT_XMM sse4 ; adds ff_ and _sse4 to function name
+; ******************************
+; void put_hevc_mc_pixels(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int height, int mx, int my)
+; ******************************
+
+%macro HEVC_PUT_HEVC_PEL_PIXELS 2
+cglobal hevc_put_hevc_pel_pixels%1_%2, 5, 5, 3, dst, dststride, src, srcstride,height
+ pxor m2, m2
+.loop
+ SIMPLE_LOAD %1, %2, srcq, m0
+ MC_PIXEL_COMPUTE %1, %2
+ PEL_10STORE%1 dstq, m0, m1
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 3, dst, dststride, src, srcstride,height
+ pxor m2, m2
+.loop
+ SIMPLE_LOAD %1, %2, srcq, m0
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_pel_pixels%1_%2, 7, 7, 6, dst, dststride, src, srcstride, src2, src2stride,height
+ pxor m2, m2
+ movdqa m5, [pw_bi_%2]
+.loop
+ SIMPLE_LOAD %1, %2, srcq, m0
+ SIMPLE_BILOAD %1, src2q, m3, m4
+ MC_PIXEL_COMPUTE %1, %2
+ BI_COMPUTE %1, %2, m0, m1, m3, m4, m5
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+%endmacro
+
+
+; ******************************
+; void put_hevc_epel_hX(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int width, int height, int mx, int my,
+; int16_t* mcbuffer)
+; ******************************
+
+
+%macro HEVC_PUT_HEVC_EPEL 2
+cglobal hevc_put_hevc_epel_h%1_%2, 6, 7, 15 , dst, dststride, src, srcstride, height, mx, rfilter
+%assign %%stride ((%2 + 7)/8)
+ EPEL_FILTER %2, mx
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ PEL_10STORE%1 dstq, m0, m1
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_epel_h%1_%2, 6, 7, 15 , dst, dststride, src, srcstride, height, mx, rfilter
+%assign %%stride ((%2 + 7)/8)
+ movdqa m9, [pw_%2]
+ EPEL_FILTER %2, mx
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ UNI_COMPUTE %1, %2, m0, m1, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_epel_h%1_%2, 8, 9, 15, dst, dststride, src, srcstride, src2, src2stride,height, mx, rfilter
+ movdqa m9, [pw_bi_%2]
+ EPEL_FILTER %2, mx
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SIMPLE_BILOAD %1, src2q, m2, m3
+ BI_COMPUTE %1, %2, m0, m1, m2, m3, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+; ******************************
+; void put_hevc_epel_v(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int width, int height, int mx, int my,
+; int16_t* mcbuffer)
+; ******************************
+
+cglobal hevc_put_hevc_epel_v%1_%2, 7, 8, 15 , dst, dststride, src, srcstride, height, r3src, my, rfilter
+ lea r3srcq, [srcstrideq*3]
+ sub srcq, srcstrideq
+ EPEL_FILTER %2, my
+.loop
+ EPEL_LOAD %2, srcq, srcstride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ PEL_10STORE%1 dstq, m0, m1
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_epel_v%1_%2, 7, 8, 15 , dst, dststride, src, srcstride, height, r3src, my, rfilter
+ lea r3srcq, [srcstrideq*3]
+ movdqa m9, [pw_%2]
+ sub srcq, srcstrideq
+ EPEL_FILTER %2, my
+.loop
+ EPEL_LOAD %2, srcq, srcstride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ UNI_COMPUTE %1, %2, m0, m1, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+
+cglobal hevc_put_hevc_bi_epel_v%1_%2, 9, 10, 15, dst, dststride, src, srcstride, src2, src2stride,height, r3src, my, rfilter
+ lea r3srcq, [srcstrideq*3]
+ movdqa m9, [pw_bi_%2]
+ sub srcq, srcstrideq
+ EPEL_FILTER %2, my
+.loop
+ EPEL_LOAD %2, srcq, srcstride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SIMPLE_BILOAD %1, src2q, m2, m3
+ BI_COMPUTE %1, %2, m0, m1, m2, m3, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+%endmacro
+
+
+; ******************************
+; void put_hevc_epel_hv(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int width, int height, int mx, int my)
+; ******************************
+
+%macro HEVC_PUT_HEVC_EPEL_HV 2
+cglobal hevc_put_hevc_epel_hv%1_%2, 7, 9, 12 , dst, dststride, src, srcstride, height, mx, my, r3src, rfilter
+%assign %%stride ((%2 + 7)/8)
+ sub srcq, srcstrideq
+ EPEL_HV_FILTER %2
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m4, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m5, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m6, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m7, m0
+ punpcklwd m0, m4, m5
+ punpcklwd m2, m6, m7
+%if %1 > 4
+ punpckhwd m1, m4, m5
+ punpckhwd m3, m6, m7
+%endif
+ EPEL_COMPUTE 14, %1, m12, m13
+ PEL_10STORE%1 dstq, m0, m1
+ movdqa m4, m5
+ movdqa m5, m6
+ movdqa m6, m7
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_epel_hv%1_%2, 7, 9, 12 , dst, dststride, src, srcstride, height, mx, my, r3src, rfilter
+%assign %%stride ((%2 + 7)/8)
+ sub srcq, srcstrideq
+ EPEL_HV_FILTER %2
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m4, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m5, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m6, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m7, m0
+ punpcklwd m0, m4, m5
+ punpcklwd m2, m6, m7
+%if %1 > 4
+ punpckhwd m1, m4, m5
+ punpckhwd m3, m6, m7
+%endif
+ EPEL_COMPUTE 14, %1, m12, m13
+ UNI_COMPUTE %1, %2, m0, m1, [pw_%2]
+ PEL_%2STORE%1 dstq, m0, m1
+ movdqa m4, m5
+ movdqa m5, m6
+ movdqa m6, m7
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+
+cglobal hevc_put_hevc_bi_epel_hv%1_%2, 9, 11, 16, dst, dststride, src, srcstride, src2, src2stride, height, mx, my, r3src, rfilter
+%assign %%stride ((%2 + 7)/8)
+ sub srcq, srcstrideq
+ EPEL_HV_FILTER %2
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m4, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m5, m0
+ lea srcq, [srcq + srcstrideq]
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m6, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ EPEL_LOAD %2, srcq-%%stride, %%stride, %1
+ EPEL_COMPUTE %2, %1, m14, m15
+ SWAP m7, m0
+ punpcklwd m0, m4, m5
+ punpcklwd m2, m6, m7
+%if %1 > 4
+ punpckhwd m1, m4, m5
+ punpckhwd m3, m6, m7
+%endif
+ EPEL_COMPUTE 14, %1, m12, m13
+ SIMPLE_BILOAD %1, src2q, m8, m9
+ BI_COMPUTE %1, %2, m0, m1, m8, m9, [pw_bi_%2]
+ PEL_%2STORE%1 dstq, m0, m1
+ movdqa m4, m5
+ movdqa m5, m6
+ movdqa m6, m7
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+%endmacro
+
+; ******************************
+; void put_hevc_qpel_hX_X_X(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int width, int height, int mx, int my)
+; ******************************
+
+%macro HEVC_PUT_HEVC_QPEL 2
+cglobal hevc_put_hevc_qpel_h%1_%2, 6, 7, 15 , dst, dststride, src, srcstride, height, mx, rfilter
+ QPEL_FILTER %2, mx
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 10
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packssdw m0, m1
+%endif
+ PEL_10STORE%1 dstq, m0, m1
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_qpel_h%1_%2, 6, 7, 15 , dst, dststride, src, srcstride, height, mx, rfilter
+ movdqa m9, [pw_%2]
+ QPEL_FILTER %2, mx
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 10
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packssdw m0, m1
+%endif
+ UNI_COMPUTE %1, %2, m0, m1, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_qpel_h%1_%2, 8, 9, 16 , dst, dststride, src, srcstride, src2, src2stride, height, mx, rfilter
+ movdqa m9, [pw_bi_%2]
+ QPEL_FILTER %2, mx
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 10
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packssdw m0, m1
+%endif
+ SIMPLE_BILOAD %1, src2q, m10, m11
+ BI_COMPUTE %1, %2, m0, m1, m10, m11, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+
+; ******************************
+; void put_hevc_qpel_vX_X_X(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int width, int height, int mx, int my)
+; ******************************
+
+cglobal hevc_put_hevc_qpel_v%1_%2, 7, 14, 15 , dst, dststride, src, srcstride, height, r3src, my, rfilter
+ lea r3srcq, [srcstrideq*3]
+ QPEL_FILTER %2, my
+.loop
+ QPEL_V_LOAD %2, srcq, srcstride, %1
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packssdw m0, m1
+%endif
+ PEL_10STORE%1 dstq, m0, m1
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_qpel_v%1_%2, 7, 14, 15 , dst, dststride, src, srcstride, height, r3src, my, rfilter
+ movdqa m9, [pw_%2]
+ lea r3srcq, [srcstrideq*3]
+ QPEL_FILTER %2, my
+.loop
+ QPEL_V_LOAD %2, srcq, srcstride, %1
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packusdw m0, m1
+%endif
+ UNI_COMPUTE %1, %2, m0, m1, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_qpel_v%1_%2, 9, 14, 16 , dst, dststride, src, srcstride, src2, src2stride, height, r3src, my, rfilter
+ movdqa m9, [pw_bi_%2]
+ lea r3srcq, [srcstrideq*3]
+ QPEL_FILTER %2, my
+.loop
+ SIMPLE_BILOAD %1, src2q, m10, m11
+ QPEL_V_LOAD %2, srcq, srcstride, %1
+ QPEL_COMPUTE %1, %2
+%if %2 > 8
+ packssdw m0, m1
+%endif
+ BI_COMPUTE %1, %2, m0, m1, m10, m11, m9
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+%endmacro
+
+
+; ******************************
+; void put_hevc_qpel_hvX_X(int16_t *dst, ptrdiff_t dststride,
+; uint8_t *_src, ptrdiff_t _srcstride,
+; int height, int mx, int my)
+; ******************************
+%macro HEVC_PUT_HEVC_QPEL_HV 2
+cglobal hevc_put_hevc_qpel_hv%1_%2, 7, 9, 12 , dst, dststride, src, srcstride, height, mx, my, r3src, rfilter
+ lea mxq, [mxq*8-8]
+ lea myq, [myq*8-8]
+ lea r3srcq, [srcstrideq*3]
+ sub srcq, r3srcq
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m8, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m9, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m10, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m11, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m12, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m13, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m14, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m15, m0
+ punpcklwd m0, m8, m9
+ punpcklwd m2, m10, m11
+ punpcklwd m4, m12, m13
+ punpcklwd m6, m14, m15
+%if %1 > 4
+ punpckhwd m1, m8, m9
+ punpckhwd m3, m10, m11
+ punpckhwd m5, m12, m13
+ punpckhwd m7, m14, m15
+%endif
+ QPEL_HV_COMPUTE %1, 14, my, ackssdw
+ PEL_10STORE%1 dstq, m0, m1
+%if %1 <= 4
+ movq m8, m9
+ movq m9, m10
+ movq m10, m11
+ movq m11, m12
+ movq m12, m13
+ movq m13, m14
+ movq m14, m15
+%else
+ movdqa m8, m9
+ movdqa m9, m10
+ movdqa m10, m11
+ movdqa m11, m12
+ movdqa m12, m13
+ movdqa m13, m14
+ movdqa m14, m15
+%endif
+ LOOP_END dst, dststride, src, srcstride
+ RET
+
+cglobal hevc_put_hevc_uni_qpel_hv%1_%2, 7, 9, 12 , dst, dststride, src, srcstride, height, mx, my, r3src, rfilter
+ lea mxq, [mxq*8-8]
+ lea myq, [myq*8-8]
+ lea r3srcq, [srcstrideq*3]
+ sub srcq, r3srcq
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m8, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m9, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m10, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m11, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m12, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m13, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m14, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m15, m0
+ punpcklwd m0, m8, m9
+ punpcklwd m2, m10, m11
+ punpcklwd m4, m12, m13
+ punpcklwd m6, m14, m15
+%if %1 > 4
+ punpckhwd m1, m8, m9
+ punpckhwd m3, m10, m11
+ punpckhwd m5, m12, m13
+ punpckhwd m7, m14, m15
+%endif
+ QPEL_HV_COMPUTE %1, 14, my, ackusdw
+ UNI_COMPUTE %1, %2, m0, m1, [pw_%2]
+ PEL_%2STORE%1 dstq, m0, m1
+
+%if %1 <= 4
+ movq m8, m9
+ movq m9, m10
+ movq m10, m11
+ movq m11, m12
+ movq m12, m13
+ movq m13, m14
+ movq m14, m15
+%else
+ movdqa m8, m9
+ movdqa m9, m10
+ movdqa m10, m11
+ movdqa m11, m12
+ movdqa m12, m13
+ movdqa m13, m14
+ movdqa m14, m15
+%endif
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_qpel_hv%1_%2, 9, 11, 16, dst, dststride, src, srcstride, src2, src2stride, height, mx, my, r3src, rfilter
+ lea mxq, [mxq*8-8]
+ lea myq, [myq*8-8]
+ lea r3srcq, [srcstrideq*3]
+ sub srcq, r3srcq
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m8, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m9, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m10, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m11, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m12, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m13, m0
+ lea srcq, [srcq + srcstrideq]
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m14, m0
+ lea srcq, [srcq + srcstrideq]
+.loop
+ QPEL_H_LOAD %2, srcq, %1, 15
+ QPEL_HV_COMPUTE %1, %2, mx, ackssdw
+ SWAP m15, m0
+ punpcklwd m0, m8, m9
+ punpcklwd m2, m10, m11
+ punpcklwd m4, m12, m13
+ punpcklwd m6, m14, m15
+%if %1 > 4
+ punpckhwd m1, m8, m9
+ punpckhwd m3, m10, m11
+ punpckhwd m5, m12, m13
+ punpckhwd m7, m14, m15
+%endif
+ QPEL_HV_COMPUTE %1, 14, my, ackssdw
+ SIMPLE_BILOAD %1, src2q, m8, m9 ;m9 not used in this case
+ BI_COMPUTE %1, %2, m0, m1, m8, m9, [pw_bi_%2]
+ PEL_%2STORE%1 dstq, m0, m1
+
+%if %1 <= 4
+ movq m8, m9
+ movq m9, m10
+ movq m10, m11
+ movq m11, m12
+ movq m12, m13
+ movq m13, m14
+ movq m14, m15
+%else
+ movdqa m8, m9
+ movdqa m9, m10
+ movdqa m10, m11
+ movdqa m11, m12
+ movdqa m12, m13
+ movdqa m13, m14
+ movdqa m14, m15
+%endif
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+%endmacro
+
+%macro WEIGHTING_FUNCS 2
+cglobal hevc_put_hevc_uni_w%1_%2, 8, 10, 11, dst, dststride, src, srcstride, height, denom, wx, ox, shift
+ lea shiftd, [denomd+14-%2] ; shift = 14 - bitd + denom
+ shl oxd, %2-8 ; ox << (bitd - 8)
+ movd m2, wxd ; WX
+ movd m3, oxd ; OX
+ movd m4, shiftd ; shift
+ punpcklwd m2, m2
+ pshufd m3, m3, 0
+ pshufd m2, m2, 0
+ sub shiftd, 1
+ movd m6, shiftd
+ movdqu m5, [one_per_32]
+ pslld m5, m6
+.loop
+ SIMPLE_LOAD %1, 10, srcq, m0
+ pmulhw m6, m0, m2
+ pmullw m0, m2
+ punpckhwd m1, m0, m6
+ punpcklwd m0, m6
+ paddd m0, m5
+ paddd m1, m5
+ psrad m0, m4
+ psrad m1, m4
+ paddd m0, m3
+ paddd m1, m3
+ packusdw m0, m1
+%if %2 == 8
+ packuswb m0, m0
+%else
+ pminsw m0, [max_pixels_%2]
+%endif
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+2*srcstrideq] ; src += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+
+cglobal hevc_put_hevc_bi_w%1_%2, 12, 14, 14, dst, dststride, src, srcstride, src2, src2stride, height, denom, wx0, wx1, ox0, ox1, shift, temp
+ shl ox0d, %2-8 ; ox << (bitd - 8)
+ shl ox1d, %2-8 ; ox << (bitd - 8)
+ lea shiftd, [denomd+14-%2] ; shift = 14 - bitd + denom
+ movd m2, wx0d ; WX0
+ movd m3, wx1d ; WX1
+ punpcklwd m2, m2
+ punpcklwd m3, m3
+ pshufd m2, m2, 0
+ pshufd m3, m3, 0
+ add ox0d, ox1d
+ add ox0d, 1
+ movd m4, ox0d ; offset
+ pshufd m4, m4, 0
+ movd m5, shiftd ; shift
+ pslld m4, m5
+ add shiftd, 1
+ movd m5, shiftd ; shift
+
+.loop
+ SIMPLE_LOAD %1, 10, srcq, m0
+ SIMPLE_LOAD %1, 10, src2q, m10
+ pmulhw m6, m0, m3
+ pmullw m0, m3
+ pmulhw m7, m10, m2
+ pmullw m10, m2
+ punpckhwd m1, m0, m6
+ punpcklwd m0, m6
+ punpckhwd m11, m10, m7
+ punpcklwd m10, m7
+ paddd m0, m10
+ paddd m1, m11
+ paddd m0, m4
+ paddd m1, m4
+ psrad m0, m5
+ psrad m1, m5
+ packusdw m0, m1
+%if %2 == 8
+ packuswb m0, m0
+%else
+ pminsw m0, [max_pixels_%2]
+%endif
+ PEL_%2STORE%1 dstq, m0, m1
+ lea dstq, [dstq+dststrideq] ; dst += dststride
+ lea srcq, [srcq+2*srcstrideq] ; src += srcstride
+ lea src2q, [src2q+2*src2strideq] ; src2 += srcstride
+ dec heightd ; cmp height
+ jnz .loop ; height loop
+ RET
+%endmacro
+
+WEIGHTING_FUNCS 2, 8
+WEIGHTING_FUNCS 4, 8
+WEIGHTING_FUNCS 6, 8
+WEIGHTING_FUNCS 8, 8
+
+WEIGHTING_FUNCS 2, 10
+WEIGHTING_FUNCS 4, 10
+WEIGHTING_FUNCS 6, 10
+WEIGHTING_FUNCS 8, 10
+
+HEVC_PUT_HEVC_PEL_PIXELS 2, 8
+HEVC_PUT_HEVC_PEL_PIXELS 4, 8
+HEVC_PUT_HEVC_PEL_PIXELS 6, 8
+HEVC_PUT_HEVC_PEL_PIXELS 8, 8
+HEVC_PUT_HEVC_PEL_PIXELS 12, 8
+HEVC_PUT_HEVC_PEL_PIXELS 16, 8
+
+HEVC_PUT_HEVC_PEL_PIXELS 2, 10
+HEVC_PUT_HEVC_PEL_PIXELS 4, 10
+HEVC_PUT_HEVC_PEL_PIXELS 6, 10
+HEVC_PUT_HEVC_PEL_PIXELS 8, 10
+
+
+HEVC_PUT_HEVC_EPEL 2, 8
+HEVC_PUT_HEVC_EPEL 4, 8
+HEVC_PUT_HEVC_EPEL 6, 8
+HEVC_PUT_HEVC_EPEL 8, 8
+HEVC_PUT_HEVC_EPEL 12, 8
+HEVC_PUT_HEVC_EPEL 16, 8
+
+
+HEVC_PUT_HEVC_EPEL 2, 10
+HEVC_PUT_HEVC_EPEL 4, 10
+HEVC_PUT_HEVC_EPEL 6, 10
+HEVC_PUT_HEVC_EPEL 8, 10
+
+
+HEVC_PUT_HEVC_EPEL_HV 2, 8
+HEVC_PUT_HEVC_EPEL_HV 4, 8
+HEVC_PUT_HEVC_EPEL_HV 6, 8
+HEVC_PUT_HEVC_EPEL_HV 8, 8
+
+HEVC_PUT_HEVC_EPEL_HV 2, 10
+HEVC_PUT_HEVC_EPEL_HV 4, 10
+HEVC_PUT_HEVC_EPEL_HV 6, 10
+HEVC_PUT_HEVC_EPEL_HV 8, 10
+
+
+HEVC_PUT_HEVC_QPEL 4, 8
+HEVC_PUT_HEVC_QPEL 8, 8
+HEVC_PUT_HEVC_QPEL 12, 8
+HEVC_PUT_HEVC_QPEL 16, 8
+
+HEVC_PUT_HEVC_QPEL 4, 10
+HEVC_PUT_HEVC_QPEL 8, 10
+
+HEVC_PUT_HEVC_QPEL_HV 2, 8
+HEVC_PUT_HEVC_QPEL_HV 4, 8
+HEVC_PUT_HEVC_QPEL_HV 6, 8
+HEVC_PUT_HEVC_QPEL_HV 8, 8
+
+HEVC_PUT_HEVC_QPEL_HV 2, 10
+HEVC_PUT_HEVC_QPEL_HV 4, 10
+HEVC_PUT_HEVC_QPEL_HV 6, 10
+HEVC_PUT_HEVC_QPEL_HV 8, 10
+
+%endif ; ARCH_X86_64
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp.h b/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp.h
new file mode 100644
index 00000000000..c5a64c708a2
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp.h
@@ -0,0 +1,123 @@
+/*
+ * HEVC video decoder
+ *
+ * Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2013 - 2014 Pierre-Edouard Lepere
+ *
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_HEVCDSP_H
+#define AVCODEC_X86_HEVCDSP_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define PEL_LINK(dst, idx1, idx2, idx3, name, D, opt) \
+dst[idx1][idx2][idx3] = ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt; \
+dst ## _bi[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt; \
+dst ## _uni[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt; \
+dst ## _uni_w[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt; \
+dst ## _bi_w[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt
+
+
+#define PEL_PROTOTYPE(name, D, opt) \
+void ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt(int16_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); \
+void ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, ptrdiff_t src2stride, int height, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, ptrdiff_t src2stride, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+
+
+///////////////////////////////////////////////////////////////////////////////
+// MC functions
+///////////////////////////////////////////////////////////////////////////////
+
+#define EPEL_PROTOTYPES(fname, bitd, opt) \
+ PEL_PROTOTYPE(fname##4, bitd, opt); \
+ PEL_PROTOTYPE(fname##6, bitd, opt); \
+ PEL_PROTOTYPE(fname##8, bitd, opt); \
+ PEL_PROTOTYPE(fname##12, bitd, opt); \
+ PEL_PROTOTYPE(fname##16, bitd, opt); \
+ PEL_PROTOTYPE(fname##24, bitd, opt); \
+ PEL_PROTOTYPE(fname##32, bitd, opt); \
+ PEL_PROTOTYPE(fname##48, bitd, opt); \
+ PEL_PROTOTYPE(fname##64, bitd, opt)
+
+#define QPEL_PROTOTYPES(fname, bitd, opt) \
+ PEL_PROTOTYPE(fname##4, bitd, opt); \
+ PEL_PROTOTYPE(fname##8, bitd, opt); \
+ PEL_PROTOTYPE(fname##12, bitd, opt); \
+ PEL_PROTOTYPE(fname##16, bitd, opt); \
+ PEL_PROTOTYPE(fname##24, bitd, opt); \
+ PEL_PROTOTYPE(fname##32, bitd, opt); \
+ PEL_PROTOTYPE(fname##48, bitd, opt); \
+ PEL_PROTOTYPE(fname##64, bitd, opt)
+
+#define WEIGHTING_PROTOTYPE(width, bitd, opt) \
+void ff_hevc_put_hevc_uni_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride, int height, int denom, int _wx, int _ox); \
+void ff_hevc_put_hevc_bi_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride, int16_t *_src2, ptrdiff_t _src2stride, int height, int denom, int _wx0, int _wx1, int _ox0, int _ox1)
+
+#define WEIGHTING_PROTOTYPES(bitd, opt) \
+ WEIGHTING_PROTOTYPE(2, bitd, opt); \
+ WEIGHTING_PROTOTYPE(4, bitd, opt); \
+ WEIGHTING_PROTOTYPE(6, bitd, opt); \
+ WEIGHTING_PROTOTYPE(8, bitd, opt); \
+ WEIGHTING_PROTOTYPE(12, bitd, opt); \
+ WEIGHTING_PROTOTYPE(16, bitd, opt); \
+ WEIGHTING_PROTOTYPE(24, bitd, opt); \
+ WEIGHTING_PROTOTYPE(32, bitd, opt); \
+ WEIGHTING_PROTOTYPE(48, bitd, opt); \
+ WEIGHTING_PROTOTYPE(64, bitd, opt)
+
+
+///////////////////////////////////////////////////////////////////////////////
+// QPEL_PIXELS EPEL_PIXELS
+///////////////////////////////////////////////////////////////////////////////
+EPEL_PROTOTYPES(pel_pixels , 8, sse4);
+EPEL_PROTOTYPES(pel_pixels , 10, sse4);
+///////////////////////////////////////////////////////////////////////////////
+// EPEL
+///////////////////////////////////////////////////////////////////////////////
+EPEL_PROTOTYPES(epel_h , 8, sse4);
+EPEL_PROTOTYPES(epel_h , 10, sse4);
+
+EPEL_PROTOTYPES(epel_v , 8, sse4);
+EPEL_PROTOTYPES(epel_v , 10, sse4);
+
+EPEL_PROTOTYPES(epel_hv , 8, sse4);
+EPEL_PROTOTYPES(epel_hv , 10, sse4);
+
+///////////////////////////////////////////////////////////////////////////////
+// QPEL
+///////////////////////////////////////////////////////////////////////////////
+QPEL_PROTOTYPES(qpel_h , 8, sse4);
+QPEL_PROTOTYPES(qpel_h , 10, sse4);
+
+QPEL_PROTOTYPES(qpel_v, 8, sse4);
+QPEL_PROTOTYPES(qpel_v, 10, sse4);
+
+QPEL_PROTOTYPES(qpel_hv, 8, sse4);
+QPEL_PROTOTYPES(qpel_hv, 10, sse4);
+
+
+WEIGHTING_PROTOTYPES(8, sse4);
+WEIGHTING_PROTOTYPES(10, sse4);
+
+
+#endif // AVCODEC_X86_HEVCDSP_H
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp_init.c
new file mode 100644
index 00000000000..61ac6a98dc9
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hevcdsp_init.c
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 2013 Seppo Tomperi
+ * Copyright (c) 2013 - 2014 Pierre-Edouard Lepere
+ *
+ *
+ * This file is part of ffmpeg.
+ *
+ * ffmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * ffmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with ffmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "libavutil/cpu.h"
+#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
+#include "libavcodec/get_bits.h" /* required for hevcdsp.h GetBitContext */
+#include "libavcodec/hevcdsp.h"
+#include "libavcodec/x86/hevcdsp.h"
+
+
+#define mc_rep_func(name, bitd, step, W, opt) \
+void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *_dst, ptrdiff_t dststride, \
+ uint8_t *_src, ptrdiff_t _srcstride, int height, \
+ intptr_t mx, intptr_t my, int width) \
+{ \
+ int i; \
+ uint8_t *src; \
+ int16_t *dst; \
+ for (i = 0; i < W; i += step) { \
+ src = _src + (i * ((bitd + 7) / 8)); \
+ dst = _dst + i; \
+ ff_hevc_put_hevc_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, height, mx, my, width); \
+ } \
+}
+#define mc_rep_uni_func(name, bitd, step, W, opt) \
+void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, \
+ uint8_t *_src, ptrdiff_t _srcstride, int height, \
+ intptr_t mx, intptr_t my, int width) \
+{ \
+ int i; \
+ uint8_t *src; \
+ uint8_t *dst; \
+ for (i = 0; i < W; i += step) { \
+ src = _src + (i * ((bitd + 7) / 8)); \
+ dst = _dst + (i * ((bitd + 7) / 8)); \
+ ff_hevc_put_hevc_uni_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, \
+ height, mx, my, width); \
+ } \
+}
+#define mc_rep_bi_func(name, bitd, step, W, opt) \
+void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, uint8_t *_src, \
+ ptrdiff_t _srcstride, int16_t* _src2, ptrdiff_t _src2stride, \
+ int height, intptr_t mx, intptr_t my, int width) \
+{ \
+ int i; \
+ uint8_t *src; \
+ uint8_t *dst; \
+ int16_t *src2; \
+ for (i = 0; i < W ; i += step) { \
+ src = _src + (i * ((bitd + 7) / 8)); \
+ dst = _dst + (i * ((bitd + 7) / 8)); \
+ src2 = _src2 + i; \
+ ff_hevc_put_hevc_bi_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, \
+ _src2stride, height, mx, my, width); \
+ } \
+}
+
+#define mc_rep_funcs(name, bitd, step, W, opt) \
+ mc_rep_func(name, bitd, step, W, opt); \
+ mc_rep_uni_func(name, bitd, step, W, opt); \
+ mc_rep_bi_func(name, bitd, step, W, opt)
+
+
+#if ARCH_X86_64 && HAVE_SSE4_EXTERNAL
+
+mc_rep_funcs(pel_pixels, 8, 16, 64, sse4);
+mc_rep_funcs(pel_pixels, 8, 16, 48, sse4);
+mc_rep_funcs(pel_pixels, 8, 16, 32, sse4);
+mc_rep_funcs(pel_pixels, 8, 8, 24, sse4);
+
+mc_rep_funcs(pel_pixels,10, 8, 64, sse4);
+mc_rep_funcs(pel_pixels,10, 8, 48, sse4);
+mc_rep_funcs(pel_pixels,10, 8, 32, sse4);
+mc_rep_funcs(pel_pixels,10, 8, 24, sse4);
+mc_rep_funcs(pel_pixels,10, 8, 16, sse4);
+mc_rep_funcs(pel_pixels,10, 4, 12, sse4);
+
+mc_rep_funcs(epel_h, 8, 16, 64, sse4);
+mc_rep_funcs(epel_h, 8, 16, 48, sse4);
+mc_rep_funcs(epel_h, 8, 16, 32, sse4);
+mc_rep_funcs(epel_h, 8, 8, 24, sse4);
+mc_rep_funcs(epel_h,10, 8, 64, sse4);
+mc_rep_funcs(epel_h,10, 8, 48, sse4);
+mc_rep_funcs(epel_h,10, 8, 32, sse4);
+mc_rep_funcs(epel_h,10, 8, 24, sse4);
+mc_rep_funcs(epel_h,10, 8, 16, sse4);
+mc_rep_funcs(epel_h,10, 4, 12, sse4);
+mc_rep_funcs(epel_v, 8, 16, 64, sse4);
+mc_rep_funcs(epel_v, 8, 16, 48, sse4);
+mc_rep_funcs(epel_v, 8, 16, 32, sse4);
+mc_rep_funcs(epel_v, 8, 8, 24, sse4);
+mc_rep_funcs(epel_v,10, 8, 64, sse4);
+mc_rep_funcs(epel_v,10, 8, 48, sse4);
+mc_rep_funcs(epel_v,10, 8, 32, sse4);
+mc_rep_funcs(epel_v,10, 8, 24, sse4);
+mc_rep_funcs(epel_v,10, 8, 16, sse4);
+mc_rep_funcs(epel_v,10, 4, 12, sse4);
+mc_rep_funcs(epel_hv, 8, 8, 64, sse4);
+mc_rep_funcs(epel_hv, 8, 8, 48, sse4);
+mc_rep_funcs(epel_hv, 8, 8, 32, sse4);
+mc_rep_funcs(epel_hv, 8, 8, 24, sse4);
+mc_rep_funcs(epel_hv, 8, 8, 16, sse4);
+mc_rep_funcs(epel_hv, 8, 4, 12, sse4);
+mc_rep_funcs(epel_hv,10, 8, 64, sse4);
+mc_rep_funcs(epel_hv,10, 8, 48, sse4);
+mc_rep_funcs(epel_hv,10, 8, 32, sse4);
+mc_rep_funcs(epel_hv,10, 8, 24, sse4);
+mc_rep_funcs(epel_hv,10, 8, 16, sse4);
+mc_rep_funcs(epel_hv,10, 4, 12, sse4);
+
+mc_rep_funcs(qpel_h, 8, 16, 64, sse4);
+mc_rep_funcs(qpel_h, 8, 16, 48, sse4);
+mc_rep_funcs(qpel_h, 8, 16, 32, sse4);
+mc_rep_funcs(qpel_h, 8, 8, 24, sse4);
+mc_rep_funcs(qpel_h,10, 8, 64, sse4);
+mc_rep_funcs(qpel_h,10, 8, 48, sse4);
+mc_rep_funcs(qpel_h,10, 8, 32, sse4);
+mc_rep_funcs(qpel_h,10, 8, 24, sse4);
+mc_rep_funcs(qpel_h,10, 8, 16, sse4);
+mc_rep_funcs(qpel_h,10, 4, 12, sse4);
+mc_rep_funcs(qpel_v, 8, 16, 64, sse4);
+mc_rep_funcs(qpel_v, 8, 16, 48, sse4);
+mc_rep_funcs(qpel_v, 8, 16, 32, sse4);
+mc_rep_funcs(qpel_v, 8, 8, 24, sse4);
+mc_rep_funcs(qpel_v,10, 8, 64, sse4);
+mc_rep_funcs(qpel_v,10, 8, 48, sse4);
+mc_rep_funcs(qpel_v,10, 8, 32, sse4);
+mc_rep_funcs(qpel_v,10, 8, 24, sse4);
+mc_rep_funcs(qpel_v,10, 8, 16, sse4);
+mc_rep_funcs(qpel_v,10, 4, 12, sse4);
+mc_rep_funcs(qpel_hv, 8, 8, 64, sse4);
+mc_rep_funcs(qpel_hv, 8, 8, 48, sse4);
+mc_rep_funcs(qpel_hv, 8, 8, 32, sse4);
+mc_rep_funcs(qpel_hv, 8, 8, 24, sse4);
+mc_rep_funcs(qpel_hv, 8, 8, 16, sse4);
+mc_rep_funcs(qpel_hv, 8, 4, 12, sse4);
+mc_rep_funcs(qpel_hv,10, 8, 64, sse4);
+mc_rep_funcs(qpel_hv,10, 8, 48, sse4);
+mc_rep_funcs(qpel_hv,10, 8, 32, sse4);
+mc_rep_funcs(qpel_hv,10, 8, 24, sse4);
+mc_rep_funcs(qpel_hv,10, 8, 16, sse4);
+mc_rep_funcs(qpel_hv,10, 4, 12, sse4);
+
+#define mc_rep_uni_w(bitd, step, W, opt) \
+void ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride,\
+ int height, int denom, int _wx, int _ox) \
+{ \
+ int i; \
+ int16_t *src; \
+ uint8_t *dst; \
+ for (i = 0; i < W; i += step) { \
+ src= _src + i; \
+ dst= _dst + (i * ((bitd + 7) / 8)); \
+ ff_hevc_put_hevc_uni_w##step##_##bitd##_##opt(dst, dststride, src, _srcstride, \
+ height, denom, _wx, _ox); \
+ } \
+}
+
+mc_rep_uni_w(8, 6, 12, sse4);
+mc_rep_uni_w(8, 8, 16, sse4);
+mc_rep_uni_w(8, 8, 24, sse4);
+mc_rep_uni_w(8, 8, 32, sse4);
+mc_rep_uni_w(8, 8, 48, sse4);
+mc_rep_uni_w(8, 8, 64, sse4);
+
+mc_rep_uni_w(10, 6, 12, sse4);
+mc_rep_uni_w(10, 8, 16, sse4);
+mc_rep_uni_w(10, 8, 24, sse4);
+mc_rep_uni_w(10, 8, 32, sse4);
+mc_rep_uni_w(10, 8, 48, sse4);
+mc_rep_uni_w(10, 8, 64, sse4);
+
+#define mc_rep_bi_w(bitd, step, W, opt) \
+void ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride, \
+ int16_t *_src2, ptrdiff_t _src2stride, int height, \
+ int denom, int _wx0, int _wx1, int _ox0, int _ox1) \
+{ \
+ int i; \
+ int16_t *src; \
+ int16_t *src2; \
+ uint8_t *dst; \
+ for (i = 0; i < W; i += step) { \
+ src = _src + i; \
+ src2 = _src2 + i; \
+ dst = _dst + (i * ((bitd + 7) / 8)); \
+ ff_hevc_put_hevc_bi_w##step##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, _src2stride, \
+ height, denom, _wx0, _wx1, _ox0, _ox1); \
+ } \
+}
+
+mc_rep_bi_w(8, 6, 12, sse4);
+mc_rep_bi_w(8, 8, 16, sse4);
+mc_rep_bi_w(8, 8, 24, sse4);
+mc_rep_bi_w(8, 8, 32, sse4);
+mc_rep_bi_w(8, 8, 48, sse4);
+mc_rep_bi_w(8, 8, 64, sse4);
+
+mc_rep_bi_w(10, 6, 12, sse4);
+mc_rep_bi_w(10, 8, 16, sse4);
+mc_rep_bi_w(10, 8, 24, sse4);
+mc_rep_bi_w(10, 8, 32, sse4);
+mc_rep_bi_w(10, 8, 48, sse4);
+mc_rep_bi_w(10, 8, 64, sse4);
+
+#define mc_uni_w_func(name, bitd, W, opt) \
+void ff_hevc_put_hevc_uni_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride, \
+ uint8_t *_src, ptrdiff_t _srcstride, \
+ int height, int denom, \
+ int _wx, int _ox, \
+ intptr_t mx, intptr_t my, int width) \
+{ \
+ LOCAL_ALIGNED_16(int16_t, temp, [71 * 64]); \
+ ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, 64, _src, _srcstride, height, mx, my, width); \
+ ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(_dst, _dststride, temp, 64, height, denom, _wx, _ox);\
+}
+
+#define mc_uni_w_funcs(name, bitd, opt) \
+ mc_uni_w_func(name, bitd, 4, opt); \
+ mc_uni_w_func(name, bitd, 8, opt); \
+ mc_uni_w_func(name, bitd, 12, opt); \
+ mc_uni_w_func(name, bitd, 16, opt); \
+ mc_uni_w_func(name, bitd, 24, opt); \
+ mc_uni_w_func(name, bitd, 32, opt); \
+ mc_uni_w_func(name, bitd, 48, opt); \
+ mc_uni_w_func(name, bitd, 64, opt)
+
+mc_uni_w_funcs(pel_pixels, 8, sse4);
+mc_uni_w_func(pel_pixels, 8, 6, sse4);
+mc_uni_w_funcs(epel_h, 8, sse4);
+mc_uni_w_func(epel_h, 8, 6, sse4);
+mc_uni_w_funcs(epel_v, 8, sse4);
+mc_uni_w_func(epel_v, 8, 6, sse4);
+mc_uni_w_funcs(epel_hv, 8, sse4);
+mc_uni_w_func(epel_hv, 8, 6, sse4);
+mc_uni_w_funcs(qpel_h, 8, sse4);
+mc_uni_w_funcs(qpel_v, 8, sse4);
+mc_uni_w_funcs(qpel_hv, 8, sse4);
+
+mc_uni_w_funcs(pel_pixels, 10, sse4);
+mc_uni_w_func(pel_pixels, 10, 6, sse4);
+mc_uni_w_funcs(epel_h, 10, sse4);
+mc_uni_w_func(epel_h, 10, 6, sse4);
+mc_uni_w_funcs(epel_v, 10, sse4);
+mc_uni_w_func(epel_v, 10, 6, sse4);
+mc_uni_w_funcs(epel_hv, 10, sse4);
+mc_uni_w_func(epel_hv, 10, 6, sse4);
+mc_uni_w_funcs(qpel_h, 10, sse4);
+mc_uni_w_funcs(qpel_v, 10, sse4);
+mc_uni_w_funcs(qpel_hv, 10, sse4);
+
+
+#define mc_bi_w_func(name, bitd, W, opt) \
+void ff_hevc_put_hevc_bi_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride, \
+ uint8_t *_src, ptrdiff_t _srcstride, \
+ int16_t *_src2, ptrdiff_t _src2stride, \
+ int height, int denom, \
+ int _wx0, int _wx1, int _ox0, int _ox1, \
+ intptr_t mx, intptr_t my, int width) \
+{ \
+ LOCAL_ALIGNED_16(int16_t, temp, [71 * 64]); \
+ ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, 64, _src, _srcstride, height, mx, my, width); \
+ ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(_dst, _dststride, temp, 64, _src2, _src2stride, \
+ height, denom, _wx0, _wx1, _ox0, _ox1); \
+}
+
+#define mc_bi_w_funcs(name, bitd, opt) \
+ mc_bi_w_func(name, bitd, 4, opt); \
+ mc_bi_w_func(name, bitd, 8, opt); \
+ mc_bi_w_func(name, bitd, 12, opt); \
+ mc_bi_w_func(name, bitd, 16, opt); \
+ mc_bi_w_func(name, bitd, 24, opt); \
+ mc_bi_w_func(name, bitd, 32, opt); \
+ mc_bi_w_func(name, bitd, 48, opt); \
+ mc_bi_w_func(name, bitd, 64, opt)
+
+mc_bi_w_funcs(pel_pixels, 8, sse4);
+mc_bi_w_func(pel_pixels, 8, 6, sse4);
+mc_bi_w_funcs(epel_h, 8, sse4);
+mc_bi_w_func(epel_h, 8, 6, sse4);
+mc_bi_w_funcs(epel_v, 8, sse4);
+mc_bi_w_func(epel_v, 8, 6, sse4);
+mc_bi_w_funcs(epel_hv, 8, sse4);
+mc_bi_w_func(epel_hv, 8, 6, sse4);
+mc_bi_w_funcs(qpel_h, 8, sse4);
+mc_bi_w_funcs(qpel_v, 8, sse4);
+mc_bi_w_funcs(qpel_hv, 8, sse4);
+
+mc_bi_w_funcs(pel_pixels, 10, sse4);
+mc_bi_w_func(pel_pixels, 10, 6, sse4);
+mc_bi_w_funcs(epel_h, 10, sse4);
+mc_bi_w_func(epel_h, 10, 6, sse4);
+mc_bi_w_funcs(epel_v, 10, sse4);
+mc_bi_w_func(epel_v, 10, 6, sse4);
+mc_bi_w_funcs(epel_hv, 10, sse4);
+mc_bi_w_func(epel_hv, 10, 6, sse4);
+mc_bi_w_funcs(qpel_h, 10, sse4);
+mc_bi_w_funcs(qpel_v, 10, sse4);
+mc_bi_w_funcs(qpel_hv, 10, sse4);
+
+#endif //ARCH_X86_64 && HAVE_SSE4_EXTERNAL
+
+
+#define EPEL_LINKS(pointer, my, mx, fname, bitd, opt ) \
+ PEL_LINK(pointer, 1, my , mx , fname##4 , bitd, sse4 ); \
+ PEL_LINK(pointer, 2, my , mx , fname##6 , bitd, sse4 ); \
+ PEL_LINK(pointer, 3, my , mx , fname##8 , bitd, sse4 ); \
+ PEL_LINK(pointer, 4, my , mx , fname##12, bitd, sse4 ); \
+ PEL_LINK(pointer, 5, my , mx , fname##16, bitd, sse4 ); \
+ PEL_LINK(pointer, 6, my , mx , fname##24, bitd, sse4 ); \
+ PEL_LINK(pointer, 7, my , mx , fname##32, bitd, sse4 ); \
+ PEL_LINK(pointer, 8, my , mx , fname##48, bitd, sse4 ); \
+ PEL_LINK(pointer, 9, my , mx , fname##64, bitd, sse4 )
+#define QPEL_LINKS(pointer, my, mx, fname, bitd, sse4) \
+ PEL_LINK(pointer, 1, my , mx , fname##4 , bitd, sse4 ); \
+ PEL_LINK(pointer, 3, my , mx , fname##8 , bitd, sse4 ); \
+ PEL_LINK(pointer, 4, my , mx , fname##12, bitd, sse4 ); \
+ PEL_LINK(pointer, 5, my , mx , fname##16, bitd, sse4 ); \
+ PEL_LINK(pointer, 6, my , mx , fname##24, bitd, sse4 ); \
+ PEL_LINK(pointer, 7, my , mx , fname##32, bitd, sse4 ); \
+ PEL_LINK(pointer, 8, my , mx , fname##48, bitd, sse4 ); \
+ PEL_LINK(pointer, 9, my , mx , fname##64, bitd, sse4 )
+
+
+void ff_hevcdsp_init_x86(HEVCDSPContext *c, const int bit_depth)
+{
+ int mm_flags = av_get_cpu_flags();
+
+ if (bit_depth == 8) {
+ if (EXTERNAL_SSE4(mm_flags) && ARCH_X86_64) {
+
+ EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 8, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 8, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 8, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 8, sse4);
+
+ QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 8, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 8, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 8, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 8, sse4);
+
+ }
+ } else if (bit_depth == 10) {
+ if (EXTERNAL_SSE4(mm_flags) && ARCH_X86_64) {
+
+ EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 10, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 10, sse4);
+ EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 10, sse4);
+
+ QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 10, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 10, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 10, sse4);
+ QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 10, sse4);
+ }
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.asm
index 4eaba6eaca4..171c77b9285 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.asm
@@ -6,7 +6,7 @@
;* Copyright (c) 2002 Zdenek Kabelac <kabi@informatics.muni.cz>
;* Copyright (c) 2013 Daniel Kang
;*
-;* MMX optimized hpel functions
+;* SIMD-optimized halfpel functions
;*
;* This file is part of FFmpeg.
;*
@@ -32,7 +32,7 @@ cextern pb_1
SECTION_TEXT
-; put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_PIXELS8_X2 0
cglobal put_pixels8_x2, 4,5
lea r4, [r2*2]
@@ -64,7 +64,7 @@ INIT_MMX 3dnow
PUT_PIXELS8_X2
-; put_pixels16_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels16_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_PIXELS_16 0
cglobal put_pixels16_x2, 4,5
lea r4, [r2*2]
@@ -108,7 +108,7 @@ INIT_MMX 3dnow
PUT_PIXELS_16
-; put_no_rnd_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_NO_RND_PIXELS8_X2 0
cglobal put_no_rnd_pixels8_x2, 4,5
mova m6, [pb_1]
@@ -149,7 +149,7 @@ INIT_MMX 3dnow
PUT_NO_RND_PIXELS8_X2
-; put_no_rnd_pixels8_x2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_x2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_NO_RND_PIXELS8_X2_EXACT 0
cglobal put_no_rnd_pixels8_x2_exact, 4,5
lea r4, [r2*3]
@@ -196,7 +196,7 @@ INIT_MMX 3dnow
PUT_NO_RND_PIXELS8_X2_EXACT
-; put_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_PIXELS8_Y2 0
cglobal put_pixels8_y2, 4,5
lea r4, [r2*2]
@@ -230,7 +230,7 @@ INIT_MMX 3dnow
PUT_PIXELS8_Y2
-; put_no_rnd_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_NO_RND_PIXELS8_Y2 0
cglobal put_no_rnd_pixels8_y2, 4,5
mova m6, [pb_1]
@@ -267,7 +267,7 @@ INIT_MMX 3dnow
PUT_NO_RND_PIXELS8_Y2
-; put_no_rnd_pixels8_y2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_y2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro PUT_NO_RND_PIXELS8_Y2_EXACT 0
cglobal put_no_rnd_pixels8_y2_exact, 4,5
lea r4, [r2*3]
@@ -309,7 +309,7 @@ INIT_MMX 3dnow
PUT_NO_RND_PIXELS8_Y2_EXACT
-; avg_pixels8(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro AVG_PIXELS8 0
cglobal avg_pixels8, 4,5
lea r4, [r2*2]
@@ -339,7 +339,7 @@ INIT_MMX 3dnow
AVG_PIXELS8
-; avg_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro AVG_PIXELS8_X2 0
cglobal avg_pixels8_x2, 4,5
lea r4, [r2*2]
@@ -375,7 +375,7 @@ INIT_MMX 3dnow
AVG_PIXELS8_X2
-; avg_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro AVG_PIXELS8_Y2 0
cglobal avg_pixels8_y2, 4,5
lea r4, [r2*2]
@@ -417,7 +417,7 @@ INIT_MMX 3dnow
AVG_PIXELS8_Y2
-; avg_pixels8_xy2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_xy2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
%macro AVG_PIXELS8_XY2 0
cglobal avg_pixels8_xy2, 4,5
mova m6, [pb_1]
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.h b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.h
new file mode 100644
index 00000000000..bfa849c0cf2
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_HPELDSP_H
+#define AVCODEC_X86_HPELDSP_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+void ff_avg_pixels8_x2_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+void ff_avg_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_avg_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+void ff_put_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+void ff_put_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
+ ptrdiff_t line_size, int h);
+
+#endif /* AVCODEC_X86_HPELDSP_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_init.c
index 8ecf9091338..f860533f7e5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_init.c
@@ -1,5 +1,5 @@
/*
- * MMX optimized DSP utils
+ * SIMD-optimized halfpel functions
* Copyright (c) 2000, 2001 Fabrice Bellard
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
@@ -22,11 +22,15 @@
* MMX optimization by Nick Kurshev <nickols_k@mail.ru>
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
+#include "libavcodec/avcodec.h"
#include "libavcodec/hpeldsp.h"
-#include "dsputil_x86.h"
+#include "libavcodec/pixels.h"
+#include "fpel.h"
+#include "hpeldsp.h"
void ff_put_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h);
@@ -107,11 +111,11 @@ void ff_avg_pixels8_xy2_3dnow(uint8_t *block, const uint8_t *pixels,
#undef PAVGB
#undef STATIC
-PIXELS16(static, avg_no_rnd, , _y2, _mmx)
-PIXELS16(static, put_no_rnd, , _y2, _mmx)
+CALL_2X_PIXELS(avg_no_rnd_pixels16_y2_mmx, avg_no_rnd_pixels8_y2_mmx, 8)
+CALL_2X_PIXELS(put_no_rnd_pixels16_y2_mmx, put_no_rnd_pixels8_y2_mmx, 8)
-PIXELS16(static, avg_no_rnd, , _xy2, _mmx)
-PIXELS16(static, put_no_rnd, , _xy2, _mmx)
+CALL_2X_PIXELS(avg_no_rnd_pixels16_xy2_mmx, avg_no_rnd_pixels8_xy2_mmx, 8)
+CALL_2X_PIXELS(put_no_rnd_pixels16_xy2_mmx, put_no_rnd_pixels8_xy2_mmx, 8)
/***********************************/
/* MMX rounding */
@@ -124,26 +128,35 @@ PIXELS16(static, put_no_rnd, , _xy2, _mmx)
#include "hpeldsp_rnd_template.c"
#undef DEF
+#define DEF(x, y) ff_ ## x ## _ ## y ## _mmx
+#define STATIC
+
+#include "rnd_template.c"
+
+#undef DEF
#undef SET_RND
#undef PAVGBP
#undef PAVGB
-PIXELS16(static, avg, , _y2, _mmx)
-PIXELS16(static, put, , _y2, _mmx)
+CALL_2X_PIXELS(avg_pixels16_y2_mmx, avg_pixels8_y2_mmx, 8)
+CALL_2X_PIXELS(put_pixels16_y2_mmx, put_pixels8_y2_mmx, 8)
+
+CALL_2X_PIXELS_EXPORT(ff_avg_pixels16_xy2_mmx, ff_avg_pixels8_xy2_mmx, 8)
+CALL_2X_PIXELS_EXPORT(ff_put_pixels16_xy2_mmx, ff_put_pixels8_xy2_mmx, 8)
#endif /* HAVE_INLINE_ASM */
#if HAVE_YASM
-#define HPELDSP_AVG_PIXELS16(CPUEXT) \
- PIXELS16(static, put_no_rnd, ff_, _x2, CPUEXT) \
- PIXELS16(static, put, ff_, _y2, CPUEXT) \
- PIXELS16(static, put_no_rnd, ff_, _y2, CPUEXT) \
- PIXELS16(static, avg, ff_, , CPUEXT) \
- PIXELS16(static, avg, ff_, _x2, CPUEXT) \
- PIXELS16(static, avg, ff_, _y2, CPUEXT) \
- PIXELS16(static, avg, ff_, _xy2, CPUEXT)
+#define HPELDSP_AVG_PIXELS16(CPUEXT) \
+ CALL_2X_PIXELS(put_no_rnd_pixels16_x2 ## CPUEXT, ff_put_no_rnd_pixels8_x2 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(put_pixels16_y2 ## CPUEXT, ff_put_pixels8_y2 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(put_no_rnd_pixels16_y2 ## CPUEXT, ff_put_no_rnd_pixels8_y2 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(avg_pixels16 ## CPUEXT, ff_avg_pixels8 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(avg_pixels16_x2 ## CPUEXT, ff_avg_pixels8_x2 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(avg_pixels16_y2 ## CPUEXT, ff_avg_pixels8_y2 ## CPUEXT, 8) \
+ CALL_2X_PIXELS(avg_pixels16_xy2 ## CPUEXT, ff_avg_pixels8_xy2 ## CPUEXT, 8)
HPELDSP_AVG_PIXELS16(_3dnow)
HPELDSP_AVG_PIXELS16(_mmxext)
@@ -251,7 +264,7 @@ static void hpeldsp_init_sse2(HpelDSPContext *c, int flags, int cpu_flags)
#endif /* HAVE_SSE2_EXTERNAL */
}
-void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
+av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
{
int cpu_flags = av_get_cpu_flags();
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_mmx.c b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_mmx.c
index 50db36dc1b1..039ba776a23 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_mmx.c
@@ -24,7 +24,8 @@
#include <stdint.h>
#include "config.h"
-#include "dsputil_x86.h"
+#include "hpeldsp.h"
+#include "inline_asm.h"
#if HAVE_MMX_INLINE
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_rnd_template.c b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_rnd_template.c
index 94e06d820a4..c8a68fdf56b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_rnd_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/hpeldsp_rnd_template.c
@@ -1,5 +1,5 @@
/*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
+ * SIMD-optimized halfpel functions are compiled twice for rnd/no_rnd
* Copyright (c) 2000, 2001 Fabrice Bellard
* Copyright (c) 2003-2004 Michael Niedermayer <michaelni@gmx.at>
*
@@ -24,6 +24,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stddef.h>
+#include <stdint.h>
+
// put_pixels
static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
{
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/idct_sse2_xvid.c b/chromium/third_party/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
index af4790ca92c..a1810990cc4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
@@ -147,7 +147,7 @@ DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = {
#endif
-#define ROUND(x) "paddd "MANGLE(x)
+#define ROUND(x) "paddd "x
#define JZ(reg, to) \
"testl "reg","reg" \n\t" \
@@ -343,17 +343,17 @@ DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = {
"movdqa %%xmm6, 4*16("dct") \n\t" \
"movdqa "SREG2", 7*16("dct") \n\t"
-inline void ff_idct_xvid_sse2(short *block)
+av_extern_inline void ff_idct_xvid_sse2(short *block)
{
__asm__ volatile(
"movq "MANGLE(m127)", %%mm0 \n\t"
- iMTX_MULT("(%0)", MANGLE(iTab1), ROUND(walkenIdctRounders), PUT_EVEN(ROW0))
- iMTX_MULT("1*16(%0)", MANGLE(iTab2), ROUND(walkenIdctRounders+1*16), PUT_ODD(ROW1))
- iMTX_MULT("2*16(%0)", MANGLE(iTab3), ROUND(walkenIdctRounders+2*16), PUT_EVEN(ROW2))
+ iMTX_MULT("(%0)", MANGLE(iTab1), ROUND(MANGLE(walkenIdctRounders)), PUT_EVEN(ROW0))
+ iMTX_MULT("1*16(%0)", MANGLE(iTab2), ROUND("1*16+"MANGLE(walkenIdctRounders)), PUT_ODD(ROW1))
+ iMTX_MULT("2*16(%0)", MANGLE(iTab3), ROUND("2*16+"MANGLE(walkenIdctRounders)), PUT_EVEN(ROW2))
TEST_TWO_ROWS("3*16(%0)", "4*16(%0)", "%%eax", "%%ecx", CLEAR_ODD(ROW3), CLEAR_EVEN(ROW4))
JZ("%%eax", "1f")
- iMTX_MULT("3*16(%0)", MANGLE(iTab4), ROUND(walkenIdctRounders+3*16), PUT_ODD(ROW3))
+ iMTX_MULT("3*16(%0)", MANGLE(iTab4), ROUND("3*16+"MANGLE(walkenIdctRounders)), PUT_ODD(ROW3))
TEST_TWO_ROWS("5*16(%0)", "6*16(%0)", "%%eax", "%%edx", CLEAR_ODD(ROW5), CLEAR_EVEN(ROW6))
TEST_ONE_ROW("7*16(%0)", "%%esi", CLEAR_ODD(ROW7))
@@ -368,20 +368,20 @@ inline void ff_idct_xvid_sse2(short *block)
"2: \n\t"
iMTX_MULT("4*16(%0)", MANGLE(iTab1), "#", PUT_EVEN(ROW4))
"3: \n\t"
- iMTX_MULT("5*16(%0)", MANGLE(iTab4), ROUND(walkenIdctRounders+4*16), PUT_ODD(ROW5))
+ iMTX_MULT("5*16(%0)", MANGLE(iTab4), ROUND("4*16+"MANGLE(walkenIdctRounders)), PUT_ODD(ROW5))
JZ("%%edx", "1f")
"4: \n\t"
- iMTX_MULT("6*16(%0)", MANGLE(iTab3), ROUND(walkenIdctRounders+5*16), PUT_EVEN(ROW6))
+ iMTX_MULT("6*16(%0)", MANGLE(iTab3), ROUND("5*16+"MANGLE(walkenIdctRounders)), PUT_EVEN(ROW6))
JZ("%%esi", "1f")
"5: \n\t"
- iMTX_MULT("7*16(%0)", MANGLE(iTab2), ROUND(walkenIdctRounders+5*16), PUT_ODD(ROW7))
+ iMTX_MULT("7*16(%0)", MANGLE(iTab2), ROUND("5*16+"MANGLE(walkenIdctRounders)), PUT_ODD(ROW7))
#if ARCH_X86_32
iLLM_HEAD
#endif
iLLM_PASS("%0")
"6: \n\t"
: "+r"(block)
- :
+ : NAMED_CONSTRAINTS_ARRAY(m127,iTab1,walkenIdctRounders,iTab2,iTab3,iTab4,tan3,tan1,tan2,sqrt2)
: XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" ,
"%xmm4" , "%xmm5" , "%xmm6" , "%xmm7" ,)
#if ARCH_X86_64
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/imdct36.asm b/chromium/third_party/ffmpeg/libavcodec/x86/imdct36.asm
index d311fbe1a02..ce30b421036 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/imdct36.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/imdct36.asm
@@ -50,7 +50,7 @@ ps_cosh_sse3: dd 1.0, -0.50190991877167369479, 1.0, -5.73685662283492756461
dd 1.0, -0.51763809020504152469, 1.0, -1.93185165257813657349
dd 1.0, -0.55168895948124587824, -1.0, 1.18310079157624925896
dd 1.0, -0.61038729438072803416, -1.0, 0.87172339781054900991
- dd 1.0, 0.70710678118654752439, 0.0, 0.0
+ dd 1.0, -0.70710678118654752439, 0.0, 0.0
costabs: times 4 dd 0.98480773
times 4 dd 0.93969262
@@ -129,6 +129,19 @@ SECTION_TEXT
%endif
%endmacro
+%macro BUTTERF2 3
+%if cpuflag(sse3)
+ mulps %1, %1, [ps_cosh_sse3 + %3]
+ PSHUFD %2, %1, 0xe1
+ addsubps %1, %1, %2
+%else
+ mulps %1, [ps_cosh + %3]
+ PSHUFD %2, %1, 0xe1
+ xorps %1, [ps_p1m1p1m1]
+ addps %1, %2
+%endif
+%endmacro
+
%macro STORE 4
movhlps %2, %1
movss [%3 ], %1
@@ -279,11 +292,7 @@ cglobal imdct36_float, 4,4,9, out, buf, in, win
BUTTERF m7, m2, 16
BUTTERF m3, m6, 32
BUTTERF m4, m1, 48
-
- mulps m5, m5, [ps_cosh + 64]
- PSHUFD m1, m5, 0xe1
- xorps m5, m5, [ps_p1m1p1m1]
- addps m5, m5, m1
+ BUTTERF2 m5, m1, 64
; permutates:
; m0 0 1 2 3 => 2 6 10 14 m1
@@ -358,8 +367,10 @@ cglobal imdct36_float, 4,4,9, out, buf, in, win
RET
%endmacro
+%if ARCH_X86_32
INIT_XMM sse
DEFINE_IMDCT
+%endif
INIT_XMM sse2
DEFINE_IMDCT
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/inline_asm.h b/chromium/third_party/ffmpeg/libavcodec/x86/inline_asm.h
new file mode 100644
index 00000000000..c2f1bf0f9cf
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/inline_asm.h
@@ -0,0 +1,100 @@
+/*
+ * inline assembly helper macros
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_X86_INLINE_ASM_H
+#define AVCODEC_X86_INLINE_ASM_H
+
+#include "constants.h"
+
+#define MOVQ_WONE(regd) \
+ __asm__ volatile ( \
+ "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
+ "psrlw $15, %%" #regd ::)
+
+#define JUMPALIGN() __asm__ volatile (".p2align 3"::)
+#define MOVQ_ZERO(regd) __asm__ volatile ("pxor %%"#regd", %%"#regd ::)
+
+#define MOVQ_BFE(regd) \
+ __asm__ volatile ( \
+ "pcmpeqd %%"#regd", %%"#regd" \n\t" \
+ "paddb %%"#regd", %%"#regd" \n\t" ::)
+
+#ifndef PIC
+#define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_wtwo))
+#else
+// for shared library it's better to use this way for accessing constants
+// pcmpeqd -> -1
+#define MOVQ_WTWO(regd) \
+ __asm__ volatile ( \
+ "pcmpeqd %%"#regd", %%"#regd" \n\t" \
+ "psrlw $15, %%"#regd" \n\t" \
+ "psllw $1, %%"#regd" \n\t"::)
+
+#endif
+
+// using regr as temporary and for the output result
+// first argument is unmodifed and second is trashed
+// regfe is supposed to contain 0xfefefefefefefefe
+#define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \
+ "movq "#rega", "#regr" \n\t" \
+ "pand "#regb", "#regr" \n\t" \
+ "pxor "#rega", "#regb" \n\t" \
+ "pand "#regfe", "#regb" \n\t" \
+ "psrlq $1, "#regb" \n\t" \
+ "paddb "#regb", "#regr" \n\t"
+
+#define PAVGB_MMX(rega, regb, regr, regfe) \
+ "movq "#rega", "#regr" \n\t" \
+ "por "#regb", "#regr" \n\t" \
+ "pxor "#rega", "#regb" \n\t" \
+ "pand "#regfe", "#regb" \n\t" \
+ "psrlq $1, "#regb" \n\t" \
+ "psubb "#regb", "#regr" \n\t"
+
+// mm6 is supposed to contain 0xfefefefefefefefe
+#define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \
+ "movq "#rega", "#regr" \n\t" \
+ "movq "#regc", "#regp" \n\t" \
+ "pand "#regb", "#regr" \n\t" \
+ "pand "#regd", "#regp" \n\t" \
+ "pxor "#rega", "#regb" \n\t" \
+ "pxor "#regc", "#regd" \n\t" \
+ "pand %%mm6, "#regb" \n\t" \
+ "pand %%mm6, "#regd" \n\t" \
+ "psrlq $1, "#regb" \n\t" \
+ "psrlq $1, "#regd" \n\t" \
+ "paddb "#regb", "#regr" \n\t" \
+ "paddb "#regd", "#regp" \n\t"
+
+#define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \
+ "movq "#rega", "#regr" \n\t" \
+ "movq "#regc", "#regp" \n\t" \
+ "por "#regb", "#regr" \n\t" \
+ "por "#regd", "#regp" \n\t" \
+ "pxor "#rega", "#regb" \n\t" \
+ "pxor "#regc", "#regd" \n\t" \
+ "pand %%mm6, "#regb" \n\t" \
+ "pand %%mm6, "#regd" \n\t" \
+ "psrlq $1, "#regd" \n\t" \
+ "psrlq $1, "#regb" \n\t" \
+ "psubb "#regb", "#regr" \n\t" \
+ "psubb "#regd", "#regp" \n\t"
+
+#endif /* AVCODEC_X86_INLINE_ASM_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp.asm
new file mode 100644
index 00000000000..bacc1e927a8
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp.asm
@@ -0,0 +1,292 @@
+;******************************************************************************
+;* SIMD lossless video DSP utils
+;* Copyright (c) 2008 Loren Merritt
+;* Copyright (c) 2014 Michael Niedermayer
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pb_ef: times 8 db 14,15
+pb_67: times 8 db 6, 7
+pb_zzzz2323zzzzabab: db -1,-1,-1,-1, 2, 3, 2, 3,-1,-1,-1,-1,10,11,10,11
+pb_zzzzzzzz67676767: db -1,-1,-1,-1,-1,-1,-1,-1, 6, 7, 6, 7, 6, 7, 6, 7
+
+SECTION_TEXT
+
+%macro INT16_LOOP 2 ; %1 = a/u (aligned/unaligned), %2 = add/sub
+ movd m4, maskd
+ SPLATW m4, m4
+ add wd, wd
+ test wq, 2*mmsize - 1
+ jz %%.tomainloop
+%%.wordloop:
+ sub wq, 2
+%ifidn %2, add
+ mov ax, [srcq+wq]
+ add ax, [dstq+wq]
+%else
+ mov ax, [src1q+wq]
+ sub ax, [src2q+wq]
+%endif
+ and ax, maskw
+ mov [dstq+wq], ax
+ test wq, 2*mmsize - 1
+ jnz %%.wordloop
+%%.tomainloop:
+%ifidn %2, add
+ add srcq, wq
+%else
+ add src1q, wq
+ add src2q, wq
+%endif
+ add dstq, wq
+ neg wq
+ jz %%.end
+%%.loop:
+%ifidn %2, add
+ mov%1 m0, [srcq+wq]
+ mov%1 m1, [dstq+wq]
+ mov%1 m2, [srcq+wq+mmsize]
+ mov%1 m3, [dstq+wq+mmsize]
+%else
+ mov%1 m0, [src1q+wq]
+ mov%1 m1, [src2q+wq]
+ mov%1 m2, [src1q+wq+mmsize]
+ mov%1 m3, [src2q+wq+mmsize]
+%endif
+ p%2w m0, m1
+ p%2w m2, m3
+ pand m0, m4
+ pand m2, m4
+ mov%1 [dstq+wq] , m0
+ mov%1 [dstq+wq+mmsize], m2
+ add wq, 2*mmsize
+ jl %%.loop
+%%.end:
+ RET
+%endmacro
+
+INIT_MMX mmx
+cglobal add_int16, 4,4,5, dst, src, mask, w
+ INT16_LOOP a, add
+
+INIT_XMM sse2
+cglobal add_int16, 4,4,5, dst, src, mask, w
+ test srcq, mmsize-1
+ jnz .unaligned
+ test dstq, mmsize-1
+ jnz .unaligned
+ INT16_LOOP a, add
+.unaligned:
+ INT16_LOOP u, add
+
+INIT_MMX mmx
+cglobal diff_int16, 5,5,5, dst, src1, src2, mask, w
+ INT16_LOOP a, sub
+
+INIT_XMM sse2
+cglobal diff_int16, 5,5,5, dst, src1, src2, mask, w
+ test src1q, mmsize-1
+ jnz .unaligned
+ test src2q, mmsize-1
+ jnz .unaligned
+ test dstq, mmsize-1
+ jnz .unaligned
+ INT16_LOOP a, sub
+.unaligned:
+ INT16_LOOP u, sub
+
+
+%macro ADD_HFYU_LEFT_LOOP_INT16 2 ; %1 = dst alignment (a/u), %2 = src alignment (a/u)
+ add wd, wd
+ add srcq, wq
+ add dstq, wq
+ neg wq
+%%.loop:
+ mov%2 m1, [srcq+wq]
+ mova m2, m1
+ pslld m1, 16
+ paddw m1, m2
+ mova m2, m1
+
+ pshufb m1, m3
+ paddw m1, m2
+ pshufb m0, m5
+%if mmsize == 16
+ mova m2, m1
+ pshufb m1, m4
+ paddw m1, m2
+%endif
+ paddw m0, m1
+ pand m0, m7
+%ifidn %1, a
+ mova [dstq+wq], m0
+%else
+ movq [dstq+wq], m0
+ movhps [dstq+wq+8], m0
+%endif
+ add wq, mmsize
+ jl %%.loop
+ mov eax, mmsize-1
+ sub eax, wd
+ mov wd, eax
+ shl wd, 8
+ lea eax, [wd+eax-1]
+ movd m1, eax
+ pshufb m0, m1
+ movd eax, m0
+ RET
+%endmacro
+
+; int add_hfyu_left_prediction_int16(uint16_t *dst, const uint16_t *src, unsigned mask, int w, int left)
+INIT_MMX ssse3
+cglobal add_hfyu_left_prediction_int16, 4,4,8, dst, src, mask, w, left
+.skip_prologue:
+ mova m5, [pb_67]
+ mova m3, [pb_zzzz2323zzzzabab]
+ movd m0, leftm
+ psllq m0, 48
+ movd m7, maskm
+ SPLATW m7 ,m7
+ ADD_HFYU_LEFT_LOOP_INT16 a, a
+
+INIT_XMM sse4
+cglobal add_hfyu_left_prediction_int16, 4,4,8, dst, src, mask, w, left
+ mova m5, [pb_ef]
+ mova m4, [pb_zzzzzzzz67676767]
+ mova m3, [pb_zzzz2323zzzzabab]
+ movd m0, leftm
+ pslldq m0, 14
+ movd m7, maskm
+ SPLATW m7 ,m7
+ test srcq, 15
+ jnz .src_unaligned
+ test dstq, 15
+ jnz .dst_unaligned
+ ADD_HFYU_LEFT_LOOP_INT16 a, a
+.dst_unaligned:
+ ADD_HFYU_LEFT_LOOP_INT16 u, a
+.src_unaligned:
+ ADD_HFYU_LEFT_LOOP_INT16 u, u
+
+; void add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int mask, int w, int *left, int *left_top)
+INIT_MMX mmxext
+cglobal add_hfyu_median_prediction_int16, 7,7,0, dst, top, diff, mask, w, left, left_top
+ add wd, wd
+ movd mm6, maskd
+ SPLATW mm6, mm6
+ movq mm0, [topq]
+ movq mm2, mm0
+ movd mm4, [left_topq]
+ psllq mm2, 16
+ movq mm1, mm0
+ por mm4, mm2
+ movd mm3, [leftq]
+ psubw mm0, mm4 ; t-tl
+ add dstq, wq
+ add topq, wq
+ add diffq, wq
+ neg wq
+ jmp .skip
+.loop:
+ movq mm4, [topq+wq]
+ movq mm0, mm4
+ psllq mm4, 16
+ por mm4, mm1
+ movq mm1, mm0 ; t
+ psubw mm0, mm4 ; t-tl
+.skip:
+ movq mm2, [diffq+wq]
+%assign i 0
+%rep 4
+ movq mm4, mm0
+ paddw mm4, mm3 ; t-tl+l
+ pand mm4, mm6
+ movq mm5, mm3
+ pmaxsw mm3, mm1
+ pminsw mm5, mm1
+ pminsw mm3, mm4
+ pmaxsw mm3, mm5 ; median
+ paddw mm3, mm2 ; +residual
+ pand mm3, mm6
+%if i==0
+ movq mm7, mm3
+ psllq mm7, 48
+%else
+ movq mm4, mm3
+ psrlq mm7, 16
+ psllq mm4, 48
+ por mm7, mm4
+%endif
+%if i<3
+ psrlq mm0, 16
+ psrlq mm1, 16
+ psrlq mm2, 16
+%endif
+%assign i i+1
+%endrep
+ movq [dstq+wq], mm7
+ add wq, 8
+ jl .loop
+ movzx r2d, word [dstq-2]
+ mov [leftq], r2d
+ movzx r2d, word [topq-2]
+ mov [left_topq], r2d
+ RET
+
+cglobal sub_hfyu_median_prediction_int16, 7,7,0, dst, src1, src2, mask, w, left, left_top
+ add wd, wd
+ movd mm7, maskd
+ SPLATW mm7, mm7
+ movq mm0, [src1q]
+ movq mm2, [src2q]
+ psllq mm0, 16
+ psllq mm2, 16
+ movd mm6, [left_topq]
+ por mm0, mm6
+ movd mm6, [leftq]
+ por mm2, mm6
+ xor maskq, maskq
+.loop:
+ movq mm1, [src1q + maskq]
+ movq mm3, [src2q + maskq]
+ movq mm4, mm2
+ psubw mm2, mm0
+ paddw mm2, mm1
+ pand mm2, mm7
+ movq mm5, mm4
+ pmaxsw mm4, mm1
+ pminsw mm1, mm5
+ pminsw mm4, mm2
+ pmaxsw mm4, mm1
+ psubw mm3, mm4
+ pand mm3, mm7
+ movq [dstq + maskq], mm3
+ add maskq, 8
+ movq mm0, [src1q + maskq - 2]
+ movq mm2, [src2q + maskq - 2]
+ cmp maskq, wq
+ jb .loop
+ mov maskd, [src1q + wq - 2]
+ mov [left_topq], maskd
+ mov maskd, [src2q + wq - 2]
+ mov [leftq], maskd
+ RET
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp_init.c
new file mode 100644
index 00000000000..52802e9edff
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/lossless_videodsp_init.c
@@ -0,0 +1,62 @@
+/*
+ * Lossless video DSP utils
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../lossless_videodsp.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/x86/cpu.h"
+
+void ff_add_int16_mmx(uint16_t *dst, const uint16_t *src, unsigned mask, int w);
+void ff_add_int16_sse2(uint16_t *dst, const uint16_t *src, unsigned mask, int w);
+void ff_diff_int16_mmx (uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w);
+void ff_diff_int16_sse2(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w);
+int ff_add_hfyu_left_prediction_int16_ssse3(uint16_t *dst, const uint16_t *src, unsigned mask, int w, unsigned acc);
+int ff_add_hfyu_left_prediction_int16_sse4(uint16_t *dst, const uint16_t *src, unsigned mask, int w, unsigned acc);
+void ff_add_hfyu_median_prediction_int16_mmxext(uint16_t *dst, const uint16_t *top, const uint16_t *diff, unsigned mask, int w, int *left, int *left_top);
+void ff_sub_hfyu_median_prediction_int16_mmxext(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w, int *left, int *left_top);
+
+
+void ff_llviddsp_init_x86(LLVidDSPContext *c, AVCodecContext *avctx)
+{
+ int cpu_flags = av_get_cpu_flags();
+ const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+
+ if (EXTERNAL_MMX(cpu_flags)) {
+ c->add_int16 = ff_add_int16_mmx;
+ c->diff_int16 = ff_diff_int16_mmx;
+ }
+
+ if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc->comp[0].depth_minus1<15) {
+ c->add_hfyu_median_prediction_int16 = ff_add_hfyu_median_prediction_int16_mmxext;
+ c->sub_hfyu_median_prediction_int16 = ff_sub_hfyu_median_prediction_int16_mmxext;
+ }
+
+ if (EXTERNAL_SSE2(cpu_flags)) {
+ c->add_int16 = ff_add_int16_sse2;
+ c->diff_int16 = ff_diff_int16_sse2;
+ }
+
+ if (EXTERNAL_SSSE3(cpu_flags)) {
+ c->add_hfyu_left_prediction_int16 = ff_add_hfyu_left_prediction_int16_ssse3;
+ }
+
+ if (EXTERNAL_SSE4(cpu_flags)) {
+ c->add_hfyu_left_prediction_int16 = ff_add_hfyu_left_prediction_int16_sse4;
+ }
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/lpc.c b/chromium/third_party/ffmpeg/libavcodec/x86/lpc.c
index 8a74755d1b2..3a9493f7284 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/lpc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/lpc.c
@@ -1,5 +1,5 @@
/*
- * MMX optimized LPC DSP utils
+ * SIMD-optimized LPC functions
* Copyright (c) 2007 Loren Merritt
*
* This file is part of FFmpeg.
@@ -72,6 +72,7 @@ static void lpc_apply_welch_window_sse2(const int32_t *data, int len,
"3: \n\t"
:"+&r"(i), "+&r"(j)
:"r"(w_data+n2), "r"(data+n2), "m"(c), "r"(len)
+ NAMED_CONSTRAINTS_ARRAY_ADD(pd_1,pd_2)
XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
"%xmm5", "%xmm6", "%xmm7")
);
@@ -116,6 +117,7 @@ static void lpc_compute_autocorr_sse2(const double *data, int len, int lag,
"movsd %%xmm2, 16(%1) \n\t"
:"+&r"(i)
:"r"(autoc+j), "r"(data+len), "r"(data+len-j)
+ NAMED_CONSTRAINTS_ARRAY_ADD(pd_1)
:"memory"
);
} else {
@@ -139,6 +141,7 @@ static void lpc_compute_autocorr_sse2(const double *data, int len, int lag,
"movsd %%xmm1, %2 \n\t"
:"+&r"(i), "=m"(autoc[j]), "=m"(autoc[j+1])
:"r"(data+len), "r"(data+len-j)
+ NAMED_CONSTRAINTS_ARRAY_ADD(pd_1)
);
}
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h b/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h
index 9c48afeb209..1cca05d658c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h
@@ -24,6 +24,7 @@
#include "config.h"
#include "libavutil/common.h"
+#include "libavutil/x86/asm.h"
#if HAVE_INLINE_ASM
@@ -88,6 +89,7 @@ static inline av_const int mid_pred(int a, int b, int c)
return i;
}
+#if HAVE_6REGS
#define COPY3_IF_LT(x, y, a, b, c, d)\
__asm__ volatile(\
"cmpl %0, %3 \n\t"\
@@ -97,10 +99,11 @@ __asm__ volatile(\
: "+&r" (x), "+&r" (a), "+r" (c)\
: "r" (y), "r" (b), "r" (d)\
);
+#endif /* HAVE_6REGS */
#endif /* HAVE_I686 */
#define MASK_ABS(mask, level) \
- __asm__ ("cltd \n\t" \
+ __asm__ ("cdq \n\t" \
"xorl %1, %0 \n\t" \
"subl %1, %0 \n\t" \
: "+a"(level), "=&d"(mask))
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mlpdsp.c b/chromium/third_party/ffmpeg/libavcodec/x86/mlpdsp.c
index 94849b7e791..b473625fb7d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mlpdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mlpdsp.c
@@ -26,7 +26,7 @@
#include "libavcodec/mlpdsp.h"
#include "libavcodec/mlp.h"
-#if HAVE_7REGS && HAVE_INLINE_ASM
+#if HAVE_7REGS && HAVE_INLINE_ASM && HAVE_INLINE_ASM_NONLOCAL_LABELS
extern char ff_mlp_firorder_8;
extern char ff_mlp_firorder_7;
@@ -178,7 +178,7 @@ static void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff,
av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c)
{
-#if HAVE_7REGS && HAVE_INLINE_ASM
+#if HAVE_7REGS && HAVE_INLINE_ASM && HAVE_INLINE_ASM_NONLOCAL_LABELS
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags))
c->mlp_filter_channel = mlp_filter_channel_x86;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/motion_est.c b/chromium/third_party/ffmpeg/libavcodec/x86/motion_est.c
index 5f5d93e9bcf..f1e782b23d5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/motion_est.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/motion_est.c
@@ -27,22 +27,23 @@
#include "libavutil/mem.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
+#include "libavcodec/mpegvideo.h"
#include "dsputil_x86.h"
#if HAVE_INLINE_ASM
-DECLARE_ASM_CONST(8, uint64_t, round_tab)[3]={
-0x0000000000000000ULL,
-0x0001000100010001ULL,
-0x0002000200020002ULL,
+DECLARE_ASM_CONST(8, uint64_t, round_tab)[3] = {
+ 0x0000000000000000ULL,
+ 0x0001000100010001ULL,
+ 0x0002000200020002ULL,
};
-DECLARE_ASM_CONST(8, uint64_t, bone)= 0x0101010101010101LL;
+DECLARE_ASM_CONST(8, uint64_t, bone) = 0x0101010101010101LL;
static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
- x86_reg len= -(x86_reg)stride*h;
- __asm__ volatile(
+ x86_reg len = -(x86_reg)stride * h;
+ __asm__ volatile (
".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
@@ -71,14 +72,13 @@ static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"add %3, %%"REG_a" \n\t"
" js 1b \n\t"
: "+a" (len)
- : "r" (blk1 - len), "r" (blk2 - len), "r" ((x86_reg)stride)
- );
+ : "r" (blk1 - len), "r" (blk2 - len), "r" ((x86_reg) stride));
}
static inline void sad8_1_mmxext(uint8_t *blk1, uint8_t *blk2,
int stride, int h)
{
- __asm__ volatile(
+ __asm__ volatile (
".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
@@ -92,14 +92,14 @@ static inline void sad8_1_mmxext(uint8_t *blk1, uint8_t *blk2,
"sub $2, %0 \n\t"
" jg 1b \n\t"
: "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
+ : "r" ((x86_reg) stride));
}
-static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
+static int sad16_sse2(MpegEncContext *v, uint8_t *blk2, uint8_t *blk1,
+ int stride, int h)
{
int ret;
- __asm__ volatile(
+ __asm__ volatile (
"pxor %%xmm2, %%xmm2 \n\t"
".p2align 4 \n\t"
"1: \n\t"
@@ -116,16 +116,15 @@ static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
"movhlps %%xmm2, %%xmm0 \n\t"
"paddw %%xmm0, %%xmm2 \n\t"
"movd %%xmm2, %3 \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2), "=r"(ret)
- : "r" ((x86_reg)stride)
- );
+ : "+r" (h), "+r" (blk1), "+r" (blk2), "=r" (ret)
+ : "r" ((x86_reg) stride));
return ret;
}
static inline void sad8_x2a_mmxext(uint8_t *blk1, uint8_t *blk2,
int stride, int h)
{
- __asm__ volatile(
+ __asm__ volatile (
".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
@@ -141,14 +140,13 @@ static inline void sad8_x2a_mmxext(uint8_t *blk1, uint8_t *blk2,
"sub $2, %0 \n\t"
" jg 1b \n\t"
: "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
+ : "r" ((x86_reg) stride));
}
static inline void sad8_y2a_mmxext(uint8_t *blk1, uint8_t *blk2,
int stride, int h)
{
- __asm__ volatile(
+ __asm__ volatile (
"movq (%1), %%mm0 \n\t"
"add %3, %1 \n\t"
".p2align 4 \n\t"
@@ -167,14 +165,13 @@ static inline void sad8_y2a_mmxext(uint8_t *blk1, uint8_t *blk2,
"sub $2, %0 \n\t"
" jg 1b \n\t"
: "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
+ : "r" ((x86_reg) stride));
}
static inline void sad8_4_mmxext(uint8_t *blk1, uint8_t *blk2,
int stride, int h)
{
- __asm__ volatile(
+ __asm__ volatile (
"movq "MANGLE(bone)", %%mm5 \n\t"
"movq (%1), %%mm0 \n\t"
"pavgb 1(%1), %%mm0 \n\t"
@@ -198,14 +195,15 @@ static inline void sad8_4_mmxext(uint8_t *blk1, uint8_t *blk2,
"sub $2, %0 \n\t"
" jg 1b \n\t"
: "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
+ : "r" ((x86_reg) stride)
+ NAMED_CONSTRAINTS_ADD(bone));
}
-static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
+static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2,
+ int stride, int h)
{
- x86_reg len= -(x86_reg)stride*h;
- __asm__ volatile(
+ x86_reg len = -(x86_reg)stride * h;
+ __asm__ volatile (
".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
@@ -236,15 +234,15 @@ static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int
"add %4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+a" (len)
- : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((x86_reg)stride)
- );
+ : "r" (blk1a - len), "r" (blk1b - len), "r" (blk2 - len),
+ "r" ((x86_reg) stride));
}
static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
- x86_reg len= -(x86_reg)stride*h;
- __asm__ volatile(
- "movq (%1, %%"REG_a"), %%mm0 \n\t"
+ x86_reg len = -(x86_reg)stride * h;
+ __asm__ volatile (
+ "movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
@@ -256,7 +254,7 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"paddw %%mm3, %%mm1 \n\t"
".p2align 4 \n\t"
"1: \n\t"
- "movq (%2, %%"REG_a"), %%mm2 \n\t"
+ "movq (%2, %%"REG_a"), %%mm2 \n\t"
"movq 1(%2, %%"REG_a"), %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
@@ -266,7 +264,7 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"punpckhbw %%mm7, %%mm5 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"paddw %%mm5, %%mm3 \n\t"
- "movq 16+"MANGLE(round_tab)", %%mm5 \n\t"
+ "movq %5, %%mm5 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"paddw %%mm3, %%mm1 \n\t"
"paddw %%mm5, %%mm0 \n\t"
@@ -289,14 +287,14 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"add %4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+a" (len)
- : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((x86_reg)stride)
- );
+ : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len),
+ "r" ((x86_reg) stride), "m" (round_tab[2]));
}
static inline int sum_mmx(void)
{
int ret;
- __asm__ volatile(
+ __asm__ volatile (
"movq %%mm6, %%mm0 \n\t"
"psrlq $32, %%mm6 \n\t"
"paddw %%mm0, %%mm6 \n\t"
@@ -304,129 +302,145 @@ static inline int sum_mmx(void)
"psrlq $16, %%mm6 \n\t"
"paddw %%mm0, %%mm6 \n\t"
"movd %%mm6, %0 \n\t"
- : "=r" (ret)
- );
- return ret&0xFFFF;
+ : "=r" (ret));
+ return ret & 0xFFFF;
}
static inline int sum_mmxext(void)
{
int ret;
- __asm__ volatile(
+ __asm__ volatile (
"movd %%mm6, %0 \n\t"
- : "=r" (ret)
- );
+ : "=r" (ret));
return ret;
}
static inline void sad8_x2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
- sad8_2_mmx(blk1, blk1+1, blk2, stride, h);
+ sad8_2_mmx(blk1, blk1 + 1, blk2, stride, h);
}
+
static inline void sad8_y2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
- sad8_2_mmx(blk1, blk1+stride, blk2, stride, h);
+ sad8_2_mmx(blk1, blk1 + stride, blk2, stride, h);
}
-
-#define PIX_SAD(suf)\
-static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- av_assert2(h==8);\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t":);\
-\
- sad8_1_ ## suf(blk1, blk2, stride, 8);\
-\
- return sum_ ## suf();\
-}\
-static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- av_assert2(h==8);\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "movq %0, %%mm5 \n\t"\
- :: "m"(round_tab[1]) \
- );\
-\
- sad8_x2a_ ## suf(blk1, blk2, stride, 8);\
-\
- return sum_ ## suf();\
-}\
-\
-static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- av_assert2(h==8);\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "movq %0, %%mm5 \n\t"\
- :: "m"(round_tab[1]) \
- );\
-\
- sad8_y2a_ ## suf(blk1, blk2, stride, 8);\
-\
- return sum_ ## suf();\
-}\
-\
-static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- av_assert2(h==8);\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- ::);\
-\
- sad8_4_ ## suf(blk1, blk2, stride, 8);\
-\
- return sum_ ## suf();\
-}\
-\
-static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t":);\
-\
- sad8_1_ ## suf(blk1 , blk2 , stride, h);\
- sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\
-\
- return sum_ ## suf();\
-}\
-static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "movq %0, %%mm5 \n\t"\
- :: "m"(round_tab[1]) \
- );\
-\
- sad8_x2a_ ## suf(blk1 , blk2 , stride, h);\
- sad8_x2a_ ## suf(blk1+8, blk2+8, stride, h);\
-\
- return sum_ ## suf();\
-}\
-static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "movq %0, %%mm5 \n\t"\
- :: "m"(round_tab[1]) \
- );\
-\
- sad8_y2a_ ## suf(blk1 , blk2 , stride, h);\
- sad8_y2a_ ## suf(blk1+8, blk2+8, stride, h);\
-\
- return sum_ ## suf();\
-}\
-static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
- __asm__ volatile("pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- ::);\
-\
- sad8_4_ ## suf(blk1 , blk2 , stride, h);\
- sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\
-\
- return sum_ ## suf();\
-}\
+#define PIX_SAD(suf) \
+static int sad8_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ av_assert2(h == 8); \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ :); \
+ \
+ sad8_1_ ## suf(blk1, blk2, stride, 8); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad8_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ av_assert2(h == 8); \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ "movq %0, %%mm5 \n\t" \
+ :: "m" (round_tab[1])); \
+ \
+ sad8_x2a_ ## suf(blk1, blk2, stride, 8); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad8_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ av_assert2(h == 8); \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ "movq %0, %%mm5 \n\t" \
+ :: "m" (round_tab[1])); \
+ \
+ sad8_y2a_ ## suf(blk1, blk2, stride, 8); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ av_assert2(h == 8); \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ ::); \
+ \
+ sad8_4_ ## suf(blk1, blk2, stride, 8); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad16_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ :); \
+ \
+ sad8_1_ ## suf(blk1, blk2, stride, h); \
+ sad8_1_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad16_x2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ "movq %0, %%mm5 \n\t" \
+ :: "m" (round_tab[1])); \
+ \
+ sad8_x2a_ ## suf(blk1, blk2, stride, h); \
+ sad8_x2a_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad16_y2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ "movq %0, %%mm5 \n\t" \
+ :: "m" (round_tab[1])); \
+ \
+ sad8_y2a_ ## suf(blk1, blk2, stride, h); \
+ sad8_y2a_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
+ \
+ return sum_ ## suf(); \
+} \
+ \
+static int sad16_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2, \
+ uint8_t *blk1, int stride, int h) \
+{ \
+ __asm__ volatile ( \
+ "pxor %%mm7, %%mm7 \n\t" \
+ "pxor %%mm6, %%mm6 \n\t" \
+ ::); \
+ \
+ sad8_4_ ## suf(blk1, blk2, stride, h); \
+ sad8_4_ ## suf(blk1 + 8, blk2 + 8, stride, h); \
+ \
+ return sum_ ## suf(); \
+} \
PIX_SAD(mmx)
PIX_SAD(mmxext)
@@ -448,17 +462,17 @@ av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
c->pix_abs[1][2] = sad8_y2_mmx;
c->pix_abs[1][3] = sad8_xy2_mmx;
- c->sad[0]= sad16_mmx;
- c->sad[1]= sad8_mmx;
+ c->sad[0] = sad16_mmx;
+ c->sad[1] = sad8_mmx;
}
if (INLINE_MMXEXT(cpu_flags)) {
c->pix_abs[0][0] = sad16_mmxext;
c->pix_abs[1][0] = sad8_mmxext;
- c->sad[0] = sad16_mmxext;
- c->sad[1] = sad8_mmxext;
+ c->sad[0] = sad16_mmxext;
+ c->sad[1] = sad8_mmxext;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->pix_abs[0][1] = sad16_x2_mmxext;
c->pix_abs[0][2] = sad16_y2_mmxext;
c->pix_abs[0][3] = sad16_xy2_mmxext;
@@ -468,7 +482,7 @@ av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
}
}
if (INLINE_SSE2(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_3DNOW) && avctx->codec_id != AV_CODEC_ID_SNOW) {
- c->sad[0]= sad16_sse2;
+ c->sad[0] = sad16_sse2;
}
#endif /* HAVE_INLINE_ASM */
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mpeg4qpel.asm b/chromium/third_party/ffmpeg/libavcodec/x86/mpeg4qpel.asm
index ca52375a760..dc0f900c5bd 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mpeg4qpel.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mpeg4qpel.asm
@@ -33,7 +33,7 @@ cextern pw_20
SECTION_TEXT
-; put_no_rnd_pixels8_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put_no_rnd_pixels8_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
%macro PUT_NO_RND_PIXELS8_L2 0
cglobal put_no_rnd_pixels8_l2, 6,6
movsxdifnidn r4, r4d
@@ -99,7 +99,7 @@ INIT_MMX mmxext
PUT_NO_RND_PIXELS8_L2
-; put_no_rnd_pixels16_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put_no_rnd_pixels16_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
%macro PUT_NO_RND_PIXELS16_l2 0
cglobal put_no_rnd_pixels16_l2, 6,6
movsxdifnidn r3, r3d
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mpegaudiodsp.c b/chromium/third_party/ffmpeg/libavcodec/x86/mpegaudiodsp.c
index 9c6f7950a5d..27231674ae7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mpegaudiodsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mpegaudiodsp.c
@@ -1,5 +1,5 @@
/*
- * MMX optimized MP3 decoding functions
+ * SIMD-optimized MP3 decoding functions
* Copyright (c) 2010 Vitor Sessak
*
* This file is part of FFmpeg.
@@ -30,7 +30,9 @@
static void imdct36_blocks_ ## CPU(float *out, float *buf, float *in, int count, int switch_point, int block_type);\
void ff_imdct36_float_ ## CPU(float *out, float *buf, float *in, float *win);
+#if ARCH_X86_32
DECL(sse)
+#endif
DECL(sse2)
DECL(sse3)
DECL(ssse3)
@@ -43,7 +45,7 @@ void ff_four_imdct36_float_avx(float *out, float *buf, float *in, float *win,
DECLARE_ALIGNED(16, static float, mdct_win_sse)[2][4][4*40];
-#if HAVE_SSE2_INLINE
+#if HAVE_6REGS && HAVE_SSE_INLINE
#define MACS(rt, ra, rb) rt+=(ra)*(rb)
#define MLSS(rt, ra, rb) rt-=(ra)*(rb)
@@ -187,7 +189,7 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out,
*out = sum;
}
-#endif /* HAVE_SSE2_INLINE */
+#endif /* HAVE_6REGS && HAVE_SSE_INLINE */
#if HAVE_YASM
#define DECL_IMDCT_BLOCKS(CPU1, CPU2) \
@@ -223,7 +225,9 @@ static void imdct36_blocks_ ## CPU1(float *out, float *buf, float *in, \
}
#if HAVE_SSE
+#if ARCH_X86_32
DECL_IMDCT_BLOCKS(sse,sse)
+#endif
DECL_IMDCT_BLOCKS(sse2,sse)
DECL_IMDCT_BLOCKS(sse3,sse)
DECL_IMDCT_BLOCKS(ssse3,sse)
@@ -251,16 +255,19 @@ av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
}
}
-#if HAVE_SSE2_INLINE
- if (cpu_flags & AV_CPU_FLAG_SSE2) {
+#if HAVE_6REGS && HAVE_SSE_INLINE
+ if (INLINE_SSE(cpu_flags)) {
s->apply_window_float = apply_window_mp3;
}
-#endif /* HAVE_SSE2_INLINE */
+#endif /* HAVE_SSE_INLINE */
#if HAVE_YASM
+#if HAVE_SSE
+#if ARCH_X86_32
if (EXTERNAL_SSE(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse;
}
+#endif
if (EXTERNAL_SSE2(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse2;
}
@@ -270,8 +277,11 @@ av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
if (EXTERNAL_SSSE3(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_ssse3;
}
+#endif
+#if HAVE_AVX_EXTERNAL
if (EXTERNAL_AVX(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_avx;
}
+#endif
#endif /* HAVE_YASM */
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideo.c b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideo.c
index cee3d5f7df1..9353a829338 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideo.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideo.c
@@ -25,7 +25,6 @@
#include "libavutil/x86/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/mpegvideo.h"
-#include "dsputil_x86.h"
#if HAVE_MMX_INLINE
@@ -443,116 +442,6 @@ __asm__ volatile(
);
}
-static void denoise_dct_mmx(MpegEncContext *s, int16_t *block){
- const int intra= s->mb_intra;
- int *sum= s->dct_error_sum[intra];
- uint16_t *offset= s->dct_offset[intra];
-
- s->dct_count[intra]++;
-
- __asm__ volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "1: \n\t"
- "pxor %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "movq (%0), %%mm2 \n\t"
- "movq 8(%0), %%mm3 \n\t"
- "pcmpgtw %%mm2, %%mm0 \n\t"
- "pcmpgtw %%mm3, %%mm1 \n\t"
- "pxor %%mm0, %%mm2 \n\t"
- "pxor %%mm1, %%mm3 \n\t"
- "psubw %%mm0, %%mm2 \n\t"
- "psubw %%mm1, %%mm3 \n\t"
- "movq %%mm2, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psubusw (%2), %%mm2 \n\t"
- "psubusw 8(%2), %%mm3 \n\t"
- "pxor %%mm0, %%mm2 \n\t"
- "pxor %%mm1, %%mm3 \n\t"
- "psubw %%mm0, %%mm2 \n\t"
- "psubw %%mm1, %%mm3 \n\t"
- "movq %%mm2, (%0) \n\t"
- "movq %%mm3, 8(%0) \n\t"
- "movq %%mm4, %%mm2 \n\t"
- "movq %%mm5, %%mm3 \n\t"
- "punpcklwd %%mm7, %%mm4 \n\t"
- "punpckhwd %%mm7, %%mm2 \n\t"
- "punpcklwd %%mm7, %%mm5 \n\t"
- "punpckhwd %%mm7, %%mm3 \n\t"
- "paddd (%1), %%mm4 \n\t"
- "paddd 8(%1), %%mm2 \n\t"
- "paddd 16(%1), %%mm5 \n\t"
- "paddd 24(%1), %%mm3 \n\t"
- "movq %%mm4, (%1) \n\t"
- "movq %%mm2, 8(%1) \n\t"
- "movq %%mm5, 16(%1) \n\t"
- "movq %%mm3, 24(%1) \n\t"
- "add $16, %0 \n\t"
- "add $32, %1 \n\t"
- "add $16, %2 \n\t"
- "cmp %3, %0 \n\t"
- " jb 1b \n\t"
- : "+r" (block), "+r" (sum), "+r" (offset)
- : "r"(block+64)
- );
-}
-
-static void denoise_dct_sse2(MpegEncContext *s, int16_t *block){
- const int intra= s->mb_intra;
- int *sum= s->dct_error_sum[intra];
- uint16_t *offset= s->dct_offset[intra];
-
- s->dct_count[intra]++;
-
- __asm__ volatile(
- "pxor %%xmm7, %%xmm7 \n\t"
- "1: \n\t"
- "pxor %%xmm0, %%xmm0 \n\t"
- "pxor %%xmm1, %%xmm1 \n\t"
- "movdqa (%0), %%xmm2 \n\t"
- "movdqa 16(%0), %%xmm3 \n\t"
- "pcmpgtw %%xmm2, %%xmm0 \n\t"
- "pcmpgtw %%xmm3, %%xmm1 \n\t"
- "pxor %%xmm0, %%xmm2 \n\t"
- "pxor %%xmm1, %%xmm3 \n\t"
- "psubw %%xmm0, %%xmm2 \n\t"
- "psubw %%xmm1, %%xmm3 \n\t"
- "movdqa %%xmm2, %%xmm4 \n\t"
- "movdqa %%xmm3, %%xmm5 \n\t"
- "psubusw (%2), %%xmm2 \n\t"
- "psubusw 16(%2), %%xmm3 \n\t"
- "pxor %%xmm0, %%xmm2 \n\t"
- "pxor %%xmm1, %%xmm3 \n\t"
- "psubw %%xmm0, %%xmm2 \n\t"
- "psubw %%xmm1, %%xmm3 \n\t"
- "movdqa %%xmm2, (%0) \n\t"
- "movdqa %%xmm3, 16(%0) \n\t"
- "movdqa %%xmm4, %%xmm6 \n\t"
- "movdqa %%xmm5, %%xmm0 \n\t"
- "punpcklwd %%xmm7, %%xmm4 \n\t"
- "punpckhwd %%xmm7, %%xmm6 \n\t"
- "punpcklwd %%xmm7, %%xmm5 \n\t"
- "punpckhwd %%xmm7, %%xmm0 \n\t"
- "paddd (%1), %%xmm4 \n\t"
- "paddd 16(%1), %%xmm6 \n\t"
- "paddd 32(%1), %%xmm5 \n\t"
- "paddd 48(%1), %%xmm0 \n\t"
- "movdqa %%xmm4, (%1) \n\t"
- "movdqa %%xmm6, 16(%1) \n\t"
- "movdqa %%xmm5, 32(%1) \n\t"
- "movdqa %%xmm0, 48(%1) \n\t"
- "add $32, %0 \n\t"
- "add $64, %1 \n\t"
- "add $32, %2 \n\t"
- "cmp %3, %0 \n\t"
- " jb 1b \n\t"
- : "+r" (block), "+r" (sum), "+r" (offset)
- : "r"(block+64)
- XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
- "%xmm4", "%xmm5", "%xmm6", "%xmm7")
- );
-}
-
#endif /* HAVE_MMX_INLINE */
av_cold void ff_MPV_common_init_x86(MpegEncContext *s)
@@ -568,10 +457,6 @@ av_cold void ff_MPV_common_init_x86(MpegEncContext *s)
if(!(s->flags & CODEC_FLAG_BITEXACT))
s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx;
s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx;
- s->denoise_dct = denoise_dct_mmx;
- }
- if (INLINE_SSE2(cpu_flags)) {
- s->denoise_dct = denoise_dct_sse2;
}
#endif /* HAVE_MMX_INLINE */
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc.c b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc.c
index 77fc1635950..f14a268ce0a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc.c
@@ -26,11 +26,12 @@
#include "libavcodec/avcodec.h"
#include "libavcodec/dct.h"
#include "libavcodec/mpegvideo.h"
-#include "dsputil_x86.h"
/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
DECLARE_ALIGNED(16, static uint16_t, inv_zigzag_direct16)[64];
+#if HAVE_6REGS
+
#if HAVE_MMX_INLINE
#define COMPILE_TEMPLATE_MMXEXT 0
#define COMPILE_TEMPLATE_SSE2 0
@@ -82,6 +83,120 @@ DECLARE_ALIGNED(16, static uint16_t, inv_zigzag_direct16)[64];
#include "mpegvideoenc_template.c"
#endif /* HAVE_SSSE3_INLINE */
+#endif /* HAVE_6REGS */
+
+#if HAVE_INLINE_ASM
+static void denoise_dct_mmx(MpegEncContext *s, int16_t *block){
+ const int intra= s->mb_intra;
+ int *sum= s->dct_error_sum[intra];
+ uint16_t *offset= s->dct_offset[intra];
+
+ s->dct_count[intra]++;
+
+ __asm__ volatile(
+ "pxor %%mm7, %%mm7 \n\t"
+ "1: \n\t"
+ "pxor %%mm0, %%mm0 \n\t"
+ "pxor %%mm1, %%mm1 \n\t"
+ "movq (%0), %%mm2 \n\t"
+ "movq 8(%0), %%mm3 \n\t"
+ "pcmpgtw %%mm2, %%mm0 \n\t"
+ "pcmpgtw %%mm3, %%mm1 \n\t"
+ "pxor %%mm0, %%mm2 \n\t"
+ "pxor %%mm1, %%mm3 \n\t"
+ "psubw %%mm0, %%mm2 \n\t"
+ "psubw %%mm1, %%mm3 \n\t"
+ "movq %%mm2, %%mm4 \n\t"
+ "movq %%mm3, %%mm5 \n\t"
+ "psubusw (%2), %%mm2 \n\t"
+ "psubusw 8(%2), %%mm3 \n\t"
+ "pxor %%mm0, %%mm2 \n\t"
+ "pxor %%mm1, %%mm3 \n\t"
+ "psubw %%mm0, %%mm2 \n\t"
+ "psubw %%mm1, %%mm3 \n\t"
+ "movq %%mm2, (%0) \n\t"
+ "movq %%mm3, 8(%0) \n\t"
+ "movq %%mm4, %%mm2 \n\t"
+ "movq %%mm5, %%mm3 \n\t"
+ "punpcklwd %%mm7, %%mm4 \n\t"
+ "punpckhwd %%mm7, %%mm2 \n\t"
+ "punpcklwd %%mm7, %%mm5 \n\t"
+ "punpckhwd %%mm7, %%mm3 \n\t"
+ "paddd (%1), %%mm4 \n\t"
+ "paddd 8(%1), %%mm2 \n\t"
+ "paddd 16(%1), %%mm5 \n\t"
+ "paddd 24(%1), %%mm3 \n\t"
+ "movq %%mm4, (%1) \n\t"
+ "movq %%mm2, 8(%1) \n\t"
+ "movq %%mm5, 16(%1) \n\t"
+ "movq %%mm3, 24(%1) \n\t"
+ "add $16, %0 \n\t"
+ "add $32, %1 \n\t"
+ "add $16, %2 \n\t"
+ "cmp %3, %0 \n\t"
+ " jb 1b \n\t"
+ : "+r" (block), "+r" (sum), "+r" (offset)
+ : "r"(block+64)
+ );
+}
+
+static void denoise_dct_sse2(MpegEncContext *s, int16_t *block){
+ const int intra= s->mb_intra;
+ int *sum= s->dct_error_sum[intra];
+ uint16_t *offset= s->dct_offset[intra];
+
+ s->dct_count[intra]++;
+
+ __asm__ volatile(
+ "pxor %%xmm7, %%xmm7 \n\t"
+ "1: \n\t"
+ "pxor %%xmm0, %%xmm0 \n\t"
+ "pxor %%xmm1, %%xmm1 \n\t"
+ "movdqa (%0), %%xmm2 \n\t"
+ "movdqa 16(%0), %%xmm3 \n\t"
+ "pcmpgtw %%xmm2, %%xmm0 \n\t"
+ "pcmpgtw %%xmm3, %%xmm1 \n\t"
+ "pxor %%xmm0, %%xmm2 \n\t"
+ "pxor %%xmm1, %%xmm3 \n\t"
+ "psubw %%xmm0, %%xmm2 \n\t"
+ "psubw %%xmm1, %%xmm3 \n\t"
+ "movdqa %%xmm2, %%xmm4 \n\t"
+ "movdqa %%xmm3, %%xmm5 \n\t"
+ "psubusw (%2), %%xmm2 \n\t"
+ "psubusw 16(%2), %%xmm3 \n\t"
+ "pxor %%xmm0, %%xmm2 \n\t"
+ "pxor %%xmm1, %%xmm3 \n\t"
+ "psubw %%xmm0, %%xmm2 \n\t"
+ "psubw %%xmm1, %%xmm3 \n\t"
+ "movdqa %%xmm2, (%0) \n\t"
+ "movdqa %%xmm3, 16(%0) \n\t"
+ "movdqa %%xmm4, %%xmm6 \n\t"
+ "movdqa %%xmm5, %%xmm0 \n\t"
+ "punpcklwd %%xmm7, %%xmm4 \n\t"
+ "punpckhwd %%xmm7, %%xmm6 \n\t"
+ "punpcklwd %%xmm7, %%xmm5 \n\t"
+ "punpckhwd %%xmm7, %%xmm0 \n\t"
+ "paddd (%1), %%xmm4 \n\t"
+ "paddd 16(%1), %%xmm6 \n\t"
+ "paddd 32(%1), %%xmm5 \n\t"
+ "paddd 48(%1), %%xmm0 \n\t"
+ "movdqa %%xmm4, (%1) \n\t"
+ "movdqa %%xmm6, 16(%1) \n\t"
+ "movdqa %%xmm5, 32(%1) \n\t"
+ "movdqa %%xmm0, 48(%1) \n\t"
+ "add $32, %0 \n\t"
+ "add $64, %1 \n\t"
+ "add $32, %2 \n\t"
+ "cmp %3, %0 \n\t"
+ " jb 1b \n\t"
+ : "+r" (block), "+r" (sum), "+r" (offset)
+ : "r"(block+64)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7")
+ );
+}
+#endif /* HAVE_INLINE_ASM */
+
av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
{
const int dct_algo = s->avctx->dct_algo;
@@ -93,18 +208,26 @@ av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
#if HAVE_MMX_INLINE
int cpu_flags = av_get_cpu_flags();
- if (INLINE_MMX(cpu_flags))
+ if (INLINE_MMX(cpu_flags)) {
+#if HAVE_6REGS
s->dct_quantize = dct_quantize_MMX;
#endif
-#if HAVE_MMXEXT_INLINE
+ s->denoise_dct = denoise_dct_mmx;
+ }
+#endif
+#if HAVE_6REGS && HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags))
s->dct_quantize = dct_quantize_MMXEXT;
#endif
#if HAVE_SSE2_INLINE
- if (INLINE_SSE2(cpu_flags))
+ if (INLINE_SSE2(cpu_flags)) {
+#if HAVE_6REGS
s->dct_quantize = dct_quantize_SSE2;
#endif
-#if HAVE_SSSE3_INLINE
+ s->denoise_dct = denoise_dct_sse2;
+ }
+#endif
+#if HAVE_6REGS && HAVE_SSSE3_INLINE
if (INLINE_SSSE3(cpu_flags))
s->dct_quantize = dct_quantize_SSSE3;
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc_template.c b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc_template.c
index 0defc404fe2..76a5c5a154c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/mpegvideoenc_template.c
@@ -20,6 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
+
+#include "libavutil/internal.h"
+#include "libavutil/x86/asm.h"
+#include "libavcodec/mpegvideo.h"
+
#undef MMREG_WIDTH
#undef MM
#undef MOVQ
@@ -168,7 +174,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
" js 1b \n\t"
PMAX(MM"3", MM"0")
"movd "MM"3, %%"REG_a" \n\t"
- "movzb %%al, %%"REG_a" \n\t" // last_non_zero_p1
+ "movzbl %%al, %%eax \n\t" // last_non_zero_p1
: "+a" (last_non_zero_p1)
: "r" (block+64), "r" (qmat), "r" (bias),
"r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64)
@@ -202,7 +208,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
" js 1b \n\t"
PMAX(MM"3", MM"0")
"movd "MM"3, %%"REG_a" \n\t"
- "movzb %%al, %%"REG_a" \n\t" // last_non_zero_p1
+ "movzbl %%al, %%eax \n\t" // last_non_zero_p1
: "+a" (last_non_zero_p1)
: "r" (block+64), "r" (qmat+64), "r" (bias+64),
"r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64)
@@ -216,7 +222,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
"psubusw "MM"1, "MM"4 \n\t"
"packuswb "MM"4, "MM"4 \n\t"
#if COMPILE_TEMPLATE_SSE2
- "packuswb "MM"4, "MM"4 \n\t"
+ "packsswb "MM"4, "MM"4 \n\t"
#endif
"movd "MM"4, %0 \n\t" // *overflow
: "=g" (*overflow)
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp.asm
index aedacc2cdcc..255eb248979 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp.asm
@@ -231,8 +231,8 @@ section .text align=16
SUMSUB_SHPK m2, m3, m4, m5, m6, m7, %2
%endmacro
-; void prores_idct_put_10_<opt>(uint8_t *pixels, int stride,
-; int16_t *block, const int16_t *qmat);
+; void ff_prores_idct_put_10_<opt>(uint8_t *pixels, int stride,
+; int16_t *block, const int16_t *qmat);
%macro idct_put_fn 1
cglobal prores_idct_put_10, 4, 4, %1
movsxd r1, r1d
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp_init.c
index 0273d6141a7..394025b68e4 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/proresdsp_init.c
@@ -32,14 +32,11 @@ void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize,
void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize,
int16_t *block, const int16_t *qmat);
-av_cold void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx)
+av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp, AVCodecContext *avctx)
{
#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
- if(avctx->flags & CODEC_FLAG_BITEXACT)
- return;
-
if (EXTERNAL_SSE2(cpu_flags)) {
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
dsp->idct_put = ff_prores_idct_put_10_sse2;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/qpel.asm b/chromium/third_party/ffmpeg/libavcodec/x86/qpel.asm
index c2ffb867176..4e72d5084ff 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/qpel.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/qpel.asm
@@ -1,5 +1,5 @@
;******************************************************************************
-;* MMX optimized DSP utils
+;* SIMD-optimized quarterpel functions
;* Copyright (c) 2008 Loren Merritt
;* Copyright (c) 2003-2013 Michael Niedermayer
;* Copyright (c) 2013 Daniel Kang
@@ -44,7 +44,8 @@ SECTION .text
mova %2, %1
%endmacro
-; void pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+; int dstStride, int src1Stride, int h)
%macro PIXELS4_L2 1
%define OP op_%1h
cglobal %1_pixels4_l2, 6,6
@@ -87,7 +88,8 @@ INIT_MMX mmxext
PIXELS4_L2 put
PIXELS4_L2 avg
-; void pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+; int dstStride, int src1Stride, int h)
%macro PIXELS8_L2 1
%define OP op_%1
cglobal %1_pixels8_l2, 6,6
@@ -130,7 +132,8 @@ INIT_MMX mmxext
PIXELS8_L2 put
PIXELS8_L2 avg
-; void pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+; int dstStride, int src1Stride, int h)
%macro PIXELS16_L2 1
%define OP op_%1
cglobal %1_pixels16_l2, 6,6
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/rnd_template.c b/chromium/third_party/ffmpeg/libavcodec/x86/rnd_template.c
index e37fc19506f..c9fd71eeef9 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/rnd_template.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/rnd_template.c
@@ -1,5 +1,5 @@
/*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
+ * SIMD-optimized halfpel functions are compiled twice for rnd/no_rnd
* Copyright (c) 2000, 2001 Fabrice Bellard
* Copyright (c) 2003-2004 Michael Niedermayer <michaelni@gmx.at>
*
@@ -27,6 +27,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "inline_asm.h"
+
// put_pixels
STATIC void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h)
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/rv34dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/rv34dsp_init.c
index 027efe9668a..99c56f9d09f 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/rv34dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/rv34dsp_init.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp.asm
index 792a54f572a..24a803865fc 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp.asm
@@ -77,9 +77,9 @@ SECTION .text
;-----------------------------------------------------------------------------
; subpel MC functions:
;
-; void [put|rv40]_rv40_qpel_[h|v]_<opt>(uint8_t *dst, int deststride,
-; uint8_t *src, int srcstride,
-; int len, int m);
+; void ff_[put|rv40]_rv40_qpel_[h|v]_<opt>(uint8_t *dst, int deststride,
+; uint8_t *src, int srcstride,
+; int len, int m);
;----------------------------------------------------------------------
%macro LOAD 2
%if WIN64
@@ -438,7 +438,7 @@ FILTER_SSSE3 avg
%endmacro
-; rv40_weight_func_%1(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)
+; void ff_rv40_weight_func_%1(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)
; %1=size %2=num of xmm regs
; The weights are FP0.14 notation of fractions depending on pts.
; For timebases without rounding error (i.e. PAL), the fractions
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp_init.c
index 75ba8ba12cd..69480597b11 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/rv40dsp_init.c
@@ -30,7 +30,7 @@
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "libavutil/x86/cpu.h"
-#include "dsputil_x86.h"
+#include "hpeldsp.h"
#if HAVE_YASM
void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp.asm
index adc13c43539..d556f271124 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp.asm
@@ -124,9 +124,9 @@ cglobal sbr_hf_g_filt, 5, 6, 5
.end:
RET
-; static void sbr_hf_gen_c(float (*X_high)[2], const float (*X_low)[2],
-; const float alpha0[2], const float alpha1[2],
-; float bw, int start, int end)
+; void ff_sbr_hf_gen_sse(float (*X_high)[2], const float (*X_low)[2],
+; const float alpha0[2], const float alpha1[2],
+; float bw, int start, int end)
;
cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
; load alpha factors
@@ -249,7 +249,7 @@ cglobal sbr_neg_odd_64, 1,2,4,z
jne .loop
REP_RET
-; sbr_qmf_deint_bfly(float *v, const float *src0, const float *src1)
+; void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1)
%macro SBR_QMF_DEINT_BFLY 0
cglobal sbr_qmf_deint_bfly, 3,5,8, v,src0,src1,vrev,c
mov cq, 64*4-2*mmsize
@@ -423,3 +423,25 @@ apply_noise_main:
add count, mmsize
jl .loop
RET
+
+INIT_XMM sse
+cglobal sbr_qmf_deint_neg, 2,4,4,v,src,vrev,c
+%define COUNT 32*4
+%define OFFSET 32*4
+ mov cq, -COUNT
+ lea vrevq, [vq + OFFSET + COUNT]
+ add vq, OFFSET-mmsize
+ add srcq, 2*COUNT
+ mova m3, [ps_neg]
+.loop:
+ mova m0, [srcq + 2*cq + 0*mmsize]
+ mova m1, [srcq + 2*cq + 1*mmsize]
+ shufps m2, m0, m1, q2020
+ shufps m1, m0, q1313
+ xorps m2, m3
+ mova [vq], m1
+ mova [vrevq + cq], m2
+ sub vq, mmsize
+ add cq, mmsize
+ jl .loop
+ REP_RET
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp_init.c
index 2b912d0e9eb..a2aca742cf3 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/sbrdsp_init.c
@@ -51,6 +51,8 @@ void ff_sbr_hf_apply_noise_3_sse2(float (*Y)[2], const float *s_m,
const float *q_filt, int noise,
int kx, int m_max);
+void ff_sbr_qmf_deint_neg_sse(float *v, const float *src);
+
av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
@@ -63,6 +65,7 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
s->hf_gen = ff_sbr_hf_gen_sse;
s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_sse;
s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse;
+ s->qmf_deint_neg = ff_sbr_qmf_deint_neg_sse;
}
if (EXTERNAL_SSE2(cpu_flags)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/simple_idct.c b/chromium/third_party/ffmpeg/libavcodec/x86/simple_idct.c
index c666b1a6df4..3ae30f3488a 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/simple_idct.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/simple_idct.c
@@ -21,6 +21,7 @@
*/
#include "libavcodec/simple_idct.h"
#include "libavutil/mem.h"
+#include "libavutil/x86/asm.h"
#include "dsputil_x86.h"
#if HAVE_INLINE_ASM
@@ -1142,6 +1143,7 @@ Temp
"9: \n\t"
:: "r" (block), "r" (temp), "r" (coeffs)
+ NAMED_CONSTRAINTS_ADD(wm1010,d40000)
: "%eax"
);
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/snowdsp.c b/chromium/third_party/ffmpeg/libavcodec/x86/snowdsp.c
index 735e7905a0f..67cb868adab 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/snowdsp.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/snowdsp.c
@@ -606,6 +606,7 @@ static void ff_snow_vertical_compose97i_mmx(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM
}
#endif //HAVE_7REGS
+#if HAVE_6REGS
#define snow_inner_add_yblock_sse2_header \
IDWTELEM * * dst_array = sb->line + src_y;\
x86_reg tmp;\
@@ -671,6 +672,7 @@ static void ff_snow_vertical_compose97i_mmx(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM
:"+m"(dst8),"+m"(dst_array),"=&r"(tmp)\
:\
"rm"((x86_reg)(src_x<<1)),"m"(obmc),"a"(block),"m"(b_h),"m"(src_stride):\
+ XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", )\
"%"REG_c"","%"REG_S"","%"REG_D"","%"REG_d"");
#define snow_inner_add_yblock_sse2_end_8\
@@ -872,6 +874,7 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str
else
ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
}
+#endif /* HAVE_6REGS */
#endif /* HAVE_INLINE_ASM */
@@ -886,7 +889,9 @@ void ff_dwt_init_x86(SnowDWTContext *c)
#if HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
#endif
+#if HAVE_6REGS
c->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
+#endif
}
else{
if (mm_flags & AV_CPU_FLAG_MMXEXT) {
@@ -895,7 +900,9 @@ void ff_dwt_init_x86(SnowDWTContext *c)
c->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
#endif
}
+#if HAVE_6REGS
c->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
+#endif
}
}
#endif /* HAVE_INLINE_ASM */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp.asm
new file mode 100644
index 00000000000..8346cabac2a
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp.asm
@@ -0,0 +1,119 @@
+;******************************************************************************
+;* TTA DSP SIMD optimizations
+;*
+;* Copyright (C) 2014 James Almer
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pd_n0113: dd ~0, ~1, ~1, ~3
+pd_1224: dd 1, 2, 2, 4
+
+SECTION .text
+
+%macro TTA_FILTER 2
+INIT_XMM %1
+cglobal ttafilter_process_dec, 5,5,%2, qm, dx, dl, error, in, shift, round
+ mova m2, [qmq ]
+ mova m3, [qmq + 0x10]
+ mova m4, [dxq ]
+ mova m5, [dxq + 0x10]
+
+ movd m6, [errorq] ; if (filter->error < 0) {
+ SPLATD m6 ; for (int i = 0; i < 8; i++)
+ psignd m0, m4, m6 ; filter->qm[i] -= filter->dx[i];
+ psignd m1, m5, m6 ; } else if (filter->error > 0) {
+ paddd m2, m0 ; for (int i = 0; i < 8; i++)
+ paddd m3, m1 ; filter->qm[i] += filter->dx[i];
+ mova [qmq ], m2 ; }
+ mova [qmq + 0x10], m3 ;
+
+ mova m0, [dlq ]
+ mova m1, [dlq + 0x10]
+
+%if cpuflag(sse4)
+ pmulld m2, m0
+ pmulld m3, m1
+%else
+ pshufd m6, m0, 0xb1
+ pshufd m7, m2, 0xb1
+ pmuludq m6, m7
+ pshufd m6, m6, 0xd8
+ pmuludq m2, m0
+ pshufd m2, m2, 0xd8
+ punpckldq m2, m6
+
+ pshufd m6, m1, 0xb1
+ pshufd m7, m3, 0xb1
+ pmuludq m6, m7
+ pshufd m6, m6, 0xd8
+ pmuludq m3, m1
+ pshufd m3, m3, 0xd8
+ punpckldq m3, m6
+%endif
+ ; Using horizontal add (phaddd) seems to be slower than shuffling stuff around
+ paddd m2, m3 ; int sum = filter->round +
+ ; filter->dl[0] * filter->qm[0] +
+ punpckhqdq m3, m2, m2 ; filter->dl[1] * filter->qm[1] +
+ paddd m2, m3 ; filter->dl[2] * filter->qm[2] +
+ ; filter->dl[3] * filter->qm[3] +
+ movd m6, roundm ; filter->dl[4] * filter->qm[4] +
+ paddd m6, m2 ; filter->dl[5] * filter->qm[5] +
+ pshufd m2, m2, 0x1 ; filter->dl[6] * filter->qm[6] +
+ paddd m6, m2 ; filter->dl[7] * filter->qm[7];
+
+ palignr m5, m4, 4 ; filter->dx[0] = filter->dx[1]; filter->dx[1] = filter->dx[2];
+ ; filter->dx[2] = filter->dx[3]; filter->dx[3] = filter->dx[4];
+
+ palignr m2, m1, m0, 4 ; filter->dl[0] = filter->dl[1]; filter->dl[1] = filter->dl[2];
+ ; filter->dl[2] = filter->dl[3]; filter->dl[3] = filter->dl[4];
+
+ psrad m4, m1, 30 ; filter->dx[4] = ((filter->dl[4] >> 30) | 1);
+ por m4, [pd_1224 ] ; filter->dx[5] = ((filter->dl[5] >> 30) | 2) & ~1;
+ pand m4, [pd_n0113] ; filter->dx[6] = ((filter->dl[6] >> 30) | 2) & ~1;
+ ; filter->dx[7] = ((filter->dl[7] >> 30) | 4) & ~3;
+
+ mova [dlq ], m2
+ mova [dxq ], m5
+ mova [dxq + 0x10], m4
+ movd m0, [inq] ; filter->error = *in;
+ movd [errorq], m0 ;
+
+ movd m2, shiftm ; *in += (sum >> filter->shift);
+ psrad m6, m2 ;
+ paddd m0, m6 ;
+ movd [inq], m0 ;
+
+ psrldq m1, 4 ;
+ pslldq m0, 12 ; filter->dl[4] = -filter->dl[5];
+ pshufd m0, m0, 0xf0 ; filter->dl[5] = -filter->dl[6];
+ psubd m0, m1 ; filter->dl[6] = *in - filter->dl[7];
+ psrldq m1, m0, 4 ; filter->dl[7] = *in;
+ pshufd m1, m1, 0xf4 ; filter->dl[5] += filter->dl[6];
+ paddd m0, m1 ; filter->dl[4] += filter->dl[5];
+ psrldq m1, 4 ;
+ paddd m0, m1 ;
+ mova [dlq + 0x10], m0 ;
+ RET
+%endmacro
+
+TTA_FILTER ssse3, 8
+TTA_FILTER sse4, 7
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp_init.c
new file mode 100644
index 00000000000..47dc87f6afd
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/ttadsp_init.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 James Almer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/ttadsp.h"
+#include "libavutil/x86/cpu.h"
+#include "config.h"
+
+void ff_ttafilter_process_dec_ssse3(int32_t *qm, int32_t *dx, int32_t *dl,
+ int32_t *error, int32_t *in, int32_t shift,
+ int32_t round);
+void ff_ttafilter_process_dec_sse4(int32_t *qm, int32_t *dx, int32_t *dl,
+ int32_t *error, int32_t *in, int32_t shift,
+ int32_t round);
+
+av_cold void ff_ttadsp_init_x86(TTADSPContext *c)
+{
+#if HAVE_YASM
+ int cpu_flags = av_get_cpu_flags();
+
+ if (EXTERNAL_SSSE3(cpu_flags))
+ c->ttafilter_process_dec = ff_ttafilter_process_dec_ssse3;
+ if (EXTERNAL_SSE4(cpu_flags))
+ c->ttafilter_process_dec = ff_ttafilter_process_dec_sse4;
+#endif
+}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_init.c
index 9f18131a24b..2bef5f5fb59 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_init.c
@@ -24,10 +24,12 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
+#include "libavutil/x86/asm.h"
#include "libavcodec/vc1dsp.h"
-#include "dsputil_x86.h"
+#include "fpel.h"
#include "vc1dsp.h"
#include "config.h"
@@ -61,12 +63,17 @@ static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
ff_vc1_h_loop_filter8_sse4(src, stride, pq);
ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
}
-
static void avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride, int rnd)
{
ff_avg_pixels8_mmxext(dst, src, stride, 8);
}
+static void avg_vc1_mspel_mc00_16_sse2(uint8_t *dst, const uint8_t *src,
+ ptrdiff_t stride, int rnd)
+{
+ ff_avg_pixels16_sse2(dst, src, stride, 16);
+}
+
#endif /* HAVE_YASM */
void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
@@ -85,10 +92,10 @@ av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (INLINE_MMX(cpu_flags))
+ if (HAVE_6REGS && INLINE_MMX(cpu_flags))
ff_vc1dsp_init_mmx(dsp);
- if (INLINE_MMXEXT(cpu_flags))
+ if (HAVE_6REGS && INLINE_MMXEXT(cpu_flags))
ff_vc1dsp_init_mmxext(dsp);
#define ASSIGN_LF(EXT) \
@@ -110,13 +117,14 @@ av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
ASSIGN_LF(mmxext);
dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[0] = avg_vc1_mspel_mc00_mmxext;
+ dsp->avg_vc1_mspel_pixels_tab[1][0] = avg_vc1_mspel_mc00_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
+ dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_vc1_mspel_mc00_16_sse2;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
ASSIGN_LF(ssse3);
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_mmx.c b/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
index 5ceacd348e2..87e4638ca79 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
@@ -30,10 +30,10 @@
#include "libavutil/x86/cpu.h"
#include "libavcodec/vc1dsp.h"
#include "constants.h"
-#include "dsputil_x86.h"
+#include "fpel.h"
#include "vc1dsp.h"
-#if HAVE_INLINE_ASM
+#if HAVE_6REGS && HAVE_INLINE_ASM
#define OP_PUT(S,D)
#define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
@@ -110,6 +110,7 @@ static void vc1_put_ver_16b_shift2_mmx(int16_t *dst,
: "+r"(src), "+r"(dst)
: "r"(stride), "r"(-2*stride),
"m"(shift), "m"(rnd), "r"(9*stride-4)
+ NAMED_CONSTRAINTS_ADD(ff_pw_9)
: "%"REG_c, "memory"
);
}
@@ -154,6 +155,7 @@ static void OPNAME ## vc1_hor_16b_shift2_mmx(uint8_t *dst, x86_reg stride,\
"jnz 1b \n\t"\
: "+r"(h), "+r" (src), "+r" (dst)\
: "r"(stride), "m"(rnd)\
+ NAMED_CONSTRAINTS_ADD(ff_pw_128,ff_pw_9)\
: "memory"\
);\
}
@@ -212,6 +214,7 @@ static void OPNAME ## vc1_shift2_mmx(uint8_t *dst, const uint8_t *src,\
: "+r"(src), "+r"(dst)\
: "r"(offset), "r"(-2*offset), "g"(stride), "m"(rnd),\
"g"(stride-offset)\
+ NAMED_CONSTRAINTS_ADD(ff_pw_9)\
: "%"REG_c, "memory"\
);\
}
@@ -314,6 +317,7 @@ vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src, \
: "+r"(h), "+r" (src), "+r" (dst) \
: "r"(src_stride), "r"(3*src_stride), \
"m"(rnd), "m"(shift) \
+ NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_53,ff_pw_18) \
: "memory" \
); \
}
@@ -351,6 +355,7 @@ OPNAME ## vc1_hor_16b_ ## NAME ## _mmx(uint8_t *dst, x86_reg stride, \
"jnz 1b \n\t" \
: "+r"(h), "+r" (src), "+r" (dst) \
: "r"(stride), "m"(rnd) \
+ NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_18,ff_pw_53,ff_pw_128) \
: "memory" \
); \
}
@@ -386,6 +391,7 @@ OPNAME ## vc1_## NAME ## _mmx(uint8_t *dst, const uint8_t *src, \
"jnz 1b \n\t" \
: "+r"(h), "+r" (src), "+r" (dst) \
: "r"(offset), "r"(3*offset), "g"(stride), "m"(rnd) \
+ NAMED_CONSTRAINTS_ADD(ff_pw_53,ff_pw_18,ff_pw_3) \
: "memory" \
); \
}
@@ -456,6 +462,15 @@ static void OP ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride,\
\
/* Horizontal mode with no vertical mode */\
vc1_put_shift_8bits[hmode](dst, src, stride, rnd, 1);\
+} \
+static void OP ## vc1_mspel_mc_16(uint8_t *dst, const uint8_t *src, \
+ int stride, int hmode, int vmode, int rnd)\
+{ \
+ OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
+ OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
+ dst += 8*stride; src += 8*stride; \
+ OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
+ OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
}
VC1_MSPEL_MC(put_)
@@ -476,6 +491,20 @@ static void avg_vc1_mspel_mc ## a ## b ## _mmxext(uint8_t *dst, \
int rnd) \
{ \
avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+}\
+static void put_vc1_mspel_mc ## a ## b ## _16_mmx(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, \
+ int rnd) \
+{ \
+ put_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
+}\
+static void avg_vc1_mspel_mc ## a ## b ## _16_mmxext(uint8_t *dst, \
+ const uint8_t *src,\
+ ptrdiff_t stride, \
+ int rnd) \
+{ \
+ avg_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
}
DECLARE_FUNCTION(0, 1)
@@ -704,54 +733,75 @@ static void put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src,
{
ff_put_pixels8_mmx(dst, src, stride, 8);
}
+static void put_vc1_mspel_mc00_16_mmx(uint8_t *dst, const uint8_t *src,
+ ptrdiff_t stride, int rnd)
+{
+ ff_put_pixels16_mmx(dst, src, stride, 16);
+}
+static void avg_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src,
+ ptrdiff_t stride, int rnd)
+{
+ ff_avg_pixels8_mmx(dst, src, stride, 8);
+}
+static void avg_vc1_mspel_mc00_16_mmx(uint8_t *dst, const uint8_t *src,
+ ptrdiff_t stride, int rnd)
+{
+ ff_avg_pixels16_mmx(dst, src, stride, 16);
+}
+
+#define FN_ASSIGN(OP, X, Y, INSN) \
+ dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = OP##vc1_mspel_mc##X##Y##INSN; \
+ dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = OP##vc1_mspel_mc##X##Y##_16##INSN
av_cold void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
{
- dsp->put_vc1_mspel_pixels_tab[ 0] = put_vc1_mspel_mc00_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_mmx;
- dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_mmx;
- dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_mmx;
- dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_mmx;
- dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_mmx;
-
- dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_mmx;
- dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_mmx;
- dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_mmx;
- dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_mmx;
+ FN_ASSIGN(put_, 0, 0, _mmx);
+ FN_ASSIGN(put_, 0, 1, _mmx);
+ FN_ASSIGN(put_, 0, 2, _mmx);
+ FN_ASSIGN(put_, 0, 3, _mmx);
+
+ FN_ASSIGN(put_, 1, 0, _mmx);
+ FN_ASSIGN(put_, 1, 1, _mmx);
+ FN_ASSIGN(put_, 1, 2, _mmx);
+ FN_ASSIGN(put_, 1, 3, _mmx);
+
+ FN_ASSIGN(put_, 2, 0, _mmx);
+ FN_ASSIGN(put_, 2, 1, _mmx);
+ FN_ASSIGN(put_, 2, 2, _mmx);
+ FN_ASSIGN(put_, 2, 3, _mmx);
+
+ FN_ASSIGN(put_, 3, 0, _mmx);
+ FN_ASSIGN(put_, 3, 1, _mmx);
+ FN_ASSIGN(put_, 3, 2, _mmx);
+ FN_ASSIGN(put_, 3, 3, _mmx);
+
+ FN_ASSIGN(avg_, 0, 0, _mmx);
}
av_cold void ff_vc1dsp_init_mmxext(VC1DSPContext *dsp)
{
- dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_mmxext;
+ FN_ASSIGN(avg_, 0, 1, _mmxext);
+ FN_ASSIGN(avg_, 0, 2, _mmxext);
+ FN_ASSIGN(avg_, 0, 3, _mmxext);
- dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_mmxext;
+ FN_ASSIGN(avg_, 1, 0, _mmxext);
+ FN_ASSIGN(avg_, 1, 1, _mmxext);
+ FN_ASSIGN(avg_, 1, 2, _mmxext);
+ FN_ASSIGN(avg_, 1, 3, _mmxext);
- dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_mmxext;
+ FN_ASSIGN(avg_, 2, 0, _mmxext);
+ FN_ASSIGN(avg_, 2, 1, _mmxext);
+ FN_ASSIGN(avg_, 2, 2, _mmxext);
+ FN_ASSIGN(avg_, 2, 3, _mmxext);
- dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_mmxext;
- dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_mmxext;
+ FN_ASSIGN(avg_, 3, 0, _mmxext);
+ FN_ASSIGN(avg_, 3, 1, _mmxext);
+ FN_ASSIGN(avg_, 3, 2, _mmxext);
+ FN_ASSIGN(avg_, 3, 3, _mmxext);
dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_mmxext;
dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_mmxext;
dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_mmxext;
dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_mmxext;
}
-#endif /* HAVE_INLINE_ASM */
+#endif /* HAVE_6REGS && HAVE_INLINE_ASM */
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/videodsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/videodsp_init.c
index 2013a93b90d..3218abdd88e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/videodsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/videodsp_init.c
@@ -231,7 +231,8 @@ static av_noinline void emulated_edge_mc_sse2(uint8_t *buf, const uint8_t *src,
ptrdiff_t buf_stride,
ptrdiff_t src_stride,
int block_w, int block_h,
- int src_x, int src_y, int w, int h)
+ int src_x, int src_y, int w,
+ int h)
{
emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h,
src_x, src_y, w, h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vorbisdsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vorbisdsp_init.c
index 284a528a0c7..bc1cc43a186 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vorbisdsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vorbisdsp_init.c
@@ -31,7 +31,6 @@ void ff_vorbis_inverse_coupling_sse(float *mag, float *ang,
av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp)
{
-#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
@@ -40,5 +39,4 @@ av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp)
#endif /* ARCH_X86_32 */
if (EXTERNAL_SSE(cpu_flags))
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;
-#endif /* HAVE_YASM */
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp3dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vp3dsp_init.c
index 1f02a6f7090..cc3eba4e9af 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp3dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp3dsp_init.c
@@ -25,7 +25,6 @@
#include "libavutil/x86/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
#include "libavcodec/vp3dsp.h"
#include "config.h"
@@ -64,6 +63,7 @@ void ff_vp3_h_loop_filter_mmxext(uint8_t *src, int stride,
"paddb "#regb", "#regr" \n\t" \
"paddb "#regd", "#regp" \n\t"
+#if HAVE_6REGS
static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
{
// START_TIMER
@@ -95,15 +95,16 @@ static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const u
:"memory");
// STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx")
}
+#endif /*HAVE_6REGS */
#endif /* HAVE_MMX_INLINE */
av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags)
{
int cpu_flags = av_get_cpu_flags();
-#if HAVE_MMX_INLINE
+#if HAVE_6REGS && HAVE_MMX_INLINE
c->put_no_rnd_pixels_l2 = put_vp_no_rnd_pixels8_l2_mmx;
-#endif /* HAVE_MMX_INLINE */
+#endif /* HAVE_6REGS && HAVE_MMX_INLINE */
#if ARCH_X86_32
if (EXTERNAL_MMX(cpu_flags)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp56_arith.h b/chromium/third_party/ffmpeg/libavcodec/x86/vp56_arith.h
index e71dbf8ed0f..810cc8dcd81 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp56_arith.h
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp56_arith.h
@@ -24,29 +24,26 @@
#ifndef AVCODEC_X86_VP56_ARITH_H
#define AVCODEC_X86_VP56_ARITH_H
-#if HAVE_INLINE_ASM && HAVE_FAST_CMOV
+#if HAVE_INLINE_ASM && HAVE_FAST_CMOV && HAVE_6REGS
#define vp56_rac_get_prob vp56_rac_get_prob
static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
{
unsigned int code_word = vp56_rac_renorm(c);
- unsigned int high = c->high;
- unsigned int low = 1 + (((high - 1) * prob) >> 8);
+ unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
unsigned int low_shift = low << 16;
int bit = 0;
+ c->code_word = code_word;
__asm__(
"subl %4, %1 \n\t"
"subl %3, %2 \n\t"
- "leal (%2, %3), %3 \n\t"
"setae %b0 \n\t"
"cmovb %4, %1 \n\t"
- "cmovb %3, %2 \n\t"
- : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift)
- : "r"(low)
+ "cmovb %5, %2 \n\t"
+ : "+q"(bit), "+&r"(c->high), "+&r"(c->code_word)
+ : "r"(low_shift), "r"(low), "r"(code_word)
);
- c->high = high;
- c->code_word = code_word;
return bit;
}
#endif
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp6dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vp6dsp_init.c
index 8718e23a83e..82baee7e971 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp6dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp6dsp_init.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp.asm
index 85c7e9948c8..4407dd3dd0d 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp.asm
@@ -153,13 +153,13 @@ cextern pw_64
SECTION .text
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
; subpel MC functions:
;
-; void put_vp8_epel<size>_h<htap>v<vtap>_<opt>(uint8_t *dst, int deststride,
-; uint8_t *src, int srcstride,
-; int height, int mx, int my);
-;-----------------------------------------------------------------------------
+; void ff_put_vp8_epel<size>_h<htap>v<vtap>_<opt>(uint8_t *dst, int deststride,
+; uint8_t *src, int srcstride,
+; int height, int mx, int my);
+;-------------------------------------------------------------------------------
%macro FILTER_SSSE3 1
cglobal put_vp8_epel%1_h6, 6, 6 + npicregs, 8, dst, dststride, src, srcstride, height, mx, picreg
@@ -884,7 +884,7 @@ cglobal put_vp8_pixels16, 5, 5, 2, dst, dststride, src, srcstride, height
REP_RET
;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
+; void ff_vp8_idct_dc_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
;-----------------------------------------------------------------------------
%macro ADD_DC 4
@@ -962,7 +962,7 @@ cglobal vp8_idct_dc_add, 3, 3, 6, dst, block, stride
RET
;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
+; void ff_vp8_idct_dc_add4y_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
;-----------------------------------------------------------------------------
%if ARCH_X86_32
@@ -1035,7 +1035,7 @@ cglobal vp8_idct_dc_add4y, 3, 3, 6, dst, block, stride
RET
;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
+; void ff_vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
;-----------------------------------------------------------------------------
INIT_MMX mmx
@@ -1077,7 +1077,7 @@ cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride
RET
;-----------------------------------------------------------------------------
-; void vp8_idct_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
+; void ff_vp8_idct_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
;-----------------------------------------------------------------------------
; calculate %1=mul_35468(%1)-mul_20091(%2); %2=mul_20091(%1)+mul_35468(%2)
@@ -1157,7 +1157,7 @@ INIT_MMX sse
VP8_IDCT_ADD
;-----------------------------------------------------------------------------
-; void vp8_luma_dc_wht_mmxext(int16_t block[4][4][16], int16_t dc[16])
+; void ff_vp8_luma_dc_wht(int16_t block[4][4][16], int16_t dc[16])
;-----------------------------------------------------------------------------
%macro SCATTER_WHT 3
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_init.c
index dca00f575aa..ff743d62dcb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_init.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/mem.h"
#include "libavutil/x86/asm.h"
@@ -314,25 +315,69 @@ DECLARE_LOOP_FILTER(sse4)
c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT
-av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
+av_cold void ff_vp78dsp_init_x86(VP8DSPContext *c)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_MMX(cpu_flags)) {
- c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
- c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
#if ARCH_X86_32
- c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx;
- c->vp8_idct_add = ff_vp8_idct_add_mmx;
- c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx;
c->put_vp8_epel_pixels_tab[0][0][0] =
c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
#endif
c->put_vp8_epel_pixels_tab[1][0][0] =
c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;
+ }
+
+ /* note that 4-tap width=16 functions are missing because w=16
+ * is only used for luma, and luma is always a copy or sixtap. */
+ if (EXTERNAL_MMXEXT(cpu_flags)) {
+ VP8_MC_FUNC(2, 4, mmxext);
+ VP8_BILINEAR_MC_FUNC(2, 4, mmxext);
+#if ARCH_X86_32
+ VP8_LUMA_MC_FUNC(0, 16, mmxext);
+ VP8_MC_FUNC(1, 8, mmxext);
+ VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
+ VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
+#endif
+ }
+
+ if (EXTERNAL_SSE(cpu_flags)) {
+ c->put_vp8_epel_pixels_tab[0][0][0] =
+ c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
+ }
+
+ if (HAVE_SSE2_EXTERNAL && cpu_flags & (AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_SSE2SLOW)) {
+ VP8_LUMA_MC_FUNC(0, 16, sse2);
+ VP8_MC_FUNC(1, 8, sse2);
+ VP8_BILINEAR_MC_FUNC(0, 16, sse2);
+ VP8_BILINEAR_MC_FUNC(1, 8, sse2);
+ }
+
+ if (EXTERNAL_SSSE3(cpu_flags)) {
+ VP8_LUMA_MC_FUNC(0, 16, ssse3);
+ VP8_MC_FUNC(1, 8, ssse3);
+ VP8_MC_FUNC(2, 4, ssse3);
+ VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
+ VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
+ VP8_BILINEAR_MC_FUNC(2, 4, ssse3);
+ }
+#endif /* HAVE_YASM */
+}
+av_cold void ff_vp8dsp_init_x86(VP8DSPContext *c)
+{
+#if HAVE_YASM
+ int cpu_flags = av_get_cpu_flags();
+
+ if (EXTERNAL_MMX(cpu_flags)) {
+ c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
+ c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
#if ARCH_X86_32
+ c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx;
+ c->vp8_idct_add = ff_vp8_idct_add_mmx;
+ c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx;
+
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;
@@ -351,14 +396,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
/* note that 4-tap width=16 functions are missing because w=16
* is only used for luma, and luma is always a copy or sixtap. */
if (EXTERNAL_MMXEXT(cpu_flags)) {
- VP8_MC_FUNC(2, 4, mmxext);
- VP8_BILINEAR_MC_FUNC(2, 4, mmxext);
#if ARCH_X86_32
- VP8_LUMA_MC_FUNC(0, 16, mmxext);
- VP8_MC_FUNC(1, 8, mmxext);
- VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
- VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
-
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext;
@@ -377,16 +415,9 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
if (EXTERNAL_SSE(cpu_flags)) {
c->vp8_idct_add = ff_vp8_idct_add_sse;
c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_sse;
- c->put_vp8_epel_pixels_tab[0][0][0] =
- c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
}
if (HAVE_SSE2_EXTERNAL && cpu_flags & (AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_SSE2SLOW)) {
- VP8_LUMA_MC_FUNC(0, 16, sse2);
- VP8_MC_FUNC(1, 8, sse2);
- VP8_BILINEAR_MC_FUNC(0, 16, sse2);
- VP8_BILINEAR_MC_FUNC(1, 8, sse2);
-
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2;
c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2;
@@ -399,7 +430,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
if (EXTERNAL_SSE2(cpu_flags)) {
c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_sse2;
- c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;
+ c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;
c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;
c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;
@@ -409,13 +440,6 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
}
if (EXTERNAL_SSSE3(cpu_flags)) {
- VP8_LUMA_MC_FUNC(0, 16, ssse3);
- VP8_MC_FUNC(1, 8, ssse3);
- VP8_MC_FUNC(2, 4, ssse3);
- VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
- VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
- VP8_BILINEAR_MC_FUNC(2, 4, ssse3);
-
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_ssse3;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_ssse3;
@@ -431,7 +455,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
}
if (EXTERNAL_SSE4(cpu_flags)) {
- c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
+ c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse4;
c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_sse4;
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_loopfilter.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_loopfilter.asm
index 45dd54b6a2a..98bd8a5e388 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_loopfilter.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp8dsp_loopfilter.asm
@@ -43,7 +43,7 @@ cextern pb_80
SECTION .text
;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim);
+; void ff_vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim);
;-----------------------------------------------------------------------------
; macro called with 7 mm register indexes as argument, and 4 regular registers
@@ -429,8 +429,8 @@ INIT_XMM sse4
SIMPLE_LOOPFILTER h, 5
;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter<size>_inner_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
-; int flimE, int flimI, int hev_thr);
+; void ff_vp8_h/v_loop_filter<size>_inner_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+; int flimE, int flimI, int hev_thr);
;-----------------------------------------------------------------------------
%macro INNER_LOOPFILTER 2
@@ -921,8 +921,8 @@ INNER_LOOPFILTER v, 8
INNER_LOOPFILTER h, 8
;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter<size>_mbedge_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
-; int flimE, int flimI, int hev_thr);
+; void ff_vp8_h/v_loop_filter<size>_mbedge_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+; int flimE, int flimI, int hev_thr);
;-----------------------------------------------------------------------------
%macro MBEDGE_LOOPFILTER 2
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp9dsp_init.c b/chromium/third_party/ffmpeg/libavcodec/x86/vp9dsp_init.c
index 3c02520e0ec..3fd274d17ff 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp9dsp_init.c
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp9dsp_init.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/mem.h"
#include "libavutil/x86/asm.h"
@@ -29,25 +30,25 @@
#if HAVE_YASM
#define fpel_func(avg, sz, opt) \
-void ff_##avg##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
- const uint8_t *src, ptrdiff_t src_stride, \
- int h, int mx, int my)
+void ff_vp9_##avg##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
+ const uint8_t *src, ptrdiff_t src_stride, \
+ int h, int mx, int my)
fpel_func(put, 4, mmx);
fpel_func(put, 8, mmx);
fpel_func(put, 16, sse);
fpel_func(put, 32, sse);
fpel_func(put, 64, sse);
-fpel_func(avg, 4, sse);
-fpel_func(avg, 8, sse);
+fpel_func(avg, 4, mmxext);
+fpel_func(avg, 8, mmxext);
fpel_func(avg, 16, sse2);
fpel_func(avg, 32, sse2);
fpel_func(avg, 64, sse2);
#undef fpel_func
#define mc_func(avg, sz, dir, opt) \
-void ff_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
- const uint8_t *src, ptrdiff_t src_stride, \
- int h, const int8_t (*filter)[16])
+void ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
+ const uint8_t *src, ptrdiff_t src_stride, \
+ int h, const int8_t (*filter)[16])
#define mc_funcs(sz) \
mc_func(put, sz, h, ssse3); \
mc_func(avg, sz, h, ssse3); \
@@ -56,20 +57,23 @@ mc_func(avg, sz, v, ssse3)
mc_funcs(4);
mc_funcs(8);
+#if ARCH_X86_64
+mc_funcs(16);
+#endif
#undef mc_funcs
#undef mc_func
#define mc_rep_func(avg, sz, hsz, dir, opt) \
static av_always_inline void \
-ff_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
- const uint8_t *src, ptrdiff_t src_stride, \
- int h, const int8_t (*filter)[16]) \
+ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
+ const uint8_t *src, ptrdiff_t src_stride, \
+ int h, const int8_t (*filter)[16]) \
{ \
- ff_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst, dst_stride, src, \
- src_stride, h, filter); \
- ff_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst + hsz, dst_stride, src + hsz, \
- src_stride, h, filter); \
+ ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst, dst_stride, src, \
+ src_stride, h, filter); \
+ ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##opt(dst + hsz, dst_stride, src + hsz, \
+ src_stride, h, filter); \
}
#define mc_rep_funcs(sz, hsz) \
@@ -78,7 +82,9 @@ mc_rep_func(avg, sz, hsz, h, ssse3); \
mc_rep_func(put, sz, hsz, v, ssse3); \
mc_rep_func(avg, sz, hsz, v, ssse3)
+#if ARCH_X86_32
mc_rep_funcs(16, 8);
+#endif
mc_rep_funcs(32, 16);
mc_rep_funcs(64, 32);
@@ -93,10 +99,10 @@ static void op##_8tap_##fname##_##sz##hv_ssse3(uint8_t *dst, ptrdiff_t dst_strid
int h, int mx, int my) \
{ \
LOCAL_ALIGNED_16(uint8_t, temp, [71 * 64]); \
- ff_put_8tap_1d_h_##sz##_ssse3(temp, 64, src - 3 * src_stride, src_stride, \
- h + 7, ff_filters_ssse3[f][mx - 1]); \
- ff_##op##_8tap_1d_v_##sz##_ssse3(dst, dst_stride, temp + 3 * 64, 64, \
- h, ff_filters_ssse3[f][my - 1]); \
+ ff_vp9_put_8tap_1d_h_##sz##_ssse3(temp, 64, src - 3 * src_stride, src_stride, \
+ h + 7, ff_filters_ssse3[f][mx - 1]); \
+ ff_vp9_##op##_8tap_1d_v_##sz##_ssse3(dst, dst_stride, temp + 3 * 64, 64, \
+ h, ff_filters_ssse3[f][my - 1]); \
}
#define filters_8tap_2d_fn(op, sz) \
@@ -123,8 +129,8 @@ static void op##_8tap_##fname##_##sz##dir##_ssse3(uint8_t *dst, ptrdiff_t dst_st
const uint8_t *src, ptrdiff_t src_stride, \
int h, int mx, int my) \
{ \
- ff_##op##_8tap_1d_##dir##_##sz##_ssse3(dst, dst_stride, src, src_stride, \
- h, ff_filters_ssse3[f][dvar - 1]); \
+ ff_vp9_##op##_8tap_1d_##dir##_##sz##_ssse3(dst, dst_stride, src, src_stride, \
+ h, ff_filters_ssse3[f][dvar - 1]); \
}
#define filters_8tap_1d_fn(op, sz, dir, dvar) \
@@ -151,8 +157,93 @@ filters_8tap_1d_fn3(avg)
#undef filters_8tap_1d_fn3
#undef filter_8tap_1d_fn
-void ff_vp9_idct_idct_4x4_add_ssse3(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
-void ff_vp9_idct_idct_8x8_add_ssse3(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+#define itxfm_func(typea, typeb, size, opt) \
+void ff_vp9_##typea##_##typeb##_##size##x##size##_add_##opt(uint8_t *dst, ptrdiff_t stride, \
+ int16_t *block, int eob)
+#define itxfm_funcs(size, opt) \
+itxfm_func(idct, idct, size, opt); \
+itxfm_func(iadst, idct, size, opt); \
+itxfm_func(idct, iadst, size, opt); \
+itxfm_func(iadst, iadst, size, opt)
+
+itxfm_funcs(4, ssse3);
+itxfm_funcs(8, ssse3);
+itxfm_funcs(8, avx);
+itxfm_funcs(16, ssse3);
+itxfm_funcs(16, avx);
+itxfm_func(idct, idct, 32, ssse3);
+itxfm_func(idct, idct, 32, avx);
+itxfm_func(iwht, iwht, 4, mmx);
+
+#undef itxfm_func
+#undef itxfm_funcs
+
+#define lpf_funcs(size1, size2, opt) \
+void ff_vp9_loop_filter_v_##size1##_##size2##_##opt(uint8_t *dst, ptrdiff_t stride, \
+ int E, int I, int H); \
+void ff_vp9_loop_filter_h_##size1##_##size2##_##opt(uint8_t *dst, ptrdiff_t stride, \
+ int E, int I, int H)
+
+lpf_funcs(16, 16, sse2);
+lpf_funcs(16, 16, ssse3);
+lpf_funcs(16, 16, avx);
+lpf_funcs(44, 16, sse2);
+lpf_funcs(44, 16, ssse3);
+lpf_funcs(44, 16, avx);
+lpf_funcs(84, 16, sse2);
+lpf_funcs(84, 16, ssse3);
+lpf_funcs(84, 16, avx);
+lpf_funcs(48, 16, sse2);
+lpf_funcs(48, 16, ssse3);
+lpf_funcs(48, 16, avx);
+lpf_funcs(88, 16, sse2);
+lpf_funcs(88, 16, ssse3);
+lpf_funcs(88, 16, avx);
+
+#undef lpf_funcs
+
+#define ipred_func(size, type, opt) \
+void ff_vp9_ipred_##type##_##size##x##size##_##opt(uint8_t *dst, ptrdiff_t stride, \
+ const uint8_t *l, const uint8_t *a)
+
+#define ipred_funcs(type, opt) \
+ipred_func(4, type, opt); \
+ipred_func(8, type, opt); \
+ipred_func(16, type, opt); \
+ipred_func(32, type, opt)
+
+ipred_funcs(dc, ssse3);
+ipred_funcs(dc_left, ssse3);
+ipred_funcs(dc_top, ssse3);
+
+#undef ipred_funcs
+
+ipred_func(8, v, mmx);
+ipred_func(16, v, sse2);
+ipred_func(32, v, sse2);
+
+#define ipred_func_set(size, type, opt1, opt2) \
+ipred_func(size, type, opt1); \
+ipred_func(size, type, opt2)
+
+#define ipred_funcs(type, opt1, opt2) \
+ipred_func(4, type, opt1); \
+ipred_func_set(8, type, opt1, opt2); \
+ipred_func_set(16, type, opt1, opt2); \
+ipred_func_set(32, type, opt1, opt2)
+
+ipred_funcs(h, ssse3, avx);
+ipred_funcs(tm, ssse3, avx);
+ipred_funcs(dl, ssse3, avx);
+ipred_funcs(dr, ssse3, avx);
+ipred_funcs(hu, ssse3, avx);
+ipred_funcs(hd, ssse3, avx);
+ipred_funcs(vl, ssse3, avx);
+ipred_funcs(vr, ssse3, avx);
+
+#undef ipred_funcs
+#undef ipred_func_set
+#undef ipred_func
#endif /* HAVE_YASM */
@@ -165,8 +256,7 @@ av_cold void ff_vp9dsp_init_x86(VP9DSPContext *dsp)
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
- dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_##type##sz##_##opt
-
+ dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##_##opt
#define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, opt) \
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = type##_8tap_smooth_##sz##dir##_##opt; \
@@ -185,31 +275,117 @@ av_cold void ff_vp9dsp_init_x86(VP9DSPContext *dsp)
init_subpel2(idx, 0, 1, v, type, opt); \
init_subpel2(idx, 1, 0, h, type, opt)
+#define init_lpf(opt) do { \
+ if (ARCH_X86_64) { \
+ dsp->loop_filter_16[0] = ff_vp9_loop_filter_h_16_16_##opt; \
+ dsp->loop_filter_16[1] = ff_vp9_loop_filter_v_16_16_##opt; \
+ dsp->loop_filter_mix2[0][0][0] = ff_vp9_loop_filter_h_44_16_##opt; \
+ dsp->loop_filter_mix2[0][0][1] = ff_vp9_loop_filter_v_44_16_##opt; \
+ dsp->loop_filter_mix2[0][1][0] = ff_vp9_loop_filter_h_48_16_##opt; \
+ dsp->loop_filter_mix2[0][1][1] = ff_vp9_loop_filter_v_48_16_##opt; \
+ dsp->loop_filter_mix2[1][0][0] = ff_vp9_loop_filter_h_84_16_##opt; \
+ dsp->loop_filter_mix2[1][0][1] = ff_vp9_loop_filter_v_84_16_##opt; \
+ dsp->loop_filter_mix2[1][1][0] = ff_vp9_loop_filter_h_88_16_##opt; \
+ dsp->loop_filter_mix2[1][1][1] = ff_vp9_loop_filter_v_88_16_##opt; \
+ } \
+} while (0)
+
+#define init_ipred(tx, sz, opt) do { \
+ dsp->intra_pred[tx][HOR_PRED] = ff_vp9_ipred_h_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][DIAG_DOWN_LEFT_PRED] = ff_vp9_ipred_dl_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][DIAG_DOWN_RIGHT_PRED] = ff_vp9_ipred_dr_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][HOR_DOWN_PRED] = ff_vp9_ipred_hd_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][VERT_LEFT_PRED] = ff_vp9_ipred_vl_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][HOR_UP_PRED] = ff_vp9_ipred_hu_##sz##x##sz##_##opt; \
+ if (ARCH_X86_64 || tx != TX_32X32) { \
+ dsp->intra_pred[tx][VERT_RIGHT_PRED] = ff_vp9_ipred_vr_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][TM_VP8_PRED] = ff_vp9_ipred_tm_##sz##x##sz##_##opt; \
+ } \
+} while (0)
+#define init_dc_ipred(tx, sz, opt) do { \
+ init_ipred(tx, sz, opt); \
+ dsp->intra_pred[tx][DC_PRED] = ff_vp9_ipred_dc_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][LEFT_DC_PRED] = ff_vp9_ipred_dc_left_##sz##x##sz##_##opt; \
+ dsp->intra_pred[tx][TOP_DC_PRED] = ff_vp9_ipred_dc_top_##sz##x##sz##_##opt; \
+} while (0)
+
if (EXTERNAL_MMX(cpu_flags)) {
init_fpel(4, 0, 4, put, mmx);
init_fpel(3, 0, 8, put, mmx);
+ dsp->itxfm_add[4 /* lossless */][DCT_DCT] =
+ dsp->itxfm_add[4 /* lossless */][ADST_DCT] =
+ dsp->itxfm_add[4 /* lossless */][DCT_ADST] =
+ dsp->itxfm_add[4 /* lossless */][ADST_ADST] = ff_vp9_iwht_iwht_4x4_add_mmx;
+ dsp->intra_pred[TX_8X8][VERT_PRED] = ff_vp9_ipred_v_8x8_mmx;
+ }
+
+ if (EXTERNAL_MMXEXT(cpu_flags)) {
+ init_fpel(4, 1, 4, avg, mmxext);
+ init_fpel(3, 1, 8, avg, mmxext);
}
if (EXTERNAL_SSE(cpu_flags)) {
init_fpel(2, 0, 16, put, sse);
init_fpel(1, 0, 32, put, sse);
init_fpel(0, 0, 64, put, sse);
- init_fpel(4, 1, 4, avg, sse);
- init_fpel(3, 1, 8, avg, sse);
}
if (EXTERNAL_SSE2(cpu_flags)) {
init_fpel(2, 1, 16, avg, sse2);
init_fpel(1, 1, 32, avg, sse2);
init_fpel(0, 1, 64, avg, sse2);
+ init_lpf(sse2);
+ dsp->intra_pred[TX_16X16][VERT_PRED] = ff_vp9_ipred_v_16x16_sse2;
+ dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_sse2;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
init_subpel3(0, put, ssse3);
init_subpel3(1, avg, ssse3);
dsp->itxfm_add[TX_4X4][DCT_DCT] = ff_vp9_idct_idct_4x4_add_ssse3;
- if (ARCH_X86_64)
+ dsp->itxfm_add[TX_4X4][ADST_DCT] = ff_vp9_idct_iadst_4x4_add_ssse3;
+ dsp->itxfm_add[TX_4X4][DCT_ADST] = ff_vp9_iadst_idct_4x4_add_ssse3;
+ dsp->itxfm_add[TX_4X4][ADST_ADST] = ff_vp9_iadst_iadst_4x4_add_ssse3;
+ if (ARCH_X86_64) {
dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_ssse3;
+ dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_ssse3;
+ dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_ssse3;
+ dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_ssse3;
+ dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_ssse3;
+ dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_ssse3;
+ dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_ssse3;
+ dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_ssse3;
+ dsp->itxfm_add[TX_32X32][ADST_ADST] =
+ dsp->itxfm_add[TX_32X32][ADST_DCT] =
+ dsp->itxfm_add[TX_32X32][DCT_ADST] =
+ dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_ssse3;
+ }
+ init_lpf(ssse3);
+ init_dc_ipred(TX_4X4, 4, ssse3);
+ init_dc_ipred(TX_8X8, 8, ssse3);
+ init_dc_ipred(TX_16X16, 16, ssse3);
+ init_dc_ipred(TX_32X32, 32, ssse3);
+ }
+
+ if (EXTERNAL_AVX(cpu_flags)) {
+ if (ARCH_X86_64) {
+ dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_avx;
+ dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_avx;
+ dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_avx;
+ dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_avx;
+ dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_avx;
+ dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_avx;
+ dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_avx;
+ dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_avx;
+ dsp->itxfm_add[TX_32X32][ADST_ADST] =
+ dsp->itxfm_add[TX_32X32][ADST_DCT] =
+ dsp->itxfm_add[TX_32X32][DCT_ADST] =
+ dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_avx;
+ }
+ init_lpf(avx);
+ init_ipred(TX_8X8, 8, avx);
+ init_ipred(TX_16X16, 16, avx);
+ init_ipred(TX_32X32, 32, avx);
}
#undef init_fpel
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp9intrapred.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp9intrapred.asm
new file mode 100644
index 00000000000..3faf1c564d9
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp9intrapred.asm
@@ -0,0 +1,1405 @@
+;******************************************************************************
+;* VP9 Intra prediction SIMD optimizations
+;*
+;* Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com>
+;*
+;* Parts based on:
+;* H.264 intra prediction asm optimizations
+;* Copyright (c) 2010 Jason Garrett-Glaser
+;* Copyright (c) 2010 Holger Lubitz
+;* Copyright (c) 2010 Loren Merritt
+;* Copyright (c) 2010 Ronald S. Bultje
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pw_m256: times 8 dw -256
+pw_m255: times 8 dw -255
+pw_512: times 8 dw 512
+pw_1024: times 8 dw 1024
+pw_2048: times 8 dw 2048
+pw_4096: times 8 dw 4096
+pw_8192: times 8 dw 8192
+
+pb_4x3_4x2_4x1_4x0: times 4 db 3
+ times 4 db 2
+ times 4 db 1
+ times 4 db 0
+pb_8x1_8x0: times 8 db 1
+ times 8 db 0
+pb_8x3_8x2: times 8 db 3
+ times 8 db 2
+pb_0to5_2x7: db 0, 1, 2, 3, 4, 5, 7, 7
+ times 8 db -1
+pb_0to6_9x7: db 0, 1, 2, 3, 4, 5, 6
+ times 9 db 7
+pb_1to6_10x7: db 1, 2, 3, 4, 5, 6
+ times 10 db 7
+pb_2to6_3x7:
+pb_2to6_11x7: db 2, 3, 4, 5, 6
+ times 11 db 7
+pb_1toE_2xF: db 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15
+pb_2toE_3xF: db 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15
+pb_13456_3xm1: db 1, 3, 4, 5, 6
+ times 3 db -1
+pb_6012_4xm1: db 6, 0, 1, 2
+ times 4 db -1
+pb_6xm1_246_8toE: times 6 db -1
+ db 2, 4, 6, 8, 9, 10, 11, 12, 13, 14
+pb_6xm1_BDF_0to6: times 6 db -1
+ db 11, 13, 15, 0, 1, 2, 3, 4, 5, 6
+pb_02468ACE_13579BDF: db 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15
+pb_7to1_9x0: db 7, 6, 5, 4
+pb_3to1_5x0: db 3, 2, 1
+ times 9 db 0
+pb_Fto0: db 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
+
+pb_2: times 16 db 2
+pb_15: times 16 db 15
+
+cextern pb_1
+cextern pb_3
+
+SECTION .text
+
+; dc_NxN(uint8_t *dst, ptrdiff_t stride, const uint8_t *l, const uint8_t *a)
+
+INIT_MMX ssse3
+cglobal vp9_ipred_dc_4x4, 4, 4, 0, dst, stride, l, a
+ movd m0, [lq]
+ punpckldq m0, [aq]
+ pxor m1, m1
+ psadbw m0, m1
+ pmulhrsw m0, [pw_4096]
+ pshufb m0, m1
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*1], m0
+ lea dstq, [dstq+strideq*2]
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*1], m0
+ RET
+
+INIT_MMX ssse3
+cglobal vp9_ipred_dc_8x8, 4, 4, 0, dst, stride, l, a
+ movq m0, [lq]
+ movq m1, [aq]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ pxor m2, m2
+ psadbw m0, m2
+ psadbw m1, m2
+ paddw m0, m1
+ pmulhrsw m0, [pw_2048]
+ pshufb m0, m2
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ RET
+
+INIT_XMM ssse3
+cglobal vp9_ipred_dc_16x16, 4, 4, 3, dst, stride, l, a
+ mova m0, [lq]
+ mova m1, [aq]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ pxor m2, m2
+ psadbw m0, m2
+ psadbw m1, m2
+ paddw m0, m1
+ movhlps m1, m0
+ paddw m0, m1
+ pmulhrsw m0, [pw_1024]
+ pshufb m0, m2
+ mov cntd, 4
+.loop:
+ mova [dstq+strideq*0], m0
+ mova [dstq+strideq*1], m0
+ mova [dstq+strideq*2], m0
+ mova [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM ssse3
+cglobal vp9_ipred_dc_32x32, 4, 4, 5, dst, stride, l, a
+ mova m0, [lq]
+ mova m1, [lq+16]
+ mova m2, [aq]
+ mova m3, [aq+16]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ pxor m4, m4
+ psadbw m0, m4
+ psadbw m1, m4
+ psadbw m2, m4
+ psadbw m3, m4
+ paddw m0, m1
+ paddw m2, m3
+ paddw m0, m2
+ movhlps m1, m0
+ paddw m0, m1
+ pmulhrsw m0, [pw_512]
+ pshufb m0, m4
+ mov cntd, 8
+.loop:
+ mova [dstq+strideq*0+ 0], m0
+ mova [dstq+strideq*0+16], m0
+ mova [dstq+strideq*1+ 0], m0
+ mova [dstq+strideq*1+16], m0
+ mova [dstq+strideq*2+ 0], m0
+ mova [dstq+strideq*2+16], m0
+ mova [dstq+stride3q + 0], m0
+ mova [dstq+stride3q +16], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+; dc_top/left_NxN(uint8_t *dst, ptrdiff_t stride, const uint8_t *l, const uint8_t *a)
+
+%macro DC_1D_FUNCS 2 ; dir (top or left), arg (a or l)
+INIT_MMX ssse3
+cglobal vp9_ipred_dc_%1_4x4, 4, 4, 0, dst, stride, l, a
+ movd m0, [%2q]
+ pxor m1, m1
+ psadbw m0, m1
+ pmulhrsw m0, [pw_8192]
+ pshufb m0, m1
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*1], m0
+ lea dstq, [dstq+strideq*2]
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*1], m0
+ RET
+
+INIT_MMX ssse3
+cglobal vp9_ipred_dc_%1_8x8, 4, 4, 0, dst, stride, l, a
+ movq m0, [%2q]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ pxor m1, m1
+ psadbw m0, m1
+ pmulhrsw m0, [pw_4096]
+ pshufb m0, m1
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ RET
+
+INIT_XMM ssse3
+cglobal vp9_ipred_dc_%1_16x16, 4, 4, 3, dst, stride, l, a
+ mova m0, [%2q]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ pxor m2, m2
+ psadbw m0, m2
+ movhlps m1, m0
+ paddw m0, m1
+ pmulhrsw m0, [pw_2048]
+ pshufb m0, m2
+ mov cntd, 4
+.loop:
+ mova [dstq+strideq*0], m0
+ mova [dstq+strideq*1], m0
+ mova [dstq+strideq*2], m0
+ mova [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM ssse3
+cglobal vp9_ipred_dc_%1_32x32, 4, 4, 3, dst, stride, l, a
+ mova m0, [%2q]
+ mova m1, [%2q+16]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ pxor m2, m2
+ psadbw m0, m2
+ psadbw m1, m2
+ paddw m0, m1
+ movhlps m1, m0
+ paddw m0, m1
+ pmulhrsw m0, [pw_1024]
+ pshufb m0, m2
+ mov cntd, 8
+.loop:
+ mova [dstq+strideq*0+ 0], m0
+ mova [dstq+strideq*0+16], m0
+ mova [dstq+strideq*1+ 0], m0
+ mova [dstq+strideq*1+16], m0
+ mova [dstq+strideq*2+ 0], m0
+ mova [dstq+strideq*2+16], m0
+ mova [dstq+stride3q + 0], m0
+ mova [dstq+stride3q +16], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+%endmacro
+
+DC_1D_FUNCS top, a
+DC_1D_FUNCS left, l
+
+; v
+
+INIT_MMX mmx
+cglobal vp9_ipred_v_8x8, 4, 4, 0, dst, stride, l, a
+ movq m0, [aq]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*1], m0
+ movq [dstq+strideq*2], m0
+ movq [dstq+stride3q ], m0
+ RET
+
+INIT_XMM sse2
+cglobal vp9_ipred_v_16x16, 4, 4, 1, dst, stride, l, a
+ mova m0, [aq]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ mov cntd, 4
+.loop:
+ mova [dstq+strideq*0], m0
+ mova [dstq+strideq*1], m0
+ mova [dstq+strideq*2], m0
+ mova [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM sse2
+cglobal vp9_ipred_v_32x32, 4, 4, 2, dst, stride, l, a
+ mova m0, [aq]
+ mova m1, [aq+16]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ mov cntd, 8
+.loop:
+ mova [dstq+strideq*0+ 0], m0
+ mova [dstq+strideq*0+16], m1
+ mova [dstq+strideq*1+ 0], m0
+ mova [dstq+strideq*1+16], m1
+ mova [dstq+strideq*2+ 0], m0
+ mova [dstq+strideq*2+16], m1
+ mova [dstq+stride3q + 0], m0
+ mova [dstq+stride3q +16], m1
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+; h
+
+INIT_XMM ssse3
+cglobal vp9_ipred_h_4x4, 3, 4, 1, dst, stride, l, stride3
+ movd m0, [lq]
+ pshufb m0, [pb_4x3_4x2_4x1_4x0]
+ lea stride3q, [strideq*3]
+ movd [dstq+strideq*0], m0
+ psrldq m0, 4
+ movd [dstq+strideq*1], m0
+ psrldq m0, 4
+ movd [dstq+strideq*2], m0
+ psrldq m0, 4
+ movd [dstq+stride3q ], m0
+ RET
+
+%macro H_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_h_8x8, 3, 5, 4, dst, stride, l, stride3, cnt
+ mova m2, [pb_8x1_8x0]
+ mova m3, [pb_8x3_8x2]
+ lea stride3q, [strideq*3]
+ mov cntq, 1
+.loop:
+ movd m0, [lq+cntq*4]
+ pshufb m1, m0, m3
+ pshufb m0, m2
+ movq [dstq+strideq*0], m1
+ movhps [dstq+strideq*1], m1
+ movq [dstq+strideq*2], m0
+ movhps [dstq+stride3q ], m0
+ lea dstq, [dstq+strideq*4]
+ dec cntq
+ jge .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_h_16x16, 3, 5, 8, dst, stride, l, stride3, cnt
+ mova m5, [pb_1]
+ mova m6, [pb_2]
+ mova m7, [pb_3]
+ pxor m4, m4
+ lea stride3q, [strideq*3]
+ mov cntq, 3
+.loop:
+ movd m3, [lq+cntq*4]
+ pshufb m0, m3, m7
+ pshufb m1, m3, m6
+ mova [dstq+strideq*0], m0
+ mova [dstq+strideq*1], m1
+ pshufb m2, m3, m5
+ pshufb m3, m4
+ mova [dstq+strideq*2], m2
+ mova [dstq+stride3q ], m3
+ lea dstq, [dstq+strideq*4]
+ dec cntq
+ jge .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_h_32x32, 3, 5, 8, dst, stride, l, stride3, cnt
+ mova m5, [pb_1]
+ mova m6, [pb_2]
+ mova m7, [pb_3]
+ pxor m4, m4
+ lea stride3q, [strideq*3]
+ mov cntq, 7
+.loop:
+ movd m3, [lq+cntq*4]
+ pshufb m0, m3, m7
+ pshufb m1, m3, m6
+ mova [dstq+strideq*0+ 0], m0
+ mova [dstq+strideq*0+16], m0
+ mova [dstq+strideq*1+ 0], m1
+ mova [dstq+strideq*1+16], m1
+ pshufb m2, m3, m5
+ pshufb m3, m4
+ mova [dstq+strideq*2+ 0], m2
+ mova [dstq+strideq*2+16], m2
+ mova [dstq+stride3q + 0], m3
+ mova [dstq+stride3q +16], m3
+ lea dstq, [dstq+strideq*4]
+ dec cntq
+ jge .loop
+ RET
+%endmacro
+
+H_XMM_FUNCS ssse3
+H_XMM_FUNCS avx
+
+; tm
+
+INIT_MMX ssse3
+cglobal vp9_ipred_tm_4x4, 4, 4, 0, dst, stride, l, a
+ pxor m1, m1
+ pinsrw m2, [aq-1], 0
+ movd m0, [aq]
+ DEFINE_ARGS dst, stride, l, cnt
+ mova m3, [pw_m256]
+ mova m4, [pw_m255]
+ pshufb m2, m3
+ punpcklbw m0, m1
+ psubw m0, m2
+ mov cntq, 1
+.loop:
+ pinsrw m2, [lq+cntq*2], 0
+ pshufb m1, m2, m4
+ pshufb m2, m3
+ paddw m1, m0
+ paddw m2, m0
+ packuswb m1, m1
+ packuswb m2, m2
+ movd [dstq+strideq*0], m1
+ movd [dstq+strideq*1], m2
+ lea dstq, [dstq+strideq*2]
+ dec cntq
+ jge .loop
+ RET
+
+%macro TM_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_tm_8x8, 4, 4, 5, dst, stride, l, a
+ pxor m1, m1
+ pinsrw m2, [aq-1], 0
+ movh m0, [aq]
+ DEFINE_ARGS dst, stride, l, cnt
+ mova m3, [pw_m256]
+ mova m4, [pw_m255]
+ pshufb m2, m3
+ punpcklbw m0, m1
+ psubw m0, m2
+ mov cntq, 3
+.loop:
+ pinsrw m2, [lq+cntq*2], 0
+ pshufb m1, m2, m4
+ pshufb m2, m3
+ paddw m1, m0
+ paddw m2, m0
+ packuswb m1, m2
+ movh [dstq+strideq*0], m1
+ movhps [dstq+strideq*1], m1
+ lea dstq, [dstq+strideq*2]
+ dec cntq
+ jge .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_tm_16x16, 4, 4, 8, dst, stride, l, a
+ pxor m3, m3
+ pinsrw m2, [aq-1], 0
+ mova m0, [aq]
+ DEFINE_ARGS dst, stride, l, cnt
+ mova m4, [pw_m256]
+ mova m5, [pw_m255]
+ pshufb m2, m4
+ punpckhbw m1, m0, m3
+ punpcklbw m0, m3
+ psubw m1, m2
+ psubw m0, m2
+ mov cntq, 7
+.loop:
+ pinsrw m7, [lq+cntq*2], 0
+ pshufb m3, m7, m5
+ pshufb m7, m4
+ paddw m2, m3, m0
+ paddw m3, m1
+ paddw m6, m7, m0
+ paddw m7, m1
+ packuswb m2, m3
+ packuswb m6, m7
+ mova [dstq+strideq*0], m2
+ mova [dstq+strideq*1], m6
+ lea dstq, [dstq+strideq*2]
+ dec cntq
+ jge .loop
+ RET
+
+%if ARCH_X86_64
+INIT_XMM %1
+cglobal vp9_ipred_tm_32x32, 4, 4, 14, dst, stride, l, a
+ pxor m5, m5
+ pinsrw m4, [aq-1], 0
+ mova m0, [aq]
+ mova m2, [aq+16]
+ DEFINE_ARGS dst, stride, l, cnt
+ mova m8, [pw_m256]
+ mova m9, [pw_m255]
+ pshufb m4, m8
+ punpckhbw m1, m0, m5
+ punpckhbw m3, m2, m5
+ punpcklbw m0, m5
+ punpcklbw m2, m5
+ psubw m1, m4
+ psubw m0, m4
+ psubw m3, m4
+ psubw m2, m4
+ mov cntq, 15
+.loop:
+ pinsrw m13, [lq+cntq*2], 0
+ pshufb m7, m13, m9
+ pshufb m13, m8
+ paddw m4, m7, m0
+ paddw m5, m7, m1
+ paddw m6, m7, m2
+ paddw m7, m3
+ paddw m10, m13, m0
+ paddw m11, m13, m1
+ paddw m12, m13, m2
+ paddw m13, m3
+ packuswb m4, m5
+ packuswb m6, m7
+ packuswb m10, m11
+ packuswb m12, m13
+ mova [dstq+strideq*0+ 0], m4
+ mova [dstq+strideq*0+16], m6
+ mova [dstq+strideq*1+ 0], m10
+ mova [dstq+strideq*1+16], m12
+ lea dstq, [dstq+strideq*2]
+ dec cntq
+ jge .loop
+ RET
+%endif
+%endmacro
+
+TM_XMM_FUNCS ssse3
+TM_XMM_FUNCS avx
+
+; dl
+
+%macro LOWPASS 4 ; left [dst], center, right, tmp
+ pxor m%4, m%1, m%3
+ pand m%4, [pb_1]
+ pavgb m%1, m%3
+ psubusb m%1, m%4
+ pavgb m%1, m%2
+%endmacro
+
+INIT_MMX ssse3
+cglobal vp9_ipred_dl_4x4, 4, 4, 0, dst, stride, l, a
+ movq m1, [aq]
+ pshufb m0, m1, [pb_0to5_2x7]
+ pshufb m2, m1, [pb_2to6_3x7]
+ psrlq m1, 8
+ LOWPASS 0, 1, 2, 3
+
+ pshufw m1, m0, q3321
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*2], m1
+ psrlq m0, 8
+ psrlq m1, 8
+ add dstq, strideq
+ movd [dstq+strideq*0], m0
+ movd [dstq+strideq*2], m1
+ RET
+
+%macro DL_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_dl_8x8, 4, 4, 4, dst, stride, stride5, a
+ movq m0, [aq]
+ lea stride5q, [strideq*5]
+ pshufb m1, m0, [pb_1to6_10x7]
+ psrldq m2, m1, 1
+ shufps m0, m1, q3210
+ LOWPASS 0, 1, 2, 3
+
+ pshufd m1, m0, q3321
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*4], m1
+ psrldq m0, 1
+ psrldq m1, 1
+ movq [dstq+strideq*1], m0
+ movq [dstq+stride5q ], m1
+ lea dstq, [dstq+strideq*2]
+ psrldq m0, 1
+ psrldq m1, 1
+ movq [dstq+strideq*0], m0
+ movq [dstq+strideq*4], m1
+ psrldq m0, 1
+ psrldq m1, 1
+ movq [dstq+strideq*1], m0
+ movq [dstq+stride5q ], m1
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_dl_16x16, 4, 4, 6, dst, stride, l, a
+ mova m5, [pb_1toE_2xF]
+ mova m0, [aq]
+ pshufb m1, m0, m5
+ pshufb m2, m1, m5
+ pshufb m4, m0, [pb_15]
+ LOWPASS 0, 1, 2, 3
+ DEFINE_ARGS dst, stride, cnt, stride9
+ lea stride9q, [strideq*3]
+ mov cntd, 4
+ lea stride9q, [stride9q*3]
+
+.loop:
+ movhlps m4, m0
+ mova [dstq+strideq*0], m0
+ pshufb m0, m5
+ mova [dstq+strideq*8], m4
+ movhlps m4, m0
+ mova [dstq+strideq*1], m0
+ pshufb m0, m5
+ mova [dstq+stride9q ], m4
+ lea dstq, [dstq+strideq*2]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_dl_32x32, 4, 5, 8, dst, stride, cnt, a, dst16
+ mova m5, [pb_1toE_2xF]
+ mova m0, [aq]
+ mova m1, [aq+16]
+ palignr m2, m1, m0, 1
+ palignr m3, m1, m0, 2
+ LOWPASS 0, 2, 3, 4
+ pshufb m2, m1, m5
+ pshufb m3, m2, m5
+ pshufb m6, m1, [pb_15]
+ LOWPASS 1, 2, 3, 4
+ mova m7, m6
+ lea dst16q, [dstq +strideq*8]
+ mov cntd, 8
+ lea dst16q, [dst16q+strideq*8]
+.loop:
+ movhlps m7, m1
+ mova [dstq +strideq*0+ 0], m0
+ mova [dstq +strideq*0+16], m1
+ movhps [dstq+strideq*8+ 0], m0
+ movq [dstq +strideq*8+ 8], m1
+ mova [dstq +strideq*8+16], m7
+ mova [dst16q+strideq*0+ 0], m1
+ mova [dst16q+strideq*0+16], m6
+ mova [dst16q+strideq*8+ 0], m7
+ mova [dst16q+strideq*8+16], m6
+%if cpuflag(avx)
+ vpalignr m0, m1, m0, 1
+ pshufb m1, m5
+%else
+ palignr m2, m1, m0, 1
+ pshufb m1, m5
+ mova m0, m2
+%endif
+ add dstq, strideq
+ add dst16q, strideq
+ dec cntd
+ jg .loop
+ RET
+%endmacro
+
+DL_XMM_FUNCS ssse3
+DL_XMM_FUNCS avx
+
+; dr
+
+INIT_MMX ssse3
+cglobal vp9_ipred_dr_4x4, 4, 4, 0, dst, stride, l, a
+ movd m0, [lq]
+ punpckldq m0, [aq-1]
+ movd m1, [aq+3]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ palignr m1, m0, 1
+ psrlq m2, m1, 8
+ LOWPASS 0, 1, 2, 3
+
+ movd [dstq+stride3q ], m0
+ psrlq m0, 8
+ movd [dstq+strideq*2], m0
+ psrlq m0, 8
+ movd [dstq+strideq*1], m0
+ psrlq m0, 8
+ movd [dstq+strideq*0], m0
+ RET
+
+%macro DR_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_dr_8x8, 4, 4, 4, dst, stride, l, a
+ movq m1, [lq]
+ movhps m1, [aq-1]
+ movd m2, [aq+7]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ pslldq m0, m1, 1
+ palignr m2, m1, 1
+ LOWPASS 0, 1, 2, 3
+
+ movhps [dstq+strideq*0], m0
+ pslldq m0, 1
+ movhps [dstq+strideq*1], m0
+ pslldq m0, 1
+ movhps [dstq+strideq*2], m0
+ pslldq m0, 1
+ movhps [dstq+stride3q ], m0
+ pslldq m0, 1
+ lea dstq, [dstq+strideq*4]
+ movhps [dstq+strideq*0], m0
+ pslldq m0, 1
+ movhps [dstq+strideq*1], m0
+ pslldq m0, 1
+ movhps [dstq+strideq*2], m0
+ pslldq m0, 1
+ movhps [dstq+stride3q ], m0
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_dr_16x16, 4, 4, 6, dst, stride, l, a
+ mova m1, [lq]
+ movu m2, [aq-1]
+ movd m4, [aq+15]
+ DEFINE_ARGS dst, stride, stride9, cnt
+ lea stride9q, [strideq *3]
+ mov cntd, 4
+ lea stride9q, [stride9q*3]
+ palignr m4, m2, 1
+ palignr m3, m2, m1, 15
+ LOWPASS 3, 2, 4, 5
+ pslldq m0, m1, 1
+ palignr m2, m1, 1
+ LOWPASS 0, 1, 2, 4
+
+.loop:
+ mova [dstq+strideq*0 ], m3
+ movhps [dstq+strideq*8+0], m0
+ movq [dstq+strideq*8+8], m3
+ palignr m3, m0, 15
+ pslldq m0, 1
+ mova [dstq+strideq*1 ], m3
+ movhps [dstq+stride9q +0], m0
+ movq [dstq+stride9q +8], m3
+ palignr m3, m0, 15
+ pslldq m0, 1
+ lea dstq, [dstq+strideq*2]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_dr_32x32, 4, 4, 8, dst, stride, l, a
+ mova m1, [lq]
+ mova m2, [lq+16]
+ movu m3, [aq-1]
+ movu m4, [aq+15]
+ movd m5, [aq+31]
+ DEFINE_ARGS dst, stride, stride8, cnt
+ lea stride8q, [strideq*8]
+ palignr m5, m4, 1
+ palignr m6, m4, m3, 15
+ LOWPASS 5, 4, 6, 7
+ palignr m4, m3, 1
+ palignr m6, m3, m2, 15
+ LOWPASS 4, 3, 6, 7
+ palignr m3, m2, 1
+ palignr m6, m2, m1, 15
+ LOWPASS 3, 2, 6, 7
+ palignr m2, m1, 1
+ pslldq m0, m1, 1
+ LOWPASS 2, 1, 0, 6
+ mov cntd, 16
+
+ ; out=m2/m3/m4/m5
+.loop:
+ mova [dstq+stride8q*0+ 0], m4
+ mova [dstq+stride8q*0+16], m5
+ mova [dstq+stride8q*2+ 0], m3
+ mova [dstq+stride8q*2+16], m4
+ palignr m5, m4, 15
+ palignr m4, m3, 15
+ palignr m3, m2, 15
+ pslldq m2, 1
+ add dstq, strideq
+ dec cntd
+ jg .loop
+ RET
+%endmacro
+
+DR_XMM_FUNCS ssse3
+DR_XMM_FUNCS avx
+
+; vl
+
+INIT_MMX ssse3
+cglobal vp9_ipred_vl_4x4, 4, 4, 0, dst, stride, l, a
+ movq m0, [aq]
+ psrlq m1, m0, 8
+ psrlq m2, m1, 8
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+ movq [dstq+strideq*0], m1
+ movq [dstq+strideq*1], m2
+ lea dstq, [dstq+strideq*2]
+ psrlq m1, 8
+ psrlq m2, 8
+ movq [dstq+strideq*0], m1
+ movq [dstq+strideq*1], m2
+ RET
+
+%macro VL_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_vl_8x8, 4, 4, 4, dst, stride, l, a
+ movq m0, [aq]
+ pshufb m0, [pb_0to6_9x7]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ psrldq m1, m0, 1
+ psrldq m2, m0, 2
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+
+ movq [dstq+strideq*0], m1
+ movq [dstq+strideq*1], m2
+ psrldq m1, 1
+ psrldq m2, 1
+ movq [dstq+strideq*2], m1
+ movq [dstq+stride3q ], m2
+ lea dstq, [dstq+strideq*4]
+ psrldq m1, 1
+ psrldq m2, 1
+ movq [dstq+strideq*0], m1
+ movq [dstq+strideq*1], m2
+ psrldq m1, 1
+ psrldq m2, 1
+ movq [dstq+strideq*2], m1
+ movq [dstq+stride3q ], m2
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_vl_16x16, 4, 4, 5, dst, stride, l, a
+ mova m0, [aq]
+ mova m4, [pb_1toE_2xF]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ pshufb m1, m0, m4
+ pshufb m2, m1, m4
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+ mov cntd, 4
+.loop:
+ mova [dstq+strideq*0], m1
+ mova [dstq+strideq*1], m2
+ pshufb m1, m4
+ pshufb m2, m4
+ mova [dstq+strideq*2], m1
+ mova [dstq+stride3q ], m2
+ pshufb m1, m4
+ pshufb m2, m4
+ lea dstq, [dstq+strideq*4]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_vl_32x32, 4, 4, 7, dst, stride, l, a
+ mova m0, [aq]
+ mova m5, [aq+16]
+ mova m4, [pb_1toE_2xF]
+ DEFINE_ARGS dst, stride, dst16, cnt
+ palignr m2, m5, m0, 1
+ palignr m3, m5, m0, 2
+ lea dst16q, [dstq +strideq*8]
+ LOWPASS 3, 2, 0, 6
+ pavgb m2, m0
+ pshufb m0, m5, m4
+ pshufb m1, m0, m4
+ lea dst16q, [dst16q+strideq*8]
+ LOWPASS 1, 0, 5, 6
+ pavgb m0, m5
+ pshufb m5, [pb_15]
+ mov cntd, 8
+
+.loop:
+%macro %%write 3
+ mova [dstq+stride%1+ 0], %2
+ mova [dstq+stride%1+16], %3
+ movhps [dst16q+stride%1 ], %2
+ movu [dst16q+stride%1+ 8], %3
+ movq [dst16q+stride%1+24], m5
+%if cpuflag(avx)
+ palignr %2, %3, %2, 1
+ pshufb %3, m4
+%else
+ palignr m6, %3, %2, 1
+ pshufb %3, m4
+ mova %2, m6
+%endif
+%endmacro
+
+ %%write q*0, m2, m0
+ %%write q*1, m3, m1
+ lea dstq, [dstq +strideq*2]
+ lea dst16q, [dst16q+strideq*2]
+ dec cntd
+ jg .loop
+ RET
+%endmacro
+
+VL_XMM_FUNCS ssse3
+VL_XMM_FUNCS avx
+
+; vr
+
+INIT_MMX ssse3
+cglobal vp9_ipred_vr_4x4, 4, 4, 0, dst, stride, l, a
+ movq m1, [aq-1]
+ punpckldq m2, [lq]
+ movd m0, [aq]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ pavgb m0, m1
+ palignr m1, m2, 5
+ psrlq m2, m1, 8
+ psllq m3, m1, 8
+ LOWPASS 2, 1, 3, 4
+
+ ; ABCD <- for the following predictor:
+ ; EFGH
+ ; IABC | m0 contains ABCDxxxx
+ ; JEFG | m2 contains xJIEFGHx
+
+ punpckldq m0, m2
+ pshufb m2, [pb_13456_3xm1]
+ movd [dstq+strideq*0], m0
+ pshufb m0, [pb_6012_4xm1]
+ movd [dstq+stride3q ], m2
+ psrlq m2, 8
+ movd [dstq+strideq*2], m0
+ movd [dstq+strideq*1], m2
+ RET
+
+%macro VR_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_vr_8x8, 4, 4, 5, dst, stride, l, a
+ movu m1, [aq-1]
+ movhps m2, [lq]
+ movq m0, [aq]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ pavgb m0, m1
+ palignr m1, m2, 9
+ pslldq m2, m1, 1
+ pslldq m3, m1, 2
+ LOWPASS 1, 2, 3, 4
+
+ ; ABCDEFGH <- for the following predictor:
+ ; IJKLMNOP
+ ; QABCDEFG | m0 contains ABCDEFGHxxxxxxxx
+ ; RIJKLMNO | m1 contains xxVUTSRQIJKLMNOP
+ ; SQABCDEF
+ ; TRIJKLMN
+ ; USQABCDE
+ ; VTRIJKLM
+
+ punpcklqdq m0, m1 ; ABCDEFGHxxVUTSRQ
+ movq [dstq+strideq*0], m0
+ pshufb m0, [pb_6xm1_BDF_0to6] ; xxxxxxUSQABCDEFG
+ movhps [dstq+strideq*1], m1
+ pshufb m1, [pb_6xm1_246_8toE] ; xxxxxxVTRIJKLMNO
+ movhps [dstq+strideq*2], m0
+ pslldq m0, 1
+ movhps [dstq+stride3q ], m1
+ lea dstq, [dstq+strideq*4]
+ pslldq m1, 1
+ movhps [dstq+strideq*0], m0
+ pslldq m0, 1
+ movhps [dstq+strideq*1], m1
+ pslldq m1, 1
+ movhps [dstq+strideq*2], m0
+ movhps [dstq+stride3q ], m1
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_vr_16x16, 4, 4, 6, dst, stride, l, a
+ mova m0, [aq]
+ movu m1, [aq-1]
+ mova m2, [lq]
+ DEFINE_ARGS dst, stride, stride3, cnt
+ lea stride3q, [strideq*3]
+ palignr m3, m1, m2, 15
+ LOWPASS 3, 1, 0, 4
+ pavgb m0, m1
+ palignr m1, m2, 1
+ pslldq m4, m2, 1
+ LOWPASS 1, 2, 4, 5
+ pshufb m1, [pb_02468ACE_13579BDF]
+ mov cntd, 4
+
+.loop:
+ movlhps m2, m1
+ mova [dstq+strideq*0], m0
+ mova [dstq+strideq*1], m3
+ palignr m4, m0, m1, 15
+ palignr m5, m3, m2, 15
+ mova [dstq+strideq*2], m4
+ mova [dstq+stride3q ], m5
+ lea dstq, [dstq+strideq*4]
+ palignr m0, m1, 14
+ palignr m3, m2, 14
+ pslldq m1, 2
+ dec cntd
+ jg .loop
+ RET
+
+%if ARCH_X86_64
+INIT_XMM %1
+cglobal vp9_ipred_vr_32x32, 4, 4, 9, dst, stride, l, a
+ mova m0, [aq]
+ mova m2, [aq+16]
+ movu m1, [aq-1]
+ palignr m3, m2, m0, 15
+ palignr m4, m2, m0, 14
+ LOWPASS 4, 3, 2, 5
+ pavgb m3, m2
+ mova m2, [lq+16]
+ palignr m5, m1, m2, 15
+ LOWPASS 5, 1, 0, 6
+ pavgb m0, m1
+ mova m6, [lq]
+ palignr m1, m2, 1
+ palignr m7, m2, m6, 15
+ LOWPASS 1, 2, 7, 8
+ palignr m2, m6, 1
+ pslldq m7, m6, 1
+ LOWPASS 2, 6, 7, 8
+ pshufb m1, [pb_02468ACE_13579BDF]
+ pshufb m2, [pb_02468ACE_13579BDF]
+ DEFINE_ARGS dst, stride, dst16, cnt
+ lea dst16q, [dstq +strideq*8]
+ lea dst16q, [dst16q+strideq*8]
+ SBUTTERFLY qdq, 2, 1, 6
+ mov cntd, 8
+
+.loop:
+ ; even lines (0, 2, 4, ...): m1 | m0, m3
+ ; odd lines (1, 3, 5, ...): m2 | m5, m4
+%macro %%write 4
+ mova [dstq+stride%1+ 0], %3
+ mova [dstq+stride%1+16], %4
+ movhps [dst16q+stride%1 ], %2
+ movu [dst16q+stride%1+ 8], %3
+ movq [dst16q+stride%1+24], %4
+ palignr %4, %3, 15
+ palignr %3, %2, 15
+ pslldq %2, 1
+%endmacro
+
+ %%write q*0, m1, m0, m3
+ %%write q*1, m2, m5, m4
+ lea dstq, [dstq +strideq*2]
+ lea dst16q, [dst16q+strideq*2]
+ dec cntd
+ jg .loop
+ RET
+%endif
+%endmacro
+
+VR_XMM_FUNCS ssse3
+VR_XMM_FUNCS avx
+
+; hd
+
+INIT_MMX ssse3
+cglobal vp9_ipred_hd_4x4, 4, 4, 0, dst, stride, l, a
+ movd m0, [lq]
+ punpckldq m0, [aq-1]
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ psrlq m1, m0, 8
+ psrlq m2, m1, 8
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+
+ ; DHIJ <- for the following predictor:
+ ; CGDH
+ ; BFCG | m1 contains ABCDxxxx
+ ; AEBF | m2 contains EFGHIJxx
+
+ punpcklbw m1, m2
+ punpckhdq m0, m1, m2
+
+ ; m1 contains AEBFCGDH
+ ; m0 contains CGDHIJxx
+
+ movd [dstq+stride3q ], m1
+ movd [dstq+strideq*1], m0
+ psrlq m1, 16
+ psrlq m0, 16
+ movd [dstq+strideq*2], m1
+ movd [dstq+strideq*0], m0
+ RET
+
+%macro HD_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_hd_8x8, 4, 4, 4, dst, stride, l, a
+ movq m0, [lq]
+ movhps m0, [aq-1]
+ DEFINE_ARGS dst, stride, stride3, dst4
+ lea stride3q, [strideq*3]
+ lea dst4q, [dstq+strideq*4]
+ psrldq m1, m0, 1
+ psrldq m2, m1, 1
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+
+ ; HPQRSTUV <- for the following predictor
+ ; GOHPQRST
+ ; FNGOHPQR | m1 contains ABCDEFGHxxxxxxxx
+ ; EMFNGOHP | m2 contains IJKLMNOPQRSTUVxx
+ ; DLEMFNGO
+ ; CKDLEMFN
+ ; BJCKDLEM
+ ; AIBJCKDL
+
+ punpcklbw m1, m2
+ movhlps m2, m2
+
+ ; m1 contains AIBJCKDLEMFNGOHP
+ ; m2 contains QRSTUVxxxxxxxxxx
+
+ movhps [dstq +stride3q ], m1
+ movq [dst4q+stride3q ], m1
+ palignr m3, m2, m1, 2
+ movhps [dstq +strideq*2], m3
+ movq [dst4q+strideq*2], m3
+ palignr m3, m2, m1, 4
+ movhps [dstq +strideq*1], m3
+ movq [dst4q+strideq*1], m3
+ palignr m2, m1, 6
+ movhps [dstq +strideq*0], m2
+ movq [dst4q+strideq*0], m2
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_hd_16x16, 4, 6, 7, dst, stride, l, a
+ mova m0, [lq]
+ movu m3, [aq-1]
+ DEFINE_ARGS dst, stride, stride4, dst4, dst8, dst12
+ lea stride4q, [strideq*4]
+ lea dst4q, [dstq +stride4q]
+ lea dst8q, [dst4q+stride4q]
+ lea dst12q, [dst8q+stride4q]
+ psrldq m4, m3, 1
+ psrldq m5, m3, 2
+ LOWPASS 5, 4, 3, 6
+ palignr m1, m3, m0, 1
+ palignr m2, m3, m0, 2
+ LOWPASS 2, 1, 0, 6
+ pavgb m1, m0
+ SBUTTERFLY bw, 1, 2, 6
+
+ ; I PROBABLY INVERTED L0 ad L16 here
+ ; m1, m2, m5
+.loop:
+ sub stride4q, strideq
+ movhps [dstq +stride4q +0], m2
+ movq [dstq +stride4q +8], m5
+ mova [dst4q+stride4q ], m2
+ movhps [dst8q+stride4q +0], m1
+ movq [dst8q+stride4q +8], m2
+ mova [dst12q+stride4q ], m1
+%if cpuflag(avx)
+ palignr m1, m2, m1, 2
+ palignr m2, m5, m2, 2
+%else
+ palignr m3, m2, m1, 2
+ palignr m0, m5, m2, 2
+ mova m1, m3
+ mova m2, m0
+%endif
+ psrldq m5, 2
+ jg .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_hd_32x32, 4, 6, 8, dst, stride, l, a
+ mova m0, [lq]
+ mova m1, [lq+16]
+ movu m2, [aq-1]
+ movu m3, [aq+15]
+ DEFINE_ARGS dst, stride, stride8, dst8, dst16, dst24
+ lea stride8q, [strideq*8]
+ lea dst8q, [dstq +stride8q]
+ lea dst16q, [dst8q +stride8q]
+ lea dst24q, [dst16q+stride8q]
+ psrldq m4, m3, 1
+ psrldq m5, m3, 2
+ LOWPASS 5, 4, 3, 6
+ palignr m4, m3, m2, 2
+ palignr m3, m2, 1
+ LOWPASS 4, 3, 2, 6
+ palignr m3, m2, m1, 2
+ palignr m2, m1, 1
+ LOWPASS 3, 2, 1, 6
+ pavgb m2, m1
+ palignr m6, m1, m0, 1
+ palignr m1, m0, 2
+ LOWPASS 1, 6, 0, 7
+ pavgb m0, m1
+ SBUTTERFLY bw, 2, 3, 6
+ SBUTTERFLY bw, 0, 1, 6
+
+ ; m0, m1, m2, m3, m4, m5
+.loop:
+ sub stride8q, strideq
+ mova [dstq +stride8q+ 0], m3
+ mova [dstq +stride8q+16], m4
+ mova [dst8q +stride8q+ 0], m2
+ mova [dst8q +stride8q+16], m3
+ mova [dst16q+stride8q+ 0], m1
+ mova [dst16q+stride8q+16], m2
+ mova [dst24q+stride8q+ 0], m0
+ mova [dst24q+stride8q+16], m1
+%if cpuflag(avx)
+ palignr m0, m1, m0, 2
+ palignr m1, m2, m1, 2
+ palignr m2, m3, m2, 2
+ palignr m3, m4, m3, 2
+ palignr m4, m5, m4, 2
+ psrldq m5, 2
+%else
+ psrldq m6, m5, 2
+ palignr m5, m4, 2
+ palignr m4, m3, 2
+ palignr m3, m2, 2
+ palignr m2, m1, 2
+ palignr m1, m0, 2
+ mova m0, m1
+ mova m1, m2
+ mova m2, m3
+ mova m3, m4
+ mova m4, m5
+ mova m5, m6
+%endif
+ jg .loop
+ RET
+%endmacro
+
+HD_XMM_FUNCS ssse3
+HD_XMM_FUNCS avx
+
+INIT_MMX ssse3
+cglobal vp9_ipred_hu_4x4, 3, 3, 0, dst, stride, l
+ movd m0, [lq]
+ pshufb m0, [pb_3to1_5x0]
+ psrlq m1, m0, 8
+ psrlq m2, m1, 8
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+ DEFINE_ARGS dst, stride, stride3
+ lea stride3q, [strideq*3]
+ SBUTTERFLY bw, 1, 2, 0
+ palignr m2, m1, 2
+ movd [dstq+strideq*0], m1
+ movd [dstq+strideq*1], m2
+ punpckhdq m1, m1
+ punpckhdq m2, m2
+ movd [dstq+strideq*2], m1
+ movd [dstq+stride3q ], m2
+ RET
+
+%macro HU_XMM_FUNCS 1
+INIT_XMM %1
+cglobal vp9_ipred_hu_8x8, 3, 4, 4, dst, stride, l
+ movq m0, [lq]
+ pshufb m0, [pb_7to1_9x0]
+ psrldq m1, m0, 1
+ psrldq m2, m1, 1
+ LOWPASS 2, 1, 0, 3
+ pavgb m1, m0
+ DEFINE_ARGS dst, stride, stride3, dst4
+ lea stride3q, [strideq*3]
+ lea dst4q, [dstq+strideq*4]
+ SBUTTERFLY bw, 1, 2, 0
+ movq [dstq +strideq*0], m1
+ movhps [dst4q+strideq*0], m1
+ palignr m0, m2, m1, 2
+ movq [dstq +strideq*1], m0
+ movhps [dst4q+strideq*1], m0
+ palignr m0, m2, m1, 4
+ movq [dstq +strideq*2], m0
+ movhps [dst4q+strideq*2], m0
+ palignr m2, m1, 6
+ movq [dstq +stride3q ], m2
+ movhps [dst4q+stride3q ], m2
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_hu_16x16, 3, 4, 5, dst, stride, l
+ mova m0, [lq]
+ pshufb m0, [pb_Fto0]
+ mova m3, [pb_2toE_3xF]
+ pshufb m1, m0, [pb_1toE_2xF]
+ pshufb m2, m0, m3
+ LOWPASS 2, 1, 0, 4
+ pavgb m1, m0
+ DEFINE_ARGS dst, stride, stride9, cnt
+ lea stride9q, [strideq *3]
+ mov cntd, 4
+ lea stride9q, [stride9q*3]
+ SBUTTERFLY bw, 1, 2, 0
+
+.loop:
+ mova [dstq+strideq*0], m1
+ mova [dstq+strideq*8], m2
+ palignr m0, m2, m1, 2
+ pshufb m2, m3
+ mova [dstq+strideq*1], m0
+ mova [dstq+stride9q ], m2
+ palignr m1, m2, m0, 2
+ pshufb m2, m3
+ lea dstq, [dstq+strideq*2]
+ dec cntd
+ jg .loop
+ RET
+
+INIT_XMM %1
+cglobal vp9_ipred_hu_32x32, 3, 7, 7, dst, stride, l
+ mova m0, [lq]
+ mova m1, [lq+16]
+ mova m2, [pb_Fto0]
+ mova m4, [pb_2toE_3xF]
+ pshufb m0, m2
+ pshufb m1, m2
+ palignr m2, m0, m1, 1
+ palignr m3, m0, m1, 2
+ LOWPASS 3, 2, 1, 5
+ pavgb m2, m1
+ pshufb m1, m0, m4
+ pshufb m5, m0, [pb_1toE_2xF]
+ LOWPASS 1, 5, 0, 6
+ pavgb m0, m5
+ DEFINE_ARGS dst, stride, cnt, stride0, dst8, dst16, dst24
+ mov cntd, 8
+ xor stride0q, stride0q
+ lea dst8q, [dstq +strideq*8]
+ lea dst16q, [dst8q +strideq*8]
+ lea dst24q, [dst16q+strideq*8]
+ SBUTTERFLY bw, 0, 1, 5
+ SBUTTERFLY bw, 2, 3, 5
+ pshufb m6, m1, [pb_15]
+
+.loop:
+ mova [dstq +stride0q+ 0], m2
+ mova [dstq +stride0q+16], m3
+ mova [dst8q +stride0q+ 0], m3
+ mova [dst8q +stride0q+16], m0
+ mova [dst16q+stride0q+ 0], m0
+ mova [dst16q+stride0q+16], m1
+ mova [dst24q+stride0q+ 0], m1
+ mova [dst24q+stride0q+16], m6
+%if cpuflag(avx)
+ palignr m2, m3, m2, 2
+ palignr m3, m0, m3, 2
+ palignr m0, m1, m0, 2
+ pshufb m1, m4
+%else
+ pshufb m5, m1, m4
+ palignr m1, m0, 2
+ palignr m0, m3, 2
+ palignr m3, m2, 2
+ mova m2, m3
+ mova m3, m0
+ mova m0, m1
+ mova m1, m5
+%endif
+ add stride0q, strideq
+ dec cntd
+ jg .loop
+ RET
+%endmacro
+
+HU_XMM_FUNCS ssse3
+HU_XMM_FUNCS avx
+
+; FIXME 127, 128, 129 ?
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp9itxfm.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp9itxfm.asm
index ebf30440b2f..8087c2e3362 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp9itxfm.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp9itxfm.asm
@@ -2,6 +2,7 @@
;* VP9 IDCT SIMD optimizations
;*
;* Copyright (C) 2013 Clément Bœsch <u pkh me>
+;* Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
;*
;* This file is part of FFmpeg.
;*
@@ -24,62 +25,174 @@
SECTION_RODATA
-pw_11585x2: times 8 dw 23170
+pw_11585x2: times 8 dw 23170
+pw_m11585x2: times 8 dw -23170
-%macro VP9_IDCT_COEFFS 2
-pw_m%1_%2: dw -%1, %2, -%1, %2, -%1, %2, -%1, %2
-pw_%2_%1: dw %2, %1, %2, %1, %2, %1, %2, %1
+%macro VP9_IDCT_COEFFS 2-3 0
+pw_%1x2: times 8 dw %1*2
+pw_m%1x2: times 8 dw -%1*2
+pw_%2x2: times 8 dw %2*2
+pw_m%2x2: times 8 dw -%2*2
+pw_m%1_%2: times 4 dw -%1, %2
+pw_%2_%1: times 4 dw %2, %1
+pw_m%2_m%1: times 4 dw -%2, -%1
+%if %3 == 1
+pw_m%2_%1: times 4 dw -%2, %1
+pw_%1_%2: times 4 dw %1, %2
+%endif
%endmacro
-%macro VP9_IDCT_COEFFS_ALL 2
-pw_%1x2: times 8 dw %1*2
-pw_%2x2: times 8 dw %2*2
-VP9_IDCT_COEFFS %1, %2
-%endmacro
+VP9_IDCT_COEFFS 15137, 6270, 1
+VP9_IDCT_COEFFS 16069, 3196, 1
+VP9_IDCT_COEFFS 9102, 13623, 1
+VP9_IDCT_COEFFS 16305, 1606
+VP9_IDCT_COEFFS 10394, 12665
+VP9_IDCT_COEFFS 14449, 7723
+VP9_IDCT_COEFFS 4756, 15679
+VP9_IDCT_COEFFS 16364, 804
+VP9_IDCT_COEFFS 11003, 12140
+VP9_IDCT_COEFFS 14811, 7005
+VP9_IDCT_COEFFS 5520, 15426
+VP9_IDCT_COEFFS 15893, 3981
+VP9_IDCT_COEFFS 8423, 14053
+VP9_IDCT_COEFFS 13160, 9760
+VP9_IDCT_COEFFS 2404, 16207
-VP9_IDCT_COEFFS_ALL 15137, 6270
-VP9_IDCT_COEFFS_ALL 16069, 3196
-VP9_IDCT_COEFFS_ALL 9102, 13623
+pw_5283_13377: times 4 dw 5283, 13377
+pw_9929_13377: times 4 dw 9929, 13377
+pw_15212_m13377: times 4 dw 15212, -13377
+pw_15212_9929: times 4 dw 15212, 9929
+pw_m5283_m15212: times 4 dw -5283, -15212
+pw_13377x2: times 8 dw 13377*2
pd_8192: times 4 dd 8192
pw_2048: times 8 dw 2048
pw_1024: times 8 dw 1024
+pw_512: times 8 dw 512
+pw_m1: times 8 dw -1
SECTION .text
; (a*x + b*y + round) >> shift
-%macro VP9_MULSUB_2W_2X 6 ; dst1, dst2, src (unchanged), round, coefs1, coefs2
- pmaddwd m%1, m%3, %5
- pmaddwd m%2, m%3, %6
- paddd m%1, %4
- paddd m%2, %4
+%macro VP9_MULSUB_2W_2X 5 ; dst1, dst2/src, round, coefs1, coefs2
+ pmaddwd m%1, m%2, %4
+ pmaddwd m%2, %5
+ paddd m%1, %3
+ paddd m%2, %3
psrad m%1, 14
psrad m%2, 14
%endmacro
-%macro VP9_UNPACK_MULSUB_2W_4X 7 ; dst1, dst2, coef1, coef2, rnd, tmp1, tmp2
- punpckhwd m%6, m%2, m%1
- VP9_MULSUB_2W_2X %7, %6, %6, %5, [pw_m%3_%4], [pw_%4_%3]
- punpcklwd m%2, m%1
- VP9_MULSUB_2W_2X %1, %2, %2, %5, [pw_m%3_%4], [pw_%4_%3]
+%macro VP9_MULSUB_2W_4X 7 ; dst1, dst2, coef1, coef2, rnd, tmp1/src, tmp2
+ VP9_MULSUB_2W_2X %7, %6, %5, [pw_m%3_%4], [pw_%4_%3]
+ VP9_MULSUB_2W_2X %1, %2, %5, [pw_m%3_%4], [pw_%4_%3]
packssdw m%1, m%7
packssdw m%2, m%6
%endmacro
-%macro VP9_STORE_2X 5 ; reg1, reg2, tmp1, tmp2, zero
- movh m%3, [dstq]
- movh m%4, [dstq+strideq]
+%macro VP9_UNPACK_MULSUB_2W_4X 7-9 ; dst1, dst2, (src1, src2,) coef1, coef2, rnd, tmp1, tmp2
+%if %0 == 7
+ punpckhwd m%6, m%2, m%1
+ punpcklwd m%2, m%1
+ VP9_MULSUB_2W_4X %1, %2, %3, %4, %5, %6, %7
+%else
+ punpckhwd m%8, m%4, m%3
+ punpcklwd m%2, m%4, m%3
+ VP9_MULSUB_2W_4X %1, %2, %5, %6, %7, %8, %9
+%endif
+%endmacro
+
+%macro VP9_UNPACK_MULSUB_2D_4X 6 ; dst1 [src1], dst2 [src2], dst3, dst4, mul1, mul2
+ punpckhwd m%4, m%2, m%1
+ punpcklwd m%2, m%1
+ pmaddwd m%3, m%4, [pw_m%5_%6]
+ pmaddwd m%4, [pw_%6_%5]
+ pmaddwd m%1, m%2, [pw_m%5_%6]
+ pmaddwd m%2, [pw_%6_%5]
+%endmacro
+
+%macro VP9_RND_SH_SUMSUB_BA 6 ; dst1 [src1], dst2 [src2], src3, src4, tmp, round
+ SUMSUB_BA d, %1, %2, %5
+ SUMSUB_BA d, %3, %4, %5
+ paddd m%1, %6
+ paddd m%2, %6
+ paddd m%3, %6
+ paddd m%4, %6
+ psrad m%1, 14
+ psrad m%2, 14
+ psrad m%3, 14
+ psrad m%4, 14
+ packssdw m%1, m%3
+ packssdw m%2, m%4
+%endmacro
+
+%macro VP9_STORE_2X 5-6 dstq ; reg1, reg2, tmp1, tmp2, zero, dst
+ movh m%3, [%6]
+ movh m%4, [%6+strideq]
punpcklbw m%3, m%5
punpcklbw m%4, m%5
paddw m%3, m%1
paddw m%4, m%2
packuswb m%3, m%5
packuswb m%4, m%5
- movh [dstq], m%3
- movh [dstq+strideq], m%4
+ movh [%6], m%3
+ movh [%6+strideq], m%4
+%endmacro
+
+%macro ZERO_BLOCK 4 ; mem, stride, nnzcpl, zero_reg
+%assign %%y 0
+%rep %3
+%assign %%x 0
+%rep %3*2/mmsize
+ mova [%1+%%y+%%x], %4
+%assign %%x (%%x+mmsize)
+%endrep
+%assign %%y (%%y+%2)
+%endrep
%endmacro
;-------------------------------------------------------------------------------------------
+; void vp9_iwht_iwht_4x4_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;-------------------------------------------------------------------------------------------
+
+%macro VP9_IWHT4_1D 0
+ SWAP 1, 2, 3
+ paddw m0, m2
+ psubw m3, m1
+ psubw m4, m0, m3
+ psraw m4, 1
+ psubw m5, m4, m1
+ SWAP 5, 1
+ psubw m4, m2
+ SWAP 4, 2
+ psubw m0, m1
+ paddw m3, m2
+ SWAP 3, 2, 1
+%endmacro
+
+INIT_MMX mmx
+cglobal vp9_iwht_iwht_4x4_add, 3, 3, 0, dst, stride, block, eob
+ mova m0, [blockq+0*8]
+ mova m1, [blockq+1*8]
+ mova m2, [blockq+2*8]
+ mova m3, [blockq+3*8]
+ psraw m0, 2
+ psraw m1, 2
+ psraw m2, 2
+ psraw m3, 2
+
+ VP9_IWHT4_1D
+ TRANSPOSE4x4W 0, 1, 2, 3, 4
+ VP9_IWHT4_1D
+
+ pxor m4, m4
+ VP9_STORE_2X 0, 1, 5, 6, 4
+ lea dstq, [dstq+strideq*2]
+ VP9_STORE_2X 2, 3, 5, 6, 4
+ ZERO_BLOCK blockq, 8, 4, m4
+ RET
+
+;-------------------------------------------------------------------------------------------
; void vp9_idct_idct_4x4_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
;-------------------------------------------------------------------------------------------
@@ -175,10 +288,73 @@ cglobal vp9_idct_idct_4x4_add, 4,4,0, dst, stride, block, eob
RET
;-------------------------------------------------------------------------------------------
+; void vp9_iadst_iadst_4x4_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;-------------------------------------------------------------------------------------------
+
+%macro VP9_IADST4_1D 0
+ movq2dq xmm0, m0
+ movq2dq xmm1, m1
+ movq2dq xmm2, m2
+ movq2dq xmm3, m3
+ paddw m3, m0
+ punpcklwd xmm0, xmm1
+ punpcklwd xmm2, xmm3
+ pmaddwd xmm1, xmm0, [pw_5283_13377]
+ pmaddwd xmm4, xmm0, [pw_9929_13377]
+ pmaddwd xmm0, [pw_15212_m13377]
+ pmaddwd xmm3, xmm2, [pw_15212_9929]
+ pmaddwd xmm2, [pw_m5283_m15212]
+ psubw m3, m2
+ paddd xmm0, xmm2
+ paddd xmm3, [pd_8192]
+ paddd xmm2, [pd_8192]
+ paddd xmm1, xmm3
+ paddd xmm0, xmm3
+ paddd xmm4, xmm2
+ psrad xmm1, 14
+ psrad xmm0, 14
+ psrad xmm4, 14
+ pmulhrsw m3, [pw_13377x2] ; out2
+ packssdw xmm0, xmm0
+ packssdw xmm1, xmm1
+ packssdw xmm4, xmm4
+ movdq2q m0, xmm0 ; out3
+ movdq2q m1, xmm1 ; out0
+ movdq2q m2, xmm4 ; out1
+ SWAP 0, 1, 2, 3
+%endmacro
+
+%macro IADST4_FN 5
+INIT_MMX %5
+cglobal vp9_%1_%3_4x4_add, 3, 3, 8, dst, stride, block, eob
+ mova m0, [blockq+ 0]
+ mova m1, [blockq+ 8]
+ mova m2, [blockq+16]
+ mova m3, [blockq+24]
+ mova m6, [pw_11585x2]
+ mova m7, [pd_8192] ; rounding
+ VP9_%2_1D
+ TRANSPOSE4x4W 0, 1, 2, 3, 4
+ VP9_%4_1D
+ pxor m4, m4 ; used for the block reset, and VP9_STORE_2X
+ mova [blockq+ 0], m4
+ mova [blockq+ 8], m4
+ mova [blockq+16], m4
+ mova [blockq+24], m4
+ VP9_IDCT4_WRITEOUT
+ RET
+%endmacro
+
+IADST4_FN idct, IDCT4, iadst, IADST4, ssse3
+IADST4_FN iadst, IADST4, idct, IDCT4, ssse3
+IADST4_FN iadst, IADST4, iadst, IADST4, ssse3
+
+%if ARCH_X86_64 ; TODO: 32-bit? (32-bit limited to 8 xmm reg, we use more)
+
+;-------------------------------------------------------------------------------------------
; void vp9_idct_idct_8x8_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
;-------------------------------------------------------------------------------------------
-%if ARCH_X86_64 ; TODO: 32-bit? (32-bit limited to 8 xmm reg, we use 13 here)
%macro VP9_IDCT8_1D_FINALIZE 0
SUMSUB_BA w, 3, 10, 4 ; m3=t0+t7, m10=t0-t7
SUMSUB_BA w, 1, 2, 4 ; m1=t1+t6, m2=t1-t6
@@ -265,7 +441,8 @@ cglobal vp9_idct_idct_4x4_add, 4,4,0, dst, stride, block, eob
VP9_STORE_2X 10, 11, 6, 7, 4
%endmacro
-INIT_XMM ssse3
+%macro VP9_IDCT_IDCT_8x8_ADD_XMM 1
+INIT_XMM %1
cglobal vp9_idct_idct_8x8_add, 4,4,13, dst, stride, block, eob
mova m12, [pw_11585x2] ; often used
@@ -341,15 +518,1152 @@ cglobal vp9_idct_idct_8x8_add, 4,4,13, dst, stride, block, eob
VP9_IDCT8_1D
TRANSPOSE8x8W 0, 1, 2, 3, 8, 9, 10, 11, 4
VP9_IDCT8_1D
+
pxor m4, m4 ; used for the block reset, and VP9_STORE_2X
- mova [blockq+ 0], m4
- mova [blockq+ 16], m4
- mova [blockq+ 32], m4
- mova [blockq+ 48], m4
- mova [blockq+ 64], m4
- mova [blockq+ 80], m4
- mova [blockq+ 96], m4
- mova [blockq+112], m4
+ ZERO_BLOCK blockq, 16, 8, m4
VP9_IDCT8_WRITEOUT
RET
+%endmacro
+
+VP9_IDCT_IDCT_8x8_ADD_XMM ssse3
+VP9_IDCT_IDCT_8x8_ADD_XMM avx
+
+;---------------------------------------------------------------------------------------------
+; void vp9_iadst_iadst_8x8_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;---------------------------------------------------------------------------------------------
+
+%macro VP9_IADST8_1D 0 ; input/output=m0/1/2/3/8/9/10/11
+ VP9_UNPACK_MULSUB_2D_4X 11, 0, 4, 5, 16305, 1606 ; m11/4=t1[d], m0/5=t0[d]
+ VP9_UNPACK_MULSUB_2D_4X 3, 8, 6, 13, 10394, 12665 ; m3/6=t5[d], m8/13=t4[d]
+ VP9_RND_SH_SUMSUB_BA 8, 0, 13, 5, 14, m7 ; m8=t0[w], m0=t4[w]
+ VP9_RND_SH_SUMSUB_BA 3, 11, 6, 4, 14, m7 ; m3=t1[w], m11=t5[w]
+
+ VP9_UNPACK_MULSUB_2D_4X 9, 2, 4, 5, 14449, 7723 ; m9/4=t3[d], m2/5=t2[d]
+ VP9_UNPACK_MULSUB_2D_4X 1, 10, 6, 13, 4756, 15679 ; m1/6=t7[d], m10/13=t6[d]
+ VP9_RND_SH_SUMSUB_BA 10, 2, 13, 5, 14, m7 ; m10=t2[w], m2=t6[w]
+ VP9_RND_SH_SUMSUB_BA 1, 9, 6, 4, 14, m7 ; m1=t3[w], m9=t7[w]
+
+ ; m8=t0, m3=t1, m10=t2, m1=t3, m0=t4, m11=t5, m2=t6, m9=t7
+
+ VP9_UNPACK_MULSUB_2D_4X 0, 11, 4, 5, 15137, 6270 ; m0/4=t5[d], m11/5=t4[d]
+ VP9_UNPACK_MULSUB_2D_4X 9, 2, 6, 13, 6270, 15137 ; m9/6=t6[d], m2/13=t7[d]
+ VP9_RND_SH_SUMSUB_BA 9, 11, 6, 5, 14, m7
+ psignw m9, [pw_m1] ; m9=out1[w], m11=t6[w]
+ VP9_RND_SH_SUMSUB_BA 2, 0, 13, 4, 14, m7 ; m2=out6[w], m0=t7[w]
+
+ SUMSUB_BA w, 10, 8, 14 ; m10=out0[w], m8=t2[w]
+ SUMSUB_BA w, 1, 3, 14
+ psignw m1, [pw_m1] ; m1=out7[w], m3=t3[w]
+
+ ; m10=out0, m9=out1, m8=t2, m3=t3, m11=t6, m0=t7, m2=out6, m1=out7
+
+ SUMSUB_BA w, 3, 8, 4
+ SUMSUB_BA w, 0, 11, 5
+ pmulhrsw m3, m12
+ pmulhrsw m11, m12
+ pmulhrsw m8, m12 ; out4
+ pmulhrsw m0, m12 ; out2
+ psignw m3, [pw_m1] ; out3
+ psignw m11, [pw_m1] ; out5
+
+ ; m10=out0, m9=out1, m0=out2, m3=out3, m8=out4, m11=out5, m2=out6, m1=out7
+
+ SWAP 0, 10, 2
+ SWAP 11, 1, 9
+%endmacro
+
+%macro IADST8_FN 5
+INIT_XMM %5
+cglobal vp9_%1_%3_8x8_add, 3, 3, 15, dst, stride, block, eob
+ mova m0, [blockq+ 0] ; IN(0)
+ mova m1, [blockq+ 16] ; IN(1)
+ mova m2, [blockq+ 32] ; IN(2)
+ mova m3, [blockq+ 48] ; IN(3)
+ mova m8, [blockq+ 64] ; IN(4)
+ mova m9, [blockq+ 80] ; IN(5)
+ mova m10, [blockq+ 96] ; IN(6)
+ mova m11, [blockq+112] ; IN(7)
+
+ mova m12, [pw_11585x2] ; often used
+ mova m7, [pd_8192] ; rounding
+ VP9_%2_1D
+ TRANSPOSE8x8W 0, 1, 2, 3, 8, 9, 10, 11, 4
+ VP9_%4_1D
+
+ pxor m4, m4 ; used for the block reset, and VP9_STORE_2X
+ ZERO_BLOCK blockq, 16, 8, m4
+ VP9_IDCT8_WRITEOUT
+ RET
+%endmacro
+
+IADST8_FN idct, IDCT8, iadst, IADST8, ssse3
+IADST8_FN idct, IDCT8, iadst, IADST8, avx
+IADST8_FN iadst, IADST8, idct, IDCT8, ssse3
+IADST8_FN iadst, IADST8, idct, IDCT8, avx
+IADST8_FN iadst, IADST8, iadst, IADST8, ssse3
+IADST8_FN iadst, IADST8, iadst, IADST8, avx
+
+;---------------------------------------------------------------------------------------------
+; void vp9_idct_idct_16x16_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;---------------------------------------------------------------------------------------------
+
+; at the end of this macro, m7 is stored in stack_scratch
+; everything else (t0-6 and t8-15) is stored in m0-6 and m8-15
+; the following sumsubs have not been done yet:
+; SUMSUB_BA w, 6, 9, 15 ; t6, t9
+; SUMSUB_BA w, 7, 8, 15 ; t7, t8
+%macro VP9_IDCT16_1D_START 4 ; src, nnzc, stride, stack_scratch
+%if %2 <= 4
+ mova m3, [%1+ 1*%3] ; IN(1)
+ mova m12, [%1+ 2*%3] ; IN(2)
+ mova m0, [%1+ 3*%3] ; IN(3)
+
+ pmulhrsw m15, m12, [pw_16069x2] ; t6-7
+ pmulhrsw m12, [pw_3196x2] ; t4-5
+ pmulhrsw m4, m3, [pw_16305x2] ; t14-15
+ pmulhrsw m3, [pw_1606x2] ; t8-9
+ pmulhrsw m7, m0, [pw_m4756x2] ; t10-11
+ pmulhrsw m0, [pw_15679x2] ; t12-13
+
+ ; m8=t0, m9=t1, m10=t2, m11=t3, m12=t4, m14=t5, m13=t6, m15=t7
+ ; m3=t8, m5=t9, m1=t10, m7=t11, m0=t12, m6=t13, m2=t14, m4=t15
+
+ paddw m14, m15, m12
+ psubw m13, m15, m12
+ pmulhrsw m13, [pw_11585x2] ; t5
+ pmulhrsw m14, [pw_11585x2] ; t6
+
+ VP9_UNPACK_MULSUB_2W_4X 2, 5, 4, 3, 15137, 6270, [pd_8192], 10, 11 ; t9, t14
+ VP9_UNPACK_MULSUB_2W_4X 6, 1, 0, 7, 6270, m15137, [pd_8192], 10, 11 ; t10, t13
+
+ ; m15=t0, m14=t1, m13=t2, m12=t3, m11=t4, m10=t5, m9=t6, m8=t7
+ ; m7=t8, m6=t9, m2=t10, m3=t11, m4=t12, m5=t13, m1=t14, m0=t15
+%else
+ mova m5, [%1+ 1*%3] ; IN(1)
+ mova m14, [%1+ 2*%3] ; IN(2)
+ mova m6, [%1+ 3*%3] ; IN(3)
+ mova m9, [%1+ 4*%3] ; IN(4)
+ mova m7, [%1+ 5*%3] ; IN(5)
+ mova m15, [%1+ 6*%3] ; IN(6)
+ mova m4, [%1+ 7*%3] ; IN(7)
+%if %2 <= 8
+ pmulhrsw m8, m9, [pw_15137x2] ; t3
+ pmulhrsw m9, [pw_6270x2] ; t2
+ pmulhrsw m13, m14, [pw_16069x2] ; t7
+ pmulhrsw m14, [pw_3196x2] ; t4
+ pmulhrsw m12, m15, [pw_m9102x2] ; t5
+ pmulhrsw m15, [pw_13623x2] ; t6
+ pmulhrsw m2, m5, [pw_16305x2] ; t15
+ pmulhrsw m5, [pw_1606x2] ; t8
+ pmulhrsw m3, m4, [pw_m10394x2] ; t9
+ pmulhrsw m4, [pw_12665x2] ; t14
+ pmulhrsw m0, m7, [pw_14449x2] ; t13
+ pmulhrsw m7, [pw_7723x2] ; t10
+ pmulhrsw m1, m6, [pw_m4756x2] ; t11
+ pmulhrsw m6, [pw_15679x2] ; t12
+%else
+ mova m3, [%1+ 9*%3] ; IN(9)
+ mova m12, [%1+10*%3] ; IN(10)
+ mova m0, [%1+11*%3] ; IN(11)
+ mova m8, [%1+12*%3] ; IN(12)
+ mova m1, [%1+13*%3] ; IN(13)
+ mova m13, [%1+14*%3] ; IN(14)
+ mova m2, [%1+15*%3] ; IN(15)
+
+ ; m10=in0, m5=in1, m14=in2, m6=in3, m9=in4, m7=in5, m15=in6, m4=in7
+ ; m11=in8, m3=in9, m12=in10 m0=in11, m8=in12, m1=in13, m13=in14, m2=in15
+
+ VP9_UNPACK_MULSUB_2W_4X 9, 8, 15137, 6270, [pd_8192], 10, 11 ; t2, t3
+ VP9_UNPACK_MULSUB_2W_4X 14, 13, 16069, 3196, [pd_8192], 10, 11 ; t4, t7
+ VP9_UNPACK_MULSUB_2W_4X 12, 15, 9102, 13623, [pd_8192], 10, 11 ; t5, t6
+ VP9_UNPACK_MULSUB_2W_4X 5, 2, 16305, 1606, [pd_8192], 10, 11 ; t8, t15
+ VP9_UNPACK_MULSUB_2W_4X 3, 4, 10394, 12665, [pd_8192], 10, 11 ; t9, t14
+ VP9_UNPACK_MULSUB_2W_4X 7, 0, 14449, 7723, [pd_8192], 10, 11 ; t10, t13
+ VP9_UNPACK_MULSUB_2W_4X 1, 6, 4756, 15679, [pd_8192], 10, 11 ; t11, t12
+%endif
+
+ ; m11=t0, m10=t1, m9=t2, m8=t3, m14=t4, m12=t5, m15=t6, m13=t7
+ ; m5=t8, m3=t9, m7=t10, m1=t11, m6=t12, m0=t13, m4=t14, m2=t15
+
+ SUMSUB_BA w, 12, 14, 10 ; t4, t5
+ SUMSUB_BA w, 15, 13, 10 ; t7, t6
+ SUMSUB_BA w, 3, 5, 10 ; t8, t9
+ SUMSUB_BA w, 7, 1, 10 ; t11, t10
+ SUMSUB_BA w, 0, 6, 10 ; t12, t13
+ SUMSUB_BA w, 4, 2, 10 ; t15, t14
+
+ ; m8=t0, m9=t1, m10=t2, m11=t3, m12=t4, m14=t5, m13=t6, m15=t7
+ ; m3=t8, m5=t9, m1=t10, m7=t11, m0=t12, m6=t13, m2=t14, m4=t15
+
+ SUMSUB_BA w, 14, 13, 10
+ pmulhrsw m13, [pw_11585x2] ; t5
+ pmulhrsw m14, [pw_11585x2] ; t6
+ VP9_UNPACK_MULSUB_2W_4X 2, 5, 15137, 6270, [pd_8192], 10, 11 ; t9, t14
+ VP9_UNPACK_MULSUB_2W_4X 6, 1, 6270, m15137, [pd_8192], 10, 11 ; t10, t13
%endif
+
+ ; m8=t0, m9=t1, m10=t2, m11=t3, m12=t4, m13=t5, m14=t6, m15=t7
+ ; m3=t8, m2=t9, m6=t10, m7=t11, m0=t12, m1=t13, m5=t14, m4=t15
+
+ SUMSUB_BA w, 7, 3, 10 ; t8, t11
+ SUMSUB_BA w, 6, 2, 10 ; t9, t10
+ SUMSUB_BA w, 0, 4, 10 ; t15, t12
+ SUMSUB_BA w, 1, 5, 10 ; t14. t13
+
+ ; m15=t0, m14=t1, m13=t2, m12=t3, m11=t4, m10=t5, m9=t6, m8=t7
+ ; m7=t8, m6=t9, m2=t10, m3=t11, m4=t12, m5=t13, m1=t14, m0=t15
+
+ SUMSUB_BA w, 2, 5, 10
+ SUMSUB_BA w, 3, 4, 10
+ pmulhrsw m5, [pw_11585x2] ; t10
+ pmulhrsw m4, [pw_11585x2] ; t11
+ pmulhrsw m3, [pw_11585x2] ; t12
+ pmulhrsw m2, [pw_11585x2] ; t13
+
+ ; backup first register
+ mova [%4], m7
+
+ ; m15=t0, m14=t1, m13=t2, m12=t3, m11=t4, m10=t5, m9=t6, m8=t7
+ ; m7=t8, m6=t9, m5=t10, m4=t11, m3=t12, m2=t13, m1=t14, m0=t15
+
+ ; from load/start
+%if %2 <= 4
+ mova m11, [%1+ 0*%3] ; IN(0)
+ pmulhrsw m11, [pw_11585x2] ; t0-t3
+
+ psubw m8, m11, m15
+ paddw m15, m11
+ psubw m9, m11, m14
+ paddw m14, m11
+ psubw m10, m11, m13
+ paddw m13, m11
+%else
+ mova m10, [%1+ 0*%3] ; IN(0)
+%if %2 <= 8
+ pmulhrsw m10, [pw_11585x2] ; t0 and t1
+ psubw m11, m10, m8
+ paddw m8, m10
+%else
+ mova m11, [%1+ 8*%3] ; IN(8)
+
+ ; from 3 stages back
+ SUMSUB_BA w, 11, 10, 7
+ pmulhrsw m11, [pw_11585x2] ; t0
+ pmulhrsw m10, [pw_11585x2] ; t1
+
+ ; from 2 stages back
+ SUMSUB_BA w, 8, 11, 7 ; t0, t3
+%endif
+ SUMSUB_BA w, 9, 10, 7 ; t1, t2
+
+ ; from 1 stage back
+ SUMSUB_BA w, 15, 8, 7 ; t0, t7
+ SUMSUB_BA w, 14, 9, 7 ; t1, t6
+ SUMSUB_BA w, 13, 10, 7 ; t2, t5
+%endif
+ SUMSUB_BA w, 12, 11, 7 ; t3, t4
+
+ SUMSUB_BA w, 0, 15, 7 ; t0, t15
+ SUMSUB_BA w, 1, 14, 7 ; t1, t14
+ SUMSUB_BA w, 2, 13, 7 ; t2, t13
+ SUMSUB_BA w, 3, 12, 7 ; t3, t12
+ SUMSUB_BA w, 4, 11, 7 ; t4, t11
+ SUMSUB_BA w, 5, 10, 7 ; t5, t10
+%endmacro
+
+%macro VP9_IDCT16_1D 2-3 16 ; src, pass, nnzc
+ VP9_IDCT16_1D_START %1, %3, 32, tmpq+32
+
+%if %2 == 1
+ ; backup a different register
+ mova [tmpq+16], m15
+ mova m7, [tmpq+32]
+
+ SUMSUB_BA w, 6, 9, 15 ; t6, t9
+ SUMSUB_BA w, 7, 8, 15 ; t7, t8
+
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 15
+ mova [tmpq+ 0], m0
+ mova [tmpq+ 32], m1
+ mova [tmpq+ 64], m2
+ mova [tmpq+ 96], m3
+ mova [tmpq+128], m4
+ mova [tmpq+160], m5
+ mova [tmpq+192], m6
+ mova [tmpq+224], m7
+
+ mova m15, [tmpq+16]
+ TRANSPOSE8x8W 8, 9, 10, 11, 12, 13, 14, 15, 0
+ mova [tmpq+ 16], m8
+ mova [tmpq+ 48], m9
+ mova [tmpq+ 80], m10
+ mova [tmpq+112], m11
+ mova [tmpq+144], m12
+ mova [tmpq+176], m13
+ mova [tmpq+208], m14
+ mova [tmpq+240], m15
+%else ; %2 == 2
+ ; backup more registers
+ mova [tmpq+64], m8
+ mova [tmpq+96], m9
+
+ pxor m7, m7
+ pmulhrsw m0, [pw_512]
+ pmulhrsw m1, [pw_512]
+ VP9_STORE_2X 0, 1, 8, 9, 7
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m2, [pw_512]
+ pmulhrsw m3, [pw_512]
+ VP9_STORE_2X 2, 3, 8, 9, 7
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m4, [pw_512]
+ pmulhrsw m5, [pw_512]
+ VP9_STORE_2X 4, 5, 8, 9, 7
+ lea dstq, [dstq+strideq*2]
+
+ ; restore from cache
+ SWAP 0, 7 ; move zero from m7 to m0
+ mova m7, [tmpq+32]
+ mova m8, [tmpq+64]
+ mova m9, [tmpq+96]
+
+ SUMSUB_BA w, 6, 9, 1 ; t6, t9
+ SUMSUB_BA w, 7, 8, 1 ; t7, t8
+
+ pmulhrsw m6, [pw_512]
+ pmulhrsw m7, [pw_512]
+ VP9_STORE_2X 6, 7, 1, 2, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m8, [pw_512]
+ pmulhrsw m9, [pw_512]
+ VP9_STORE_2X 8, 9, 1, 2, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m10, [pw_512]
+ pmulhrsw m11, [pw_512]
+ VP9_STORE_2X 10, 11, 1, 2, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m12, [pw_512]
+ pmulhrsw m13, [pw_512]
+ VP9_STORE_2X 12, 13, 1, 2, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m14, [pw_512]
+ pmulhrsw m15, [pw_512]
+ VP9_STORE_2X 14, 15, 1, 2, 0
+%endif ; %2 == 1/2
+%endmacro
+
+%macro VP9_STORE_2XFULL 6-7 strideq; dc, tmp1, tmp2, tmp3, tmp4, zero, stride
+ mova m%3, [dstq]
+ mova m%5, [dstq+%7]
+ punpcklbw m%2, m%3, m%6
+ punpckhbw m%3, m%6
+ punpcklbw m%4, m%5, m%6
+ punpckhbw m%5, m%6
+ paddw m%2, m%1
+ paddw m%3, m%1
+ paddw m%4, m%1
+ paddw m%5, m%1
+ packuswb m%2, m%3
+ packuswb m%4, m%5
+ mova [dstq], m%2
+ mova [dstq+%7], m%4
+%endmacro
+
+%macro VP9_IDCT_IDCT_16x16_ADD_XMM 1
+INIT_XMM %1
+cglobal vp9_idct_idct_16x16_add, 4, 6, 16, 512, dst, stride, block, eob
+ ; 2x2=eob=3, 4x4=eob=10
+ cmp eobd, 38
+ jg .idctfull
+ cmp eobd, 1 ; faster path for when only DC is set
+ jne .idct8x8
+
+ ; dc-only
+ movd m0, [blockq]
+ mova m1, [pw_11585x2]
+ pmulhrsw m0, m1
+ pmulhrsw m0, m1
+ SPLATW m0, m0, q0000
+ pmulhrsw m0, [pw_512]
+ pxor m5, m5
+ movd [blockq], m5
+%rep 7
+ VP9_STORE_2XFULL 0, 1, 2, 3, 4, 5
+ lea dstq, [dstq+2*strideq]
+%endrep
+ VP9_STORE_2XFULL 0, 1, 2, 3, 4, 5
+ RET
+
+ DEFINE_ARGS dst, stride, block, cnt, dst_bak, tmp
+.idct8x8:
+ mov tmpq, rsp
+ VP9_IDCT16_1D blockq, 1, 8
+
+ mov cntd, 2
+ mov dst_bakq, dstq
+.loop2_8x8:
+ VP9_IDCT16_1D tmpq, 2, 8
+ lea dstq, [dst_bakq+8]
+ add tmpq, 16
+ dec cntd
+ jg .loop2_8x8
+
+ ; at the end of the loop, m0 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 32, 8, m0
+ RET
+
+.idctfull:
+ mov cntd, 2
+ mov tmpq, rsp
+.loop1_full:
+ VP9_IDCT16_1D blockq, 1
+ add blockq, 16
+ add tmpq, 256
+ dec cntd
+ jg .loop1_full
+ sub blockq, 32
+
+ mov cntd, 2
+ mov tmpq, rsp
+ mov dst_bakq, dstq
+.loop2_full:
+ VP9_IDCT16_1D tmpq, 2
+ lea dstq, [dst_bakq+8]
+ add tmpq, 16
+ dec cntd
+ jg .loop2_full
+
+ ; at the end of the loop, m0 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 32, 16, m0
+ RET
+%endmacro
+
+VP9_IDCT_IDCT_16x16_ADD_XMM ssse3
+VP9_IDCT_IDCT_16x16_ADD_XMM avx
+
+;---------------------------------------------------------------------------------------------
+; void vp9_iadst_iadst_16x16_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;---------------------------------------------------------------------------------------------
+
+%macro VP9_IADST16_1D 2 ; src, pass
+%assign %%str 16*%2
+ mova m0, [%1+ 0*32] ; in0
+ mova m1, [%1+15*32] ; in15
+ mova m8, [%1+ 7*32] ; in7
+ mova m9, [%1+ 8*32] ; in8
+
+ VP9_UNPACK_MULSUB_2D_4X 1, 0, 2, 3, 16364, 804 ; m1/2=t1[d], m0/3=t0[d]
+ VP9_UNPACK_MULSUB_2D_4X 8, 9, 11, 10, 11003, 12140 ; m8/11=t9[d], m9/10=t8[d]
+ VP9_RND_SH_SUMSUB_BA 9, 0, 10, 3, 4, [pd_8192] ; m9=t0[w], m0=t8[w]
+ VP9_RND_SH_SUMSUB_BA 8, 1, 11, 2, 4, [pd_8192] ; m8=t1[w], m1=t9[w]
+
+ mova m11, [%1+ 2*32] ; in2
+ mova m10, [%1+13*32] ; in13
+ mova m3, [%1+ 5*32] ; in5
+ mova m2, [%1+10*32] ; in10
+
+ VP9_UNPACK_MULSUB_2D_4X 10, 11, 6, 7, 15893, 3981 ; m10/6=t3[d], m11/7=t2[d]
+ VP9_UNPACK_MULSUB_2D_4X 3, 2, 4, 5, 8423, 14053 ; m3/4=t11[d], m2/5=t10[d]
+ VP9_RND_SH_SUMSUB_BA 2, 11, 5, 7, 12, [pd_8192] ; m2=t2[w], m11=t10[w]
+ VP9_RND_SH_SUMSUB_BA 3, 10, 4, 6, 12, [pd_8192] ; m3=t3[w], m10=t11[w]
+
+ mova [tmpq+ 0*%%str], m9 ; make some scratch space (t0:m9->r0)
+ mova m4, [%1+ 4*32] ; in4
+ mova m5, [%1+11*32] ; in11
+ mova m12, [%1+ 3*32] ; in3
+ mova m13, [%1+12*32] ; in12
+
+ VP9_UNPACK_MULSUB_2D_4X 5, 4, 7, 6, 14811, 7005 ; m5/7=t5[d], m4/6=t4[d]
+ VP9_UNPACK_MULSUB_2D_4X 12, 13, 14, 15, 5520, 15426 ; m12/14=t13[d], m13/15=t12[d]
+ VP9_RND_SH_SUMSUB_BA 13, 4, 15, 6, 9, [pd_8192] ; m13=t4[w], m4=t12[w]
+ VP9_RND_SH_SUMSUB_BA 12, 5, 14, 7, 9, [pd_8192] ; m12=t5[w], m5=t13[w]
+
+ mova [tmpq+ 2*%%str], m8 ; t1:m9->r2
+ mova [tmpq+ 3*%%str], m2 ; t2:m2->r3
+ mova [tmpq+ 4*%%str], m3 ; t3:m3->r4
+ mova [tmpq+ 5*%%str], m13 ; t4:m13->r5
+ mova m2, [%1+ 6*32] ; in6
+ mova m3, [%1+ 9*32] ; in9
+ mova m8, [%1+ 1*32] ; in1
+ mova m9, [%1+14*32] ; in14
+
+ VP9_UNPACK_MULSUB_2D_4X 3, 2, 7, 6, 13160, 9760 ; m3/7=t7[d], m2/6=t6[d]
+ VP9_UNPACK_MULSUB_2D_4X 8, 9, 13, 14, 2404, 16207 ; m8/13=t15[d], m9/14=t14[d]
+ VP9_RND_SH_SUMSUB_BA 9, 2, 14, 6, 15, [pd_8192] ; m9=t6[w], m2=t14[w]
+ VP9_RND_SH_SUMSUB_BA 8, 3, 13, 7, 15, [pd_8192] ; m8=t7[w], m3=t15[w]
+
+ ; r0=t0, r2=t1, r3=t2, r4=t3, r5=t4, m12=t5, m9=t6, m8=t7
+ ; m0=t8, m1=t9, m11=t10, m10=t11, m4=t12, m5=t13, m2=t14, m3=t15
+
+ ; handle t8-15 first
+ VP9_UNPACK_MULSUB_2D_4X 0, 1, 6, 7, 16069, 3196 ; m1/7=t8[d], m0/6=t9[d]
+ VP9_UNPACK_MULSUB_2D_4X 5, 4, 13, 14, 3196, 16069 ; m5/13=t12[d], m4/14=t13[d]
+ VP9_RND_SH_SUMSUB_BA 5, 1, 13, 7, 15, [pd_8192] ; m5=t8[w], m1=t12[w]
+ VP9_RND_SH_SUMSUB_BA 4, 0, 14, 6, 15, [pd_8192] ; m4=t9[w], m0=t13[w]
+
+ VP9_UNPACK_MULSUB_2D_4X 11, 10, 6, 7, 9102, 13623 ; m11/6=t11[d], m10/7=t10[d]
+ VP9_UNPACK_MULSUB_2D_4X 3, 2, 13, 14, 13623, 9102 ; m3/13=t14[d], m2/14=t15[d]
+ VP9_RND_SH_SUMSUB_BA 3, 10, 13, 7, 15, [pd_8192] ; m3=t10[w], m10=t14[w]
+ VP9_RND_SH_SUMSUB_BA 2, 11, 14, 6, 15, [pd_8192] ; m2=t11[w], m11=t15[w]
+
+ ; m5=t8, m4=t9, m3=t10, m2=t11, m1=t12, m0=t13, m10=t14, m11=t15
+
+ VP9_UNPACK_MULSUB_2D_4X 1, 0, 6, 7, 15137, 6270 ; m1/6=t13[d], m0/7=t12[d]
+ VP9_UNPACK_MULSUB_2D_4X 11, 10, 13, 14, 6270, 15137 ; m11/13=t14[d], m10/14=t15[d]
+ VP9_RND_SH_SUMSUB_BA 11, 0, 13, 7, 15, [pd_8192] ; m11=out2[w], m0=t14[w]
+ VP9_RND_SH_SUMSUB_BA 10, 1, 14, 6, 15, [pd_8192]
+ psignw m10, [pw_m1] ; m10=out13[w], m1=t15[w]
+
+ SUMSUB_BA w, 3, 5, 15
+ psignw m3, [pw_m1] ; m3=out1[w], m5=t10[w]
+ SUMSUB_BA w, 2, 4, 15 ; m2=out14[w], m4=t11[w]
+
+ SUMSUB_BA w, 5, 4, 15
+ pmulhrsw m5, [pw_11585x2] ; m5=out6[w]
+ pmulhrsw m4, [pw_11585x2] ; m4=out9[w]
+ SUMSUB_BA w, 1, 0, 15
+ pmulhrsw m1, [pw_m11585x2] ; m1=out5[w]
+ pmulhrsw m0, [pw_11585x2] ; m0=out10[w]
+
+ ; m3=out1, m11=out2, m1=out5, m5=out6, m4=out9, m0=out10, m10=out13, m2=out14
+
+ mova m6, [tmpq+ 0*%%str]
+ mova m7, [tmpq+ 2*%%str]
+ mova m13, [tmpq+ 3*%%str]
+ mova m14, [tmpq+ 4*%%str]
+ mova m15, [tmpq+ 5*%%str]
+ mova [tmpq+ 8*%%str], m5
+ mova [tmpq+ 9*%%str], m4
+ mova [tmpq+10*%%str], m0
+ mova [tmpq+11*%%str], m10
+ mova [tmpq+12*%%str], m2
+
+ ; m6=t0, m7=t1, m13=t2, m14=t3, m15=t4, m12=t5, m9=t6, m8=t7
+ ; m3=out1, m11=out2, m1=out5, r8=out6, r9=out9, r10=out10, r11=out13, r12=out14
+
+ SUMSUB_BA w, 15, 6, 0 ; m15=t0[w], m6=t4[w]
+ SUMSUB_BA w, 12, 7, 0 ; m12=t1[w], m7=t5[w]
+ SUMSUB_BA w, 9, 13, 0 ; m9=t2[w], m13=t6[w]
+ SUMSUB_BA w, 8, 14, 0 ; m8=t3[w], m14=t7[w]
+
+ VP9_UNPACK_MULSUB_2D_4X 6, 7, 0, 2, 15137, 6270 ; m6/0=t5[d], m7/2=t4[d]
+ VP9_UNPACK_MULSUB_2D_4X 14, 13, 4, 5, 6270, 15137 ; m14/4=t6[d], m13/5=t7[d]
+ VP9_RND_SH_SUMSUB_BA 14, 7, 4, 2, 10, [pd_8192]
+ psignw m14, [pw_m1] ; m14=out3[w], m7=t6[w]
+ VP9_RND_SH_SUMSUB_BA 13, 6, 5, 0, 10, [pd_8192] ; m13=out12[w], m6=t7[w]
+ SUMSUB_BA w, 9, 15, 10 ; m9=out0[w], m15=t2[w]
+ SUMSUB_BA w, 8, 12, 10
+ psignw m8, [pw_m1] ; m8=out15[w], m12=t3[w]
+
+ SUMSUB_BA w, 12, 15, 10
+ pmulhrsw m12, [pw_m11585x2] ; m12=out7[w]
+ pmulhrsw m15, [pw_11585x2] ; m15=out8[w]
+ SUMSUB_BA w, 7, 6, 10
+ pmulhrsw m7, [pw_11585x2] ; m7=out4[w]
+ pmulhrsw m6, [pw_11585x2] ; m6=out11[w]
+
+ ; m9=out0, m14=out3, m7=out4, m12=out7, m15=out8, m6=out11, m13=out12, m8=out15
+ ; m3=out1, m11=out2, m1=out5, r8=out6, r9=out9, r10=out10, r11=out13, r12=out14
+
+%if %2 == 1
+ mova m0, [tmpq+ 8*%%str]
+ TRANSPOSE8x8W 9, 3, 11, 14, 7, 1, 0, 12, 2
+ mova [tmpq+ 0*16], m9
+ mova [tmpq+ 2*16], m3
+ mova [tmpq+ 4*16], m11
+ mova [tmpq+ 6*16], m14
+ mova m9, [tmpq+ 9*%%str]
+ mova m3, [tmpq+10*%%str]
+ mova m11, [tmpq+11*%%str]
+ mova m14, [tmpq+12*%%str]
+ mova [tmpq+ 8*16], m7
+ mova [tmpq+10*16], m1
+ mova [tmpq+12*16], m0
+ mova [tmpq+14*16], m12
+
+ TRANSPOSE8x8W 15, 9, 3, 6, 13, 11, 14, 8, 2
+ mova [tmpq+ 1*16], m15
+ mova [tmpq+ 3*16], m9
+ mova [tmpq+ 5*16], m3
+ mova [tmpq+ 7*16], m6
+ mova [tmpq+ 9*16], m13
+ mova [tmpq+11*16], m11
+ mova [tmpq+13*16], m14
+ mova [tmpq+15*16], m8
+%else
+ mova m5, [tmpq+ 8*%%str]
+ pxor m0, m0
+
+ pmulhrsw m9, [pw_512]
+ pmulhrsw m3, [pw_512]
+ VP9_STORE_2X 9, 3, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m11, [pw_512]
+ pmulhrsw m14, [pw_512]
+ VP9_STORE_2X 11, 14, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m7, [pw_512]
+ pmulhrsw m1, [pw_512]
+ VP9_STORE_2X 7, 1, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m5, [pw_512]
+ pmulhrsw m12, [pw_512]
+ VP9_STORE_2X 5, 12, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+
+ mova m9, [tmpq+ 9*%%str]
+ mova m3, [tmpq+10*%%str]
+ mova m11, [tmpq+11*%%str]
+ mova m14, [tmpq+12*%%str]
+
+ pmulhrsw m15, [pw_512]
+ pmulhrsw m9, [pw_512]
+ VP9_STORE_2X 15, 9, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m3, [pw_512]
+ pmulhrsw m6, [pw_512]
+ VP9_STORE_2X 3, 6, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m13, [pw_512]
+ pmulhrsw m11, [pw_512]
+ VP9_STORE_2X 13, 11, 2, 4, 0
+ lea dstq, [dstq+strideq*2]
+ pmulhrsw m14, [pw_512]
+ pmulhrsw m8, [pw_512]
+ VP9_STORE_2X 14, 8, 2, 4, 0
+%endif
+%endmacro
+
+%macro IADST16_FN 5
+INIT_XMM %5
+cglobal vp9_%1_%3_16x16_add, 3, 6, 16, 512, dst, stride, block, cnt, dst_bak, tmp
+ mov cntd, 2
+ mov tmpq, rsp
+.loop1_full:
+ VP9_%2_1D blockq, 1
+ add blockq, 16
+ add tmpq, 256
+ dec cntd
+ jg .loop1_full
+ sub blockq, 32
+
+ mov cntd, 2
+ mov tmpq, rsp
+ mov dst_bakq, dstq
+.loop2_full:
+ VP9_%4_1D tmpq, 2
+ lea dstq, [dst_bakq+8]
+ add tmpq, 16
+ dec cntd
+ jg .loop2_full
+
+ ; at the end of the loop, m0 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 32, 16, m0
+ RET
+%endmacro
+
+IADST16_FN idct, IDCT16, iadst, IADST16, ssse3
+IADST16_FN idct, IDCT16, iadst, IADST16, avx
+IADST16_FN iadst, IADST16, idct, IDCT16, ssse3
+IADST16_FN iadst, IADST16, idct, IDCT16, avx
+IADST16_FN iadst, IADST16, iadst, IADST16, ssse3
+IADST16_FN iadst, IADST16, iadst, IADST16, avx
+
+;---------------------------------------------------------------------------------------------
+; void vp9_idct_idct_32x32_add_<opt>(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob);
+;---------------------------------------------------------------------------------------------
+
+%macro VP9_IDCT32_1D 2-3 32 ; src, pass, nnzc
+%assign %%str 16*%2*%2
+ ; first do t0-15, this can be done identical to idct16x16
+ VP9_IDCT16_1D_START %1, %3/2, 64*2, tmpq+ 4*%%str
+
+ ; backup a different register
+ mova [tmpq+30*%%str], m15 ; t15
+ mova m7, [tmpq+ 4*%%str]
+
+ SUMSUB_BA w, 6, 9, 15 ; t6, t9
+ SUMSUB_BA w, 7, 8, 15 ; t7, t8
+
+ ; store everything on stack to make space available for t16-31
+ ; we store interleaved with the output of the second half (t16-31)
+ ; so we don't need to allocate extra stack space
+ mova [tmpq+ 0*%%str], m0 ; t0
+ mova [tmpq+ 4*%%str], m1 ; t1
+ mova [tmpq+ 8*%%str], m2 ; t2
+ mova [tmpq+12*%%str], m3 ; t3
+ mova [tmpq+16*%%str], m4 ; t4
+ mova [tmpq+20*%%str], m5 ; t5
+ mova [tmpq+24*%%str], m6 ; t6
+ mova [tmpq+28*%%str], m7 ; t7
+ mova [tmpq+ 2*%%str], m8 ; t8
+ mova [tmpq+ 6*%%str], m9 ; t9
+ mova [tmpq+10*%%str], m10 ; t10
+ mova [tmpq+14*%%str], m11 ; t11
+ mova [tmpq+18*%%str], m12 ; t12
+ mova [tmpq+22*%%str], m13 ; t13
+ mova [tmpq+26*%%str], m14 ; t14
+
+ ; then, secondly, do t16-31
+%if %3 <= 8
+ mova m4, [%1+ 1*64]
+ mova m3, [%1+ 3*64]
+ mova m0, [%1+ 5*64]
+ mova m7, [%1+ 7*64]
+
+ pmulhrsw m11, m4, [pw_16364x2] ;t31
+ pmulhrsw m4, [pw_804x2] ;t16
+ pmulhrsw m8, m7, [pw_m5520x2] ;t19
+ pmulhrsw m7, [pw_15426x2] ;t28
+ pmulhrsw m15, m0, [pw_15893x2] ;t27
+ pmulhrsw m0, [pw_3981x2] ;t20
+ pmulhrsw m12, m3, [pw_m2404x2] ;t23
+ pmulhrsw m3, [pw_16207x2] ;t24
+
+ ; m4=t16/17, m8=t18/19, m0=t20/21, m12=t22/23,
+ ; m3=t24/25, m15=t26/27, m7=t28/29, m11=t30/31
+
+ VP9_UNPACK_MULSUB_2W_4X 5, 10, 11, 4, 16069, 3196, [pd_8192], 6, 9 ; t17, t30
+ VP9_UNPACK_MULSUB_2W_4X 9, 6, 7, 8, 3196, m16069, [pd_8192], 1, 14 ; t18, t29
+ ; from 1 stage forward
+ SUMSUB_BA w, 8, 4, 1
+ ; temporary storage
+ mova [tmpq+17*%%str], m8 ; t16
+ mova [tmpq+21*%%str], m4 ; t19
+ VP9_UNPACK_MULSUB_2W_4X 1, 14, 15, 0, 9102, 13623, [pd_8192], 4, 8 ; t21, t26
+ VP9_UNPACK_MULSUB_2W_4X 13, 2, 3, 12, 13623, m9102, [pd_8192], 4, 8 ; t22, t25
+
+ ; m4=t16, m5=t17, m9=t18, m8=t19, m0=t20, m1=t21, m13=t22, m12=t23,
+ ; m3=t24, m2=t25, m14=t26, m15=t27, m7=t28, m6=t29, m10=t30, m11=t31
+%else
+ mova m10, [%1+ 1*64]
+ mova m13, [%1+ 3*64]
+ mova m14, [%1+ 5*64]
+ mova m9, [%1+ 7*64]
+ mova m8, [%1+ 9*64]
+ mova m15, [%1+11*64]
+ mova m12, [%1+13*64]
+ mova m11, [%1+15*64]
+%if %3 <= 16
+ pmulhrsw m5, m10, [pw_16364x2]
+ pmulhrsw m10, [pw_804x2]
+ pmulhrsw m4, m11, [pw_m11003x2]
+ pmulhrsw m11, [pw_12140x2]
+ pmulhrsw m7, m8, [pw_14811x2]
+ pmulhrsw m8, [pw_7005x2]
+ pmulhrsw m6, m9, [pw_m5520x2]
+ pmulhrsw m9, [pw_15426x2]
+ pmulhrsw m1, m14, [pw_15893x2]
+ pmulhrsw m14, [pw_3981x2]
+ pmulhrsw m0, m15, [pw_m8423x2]
+ pmulhrsw m15, [pw_14053x2]
+%else
+ mova m4, [%1+17*64]
+ mova m0, [%1+21*64]
+ mova m7, [%1+23*64]
+ mova m6, [%1+25*64]
+ mova m1, [%1+27*64]
+ mova m5, [%1+31*64]
+
+ ; m10=in1, m4=in17, m8=in9, m6=in25, m14=in5, m0=in21, m12=in13, m2=in29,
+ ; m13=in3, m3=in19, m15=in11, m1=in27, m9=in7, m7=in23, m11=in15, m5=in31
+
+ VP9_UNPACK_MULSUB_2W_4X 10, 5, 16364, 804, [pd_8192], 2, 3 ; t16, t31
+ VP9_UNPACK_MULSUB_2W_4X 4, 11, 11003, 12140, [pd_8192], 2, 3 ; t17, t30
+ VP9_UNPACK_MULSUB_2W_4X 8, 7, 14811, 7005, [pd_8192], 2, 3 ; t18, t29
+ VP9_UNPACK_MULSUB_2W_4X 6, 9, 5520, 15426, [pd_8192], 2, 3 ; t19, t28
+ VP9_UNPACK_MULSUB_2W_4X 14, 1, 15893, 3981, [pd_8192], 2, 3 ; t20, t27
+ VP9_UNPACK_MULSUB_2W_4X 0, 15, 8423, 14053, [pd_8192], 2, 3 ; t21, t26
+%endif
+
+ ; from 1 stage forward
+ SUMSUB_BA w, 4, 10, 2
+ SUMSUB_BA w, 8, 6, 2
+ ; from 2 stages forward
+ SUMSUB_BA w, 8, 4, 2
+ ; temporary storage
+ mova [tmpq+17*%%str], m8 ; t16
+ mova [tmpq+21*%%str], m4 ; t19
+%if %3 <= 16
+ pmulhrsw m3, m12, [pw_13160x2]
+ pmulhrsw m12, [pw_9760x2]
+ pmulhrsw m2, m13, [pw_m2404x2]
+ pmulhrsw m13, [pw_16207x2]
+%else
+ mova m2, [%1+29*64]
+ mova m3, [%1+19*64]
+ VP9_UNPACK_MULSUB_2W_4X 12, 3, 13160, 9760, [pd_8192], 4, 8 ; t22, t25
+ VP9_UNPACK_MULSUB_2W_4X 2, 13, 2404, 16207, [pd_8192], 4, 8 ; t23, t24
+%endif
+
+ ; m10=t16, m4=t17, m8=t18, m6=t19, m14=t20, m0=t21, m12=t22, m2=t23,
+ ; m13=t24, m3=t25, m15=t26, m1=t27, m9=t28, m7=t29, m11=t30, m5=t31
+
+ SUMSUB_BA w, 0, 14, 4
+ SUMSUB_BA w, 12, 2, 4
+ SUMSUB_BA w, 3, 13, 4
+ SUMSUB_BA w, 15, 1, 4
+ SUMSUB_BA w, 7, 9, 4
+ SUMSUB_BA w, 11, 5, 4
+
+ ; m4=t16, m10=t17, m6=t18, m8=t19, m0=t20, m14=t21, m2=t22, m12=t23,
+ ; m3=t24, m13=t25, m1=t26, m15=t27, m7=t28, m9=t29, m5=t30, m11=t31
+
+ VP9_UNPACK_MULSUB_2W_4X 5, 10, 16069, 3196, [pd_8192], 4, 8 ; t17, t30
+ VP9_UNPACK_MULSUB_2W_4X 9, 6, 3196, m16069, [pd_8192], 4, 8 ; t18, t29
+ VP9_UNPACK_MULSUB_2W_4X 1, 14, 9102, 13623, [pd_8192], 4, 8 ; t21, t26
+ VP9_UNPACK_MULSUB_2W_4X 13, 2, 13623, m9102, [pd_8192], 4, 8 ; t22, t25
+%endif
+
+ ; m4=t16, m5=t17, m9=t18, m8=t19, m0=t20, m1=t21, m13=t22, m12=t23,
+ ; m3=t24, m2=t25, m14=t26, m15=t27, m7=t28, m6=t29, m10=t30, m11=t31
+
+ SUMSUB_BA w, 9, 5, 4
+ SUMSUB_BA w, 1, 13, 4
+ SUMSUB_BA w, 0, 12, 4
+ SUMSUB_BA w, 15, 3, 4
+ SUMSUB_BA w, 14, 2, 4
+ SUMSUB_BA w, 6, 10, 4
+ SUMSUB_BA w, 7, 11, 4
+
+ ; m8[s]=t16, m9=t17, m5=t18, m4[s]=t19, m12=t20, m13=t21, m1=t22, m0=t23,
+ ; m15=t24, m14=t25, m2=t26, m3=t27, m11=t28, m10=t29, m6=t30, m7=t31
+
+ mova m8, [tmpq+17*%%str] ; t16
+ ; from 2 stages forward
+ SUMSUB_BA w, 0, 8, 4
+ SUMSUB_BA w, 15, 7, 4
+ ; from 3 stages forward
+ SUMSUB_BA w, 8, 7, 4
+ pmulhrsw m7, [pw_11585x2]
+ pmulhrsw m8, [pw_11585x2]
+ ; store t16/t23
+ mova [tmpq+ 1*%%str], m0 ; t16
+ mova [tmpq+29*%%str], m7 ; t23
+
+ mova m4, [tmpq+21*%%str] ; t19
+ VP9_UNPACK_MULSUB_2W_4X 10, 5, 15137, 6270, [pd_8192], 0, 7 ; t18, t29
+ VP9_UNPACK_MULSUB_2W_4X 11, 4, 15137, 6270, [pd_8192], 0, 7 ; t19, t28
+ VP9_UNPACK_MULSUB_2W_4X 3, 12, 6270, m15137, [pd_8192], 0, 7 ; t20, t27
+ VP9_UNPACK_MULSUB_2W_4X 2, 13, 6270, m15137, [pd_8192], 0, 7 ; t21, t26
+
+ ; m8=t16, m9=t17, m10=t18, m11=t19, m3=t20, m2=t21, m1=t22, m0=t23,
+ ; m15=t24, m14=t25, m13=t26, m12=t27, m4=t28, m5=t29, m6=t30, m7=t31
+
+ SUMSUB_BA w, 1, 9, 0
+ SUMSUB_BA w, 2, 10, 0
+ SUMSUB_BA w, 3, 11, 0
+ SUMSUB_BA w, 12, 4, 0
+ SUMSUB_BA w, 13, 5, 0
+ SUMSUB_BA w, 14, 6, 0
+
+ ; m0=t16, m1=t17, m2=t18, m3=t19, m11=t20, m10=t21, m9=t22, m8=t23,
+ ; m7=t24, m6=t25, m5=t26, m4=t27, m12=t28, m13=t29, m14=t30, m15=t31
+
+ SUMSUB_BA w, 9, 6, 0
+ SUMSUB_BA w, 10, 5, 0
+ SUMSUB_BA w, 11, 4, 0
+
+ pmulhrsw m6, [pw_11585x2]
+ pmulhrsw m9, [pw_11585x2]
+ pmulhrsw m5, [pw_11585x2]
+ pmulhrsw m10, [pw_11585x2]
+ pmulhrsw m4, [pw_11585x2]
+ pmulhrsw m11, [pw_11585x2]
+
+ ; m0=t16, m1=t17, m2=t18, m3=t19, m4=t20, m5=t21, m6=t22, m7=t23,
+ ; m8=t24, m9=t25, m10=t26, m11=t27, m12=t28, m13=t29, m14=t30, m15=t31
+
+ ; store t17-19 (and t20-22 for pass 1) - keep t24-31 in registers for
+ ; final sumsub in pass 1, or keep t20-22 and t24-31 in registers for
+ ; final sumsub of pass 2
+ mova [tmpq+ 5*%%str], m1 ; t17
+ mova [tmpq+ 9*%%str], m2 ; t18
+ mova [tmpq+13*%%str], m3 ; t19
+
+ ; then do final pass to sumsub+store the two halves
+%if %2 == 1
+ mova [tmpq+17*%%str], m4 ; t20
+ mova [tmpq+21*%%str], m5 ; t21
+ mova [tmpq+25*%%str], m6 ; t22
+
+ mova m0, [tmpq+ 0*%%str] ; t0
+ mova m1, [tmpq+ 4*%%str] ; t1
+ mova m2, [tmpq+ 8*%%str] ; t2
+ mova m3, [tmpq+12*%%str] ; t3
+ mova m4, [tmpq+16*%%str] ; t4
+ mova m5, [tmpq+20*%%str] ; t5
+ mova m6, [tmpq+24*%%str] ; t6
+
+ SUMSUB_BA w, 15, 0, 7
+ mova [tmpq+ 3*%%str], m0 ; t15
+ mova m7, [tmpq+28*%%str] ; t7
+ SUMSUB_BA w, 14, 1, 0
+ SUMSUB_BA w, 13, 2, 0
+ SUMSUB_BA w, 12, 3, 0
+ SUMSUB_BA w, 11, 4, 0
+ SUMSUB_BA w, 10, 5, 0
+ SUMSUB_BA w, 9, 6, 0
+ SUMSUB_BA w, 8, 7, 0
+
+ TRANSPOSE8x8W 15, 14, 13, 12, 11, 10, 9, 8, 0
+ mova [tmpq+ 0*%%str], m15
+ mova [tmpq+ 4*%%str], m14
+ mova [tmpq+ 8*%%str], m13
+ mova [tmpq+12*%%str], m12
+ mova [tmpq+16*%%str], m11
+ mova [tmpq+20*%%str], m10
+ mova [tmpq+24*%%str], m9
+ mova [tmpq+28*%%str], m8
+
+ mova m0, [tmpq+ 3*%%str] ; t15
+ TRANSPOSE8x8W 7, 6, 5, 4, 3, 2, 1, 0, 8
+ mova [tmpq+ 3*%%str], m7
+ mova [tmpq+ 7*%%str], m6
+ mova [tmpq+11*%%str], m5
+ mova [tmpq+15*%%str], m4
+ mova [tmpq+19*%%str], m3
+ mova [tmpq+23*%%str], m2
+ mova [tmpq+27*%%str], m1
+ mova [tmpq+31*%%str], m0
+
+ mova m15, [tmpq+ 2*%%str] ; t8
+ mova m14, [tmpq+ 6*%%str] ; t9
+ mova m13, [tmpq+10*%%str] ; t10
+ mova m12, [tmpq+14*%%str] ; t11
+ mova m11, [tmpq+18*%%str] ; t12
+ mova m10, [tmpq+22*%%str] ; t13
+ mova m9, [tmpq+26*%%str] ; t14
+ mova m8, [tmpq+30*%%str] ; t15
+ mova m7, [tmpq+ 1*%%str] ; t16
+ mova m6, [tmpq+ 5*%%str] ; t17
+ mova m5, [tmpq+ 9*%%str] ; t18
+ mova m4, [tmpq+13*%%str] ; t19
+ mova m3, [tmpq+17*%%str] ; t20
+ mova m2, [tmpq+21*%%str] ; t21
+ mova m1, [tmpq+25*%%str] ; t22
+
+ SUMSUB_BA w, 7, 8, 0
+ mova [tmpq+ 2*%%str], m8
+ mova m0, [tmpq+29*%%str] ; t23
+ SUMSUB_BA w, 6, 9, 8
+ SUMSUB_BA w, 5, 10, 8
+ SUMSUB_BA w, 4, 11, 8
+ SUMSUB_BA w, 3, 12, 8
+ SUMSUB_BA w, 2, 13, 8
+ SUMSUB_BA w, 1, 14, 8
+ SUMSUB_BA w, 0, 15, 8
+
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
+ mova [tmpq+ 1*%%str], m0
+ mova [tmpq+ 5*%%str], m1
+ mova [tmpq+ 9*%%str], m2
+ mova [tmpq+13*%%str], m3
+ mova [tmpq+17*%%str], m4
+ mova [tmpq+21*%%str], m5
+ mova [tmpq+25*%%str], m6
+ mova [tmpq+29*%%str], m7
+
+ mova m8, [tmpq+ 2*%%str]
+ TRANSPOSE8x8W 8, 9, 10, 11, 12, 13, 14, 15, 0
+ mova [tmpq+ 2*%%str], m8
+ mova [tmpq+ 6*%%str], m9
+ mova [tmpq+10*%%str], m10
+ mova [tmpq+14*%%str], m11
+ mova [tmpq+18*%%str], m12
+ mova [tmpq+22*%%str], m13
+ mova [tmpq+26*%%str], m14
+ mova [tmpq+30*%%str], m15
+%else
+ ; t0-7 is in [tmpq+{0,4,8,12,16,20,24,28}*%%str]
+ ; t8-15 is in [tmpq+{2,6,10,14,18,22,26,30}*%%str]
+ ; t16-19 and t23 is in [tmpq+{1,5,9,13,29}*%%str]
+ ; t20-22 is in m4-6
+ ; t24-31 is in m8-15
+ pxor m7, m7
+
+%macro %%STORE_2X2 7-8 1 ; src[1-4], tmp[1-2], zero, inc_dst_ptrs
+ SUMSUB_BA w, %4, %1, %5
+ SUMSUB_BA w, %3, %2, %5
+ pmulhrsw m%4, [pw_512]
+ pmulhrsw m%3, [pw_512]
+ VP9_STORE_2X %4, %3, %5, %6, %7
+%if %8 == 1
+ add dstq, stride2q
+%endif
+ pmulhrsw m%2, [pw_512]
+ pmulhrsw m%1, [pw_512]
+ VP9_STORE_2X %2, %1, %5, %6, %7, dst_endq
+%if %8 == 1
+ sub dst_endq, stride2q
+%endif
+%endmacro
+
+ ; store t0-1 and t30-31
+ mova m0, [tmpq+ 0*%%str]
+ mova m1, [tmpq+ 4*%%str]
+ %%STORE_2X2 0, 1, 14, 15, 2, 3, 7
+
+ ; store t2-3 and t28-29
+ mova m0, [tmpq+ 8*%%str]
+ mova m1, [tmpq+12*%%str]
+ %%STORE_2X2 0, 1, 12, 13, 2, 3, 7
+
+ ; store t4-5 and t26-27
+ mova m0, [tmpq+16*%%str]
+ mova m1, [tmpq+20*%%str]
+ %%STORE_2X2 0, 1, 10, 11, 2, 3, 7
+
+ ; store t6-7 and t24-25
+ mova m0, [tmpq+24*%%str]
+ mova m1, [tmpq+28*%%str]
+ %%STORE_2X2 0, 1, 8, 9, 2, 3, 7
+
+ ; store t8-9 and t22-23
+ mova m0, [tmpq+ 2*%%str]
+ mova m1, [tmpq+ 6*%%str]
+ mova m8, [tmpq+29*%%str]
+ %%STORE_2X2 0, 1, 6, 8, 2, 3, 7
+
+ ; store t10-11 and t20-21
+ mova m0, [tmpq+10*%%str]
+ mova m1, [tmpq+14*%%str]
+ %%STORE_2X2 0, 1, 4, 5, 2, 3, 7
+
+ ; store t12-13 and t18-19
+ mova m0, [tmpq+18*%%str]
+ mova m1, [tmpq+22*%%str]
+ mova m5, [tmpq+13*%%str]
+ mova m4, [tmpq+ 9*%%str]
+ %%STORE_2X2 0, 1, 4, 5, 2, 3, 7
+
+ ; store t14-17
+ mova m0, [tmpq+26*%%str]
+ mova m1, [tmpq+30*%%str]
+ mova m5, [tmpq+ 5*%%str]
+ mova m4, [tmpq+ 1*%%str]
+ %%STORE_2X2 0, 1, 4, 5, 2, 3, 7, 0
+%endif
+%endmacro
+
+%macro VP9_IDCT_IDCT_32x32_ADD_XMM 1
+INIT_XMM %1
+cglobal vp9_idct_idct_32x32_add, 4, 9, 16, 2048, dst, stride, block, eob
+ cmp eobd, 135
+ jg .idctfull
+ cmp eobd, 34
+ jg .idct16x16
+ cmp eobd, 1
+ jg .idct8x8
+
+ ; dc-only case
+ movd m0, [blockq]
+ mova m1, [pw_11585x2]
+ pmulhrsw m0, m1
+ pmulhrsw m0, m1
+ SPLATW m0, m0, q0000
+ pmulhrsw m0, [pw_512]
+ pxor m5, m5
+ movd [blockq], m5
+ DEFINE_ARGS dst, stride, block, cnt
+%rep 31
+ VP9_STORE_2XFULL 0, 1, 2, 3, 4, 5, mmsize
+ add dstq, strideq
+%endrep
+ VP9_STORE_2XFULL 0, 1, 2, 3, 4, 5, mmsize
+ RET
+
+ DEFINE_ARGS dst_bak, stride, block, cnt, dst, stride30, dst_end, stride2, tmp
+.idct8x8:
+ mov tmpq, rsp
+ VP9_IDCT32_1D blockq, 1, 8
+
+ mov stride30q, strideq ; stride
+ lea stride2q, [strideq*2] ; stride*2
+ shl stride30q, 5 ; stride*32
+ mov cntd, 4
+ sub stride30q, stride2q ; stride*30
+.loop2_8x8:
+ mov dstq, dst_bakq
+ lea dst_endq, [dst_bakq+stride30q]
+ VP9_IDCT32_1D tmpq, 2, 8
+ add dst_bakq, 8
+ add tmpq, 16
+ dec cntd
+ jg .loop2_8x8
+
+ ; at the end of the loop, m7 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 64, 8, m7
+ RET
+
+.idct16x16:
+ mov cntd, 2
+ mov tmpq, rsp
+.loop1_16x16:
+ VP9_IDCT32_1D blockq, 1, 16
+ add blockq, 16
+ add tmpq, 512
+ dec cntd
+ jg .loop1_16x16
+ sub blockq, 32
+
+ mov stride30q, strideq ; stride
+ lea stride2q, [strideq*2] ; stride*2
+ shl stride30q, 5 ; stride*32
+ mov cntd, 4
+ mov tmpq, rsp
+ sub stride30q, stride2q ; stride*30
+.loop2_16x16:
+ mov dstq, dst_bakq
+ lea dst_endq, [dst_bakq+stride30q]
+ VP9_IDCT32_1D tmpq, 2, 16
+ add dst_bakq, 8
+ add tmpq, 16
+ dec cntd
+ jg .loop2_16x16
+
+ ; at the end of the loop, m7 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 64, 16, m7
+ RET
+
+.idctfull:
+ mov cntd, 4
+ mov tmpq, rsp
+.loop1_full:
+ VP9_IDCT32_1D blockq, 1
+ add blockq, 16
+ add tmpq, 512
+ dec cntd
+ jg .loop1_full
+ sub blockq, 64
+
+ mov stride30q, strideq ; stride
+ lea stride2q, [strideq*2] ; stride*2
+ shl stride30q, 5 ; stride*32
+ mov cntd, 4
+ mov tmpq, rsp
+ sub stride30q, stride2q ; stride*30
+.loop2_full:
+ mov dstq, dst_bakq
+ lea dst_endq, [dst_bakq+stride30q]
+ VP9_IDCT32_1D tmpq, 2
+ add dst_bakq, 8
+ add tmpq, 16
+ dec cntd
+ jg .loop2_full
+
+ ; at the end of the loop, m7 should still be zero
+ ; use that to zero out block coefficients
+ ZERO_BLOCK blockq, 64, 32, m7
+ RET
+%endmacro
+
+VP9_IDCT_IDCT_32x32_ADD_XMM ssse3
+VP9_IDCT_IDCT_32x32_ADD_XMM avx
+
+%endif ; x86-64
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp9lpf.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp9lpf.asm
new file mode 100644
index 00000000000..c5db0caffb5
--- /dev/null
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp9lpf.asm
@@ -0,0 +1,817 @@
+;******************************************************************************
+;* VP9 loop filter SIMD optimizations
+;*
+;* Copyright (C) 2013-2014 Clément Bœsch <u pkh me>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%if ARCH_X86_64
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+cextern pb_3
+cextern pb_80
+
+pb_4: times 16 db 0x04
+pb_10: times 16 db 0x10
+pb_40: times 16 db 0x40
+pb_81: times 16 db 0x81
+pb_f8: times 16 db 0xf8
+pb_fe: times 16 db 0xfe
+
+pw_4: times 8 dw 4
+pw_8: times 8 dw 8
+
+; with mix functions, two 8-bit thresholds are stored in a 16-bit storage,
+; the following mask is used to splat both in the same register
+mask_mix: times 8 db 0
+ times 8 db 1
+
+mask_mix84: times 8 db 0xff
+ times 8 db 0x00
+mask_mix48: times 8 db 0x00
+ times 8 db 0xff
+
+SECTION .text
+
+; %1 = abs(%2-%3)
+%macro ABSSUB 4 ; dst, src1 (RO), src2 (RO), tmp
+ psubusb %1, %3, %2
+ psubusb %4, %2, %3
+ por %1, %4
+%endmacro
+
+; %1 = %1<=%2
+%macro CMP_LTE 3-4 ; src/dst, cmp, tmp, pb_80
+%if %0 == 4
+ pxor %1, %4
+%endif
+ pcmpgtb %3, %2, %1 ; cmp > src?
+ pcmpeqb %1, %2 ; cmp == src? XXX: avoid this with a -1/+1 well placed?
+ por %1, %3 ; cmp >= src?
+%endmacro
+
+; %1 = abs(%2-%3) <= %4
+%macro ABSSUB_CMP 6-7 [pb_80]; dst, src1, src2, cmp, tmp1, tmp2, [pb_80]
+ ABSSUB %1, %2, %3, %6 ; dst = abs(src1-src2)
+ CMP_LTE %1, %4, %6, %7 ; dst <= cmp
+%endmacro
+
+%macro MASK_APPLY 4 ; %1=new_data/dst %2=old_data %3=mask %4=tmp
+ pand %1, %3 ; new &= mask
+ pandn %4, %3, %2 ; tmp = ~mask & old
+ por %1, %4 ; new&mask | old&~mask
+%endmacro
+
+%macro FILTER_SUBx2_ADDx2 8 ; %1=dst %2=h/l %3=cache %4=sub1 %5=sub2 %6=add1 %7=add2 %8=rshift
+ punpck%2bw %3, %4, m0
+ psubw %1, %3
+ punpck%2bw %3, %5, m0
+ psubw %1, %3
+ punpck%2bw %3, %6, m0
+ paddw %1, %3
+ punpck%2bw %3, %7, m0
+ paddw %3, %1
+ psraw %1, %3, %8
+%endmacro
+
+%macro FILTER_INIT 8 ; tmp1, tmp2, cacheL, cacheH, dstp, filterid, mask, source
+ FILTER%6_INIT %1, l, %3
+ FILTER%6_INIT %2, h, %4
+ packuswb %1, %2
+ MASK_APPLY %1, %8, %7, %2
+ mova %5, %1
+%endmacro
+
+%macro FILTER_UPDATE 11-14 ; tmp1, tmp2, cacheL, cacheH, dstp, -, -, +, +, rshift, mask, [source], [preload reg + value]
+%if %0 == 13 ; no source + preload
+ mova %12, %13
+%elif %0 == 14 ; source + preload
+ mova %13, %14
+%endif
+ FILTER_SUBx2_ADDx2 %1, l, %3, %6, %7, %8, %9, %10
+ FILTER_SUBx2_ADDx2 %2, h, %4, %6, %7, %8, %9, %10
+ packuswb %1, %2
+%if %0 == 12 || %0 == 14
+ MASK_APPLY %1, %12, %11, %2
+%else
+ MASK_APPLY %1, %5, %11, %2
+%endif
+ mova %5, %1
+%endmacro
+
+%macro SRSHIFT3B_2X 4 ; reg1, reg2, [pb_10], tmp
+ mova %4, [pb_f8]
+ pand %1, %4
+ pand %2, %4
+ psrlq %1, 3
+ psrlq %2, 3
+ pxor %1, %3
+ pxor %2, %3
+ psubb %1, %3
+ psubb %2, %3
+%endmacro
+
+%macro EXTRACT_POS_NEG 3 ; i8, neg, pos
+ pxor %3, %3
+ pxor %2, %2
+ pcmpgtb %3, %1 ; i8 < 0 mask
+ psubb %2, %1 ; neg values (only the originally - will be kept)
+ pand %2, %3 ; negative values of i8 (but stored as +)
+ pandn %3, %1 ; positive values of i8
+%endmacro
+
+; clip_u8(u8 + i8)
+%macro SIGN_ADD 5 ; dst, u8, i8, tmp1, tmp2
+ EXTRACT_POS_NEG %3, %4, %5
+ psubusb %1, %2, %4 ; sub the negatives
+ paddusb %1, %5 ; add the positives
+%endmacro
+
+; clip_u8(u8 - i8)
+%macro SIGN_SUB 5 ; dst, u8, i8, tmp1, tmp2
+ EXTRACT_POS_NEG %3, %4, %5
+ psubusb %1, %2, %5 ; sub the positives
+ paddusb %1, %4 ; add the negatives
+%endmacro
+
+%macro FILTER6_INIT 3 ; %1=dst %2=h/l %3=cache
+ punpck%2bw %1, m14, m0 ; p3: B->W
+ paddw %3, %1, %1 ; p3*2
+ paddw %3, %1 ; p3*3
+ punpck%2bw %1, m15, m0 ; p2: B->W
+ paddw %3, %1 ; p3*3 + p2
+ paddw %3, %1 ; p3*3 + p2*2
+ punpck%2bw %1, m10, m0 ; p1: B->W
+ paddw %3, %1 ; p3*3 + p2*2 + p1
+ punpck%2bw %1, m11, m0 ; p0: B->W
+ paddw %3, %1 ; p3*3 + p2*2 + p1 + p0
+ punpck%2bw %1, m12, m0 ; q0: B->W
+ paddw %3, %1 ; p3*3 + p2*2 + p1 + p0 + q0
+ paddw %3, [pw_4] ; p3*3 + p2*2 + p1 + p0 + q0 + 4
+ psraw %1, %3, 3 ; (p3*3 + p2*2 + p1 + p0 + q0 + 4) >> 3
+%endmacro
+
+%macro FILTER14_INIT 3 ; %1=dst %2=h/l %3=cache
+ punpck%2bw %1, m2, m0 ; p7: B->W
+ psllw %3, %1, 3 ; p7*8
+ psubw %3, %1 ; p7*7
+ punpck%2bw %1, m3, m0 ; p6: B->W
+ paddw %3, %1 ; p7*7 + p6
+ paddw %3, %1 ; p7*7 + p6*2
+ punpck%2bw %1, m8, m0 ; p5: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5
+ punpck%2bw %1, m9, m0 ; p4: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + p4
+ punpck%2bw %1, m14, m0 ; p3: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + p4 + p3
+ punpck%2bw %1, m15, m0 ; p2: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + .. + p2
+ punpck%2bw %1, m10, m0 ; p1: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + .. + p1
+ punpck%2bw %1, m11, m0 ; p0: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + .. + p0
+ punpck%2bw %1, m12, m0 ; q0: B->W
+ paddw %3, %1 ; p7*7 + p6*2 + p5 + .. + p0 + q0
+ paddw %3, [pw_8] ; p7*7 + p6*2 + p5 + .. + p0 + q0 + 8
+ psraw %1, %3, 4 ; (p7*7 + p6*2 + p5 + .. + p0 + q0 + 8) >> 4
+%endmacro
+
+%macro TRANSPOSE16x16B 17
+ mova %17, m%16
+ SBUTTERFLY bw, %1, %2, %16
+ SBUTTERFLY bw, %3, %4, %16
+ SBUTTERFLY bw, %5, %6, %16
+ SBUTTERFLY bw, %7, %8, %16
+ SBUTTERFLY bw, %9, %10, %16
+ SBUTTERFLY bw, %11, %12, %16
+ SBUTTERFLY bw, %13, %14, %16
+ mova m%16, %17
+ mova %17, m%14
+ SBUTTERFLY bw, %15, %16, %14
+ SBUTTERFLY wd, %1, %3, %14
+ SBUTTERFLY wd, %2, %4, %14
+ SBUTTERFLY wd, %5, %7, %14
+ SBUTTERFLY wd, %6, %8, %14
+ SBUTTERFLY wd, %9, %11, %14
+ SBUTTERFLY wd, %10, %12, %14
+ SBUTTERFLY wd, %13, %15, %14
+ mova m%14, %17
+ mova %17, m%12
+ SBUTTERFLY wd, %14, %16, %12
+ SBUTTERFLY dq, %1, %5, %12
+ SBUTTERFLY dq, %2, %6, %12
+ SBUTTERFLY dq, %3, %7, %12
+ SBUTTERFLY dq, %4, %8, %12
+ SBUTTERFLY dq, %9, %13, %12
+ SBUTTERFLY dq, %10, %14, %12
+ SBUTTERFLY dq, %11, %15, %12
+ mova m%12, %17
+ mova %17, m%8
+ SBUTTERFLY dq, %12, %16, %8
+ SBUTTERFLY qdq, %1, %9, %8
+ SBUTTERFLY qdq, %2, %10, %8
+ SBUTTERFLY qdq, %3, %11, %8
+ SBUTTERFLY qdq, %4, %12, %8
+ SBUTTERFLY qdq, %5, %13, %8
+ SBUTTERFLY qdq, %6, %14, %8
+ SBUTTERFLY qdq, %7, %15, %8
+ mova m%8, %17
+ mova %17, m%1
+ SBUTTERFLY qdq, %8, %16, %1
+ mova m%1, %17
+ SWAP %2, %9
+ SWAP %3, %5
+ SWAP %4, %13
+ SWAP %6, %11
+ SWAP %8, %15
+ SWAP %12, %14
+%endmacro
+
+; transpose 16 half lines (high part) to 8 full centered lines
+%macro TRANSPOSE16x8B 16
+ punpcklbw m%1, m%2
+ punpcklbw m%3, m%4
+ punpcklbw m%5, m%6
+ punpcklbw m%7, m%8
+ punpcklbw m%9, m%10
+ punpcklbw m%11, m%12
+ punpcklbw m%13, m%14
+ punpcklbw m%15, m%16
+ SBUTTERFLY wd, %1, %3, %2
+ SBUTTERFLY wd, %5, %7, %2
+ SBUTTERFLY wd, %9, %11, %2
+ SBUTTERFLY wd, %13, %15, %2
+ SBUTTERFLY dq, %1, %5, %2
+ SBUTTERFLY dq, %3, %7, %2
+ SBUTTERFLY dq, %9, %13, %2
+ SBUTTERFLY dq, %11, %15, %2
+ SBUTTERFLY qdq, %1, %9, %2
+ SBUTTERFLY qdq, %3, %11, %2
+ SBUTTERFLY qdq, %5, %13, %2
+ SBUTTERFLY qdq, %7, %15, %2
+ SWAP %5, %1
+ SWAP %6, %9
+ SWAP %7, %1
+ SWAP %8, %13
+ SWAP %9, %3
+ SWAP %10, %11
+ SWAP %11, %1
+ SWAP %12, %15
+%endmacro
+
+%macro DEFINE_REAL_P7_TO_Q7 0-1 0
+%define P7 dst1q + 2*mstrideq + %1
+%define P6 dst1q + mstrideq + %1
+%define P5 dst1q + %1
+%define P4 dst1q + strideq + %1
+%define P3 dstq + 4*mstrideq + %1
+%define P2 dstq + mstride3q + %1
+%define P1 dstq + 2*mstrideq + %1
+%define P0 dstq + mstrideq + %1
+%define Q0 dstq + %1
+%define Q1 dstq + strideq + %1
+%define Q2 dstq + 2*strideq + %1
+%define Q3 dstq + stride3q + %1
+%define Q4 dstq + 4*strideq + %1
+%define Q5 dst2q + mstrideq + %1
+%define Q6 dst2q + %1
+%define Q7 dst2q + strideq + %1
+%endmacro
+
+; ..............AB -> AAAAAAAABBBBBBBB
+%macro SPLATB_MIX 1-2 [mask_mix]
+%if cpuflag(ssse3)
+ pshufb %1, %2
+%else
+ punpcklbw %1, %1
+ punpcklqdq %1, %1
+ pshuflw %1, %1, 0
+ pshufhw %1, %1, 0x55
+%endif
+%endmacro
+
+%macro LOOPFILTER 2 ; %1=v/h %2=size1
+ lea mstrideq, [strideq]
+ neg mstrideq
+
+ lea stride3q, [strideq+2*strideq]
+ mov mstride3q, stride3q
+ neg mstride3q
+
+%ifidn %1, h
+%if %2 > 16
+%define movx movh
+ lea dstq, [dstq + 8*strideq - 4]
+%else
+%define movx movu
+ lea dstq, [dstq + 8*strideq - 8] ; go from top center (h pos) to center left (v pos)
+%endif
+%endif
+
+ lea dst1q, [dstq + 2*mstride3q] ; dst1q = &dst[stride * -6]
+ lea dst2q, [dstq + 2* stride3q] ; dst2q = &dst[stride * +6]
+
+ DEFINE_REAL_P7_TO_Q7
+
+%ifidn %1, h
+ movx m0, [P7]
+ movx m1, [P6]
+ movx m2, [P5]
+ movx m3, [P4]
+ movx m4, [P3]
+ movx m5, [P2]
+ movx m6, [P1]
+ movx m7, [P0]
+ movx m8, [Q0]
+ movx m9, [Q1]
+ movx m10, [Q2]
+ movx m11, [Q3]
+ movx m12, [Q4]
+ movx m13, [Q5]
+ movx m14, [Q6]
+ movx m15, [Q7]
+%define P7 rsp + 0
+%define P6 rsp + 16
+%define P5 rsp + 32
+%define P4 rsp + 48
+%define P3 rsp + 64
+%define P2 rsp + 80
+%define P1 rsp + 96
+%define P0 rsp + 112
+%define Q0 rsp + 128
+%define Q1 rsp + 144
+%define Q2 rsp + 160
+%define Q3 rsp + 176
+%define Q4 rsp + 192
+%define Q5 rsp + 208
+%define Q6 rsp + 224
+%define Q7 rsp + 240
+
+%if %2 == 16
+ TRANSPOSE16x16B 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, [rsp]
+ mova [P7], m0
+ mova [P6], m1
+ mova [P5], m2
+ mova [P4], m3
+%else
+ TRANSPOSE16x8B 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+%endif
+ mova [P3], m4
+ mova [P2], m5
+ mova [P1], m6
+ mova [P0], m7
+ mova [Q0], m8
+ mova [Q1], m9
+ mova [Q2], m10
+ mova [Q3], m11
+%if %2 == 16
+ mova [Q4], m12
+ mova [Q5], m13
+ mova [Q6], m14
+ mova [Q7], m15
+%endif
+%endif
+
+ ; calc fm mask
+%if %2 == 16
+%if cpuflag(ssse3)
+ pxor m0, m0
+%endif
+ SPLATB_REG m2, I, m0 ; I I I I ...
+ SPLATB_REG m3, E, m0 ; E E E E ...
+%else
+%if cpuflag(ssse3)
+ mova m0, [mask_mix]
+%endif
+ movd m2, Id
+ movd m3, Ed
+ SPLATB_MIX m2, m0
+ SPLATB_MIX m3, m0
+%endif
+ mova m0, [pb_80]
+ pxor m2, m0
+ pxor m3, m0
+%ifidn %1, v
+ mova m8, [P3]
+ mova m9, [P2]
+ mova m10, [P1]
+ mova m11, [P0]
+ mova m12, [Q0]
+ mova m13, [Q1]
+ mova m14, [Q2]
+ mova m15, [Q3]
+%else
+ ; In case of horizontal, P3..Q3 are already present in some registers due
+ ; to the previous transpose, so we just swap registers.
+ SWAP 8, 4, 12
+ SWAP 9, 5, 13
+ SWAP 10, 6, 14
+ SWAP 11, 7, 15
+%endif
+ ABSSUB_CMP m5, m8, m9, m2, m6, m7, m0 ; m5 = abs(p3-p2) <= I
+ ABSSUB_CMP m1, m9, m10, m2, m6, m7, m0 ; m1 = abs(p2-p1) <= I
+ pand m5, m1
+ ABSSUB_CMP m1, m10, m11, m2, m6, m7, m0 ; m1 = abs(p1-p0) <= I
+ pand m5, m1
+ ABSSUB_CMP m1, m12, m13, m2, m6, m7, m0 ; m1 = abs(q1-q0) <= I
+ pand m5, m1
+ ABSSUB_CMP m1, m13, m14, m2, m6, m7, m0 ; m1 = abs(q2-q1) <= I
+ pand m5, m1
+ ABSSUB_CMP m1, m14, m15, m2, m6, m7, m0 ; m1 = abs(q3-q2) <= I
+ pand m5, m1
+ ABSSUB m1, m11, m12, m7 ; abs(p0-q0)
+ paddusb m1, m1 ; abs(p0-q0) * 2
+ ABSSUB m2, m10, m13, m7 ; abs(p1-q1)
+ pand m2, [pb_fe] ; drop lsb so shift can work
+ psrlq m2, 1 ; abs(p1-q1)/2
+ paddusb m1, m2 ; abs(p0-q0)*2 + abs(p1-q1)/2
+ pxor m1, m0
+ pcmpgtb m4, m3, m1 ; E > X?
+ pcmpeqb m3, m1 ; E == X?
+ por m3, m4 ; E >= X?
+ pand m3, m5 ; fm final value
+
+ ; (m3: fm, m8..15: p3 p2 p1 p0 q0 q1 q2 q3)
+ ; calc flat8in (if not 44_16) and hev masks
+ mova m6, [pb_81] ; [1 1 1 1 ...] ^ 0x80
+%if %2 != 44
+ ABSSUB_CMP m2, m8, m11, m6, m4, m5 ; abs(p3 - p0) <= 1
+ mova m8, [pb_80]
+ ABSSUB_CMP m1, m9, m11, m6, m4, m5, m8 ; abs(p2 - p0) <= 1
+ pand m2, m1
+ ABSSUB m4, m10, m11, m5 ; abs(p1 - p0)
+%if %2 == 16
+%if cpuflag(ssse3)
+ pxor m0, m0
+%endif
+ SPLATB_REG m7, H, m0 ; H H H H ...
+%else
+ movd m7, Hd
+ SPLATB_MIX m7
+%endif
+ pxor m7, m8
+ pxor m4, m8
+ pcmpgtb m0, m4, m7 ; abs(p1 - p0) > H (1/2 hev condition)
+ CMP_LTE m4, m6, m5 ; abs(p1 - p0) <= 1
+ pand m2, m4 ; (flat8in)
+ ABSSUB m4, m13, m12, m1 ; abs(q1 - q0)
+ pxor m4, m8
+ pcmpgtb m5, m4, m7 ; abs(q1 - q0) > H (2/2 hev condition)
+ por m0, m5 ; hev final value
+ CMP_LTE m4, m6, m5 ; abs(q1 - q0) <= 1
+ pand m2, m4 ; (flat8in)
+ ABSSUB_CMP m1, m14, m12, m6, m4, m5, m8 ; abs(q2 - q0) <= 1
+ pand m2, m1
+ ABSSUB_CMP m1, m15, m12, m6, m4, m5, m8 ; abs(q3 - q0) <= 1
+ pand m2, m1 ; flat8in final value
+%if %2 == 84 || %2 == 48
+ pand m2, [mask_mix%2]
+%endif
+%else
+ mova m6, [pb_80]
+ movd m7, Hd
+ SPLATB_MIX m7
+ pxor m7, m6
+ ABSSUB m4, m10, m11, m1 ; abs(p1 - p0)
+ pxor m4, m6
+ pcmpgtb m0, m4, m7 ; abs(p1 - p0) > H (1/2 hev condition)
+ ABSSUB m4, m13, m12, m1 ; abs(q1 - q0)
+ pxor m4, m6
+ pcmpgtb m5, m4, m7 ; abs(q1 - q0) > H (2/2 hev condition)
+ por m0, m5 ; hev final value
+%endif
+
+%if %2 == 16
+ ; (m0: hev, m2: flat8in, m3: fm, m6: pb_81, m9..15: p2 p1 p0 q0 q1 q2 q3)
+ ; calc flat8out mask
+ mova m8, [P7]
+ mova m9, [P6]
+ ABSSUB_CMP m1, m8, m11, m6, m4, m5 ; abs(p7 - p0) <= 1
+ ABSSUB_CMP m7, m9, m11, m6, m4, m5 ; abs(p6 - p0) <= 1
+ pand m1, m7
+ mova m8, [P5]
+ mova m9, [P4]
+ ABSSUB_CMP m7, m8, m11, m6, m4, m5 ; abs(p5 - p0) <= 1
+ pand m1, m7
+ ABSSUB_CMP m7, m9, m11, m6, m4, m5 ; abs(p4 - p0) <= 1
+ pand m1, m7
+ mova m14, [Q4]
+ mova m15, [Q5]
+ ABSSUB_CMP m7, m14, m12, m6, m4, m5 ; abs(q4 - q0) <= 1
+ pand m1, m7
+ ABSSUB_CMP m7, m15, m12, m6, m4, m5 ; abs(q5 - q0) <= 1
+ pand m1, m7
+ mova m14, [Q6]
+ mova m15, [Q7]
+ ABSSUB_CMP m7, m14, m12, m6, m4, m5 ; abs(q4 - q0) <= 1
+ pand m1, m7
+ ABSSUB_CMP m7, m15, m12, m6, m4, m5 ; abs(q5 - q0) <= 1
+ pand m1, m7 ; flat8out final value
+%endif
+
+ ; if (fm) {
+ ; if (out && in) filter_14()
+ ; else if (in) filter_6()
+ ; else if (hev) filter_2()
+ ; else filter_4()
+ ; }
+ ;
+ ; f14: fm & out & in
+ ; f6: fm & ~f14 & in => fm & ~(out & in) & in => fm & ~out & in
+ ; f2: fm & ~f14 & ~f6 & hev => fm & ~(out & in) & ~(~out & in) & hev => fm & ~in & hev
+ ; f4: fm & ~f14 & ~f6 & ~f2 => fm & ~(out & in) & ~(~out & in) & ~(~in & hev) => fm & ~in & ~hev
+
+ ; (m0: hev, [m1: flat8out], [m2: flat8in], m3: fm, m8..15: p5 p4 p1 p0 q0 q1 q6 q7)
+ ; filter2()
+%if %2 != 44
+ mova m6, [pb_80] ; already in m6 if 44_16
+%endif
+ pxor m15, m12, m6 ; q0 ^ 0x80
+ pxor m14, m11, m6 ; p0 ^ 0x80
+ psubsb m15, m14 ; (signed) q0 - p0
+ pxor m4, m10, m6 ; p1 ^ 0x80
+ pxor m5, m13, m6 ; q1 ^ 0x80
+ psubsb m4, m5 ; (signed) p1 - q1
+ paddsb m4, m15 ; (q0 - p0) + (p1 - q1)
+ paddsb m4, m15 ; 2*(q0 - p0) + (p1 - q1)
+ paddsb m4, m15 ; 3*(q0 - p0) + (p1 - q1)
+ paddsb m6, m4, [pb_4] ; m6: f1 = clip(f + 4, 127)
+ paddsb m4, [pb_3] ; m4: f2 = clip(f + 3, 127)
+ mova m14, [pb_10] ; will be reused in filter4()
+ SRSHIFT3B_2X m6, m4, m14, m7 ; f1 and f2 sign byte shift by 3
+ SIGN_SUB m7, m12, m6, m5, m9 ; m7 = q0 - f1
+ SIGN_ADD m8, m11, m4, m5, m9 ; m8 = p0 + f2
+%if %2 != 44
+ pandn m6, m2, m3 ; ~mask(in) & mask(fm)
+ pand m6, m0 ; (~mask(in) & mask(fm)) & mask(hev)
+%else
+ pand m6, m3, m0
+%endif
+ MASK_APPLY m7, m12, m6, m5 ; m7 = filter2(q0) & mask / we write it in filter4()
+ MASK_APPLY m8, m11, m6, m5 ; m8 = filter2(p0) & mask / we write it in filter4()
+
+ ; (m0: hev, [m1: flat8out], [m2: flat8in], m3: fm, m7..m8: q0' p0', m10..13: p1 p0 q0 q1, m14: pb_10, m15: q0-p0)
+ ; filter4()
+ mova m4, m15
+ paddsb m15, m4 ; 2 * (q0 - p0)
+ paddsb m15, m4 ; 3 * (q0 - p0)
+ paddsb m6, m15, [pb_4] ; m6: f1 = clip(f + 4, 127)
+ paddsb m15, [pb_3] ; m15: f2 = clip(f + 3, 127)
+ SRSHIFT3B_2X m6, m15, m14, m9 ; f1 and f2 sign byte shift by 3
+%if %2 != 44
+%define p0tmp m7
+%define q0tmp m9
+ pandn m5, m2, m3 ; ~mask(in) & mask(fm)
+ pandn m0, m5 ; ~mask(hev) & (~mask(in) & mask(fm))
+%else
+%define p0tmp m1
+%define q0tmp m2
+ pandn m0, m3
+%endif
+ SIGN_SUB q0tmp, m12, m6, m4, m14 ; q0 - f1
+ MASK_APPLY q0tmp, m7, m0, m5 ; filter4(q0) & mask
+ mova [Q0], q0tmp
+ SIGN_ADD p0tmp, m11, m15, m4, m14 ; p0 + f2
+ MASK_APPLY p0tmp, m8, m0, m5 ; filter4(p0) & mask
+ mova [P0], p0tmp
+ paddb m6, [pb_80] ;
+ pxor m8, m8 ; f=(f1+1)>>1
+ pavgb m6, m8 ;
+ psubb m6, [pb_40] ;
+ SIGN_ADD m7, m10, m6, m8, m9 ; p1 + f
+ SIGN_SUB m4, m13, m6, m8, m9 ; q1 - f
+ MASK_APPLY m7, m10, m0, m14 ; m7 = filter4(p1)
+ MASK_APPLY m4, m13, m0, m14 ; m4 = filter4(q1)
+ mova [P1], m7
+ mova [Q1], m4
+
+ ; ([m1: flat8out], m2: flat8in, m3: fm, m10..13: p1 p0 q0 q1)
+ ; filter6()
+%if %2 != 44
+ pxor m0, m0
+%if %2 > 16
+ pand m3, m2
+%else
+ pand m2, m3 ; mask(fm) & mask(in)
+ pandn m3, m1, m2 ; ~mask(out) & (mask(fm) & mask(in))
+%endif
+ mova m14, [P3]
+ mova m15, [P2]
+ mova m8, [Q2]
+ mova m9, [Q3]
+ FILTER_INIT m4, m5, m6, m7, [P2], 6, m3, m15 ; [p2]
+ FILTER_UPDATE m6, m7, m4, m5, [P1], m14, m15, m10, m13, 3, m3 ; [p1] -p3 -p2 +p1 +q1
+ FILTER_UPDATE m4, m5, m6, m7, [P0], m14, m10, m11, m8, 3, m3 ; [p0] -p3 -p1 +p0 +q2
+ FILTER_UPDATE m6, m7, m4, m5, [Q0], m14, m11, m12, m9, 3, m3 ; [q0] -p3 -p0 +q0 +q3
+ FILTER_UPDATE m4, m5, m6, m7, [Q1], m15, m12, m13, m9, 3, m3 ; [q1] -p2 -q0 +q1 +q3
+ FILTER_UPDATE m6, m7, m4, m5, [Q2], m10, m13, m8, m9, 3, m3, m8 ; [q2] -p1 -q1 +q2 +q3
+%endif
+
+ ; (m0: 0, [m1: flat8out], m2: fm & flat8in, m8..15: q2 q3 p1 p0 q0 q1 p3 p2)
+ ; filter14()
+ ;
+ ; m2 m3 m8 m9 m14 m15 m10 m11 m12 m13
+ ;
+ ; q2 q3 p3 p2 p1 p0 q0 q1
+ ; p6 -7 p7 p6 p5 p4 . . . . .
+ ; p5 -6 -p7 -p6 +p5 +q1 . . . .
+ ; p4 -5 -p7 -p5 +p4 +q2 . . . q2
+ ; p3 -4 -p7 -p4 +p3 +q3 . . . q3
+ ; p2 -3 -p7 -p3 +p2 +q4 . . . q4
+ ; p1 -2 -p7 -p2 +p1 +q5 . . . q5
+ ; p0 -1 -p7 -p1 +p0 +q6 . . . q6
+ ; q0 +0 -p7 -p0 +q0 +q7 . . . q7
+ ; q1 +1 -p6 -q0 +q1 +q7 q1 . . .
+ ; q2 +2 -p5 -q1 +q2 +q7 . q2 . .
+ ; q3 +3 -p4 -q2 +q3 +q7 . q3 . .
+ ; q4 +4 -p3 -q3 +q4 +q7 . q4 . .
+ ; q5 +5 -p2 -q4 +q5 +q7 . q5 . .
+ ; q6 +6 -p1 -q5 +q6 +q7 . q6 . .
+
+%if %2 == 16
+ pand m1, m2 ; mask(out) & (mask(fm) & mask(in))
+ mova m2, [P7]
+ mova m3, [P6]
+ mova m8, [P5]
+ mova m9, [P4]
+ FILTER_INIT m4, m5, m6, m7, [P6], 14, m1, m3
+ FILTER_UPDATE m6, m7, m4, m5, [P5], m2, m3, m8, m13, 4, m1, m8 ; [p5] -p7 -p6 +p5 +q1
+ FILTER_UPDATE m4, m5, m6, m7, [P4], m2, m8, m9, m13, 4, m1, m9, m13, [Q2] ; [p4] -p7 -p5 +p4 +q2
+ FILTER_UPDATE m6, m7, m4, m5, [P3], m2, m9, m14, m13, 4, m1, m14, m13, [Q3] ; [p3] -p7 -p4 +p3 +q3
+ FILTER_UPDATE m4, m5, m6, m7, [P2], m2, m14, m15, m13, 4, m1, m13, [Q4] ; [p2] -p7 -p3 +p2 +q4
+ FILTER_UPDATE m6, m7, m4, m5, [P1], m2, m15, m10, m13, 4, m1, m13, [Q5] ; [p1] -p7 -p2 +p1 +q5
+ FILTER_UPDATE m4, m5, m6, m7, [P0], m2, m10, m11, m13, 4, m1, m13, [Q6] ; [p0] -p7 -p1 +p0 +q6
+ FILTER_UPDATE m6, m7, m4, m5, [Q0], m2, m11, m12, m13, 4, m1, m13, [Q7] ; [q0] -p7 -p0 +q0 +q7
+ FILTER_UPDATE m4, m5, m6, m7, [Q1], m3, m12, m2, m13, 4, m1, m2, [Q1] ; [q1] -p6 -q0 +q1 +q7
+ FILTER_UPDATE m6, m7, m4, m5, [Q2], m8, m2, m3, m13, 4, m1, m3, [Q2] ; [q2] -p5 -q1 +q2 +q7
+ FILTER_UPDATE m4, m5, m6, m7, [Q3], m9, m3, m8, m13, 4, m1, m8, m8, [Q3] ; [q3] -p4 -q2 +q3 +q7
+ FILTER_UPDATE m6, m7, m4, m5, [Q4], m14, m8, m9, m13, 4, m1, m9, m9, [Q4] ; [q4] -p3 -q3 +q4 +q7
+ FILTER_UPDATE m4, m5, m6, m7, [Q5], m15, m9, m14, m13, 4, m1, m14, m14, [Q5] ; [q5] -p2 -q4 +q5 +q7
+ FILTER_UPDATE m6, m7, m4, m5, [Q6], m10, m14, m15, m13, 4, m1, m15, m15, [Q6] ; [q6] -p1 -q5 +q6 +q7
+%endif
+
+%ifidn %1, h
+%if %2 == 16
+ mova m0, [P7]
+ mova m1, [P6]
+ mova m2, [P5]
+ mova m3, [P4]
+ mova m4, [P3]
+ mova m5, [P2]
+ mova m6, [P1]
+ mova m7, [P0]
+ mova m8, [Q0]
+ mova m9, [Q1]
+ mova m10, [Q2]
+ mova m11, [Q3]
+ mova m12, [Q4]
+ mova m13, [Q5]
+ mova m14, [Q6]
+ mova m15, [Q7]
+ TRANSPOSE16x16B 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, [rsp]
+ DEFINE_REAL_P7_TO_Q7
+ movu [P7], m0
+ movu [P6], m1
+ movu [P5], m2
+ movu [P4], m3
+ movu [P3], m4
+ movu [P2], m5
+ movu [P1], m6
+ movu [P0], m7
+ movu [Q0], m8
+ movu [Q1], m9
+ movu [Q2], m10
+ movu [Q3], m11
+ movu [Q4], m12
+ movu [Q5], m13
+ movu [Q6], m14
+ movu [Q7], m15
+%elif %2 == 44
+ SWAP 0, 7 ; m0 = p1
+ SWAP 3, 4 ; m3 = q1
+ DEFINE_REAL_P7_TO_Q7 2
+ SBUTTERFLY bw, 0, 1, 8
+ SBUTTERFLY bw, 2, 3, 8
+ SBUTTERFLY wd, 0, 2, 8
+ SBUTTERFLY wd, 1, 3, 8
+ SBUTTERFLY dq, 0, 4, 8
+ SBUTTERFLY dq, 1, 5, 8
+ SBUTTERFLY dq, 2, 6, 8
+ SBUTTERFLY dq, 3, 7, 8
+ movd [P7], m0
+ punpckhqdq m0, m8
+ movd [P6], m0
+ movd [Q0], m1
+ punpckhqdq m1, m9
+ movd [Q1], m1
+ movd [P3], m2
+ punpckhqdq m2, m10
+ movd [P2], m2
+ movd [Q4], m3
+ punpckhqdq m3, m11
+ movd [Q5], m3
+ movd [P5], m4
+ punpckhqdq m4, m12
+ movd [P4], m4
+ movd [Q2], m5
+ punpckhqdq m5, m13
+ movd [Q3], m5
+ movd [P1], m6
+ punpckhqdq m6, m14
+ movd [P0], m6
+ movd [Q6], m7
+ punpckhqdq m7, m8
+ movd [Q7], m7
+%else
+ ; the following code do a transpose of 8 full lines to 16 half
+ ; lines (high part). It is inlined to avoid the need of a staging area
+ mova m0, [P3]
+ mova m1, [P2]
+ mova m2, [P1]
+ mova m3, [P0]
+ mova m4, [Q0]
+ mova m5, [Q1]
+ mova m6, [Q2]
+ mova m7, [Q3]
+ DEFINE_REAL_P7_TO_Q7
+ SBUTTERFLY bw, 0, 1, 8
+ SBUTTERFLY bw, 2, 3, 8
+ SBUTTERFLY bw, 4, 5, 8
+ SBUTTERFLY bw, 6, 7, 8
+ SBUTTERFLY wd, 0, 2, 8
+ SBUTTERFLY wd, 1, 3, 8
+ SBUTTERFLY wd, 4, 6, 8
+ SBUTTERFLY wd, 5, 7, 8
+ SBUTTERFLY dq, 0, 4, 8
+ SBUTTERFLY dq, 1, 5, 8
+ SBUTTERFLY dq, 2, 6, 8
+ SBUTTERFLY dq, 3, 7, 8
+ movh [P7], m0
+ punpckhqdq m0, m8
+ movh [P6], m0
+ movh [Q0], m1
+ punpckhqdq m1, m9
+ movh [Q1], m1
+ movh [P3], m2
+ punpckhqdq m2, m10
+ movh [P2], m2
+ movh [Q4], m3
+ punpckhqdq m3, m11
+ movh [Q5], m3
+ movh [P5], m4
+ punpckhqdq m4, m12
+ movh [P4], m4
+ movh [Q2], m5
+ punpckhqdq m5, m13
+ movh [Q3], m5
+ movh [P1], m6
+ punpckhqdq m6, m14
+ movh [P0], m6
+ movh [Q6], m7
+ punpckhqdq m7, m8
+ movh [Q7], m7
+%endif
+%endif
+
+ RET
+%endmacro
+
+%macro LPF_16_VH 2
+INIT_XMM %2
+cglobal vp9_loop_filter_v_%1_16, 5,10,16, dst, stride, E, I, H, mstride, dst1, dst2, stride3, mstride3
+ LOOPFILTER v, %1
+cglobal vp9_loop_filter_h_%1_16, 5,10,16, 256, dst, stride, E, I, H, mstride, dst1, dst2, stride3, mstride3
+ LOOPFILTER h, %1
+%endmacro
+
+%macro LPF_16_VH_ALL_OPTS 1
+LPF_16_VH %1, sse2
+LPF_16_VH %1, ssse3
+LPF_16_VH %1, avx
+%endmacro
+
+LPF_16_VH_ALL_OPTS 16
+LPF_16_VH_ALL_OPTS 44
+LPF_16_VH_ALL_OPTS 48
+LPF_16_VH_ALL_OPTS 84
+LPF_16_VH_ALL_OPTS 88
+
+%endif ; x86-64
diff --git a/chromium/third_party/ffmpeg/libavcodec/x86/vp9mc.asm b/chromium/third_party/ffmpeg/libavcodec/x86/vp9mc.asm
index 21c38b4f0d4..7c2a38c8b33 100644
--- a/chromium/third_party/ffmpeg/libavcodec/x86/vp9mc.asm
+++ b/chromium/third_party/ffmpeg/libavcodec/x86/vp9mc.asm
@@ -87,7 +87,7 @@ SECTION .text
%macro filter_h_fn 1
%assign %%px mmsize/2
-cglobal %1_8tap_1d_h_ %+ %%px, 6, 6, 11, dst, dstride, src, sstride, h, filtery
+cglobal vp9_%1_8tap_1d_h_ %+ %%px, 6, 6, 11, dst, dstride, src, sstride, h, filtery
mova m6, [pw_256]
mova m7, [filteryq+ 0]
%if ARCH_X86_64 && mmsize > 8
@@ -145,22 +145,76 @@ INIT_XMM ssse3
filter_h_fn put
filter_h_fn avg
+%if ARCH_X86_64
+%macro filter_hx2_fn 1
+%assign %%px mmsize
+cglobal vp9_%1_8tap_1d_h_ %+ %%px, 6, 6, 14, dst, dstride, src, sstride, h, filtery
+ mova m13, [pw_256]
+ mova m8, [filteryq+ 0]
+ mova m9, [filteryq+16]
+ mova m10, [filteryq+32]
+ mova m11, [filteryq+48]
+.loop:
+ movu m0, [srcq-3]
+ movu m1, [srcq-2]
+ movu m2, [srcq-1]
+ movu m3, [srcq+0]
+ movu m4, [srcq+1]
+ movu m5, [srcq+2]
+ movu m6, [srcq+3]
+ movu m7, [srcq+4]
+ add srcq, sstrideq
+ SBUTTERFLY bw, 0, 1, 12
+ SBUTTERFLY bw, 2, 3, 12
+ SBUTTERFLY bw, 4, 5, 12
+ SBUTTERFLY bw, 6, 7, 12
+ pmaddubsw m0, m8
+ pmaddubsw m1, m8
+ pmaddubsw m2, m9
+ pmaddubsw m3, m9
+ pmaddubsw m4, m10
+ pmaddubsw m5, m10
+ pmaddubsw m6, m11
+ pmaddubsw m7, m11
+ paddw m0, m2
+ paddw m1, m3
+ paddw m4, m6
+ paddw m5, m7
+ paddsw m0, m4
+ paddsw m1, m5
+ pmulhrsw m0, m13
+ pmulhrsw m1, m13
+ packuswb m0, m1
+%ifidn %1, avg
+ pavgb m0, [dstq]
+%endif
+ mova [dstq], m0
+ add dstq, dstrideq
+ dec hd
+ jg .loop
+ RET
+%endmacro
+
+INIT_XMM ssse3
+filter_hx2_fn put
+filter_hx2_fn avg
+
+%endif ; ARCH_X86_64
+
%macro filter_v_fn 1
%assign %%px mmsize/2
%if ARCH_X86_64
-cglobal %1_8tap_1d_v_ %+ %%px, 6, 8, 11, dst, dstride, src, sstride, h, filtery, src4, sstride3
+cglobal vp9_%1_8tap_1d_v_ %+ %%px, 6, 8, 11, dst, dstride, src, sstride, h, filtery, src4, sstride3
%else
-cglobal %1_8tap_1d_v_ %+ %%px, 4, 7, 11, dst, dstride, src, sstride, filtery, src4, sstride3
+cglobal vp9_%1_8tap_1d_v_ %+ %%px, 4, 7, 11, dst, dstride, src, sstride, filtery, src4, sstride3
mov filteryq, r5mp
%define hd r4mp
%endif
- sub srcq, sstrideq
- lea sstride3q, [sstrideq*3]
- sub srcq, sstrideq
mova m6, [pw_256]
- sub srcq, sstrideq
+ lea sstride3q, [sstrideq*3]
+ lea src4q, [srcq+sstrideq]
+ sub srcq, sstride3q
mova m7, [filteryq+ 0]
- lea src4q, [srcq+sstrideq*4]
%if ARCH_X86_64 && mmsize > 8
mova m8, [filteryq+16]
mova m9, [filteryq+32]
@@ -220,6 +274,70 @@ INIT_XMM ssse3
filter_v_fn put
filter_v_fn avg
+%if ARCH_X86_64
+
+%macro filter_vx2_fn 1
+%assign %%px mmsize
+cglobal vp9_%1_8tap_1d_v_ %+ %%px, 6, 8, 14, dst, dstride, src, sstride, h, filtery, src4, sstride3
+ mova m13, [pw_256]
+ lea sstride3q, [sstrideq*3]
+ lea src4q, [srcq+sstrideq]
+ sub srcq, sstride3q
+ mova m8, [filteryq+ 0]
+ mova m9, [filteryq+16]
+ mova m10, [filteryq+32]
+ mova m11, [filteryq+48]
+.loop:
+ ; FIXME maybe reuse loads from previous rows, or just
+ ; more generally unroll this to prevent multiple loads of
+ ; the same data?
+ movu m0, [srcq]
+ movu m1, [srcq+sstrideq]
+ movu m2, [srcq+sstrideq*2]
+ movu m3, [srcq+sstride3q]
+ movu m4, [src4q]
+ movu m5, [src4q+sstrideq]
+ movu m6, [src4q+sstrideq*2]
+ movu m7, [src4q+sstride3q]
+ add srcq, sstrideq
+ add src4q, sstrideq
+ SBUTTERFLY bw, 0, 1, 12
+ SBUTTERFLY bw, 2, 3, 12
+ SBUTTERFLY bw, 4, 5, 12
+ SBUTTERFLY bw, 6, 7, 12
+ pmaddubsw m0, m8
+ pmaddubsw m1, m8
+ pmaddubsw m2, m9
+ pmaddubsw m3, m9
+ pmaddubsw m4, m10
+ pmaddubsw m5, m10
+ pmaddubsw m6, m11
+ pmaddubsw m7, m11
+ paddw m0, m2
+ paddw m1, m3
+ paddw m4, m6
+ paddw m5, m7
+ paddsw m0, m4
+ paddsw m1, m5
+ pmulhrsw m0, m13
+ pmulhrsw m1, m13
+ packuswb m0, m1
+%ifidn %1, avg
+ pavgb m0, [dstq]
+%endif
+ mova [dstq], m0
+ add dstq, dstrideq
+ dec hd
+ jg .loop
+ RET
+%endmacro
+
+INIT_XMM ssse3
+filter_vx2_fn put
+filter_vx2_fn avg
+
+%endif ; ARCH_X86_64
+
%macro fpel_fn 6
%if %2 == 4
%define %%srcfn movh
@@ -230,11 +348,11 @@ filter_v_fn avg
%endif
%if %2 <= 16
-cglobal %1%2, 5, 7, 4, dst, dstride, src, sstride, h, dstride3, sstride3
+cglobal vp9_%1%2, 5, 7, 4, dst, dstride, src, sstride, h, dstride3, sstride3
lea sstride3q, [sstrideq*3]
lea dstride3q, [dstrideq*3]
%else
-cglobal %1%2, 5, 5, 4, dst, dstride, src, sstride, h
+cglobal vp9_%1%2, 5, 5, 4, dst, dstride, src, sstride, h
%endif
.loop:
%%srcfn m0, [srcq]
@@ -263,7 +381,7 @@ cglobal %1%2, 5, 5, 4, dst, dstride, src, sstride, h
INIT_MMX mmx
fpel_fn put, 4, strideq, strideq*2, stride3q, 4
fpel_fn put, 8, strideq, strideq*2, stride3q, 4
-INIT_MMX sse
+INIT_MMX mmxext
fpel_fn avg, 4, strideq, strideq*2, stride3q, 4
fpel_fn avg, 8, strideq, strideq*2, stride3q, 4
INIT_XMM sse
diff --git a/chromium/third_party/ffmpeg/libavcodec/xbmdec.c b/chromium/third_party/ffmpeg/libavcodec/xbmdec.c
index 2976bec8acd..e03ff31fbb7 100644
--- a/chromium/third_party/ffmpeg/libavcodec/xbmdec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/xbmdec.c
@@ -20,17 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/avstring.h"
+
#include "avcodec.h"
#include "internal.h"
#include "mathops.h"
-#include "libavutil/avstring.h"
-
-static av_cold int xbm_decode_init(AVCodecContext *avctx)
-{
- avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
-
- return 0;
-}
static int convert(uint8_t x)
{
@@ -43,42 +37,57 @@ static int convert(uint8_t x)
return x;
}
+static int parse_str_int(const uint8_t *p, int len, const uint8_t *key)
+{
+ const uint8_t *end = p + len;
+
+ for(; p<end - strlen(key); p++) {
+ if (!memcmp(p, key, strlen(key)))
+ break;
+ }
+ p += strlen(key);
+ if (p >= end)
+ return INT_MIN;
+
+ for(; p<end; p++) {
+ char *eptr;
+ int64_t ret = strtol(p, &eptr, 10);
+ if ((const uint8_t *)eptr != p)
+ return ret;
+ }
+ return INT_MIN;
+}
+
static int xbm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
AVFrame *p = data;
+ int ret, linesize, i, j;
+ int width = 0;
+ int height = 0;
const uint8_t *end, *ptr = avpkt->data;
+ const uint8_t *next;
uint8_t *dst;
- int ret, linesize, i, j;
+ avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
end = avpkt->data + avpkt->size;
- while (!avctx->width || !avctx->height) {
- char name[256];
- int number, len;
-
- ptr += strcspn(ptr, "#");
- if (sscanf(ptr, "#define %255s %u", name, &number) != 2) {
- av_log(avctx, AV_LOG_ERROR, "Unexpected preprocessor directive\n");
- return AVERROR_INVALIDDATA;
- }
- len = strlen(name);
- if ((len > 6) && !avctx->height && !memcmp(name + len - 7, "_height", 7)) {
- avctx->height = number;
- } else if ((len > 5) && !avctx->width && !memcmp(name + len - 6, "_width", 6)) {
- avctx->width = number;
- } else {
- av_log(avctx, AV_LOG_ERROR, "Unknown define '%s'\n", name);
- return AVERROR_INVALIDDATA;
- }
- ptr += strcspn(ptr, "\n\r") + 1;
- }
+ width = parse_str_int(avpkt->data, avpkt->size, "_width");
+ height = parse_str_int(avpkt->data, avpkt->size, "_height");
+
+ if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
+ return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
// goto start of image data
- ptr += strcspn(ptr, "{") + 1;
+ next = ptr + strcspn(ptr, "{");
+ if (!*next)
+ next = ptr + strcspn(ptr, "(");
+ if (!*next)
+ return AVERROR_INVALIDDATA;
+ ptr = next + 1;
linesize = (avctx->width + 7) / 8;
for (i = 0; i < avctx->height; i++) {
@@ -86,15 +95,22 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data,
for (j = 0; j < linesize; j++) {
uint8_t val;
- ptr += strcspn(ptr, "x") + 1;
+ ptr += strcspn(ptr, "x$") + 1;
if (ptr < end && av_isxdigit(*ptr)) {
- val = convert(*ptr);
- ptr++;
+ val = convert(*ptr++);
if (av_isxdigit(*ptr))
- val = (val << 4) + convert(*ptr);
+ val = (val << 4) + convert(*ptr++);
*dst++ = ff_reverse[val];
+ if (av_isxdigit(*ptr) && j+1 < linesize) {
+ j++;
+ val = convert(*ptr++);
+ if (av_isxdigit(*ptr))
+ val = (val << 4) + convert(*ptr++);
+ *dst++ = ff_reverse[val];
+ }
} else {
- av_log(avctx, AV_LOG_ERROR, "Unexpected data at '%.8s'\n", ptr);
+ av_log(avctx, AV_LOG_ERROR,
+ "Unexpected data at %.8s.\n", ptr);
return AVERROR_INVALIDDATA;
}
}
@@ -113,7 +129,6 @@ AVCodec ff_xbm_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_XBM,
- .init = xbm_decode_init,
.decode = xbm_decode_frame,
.capabilities = CODEC_CAP_DR1,
};
diff --git a/chromium/third_party/ffmpeg/libavcodec/xsubenc.c b/chromium/third_party/ffmpeg/libavcodec/xsubenc.c
index 53f4d6c3a9b..707085488c5 100644
--- a/chromium/third_party/ffmpeg/libavcodec/xsubenc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/xsubenc.c
@@ -142,7 +142,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
av_log(avctx, AV_LOG_WARNING, "No more than 4 subtitle colors supported (%d found.)\n", h->rects[0]->nb_colors);
// TODO: Palette swapping if color zero is not transparent
- if (((uint32_t *)h->rects[0]->pict.data[1])[0] & 0xff)
+ if (((uint32_t *)h->rects[0]->pict.data[1])[0] & 0xff000000)
av_log(avctx, AV_LOG_WARNING, "Color index 0 is not transparent. Transparency will be messed up.\n");
if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) {
diff --git a/chromium/third_party/ffmpeg/libavcodec/xvmc.h b/chromium/third_party/ffmpeg/libavcodec/xvmc.h
index efd69fc913e..c2e187cc16e 100644
--- a/chromium/third_party/ffmpeg/libavcodec/xvmc.h
+++ b/chromium/third_party/ffmpeg/libavcodec/xvmc.h
@@ -33,8 +33,6 @@
#include "version.h"
#include "avcodec.h"
-#if FF_API_XVMC
-
/**
* @defgroup lavc_codec_hwaccel_xvmc XvMC
* @ingroup lavc_codec_hwaccel
@@ -169,6 +167,4 @@ attribute_deprecated struct xvmc_pix_fmt {
* @}
*/
-#endif /* FF_API_XVMC */
-
#endif /* AVCODEC_XVMC_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/xvmc_internal.h b/chromium/third_party/ffmpeg/libavcodec/xvmc_internal.h
index 6a60add965d..d365ef0266b 100644
--- a/chromium/third_party/ffmpeg/libavcodec/xvmc_internal.h
+++ b/chromium/third_party/ffmpeg/libavcodec/xvmc_internal.h
@@ -25,14 +25,7 @@
#include "mpegvideo.h"
#include "version.h"
-#if FF_API_XVMC
-
void ff_xvmc_init_block(MpegEncContext *s);
void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp);
-int ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx);
-void ff_xvmc_field_end(MpegEncContext *s);
-void ff_xvmc_decode_mb(MpegEncContext *s);
-
-#endif /* FF_API_XVMC */
#endif /* AVCODEC_XVMC_INTERNAL_H */
diff --git a/chromium/third_party/ffmpeg/libavcodec/xwddec.c b/chromium/third_party/ffmpeg/libavcodec/xwddec.c
index c28e19fa8b4..62dfdace165 100644
--- a/chromium/third_party/ffmpeg/libavcodec/xwddec.c
+++ b/chromium/third_party/ffmpeg/libavcodec/xwddec.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -75,11 +77,15 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
ncolors = bytestream2_get_be32u(&gb);
bytestream2_skipu(&gb, header_size - (XWD_HEADER_SIZE - 20));
- av_log(avctx, AV_LOG_DEBUG, "pixformat %d, pixdepth %d, bunit %d, bitorder %d, bpad %d\n",
+ av_log(avctx, AV_LOG_DEBUG,
+ "pixformat %"PRIu32", pixdepth %"PRIu32", bunit %"PRIu32", bitorder %"PRIu32", bpad %"PRIu32"\n",
pixformat, pixdepth, bunit, bitorder, bpad);
- av_log(avctx, AV_LOG_DEBUG, "vclass %d, ncolors %d, bpp %d, be %d, lsize %d, xoffset %d\n",
+ av_log(avctx, AV_LOG_DEBUG,
+ "vclass %"PRIu32", ncolors %"PRIu32", bpp %"PRIu32", be %"PRIu32", lsize %"PRIu32", xoffset %"PRIu32"\n",
vclass, ncolors, bpp, be, lsize, xoffset);
- av_log(avctx, AV_LOG_DEBUG, "red %0x, green %0x, blue %0x\n", rgb[0], rgb[1], rgb[2]);
+ av_log(avctx, AV_LOG_DEBUG,
+ "red %0"PRIx32", green %0"PRIx32", blue %0"PRIx32"\n",
+ rgb[0], rgb[1], rgb[2]);
if (pixformat > XWD_Z_PIXMAP) {
av_log(avctx, AV_LOG_ERROR, "invalid pixmap format\n");
@@ -92,7 +98,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
}
if (xoffset) {
- avpriv_request_sample(avctx, "xoffset %d", xoffset);
+ avpriv_request_sample(avctx, "xoffset %"PRIu32"", xoffset);
return AVERROR_PATCHWELCOME;
}
@@ -141,7 +147,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
}
if (pixformat != XWD_Z_PIXMAP) {
- avpriv_report_missing_feature(avctx, "Pixmap format %d", pixformat);
+ avpriv_report_missing_feature(avctx, "Pixmap format %"PRIu32, pixformat);
return AVERROR_PATCHWELCOME;
}
@@ -196,7 +202,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
avpriv_request_sample(avctx,
- "Unknown file: bpp %d, pixdepth %d, vclass %d",
+ "Unknown file: bpp %"PRIu32", pixdepth %"PRIu32", vclass %"PRIu32"",
bpp, pixdepth, vclass);
return AVERROR_PATCHWELCOME;
}
diff --git a/chromium/third_party/ffmpeg/libavcodec/zmbv.c b/chromium/third_party/ffmpeg/libavcodec/zmbv.c
index 71e828771a3..21a9e35c39c 100644
--- a/chromium/third_party/ffmpeg/libavcodec/zmbv.c
+++ b/chromium/third_party/ffmpeg/libavcodec/zmbv.c
@@ -145,7 +145,7 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
prev += c->width * c->bh;
}
if (src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
src-c->decomp_buf, c->decomp_len);
return 0;
}
@@ -219,7 +219,7 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
prev += c->width * c->bh;
}
if (src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
src-c->decomp_buf, c->decomp_len);
return 0;
}
@@ -377,7 +377,7 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
prev += c->width * c->bh;
}
if (src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
src-c->decomp_buf, c->decomp_len);
return 0;
}